Lines Matching refs:bc
245 static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val){
248 ff_put_v(bc, val);
254 static void put_str(AVIOContext *bc, const char *string){
257 ff_put_v(bc, len);
258 avio_write(bc, string, len);
261 static void put_s(AVIOContext *bc, int64_t val){
262 ff_put_v(bc, 2*FFABS(val) - (val>0));
266 static inline void ff_put_v_trace(AVIOContext *bc, uint64_t v, char *file, char *func, int line){
269 ff_put_v(bc, v);
272 static inline void put_s_trace(AVIOContext *bc, int64_t v, char *file, char *func, int line){
275 put_s(bc, v);
277 #define ff_put_v(bc, v) ff_put_v_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
278 #define put_s(bc, v) put_s_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
282 static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, int calculate_checksum, uint64_t startcode){
288 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
289 avio_wb64(bc, startcode);
290 ff_put_v(bc, forw_ptr);
292 avio_wl32(bc, ffio_get_checksum(bc));
295 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
296 avio_write(bc, dyn_buf, dyn_size);
298 avio_wl32(bc, ffio_get_checksum(bc));
303 static void write_mainheader(NUTContext *nut, AVIOContext *bc){
307 ff_put_v(bc, 3); /* version */
308 ff_put_v(bc, nut->avf->nb_streams);
309 ff_put_v(bc, nut->max_distance);
310 ff_put_v(bc, nut->time_base_count);
313 ff_put_v(bc, nut->time_base[i].num);
314 ff_put_v(bc, nut->time_base[i].den);
356 ff_put_v(bc, tmp_flags);
357 ff_put_v(bc, tmp_fields);
358 if(tmp_fields>0) put_s(bc, tmp_pts);
359 if(tmp_fields>1) ff_put_v(bc, tmp_mul);
360 if(tmp_fields>2) ff_put_v(bc, tmp_stream);
361 if(tmp_fields>3) ff_put_v(bc, tmp_size);
362 if(tmp_fields>4) ff_put_v(bc, 0 /*tmp_res*/);
363 if(tmp_fields>5) ff_put_v(bc, j);
364 if(tmp_fields>6) ff_put_v(bc, tmp_match);
365 if(tmp_fields>7) ff_put_v(bc, tmp_head_idx);
367 ff_put_v(bc, nut->header_count-1);
369 ff_put_v(bc, nut->header_len[i]);
370 avio_write(bc, nut->header[i], nut->header_len[i]);
374 static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i){
377 ff_put_v(bc, i);
379 case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break;
380 case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break;
381 case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break;
382 default : ff_put_v(bc, 3); break;
384 ff_put_v(bc, 4);
386 avio_wl32(bc, codec->codec_tag);
392 ff_put_v(bc, nut->stream[i].time_base - nut->time_base);
393 ff_put_v(bc, nut->stream[i].msb_pts_shift);
394 ff_put_v(bc, nut->stream[i].max_pts_distance);
395 ff_put_v(bc, codec->has_b_frames);
396 avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
398 ff_put_v(bc, codec->extradata_size);
399 avio_write(bc, codec->extradata, codec->extradata_size);
403 ff_put_v(bc, codec->sample_rate);
404 ff_put_v(bc, 1);
405 ff_put_v(bc, codec->channels);
408 ff_put_v(bc, codec->width);
409 ff_put_v(bc, codec->height);
412 ff_put_v(bc, 0);
413 ff_put_v(bc, 0);
415 ff_put_v(bc, st->sample_aspect_ratio.num);
416 ff_put_v(bc, st->sample_aspect_ratio.den);
418 ff_put_v(bc, 0); /* csp type -- unknown */
426 static int add_info(AVIOContext *bc, const char *type, const char *value){
427 put_str(bc, type);
428 put_s(bc, -1);
429 put_str(bc, value);
433 static int write_globalinfo(NUTContext *nut, AVIOContext *bc){
446 ff_put_v(bc, 0); //stream_if_plus1
447 ff_put_v(bc, 0); //chapter_id
448 ff_put_v(bc, 0); //timestamp_start
449 ff_put_v(bc, 0); //length
451 ff_put_v(bc, count);
454 avio_write(bc, dyn_buf, dyn_size);
459 static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id){
476 ff_put_v(bc, stream_id + 1); //stream_id_plus1
477 ff_put_v(bc, 0); //chapter_id
478 ff_put_v(bc, 0); //timestamp_start
479 ff_put_v(bc, 0); //length
481 ff_put_v(bc, count);
483 avio_write(bc, dyn_buf, dyn_size);
490 static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
502 ff_put_v(bc, 0); // stream_id_plus1
503 put_s(bc, id + 1); // chapter_id
504 put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
505 ff_put_v(bc, ch->end - ch->start); // chapter_len
510 ff_put_v(bc, count);
513 avio_write(bc, dyn_buf, dyn_size);
518 static int write_headers(AVFormatContext *avctx, AVIOContext *bc){
529 put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE);
537 put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE);
544 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
554 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
573 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
583 AVIOContext *bc = s->pb;
644 avio_write(bc, ID_STRING, strlen(ID_STRING));
645 avio_w8(bc, 0);
647 if ((ret = write_headers(s, bc)) < 0)
650 avio_flush(bc);
697 AVIOContext *bc = s->pb, *dyn_bc;
708 if(1LL<<(20+3*nut->header_count) <= avio_tell(bc))
709 write_headers(s, bc);
714 if(pkt->size + 30/*FIXME check*/ + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
737 nut->last_syncpoint_pos= avio_tell(bc);
743 put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
817 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
818 avio_w8(bc, frame_code);
820 ff_put_v(bc, (flags^needed_flags) & ~(FLAG_CODED));
823 if(flags & FLAG_STREAM_ID) ff_put_v(bc, pkt->stream_index);
824 if(flags & FLAG_CODED_PTS) ff_put_v(bc, coded_pts);
825 if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul);
826 if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
828 if(flags & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));
829 else ffio_get_checksum(bc);
831 avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
850 AVIOContext *bc= s->pb;
853 write_headers(s, bc);
854 avio_flush(bc);