Lines Matching refs:bc
272 static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val)
276 ff_put_v(bc, val);
281 static void put_str(AVIOContext *bc, const char *string)
285 ff_put_v(bc, len);
286 avio_write(bc, string, len);
289 static void put_s(AVIOContext *bc, int64_t val)
291 ff_put_v(bc, 2 * FFABS(val) - (val > 0));
295 static inline void ff_put_v_trace(AVIOContext *bc, uint64_t v, const char *file,
300 ff_put_v(bc, v);
303 static inline void put_s_trace(AVIOContext *bc, int64_t v, const char *file, const char *func, int line)
307 put_s(bc, v);
309 #define ff_put_v(bc, v) ff_put_v_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
310 #define put_s(bc, v) put_s_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
314 static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc,
322 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
323 avio_wb64(bc, startcode);
324 ff_put_v(bc, forw_ptr);
326 avio_wl32(bc, ffio_get_checksum(bc));
329 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
330 avio_write(bc, dyn_buf, dyn_size);
332 avio_wl32(bc, ffio_get_checksum(bc));
337 static void write_mainheader(NUTContext *nut, AVIOContext *bc)
343 ff_put_v(bc, nut->version);
345 ff_put_v(bc, nut->minor_version = 1);
346 ff_put_v(bc, nut->avf->nb_streams);
347 ff_put_v(bc, nut->max_distance);
348 ff_put_v(bc, nut->time_base_count);
351 ff_put_v(bc, nut->time_base[i].num);
352 ff_put_v(bc, nut->time_base[i].den);
396 ff_put_v(bc, tmp_flags);
397 ff_put_v(bc, tmp_fields);
398 if (tmp_fields > 0) put_s(bc, tmp_pts);
399 if (tmp_fields > 1) ff_put_v(bc, tmp_mul);
400 if (tmp_fields > 2) ff_put_v(bc, tmp_stream);
401 if (tmp_fields > 3) ff_put_v(bc, tmp_size);
402 if (tmp_fields > 4) ff_put_v(bc, 0 /*tmp_res*/);
403 if (tmp_fields > 5) ff_put_v(bc, j);
404 if (tmp_fields > 6) ff_put_v(bc, tmp_match);
405 if (tmp_fields > 7) ff_put_v(bc, tmp_head_idx);
407 ff_put_v(bc, nut->header_count - 1);
409 ff_put_v(bc, nut->header_len[i]);
410 avio_write(bc, nut->header[i], nut->header_len[i]);
414 ff_put_v(bc, nut->flags);
417 static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
423 ff_put_v(bc, i);
425 case AVMEDIA_TYPE_VIDEO: ff_put_v(bc, 0); break;
426 case AVMEDIA_TYPE_AUDIO: ff_put_v(bc, 1); break;
427 case AVMEDIA_TYPE_SUBTITLE: ff_put_v(bc, 2); break;
428 default: ff_put_v(bc, 3); break;
430 ff_put_v(bc, 4);
432 avio_wl32(bc, codec->codec_tag);
438 ff_put_v(bc, nut->stream[i].time_base - nut->time_base);
439 ff_put_v(bc, nut->stream[i].msb_pts_shift);
440 ff_put_v(bc, nut->stream[i].max_pts_distance);
441 ff_put_v(bc, codec->has_b_frames);
442 avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
444 ff_put_v(bc, codec->extradata_size);
445 avio_write(bc, codec->extradata, codec->extradata_size);
449 ff_put_v(bc, codec->sample_rate);
450 ff_put_v(bc, 1);
451 ff_put_v(bc, codec->channels);
454 ff_put_v(bc, codec->width);
455 ff_put_v(bc, codec->height);
459 ff_put_v(bc, 0);
460 ff_put_v(bc, 0);
462 ff_put_v(bc, st->sample_aspect_ratio.num);
463 ff_put_v(bc, st->sample_aspect_ratio.den);
465 ff_put_v(bc, 0); /* csp type -- unknown */
473 static int add_info(AVIOContext *bc, const char *type, const char *value)
475 put_str(bc, type);
476 put_s(bc, -1);
477 put_str(bc, value);
481 static int write_globalinfo(NUTContext *nut, AVIOContext *bc)
495 ff_put_v(bc, 0); //stream_if_plus1
496 ff_put_v(bc, 0); //chapter_id
497 ff_put_v(bc, 0); //timestamp_start
498 ff_put_v(bc, 0); //length
500 ff_put_v(bc, count);
503 avio_write(bc, dyn_buf, dyn_size);
508 static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id) {
533 ff_put_v(bc, stream_id + 1); //stream_id_plus1
534 ff_put_v(bc, 0); //chapter_id
535 ff_put_v(bc, 0); //timestamp_start
536 ff_put_v(bc, 0); //length
538 ff_put_v(bc, count);
540 avio_write(bc, dyn_buf, dyn_size);
547 static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
559 ff_put_v(bc, 0); // stream_id_plus1
560 put_s(bc, id + 1); // chapter_id
561 put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
562 ff_put_v(bc, ch->end - ch->start); // chapter_len
567 ff_put_v(bc, count);
570 avio_write(bc, dyn_buf, dyn_size);
575 static int write_index(NUTContext *nut, AVIOContext *bc) {
579 int64_t startpos = avio_tell(bc);
582 put_tt(nut, nut->max_pts_tb, bc, nut->max_pts);
584 ff_put_v(bc, nut->sp_count);
588 ff_put_v(bc, (next_node[1]->pos >> 4) - (dummy.pos>>4));
609 ff_put_v(bc, 1 + 2*flag + 4*n);
614 ff_put_v(bc, nus->keyframe_pts[k] - last_pts);
620 payload_size = avio_tell(bc) - startpos + 8 + 4;
622 avio_wb64(bc, 8 + payload_size + av_log2(payload_size) / 7 + 1 + 4*(payload_size > 4096));
627 static int write_headers(AVFormatContext *avctx, AVIOContext *bc)
639 put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE);
648 put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE);
655 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
665 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
684 put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE);
695 AVIOContext *bc = s->pb;
770 avio_write(bc, ID_STRING, strlen(ID_STRING));
771 avio_w8(bc, 0);
773 if ((ret = write_headers(s, bc)) < 0)
779 avio_flush(bc);
831 static int write_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta)
907 ff_put_v(bc, 8);
945 ff_put_v(bc, sm_data_count);
947 avio_write(bc, dyn_buf, dyn_size);
957 AVIOContext *bc = s->pb, *dyn_bc, *sm_bc = NULL;
991 if (1LL << (20 + 3 * nut->header_count) <= avio_tell(bc))
992 write_headers(s, bc);
997 if (data_size + 30 /*FIXME check*/ + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
1026 nut->last_syncpoint_pos = avio_tell(bc);
1037 put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
1127 ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
1128 avio_w8(bc, frame_code);
1130 ff_put_v(bc, (flags ^ needed_flags) & ~(FLAG_CODED));
1133 if (flags & FLAG_STREAM_ID) ff_put_v(bc, pkt->stream_index);
1134 if (flags & FLAG_CODED_PTS) ff_put_v(bc, coded_pts);
1135 if (flags & FLAG_SIZE_MSB ) ff_put_v(bc, data_size / fc->size_mul);
1136 if (flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx = best_header_idx);
1138 if (flags & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));
1139 else ffio_get_checksum(bc);
1142 avio_write(bc, sm_buf, sm_size);
1144 avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
1176 AVIOContext *bc = s->pb, *dyn_bc;
1180 write_headers(s, bc);
1186 put_packet(nut, bc, dyn_bc, 1, INDEX_STARTCODE);