| @@ -216,6 +216,7 @@ static int update_stream_avctx(AVFormatContext *s) · 215 unmodified lines |
| 216 | 216 | int avformat_open_input(AVFormatContext **ps, const char *filename, |
| 217 | 217 | const AVInputFormat *fmt, AVDictionary **options) |
| 218 | 218 | { |
| 219 | + FormatContextInternal *fci; |
| 219 | 220 | AVFormatContext *s = *ps; |
| 220 | 221 | FFFormatContext *si; |
| 221 | 222 | AVDictionary *tmp = NULL; |
| @@ -224,7 +225,8 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, · 2 unmodified lines |
| 224 | 225 | |
| 225 | 226 | if (!s && !(s = avformat_alloc_context())) |
| 226 | 227 | return AVERROR(ENOMEM); |
| 227 | | − si = ffformatcontext(s); |
| 228 | + fci = ff_fc_internal(s); |
| 229 | + si = &fci->fc; |
| 228 | 230 | if (!s->av_class) { |
| 229 | 231 | av_log(NULL, AV_LOG_ERROR, "Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n"); |
| 230 | 232 | return AVERROR(EINVAL); |
| @@ -337,7 +339,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, · 106 unmodified lines |
| 337 | 339 | if (s->pb && !si->data_offset) |
| 338 | 340 | si->data_offset = avio_tell(s->pb); |
| 339 | 341 | |
| 340 | | − si->raw_packet_buffer_size = 0; |
| 342 | + fci->raw_packet_buffer_size = 0; |
| 341 | 343 | |
| 342 | 344 | update_stream_avctx(s); |
| 343 | 345 | |
| @@ -411,7 +413,7 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st) · 67 unmodified lines |
| 411 | 413 | |
| 412 | 414 | static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) |
| 413 | 415 | { |
| 414 | | − FFFormatContext *const si = ffformatcontext(s); |
| 416 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 415 | 417 | FFStream *const sti = ffstream(st); |
| 416 | 418 | |
| 417 | 419 | if (sti->request_probe > 0) { |
| @@ -441,8 +443,8 @@ no_packet: · 23 unmodified lines |
| 441 | 443 | } |
| 442 | 444 | } |
| 443 | 445 | |
| 444 | | − end = si->raw_packet_buffer_size >= s->probesize |
| 445 | | − || sti->probe_packets <= 0; |
| 446 | + end = fci->raw_packet_buffer_size >= s->probesize || |
| 447 | + sti->probe_packets <= 0; |
| 446 | 448 | |
| 447 | 449 | if (end || av_log2(pd->buf_size) != av_log2(pd->buf_size - pkt->size)) { |
| 448 | 450 | int score = set_codec_from_probe_data(s, st, pd); |
| @@ -564,7 +566,7 @@ static void update_timestamps(AVFormatContext *s, AVStream *st, AVPacket *pkt) · 115 unmodified lines |
| 564 | 566 | */ |
| 565 | 567 | static int handle_new_packet(AVFormatContext *s, AVPacket *pkt, int allow_passthrough) |
| 566 | 568 | { |
| 567 | | − FFFormatContext *const si = ffformatcontext(s); |
| 569 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 568 | 570 | AVStream *st; |
| 569 | 571 | FFStream *sti; |
| 570 | 572 | int err; |
| @@ -588,17 +590,17 @@ static int handle_new_packet(AVFormatContext *s, AVPacket *pkt, int allow_passth · 17 unmodified lines |
| 588 | 590 | |
| 589 | 591 | update_timestamps(s, st, pkt); |
| 590 | 592 | |
| 591 | | − if (sti->request_probe <= 0 && allow_passthrough && !si->raw_packet_buffer.head) |
| 593 | + if (sti->request_probe <= 0 && allow_passthrough && !fci->raw_packet_buffer.head) |
| 592 | 594 | return 0; |
| 593 | 595 | |
| 594 | | − err = avpriv_packet_list_put(&si->raw_packet_buffer, pkt, NULL, 0); |
| 596 | + err = avpriv_packet_list_put(&fci->raw_packet_buffer, pkt, NULL, 0); |
| 595 | 597 | if (err < 0) { |
| 596 | 598 | av_packet_unref(pkt); |
| 597 | 599 | return err; |
| 598 | 600 | } |
| 599 | 601 | |
| 600 | | − pkt = &si->raw_packet_buffer.tail->pkt; |
| 601 | | − si->raw_packet_buffer_size += pkt->size; |
| 602 | + pkt = &fci->raw_packet_buffer.tail->pkt; |
| 603 | + fci->raw_packet_buffer_size += pkt->size; |
| 602 | 604 | |
| 603 | 605 | err = probe_codec(s, st, pkt); |
| 604 | 606 | if (err < 0) |
| @@ -616,7 +618,7 @@ int ff_buffer_packet(AVFormatContext *s, AVPacket *pkt) · 11 unmodified lines |
| 616 | 618 | |
| 617 | 619 | int ff_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 618 | 620 | { |
| 619 | | − FFFormatContext *const si = ffformatcontext(s); |
| 621 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 620 | 622 | int err; |
| 621 | 623 | |
| 622 | 624 | #if FF_API_INIT_PACKET |
| @@ -630,16 +632,16 @@ FF_ENABLE_DEPRECATION_WARNINGS · 7 unmodified lines |
| 630 | 632 | #endif |
| 631 | 633 | |
| 632 | 634 | for (;;) { |
| 633 | | − PacketListEntry *pktl = si->raw_packet_buffer.head; |
| 635 | + PacketListEntry *pktl = fci->raw_packet_buffer.head; |
| 634 | 636 | |
| 635 | 637 | if (pktl) { |
| 636 | 638 | AVStream *const st = s->streams[pktl->pkt.stream_index]; |
| 637 | | − if (si->raw_packet_buffer_size >= s->probesize) |
| 639 | + if (fci->raw_packet_buffer_size >= s->probesize) |
| 638 | 640 | if ((err = probe_codec(s, st, NULL)) < 0) |
| 639 | 641 | return err; |
| 640 | 642 | if (ffstream(st)->request_probe <= 0) { |
| 641 | | − avpriv_packet_list_get(&si->raw_packet_buffer, pkt); |
| 642 | | − si->raw_packet_buffer_size -= pkt->size; |
| 643 | + avpriv_packet_list_get(&fci->raw_packet_buffer, pkt); |
| 644 | + fci->raw_packet_buffer_size -= pkt->size; |
| 643 | 645 | return 0; |
| 644 | 646 | } |
| 645 | 647 | } |
| @@ -766,11 +768,12 @@ static int has_decode_delay_been_guessed(AVStream *st) · 120 unmodified lines |
| 766 | 768 | static PacketListEntry *get_next_pkt(AVFormatContext *s, AVStream *st, |
| 767 | 769 | PacketListEntry *pktl) |
| 768 | 770 | { |
| 769 | | − FFFormatContext *const si = ffformatcontext(s); |
| 771 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 772 | + FFFormatContext *const si = &fci->fc; |
| 770 | 773 | if (pktl->next) |
| 771 | 774 | return pktl->next; |
| 772 | 775 | if (pktl == si->packet_buffer.tail) |
| 773 | | − return si->parse_queue.head; |
| 776 | + return fci->parse_queue.head; |
| 774 | 777 | return NULL; |
| 775 | 778 | } |
| 776 | 779 | |
| @@ -850,10 +853,11 @@ static void update_dts_from_pts(AVFormatContext *s, int stream_index, · 73 unmodified lines |
| 850 | 853 | static void update_initial_timestamps(AVFormatContext *s, int stream_index, |
| 851 | 854 | int64_t dts, int64_t pts, AVPacket *pkt) |
| 852 | 855 | { |
| 853 | | − FFFormatContext *const si = ffformatcontext(s); |
| 856 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 857 | + FFFormatContext *const si = &fci->fc; |
| 854 | 858 | AVStream *const st = s->streams[stream_index]; |
| 855 | 859 | FFStream *const sti = ffstream(st); |
| 856 | | − PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head; |
| 860 | + PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : fci->parse_queue.head; |
| 857 | 861 | |
| 858 | 862 | uint64_t shift; |
| 859 | 863 | |
| @@ -903,9 +907,10 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 43 unmodified lines |
| 903 | 907 | static void update_initial_durations(AVFormatContext *s, AVStream *st, |
| 904 | 908 | int stream_index, int64_t duration) |
| 905 | 909 | { |
| 906 | | − FFFormatContext *const si = ffformatcontext(s); |
| 910 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 911 | + FFFormatContext *const si = &fci->fc; |
| 907 | 912 | FFStream *const sti = ffstream(st); |
| 908 | | − PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head; |
| 913 | + PacketListEntry *pktl = si->packet_buffer.head ? si->packet_buffer.head : fci->parse_queue.head; |
| 909 | 914 | int64_t cur_dts = RELATIVE_TS_BASE; |
| 910 | 915 | |
| 911 | 916 | if (sti->first_dts != AV_NOPTS_VALUE) { |
| @@ -931,7 +936,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, · 19 unmodified lines |
| 931 | 936 | av_log(s, AV_LOG_DEBUG, "first_dts %s but no packet with dts in the queue\n", av_ts2str(sti->first_dts)); |
| 932 | 937 | return; |
| 933 | 938 | } |
| 934 | | − pktl = si->packet_buffer.head ? si->packet_buffer.head : si->parse_queue.head; |
| 939 | + pktl = si->packet_buffer.head ? si->packet_buffer.head : fci->parse_queue.head; |
| 935 | 940 | sti->first_dts = cur_dts; |
| 936 | 941 | } else if (sti->cur_dts != RELATIVE_TS_BASE) |
| 937 | 942 | return; |
| @@ -963,7 +968,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 25 unmodified lines |
| 963 | 968 | AVCodecParserContext *pc, AVPacket *pkt, |
| 964 | 969 | int64_t next_dts, int64_t next_pts) |
| 965 | 970 | { |
| 966 | | − FFFormatContext *const si = ffformatcontext(s); |
| 971 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 972 | + FFFormatContext *const si = &fci->fc; |
| 967 | 973 | FFStream *const sti = ffstream(st); |
| 968 | 974 | int num, den, presentation_delayed, delay; |
| 969 | 975 | int64_t offset; |
| @@ -1048,7 +1054,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 78 unmodified lines |
| 1048 | 1054 | } |
| 1049 | 1055 | } |
| 1050 | 1056 | |
| 1051 | | − if (pkt->duration > 0 && (si->packet_buffer.head || si->parse_queue.head)) |
| 1057 | + if (pkt->duration > 0 && (si->packet_buffer.head || fci->parse_queue.head)) |
| 1052 | 1058 | update_initial_durations(s, st, pkt->stream_index, pkt->duration); |
| 1053 | 1059 | |
| 1054 | 1060 | /* Correct timestamps with byte offset if demuxers only have timestamps |
| @@ -1156,7 +1162,8 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 101 unmodified lines |
| 1156 | 1162 | static int parse_packet(AVFormatContext *s, AVPacket *pkt, |
| 1157 | 1163 | int stream_index, int flush) |
| 1158 | 1164 | { |
| 1159 | | − FFFormatContext *const si = ffformatcontext(s); |
| 1165 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 1166 | + FFFormatContext *const si = &fci->fc; |
| 1160 | 1167 | AVPacket *out_pkt = si->parse_pkt; |
| 1161 | 1168 | AVStream *st = s->streams[stream_index]; |
| 1162 | 1169 | FFStream *const sti = ffstream(st); |
| @@ -1249,7 +1256,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, · 86 unmodified lines |
| 1249 | 1256 | |
| 1250 | 1257 | compute_pkt_fields(s, st, sti->parser, out_pkt, next_dts, next_pts); |
| 1251 | 1258 | |
| 1252 | | − ret = avpriv_packet_list_put(&si->parse_queue, |
| 1259 | + ret = avpriv_packet_list_put(&fci->parse_queue, |
| 1253 | 1260 | out_pkt, NULL, 0); |
| 1254 | 1261 | if (ret < 0) |
| 1255 | 1262 | goto fail; |
| @@ -1324,11 +1331,12 @@ static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket * · 68 unmodified lines |
| 1324 | 1331 | |
| 1325 | 1332 | static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) |
| 1326 | 1333 | { |
| 1327 | | − FFFormatContext *const si = ffformatcontext(s); |
| 1334 | + FormatContextInternal *const fci = ff_fc_internal(s); |
| 1335 | + FFFormatContext *const si = &fci->fc; |
| 1328 | 1336 | int ret, got_packet = 0; |
| 1329 | 1337 | AVDictionary *metadata = NULL; |
| 1330 | 1338 | |
| 1331 | | − while (!got_packet && !si->parse_queue.head) { |
| 1339 | + while (!got_packet && !fci->parse_queue.head) { |
| 1332 | 1340 | AVStream *st; |
| 1333 | 1341 | FFStream *sti; |
| 1334 | 1342 | |
| @@ -1456,8 +1464,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 121 unmodified lines |
| 1456 | 1464 | } |
| 1457 | 1465 | } |
| 1458 | 1466 | |
| 1459 | | − if (!got_packet && si->parse_queue.head) |
| 1460 | | − ret = avpriv_packet_list_get(&si->parse_queue, pkt); |
| 1467 | + if (!got_packet && fci->parse_queue.head) |
| 1468 | + ret = avpriv_packet_list_get(&fci->parse_queue, pkt); |
| 1461 | 1469 | |
| 1462 | 1470 | if (ret >= 0) { |
| 1463 | 1471 | AVStream *const st = s->streams[pkt->stream_index]; |
| @@ -1508,7 +1516,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines |
| 1508 | 1516 | #endif |
| 1509 | 1517 | } |
| 1510 | 1518 | |
| 1511 | | − if (!si->metafree) { |
| 1519 | + if (!fci->metafree) { |
| 1512 | 1520 | int metaret = av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata); |
| 1513 | 1521 | if (metadata) { |
| 1514 | 1522 | s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; |
| @@ -1516,7 +1524,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line |
| 1516 | 1524 | av_dict_free(&metadata); |
| 1517 | 1525 | av_opt_set_dict_val(s, "metadata", NULL, AV_OPT_SEARCH_CHILDREN); |
| 1518 | 1526 | } |
| 1519 | | − si->metafree = metaret == AVERROR_OPTION_NOT_FOUND; |
| 1527 | + fci->metafree = metaret == AVERROR_OPTION_NOT_FOUND; |
| 1520 | 1528 | } |
| 1521 | 1529 | |
| 1522 | 1530 | if (s->debug & FF_FDEBUG_TS) |