This is not an API change; the fields were explicitly declared private before.
Unified · Split
| @@ -878,7 +878,7 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb) · 877 unmodified lines | |||
| 878 | if (asf->no_resync_search) | 878 | if (asf->no_resync_search) |
| 879 | off = 3; | 879 | off = 3; |
| 880 | else if (s->packet_size > 0) | 880 | else if (s->packet_size > 0) |
| 881 | off = (avio_tell(pb) - s->data_offset) % s->packet_size + 3; | 881 | off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3; |
| 882 | 882 | ||
| 883 | c = d = e = -1; | 883 | c = d = e = -1; |
| 884 | while (off-- > 0) { | 884 | while (off-- > 0) { |
| @@ -1361,9 +1361,9 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, · 476 unmodified lines | |||
| 1361 | start_pos[i] = pos; | 1361 | start_pos[i] = pos; |
| 1362 | 1362 | ||
| 1363 | if (s->packet_size > 0) | 1363 | if (s->packet_size > 0) |
| 1364 | pos = (pos + s->packet_size - 1 - s->data_offset) / | 1364 | pos = (pos + s->packet_size - 1 - s->internal->data_offset) / |
| 1365 | s->packet_size * s->packet_size + | 1365 | s->packet_size * s->packet_size + |
| 1366 | s->data_offset; | 1366 | s->internal->data_offset; |
| 1367 | *ppos = pos; | 1367 | *ppos = pos; |
| 1368 | avio_seek(s->pb, pos, SEEK_SET); | 1368 | avio_seek(s->pb, pos, SEEK_SET); |
| 1369 | 1369 | ||
| @@ -1437,7 +1437,7 @@ static int asf_build_simple_index(AVFormatContext *s, int stream_index) · 67 unmodified lines | |||
| 1437 | for (i = 0; i < ict; i++) { | 1437 | for (i = 0; i < ict; i++) { |
| 1438 | int pktnum = avio_rl32(s->pb); | 1438 | int pktnum = avio_rl32(s->pb); |
| 1439 | int pktct = avio_rl16(s->pb); | 1439 | int pktct = avio_rl16(s->pb); |
| 1440 | int64_t pos = s->data_offset + s->packet_size * (int64_t)pktnum; | 1440 | int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum; |
| 1441 | int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0); | 1441 | int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0); |
| 1442 | 1442 | ||
| 1443 | if (pos != last_pos) { | 1443 | if (pos != last_pos) { |
| @@ -1480,7 +1480,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, · 36 unmodified lines | |||
| 1480 | /* explicitly handle the case of seeking to 0 */ | 1480 | /* explicitly handle the case of seeking to 0 */ |
| 1481 | if (!pts) { | 1481 | if (!pts) { |
| 1482 | asf_reset_header(s); | 1482 | asf_reset_header(s); |
| 1483 | avio_seek(s->pb, s->data_offset, SEEK_SET); | 1483 | avio_seek(s->pb, s->internal->data_offset, SEEK_SET); |
| 1484 | return 0; | 1484 | return 0; |
| 1485 | } | 1485 | } |
| 1486 | 1486 | ||
| @@ -1210,55 +1210,6 @@ typedef struct AVFormatContext { · 1209 unmodified lines | |||
| 1210 | #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative | 1210 | #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative |
| 1211 | #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0 | 1211 | #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0 |
| 1212 | 1212 | ||
| 1213 | /***************************************************************** | ||
| 1214 | * All fields below this line are not part of the public API. They | ||
| 1215 | * may not be used outside of libavformat and can be changed and | ||
| 1216 | * removed at will. | ||
| 1217 | * New public fields should be added right above. | ||
| 1218 | ***************************************************************** | ||
| 1219 | */ | ||
| 1220 | |||
| 1221 | /** | ||
| 1222 | * This buffer is only needed when packets were already buffered but | ||
| 1223 | * not decoded, for example to get the codec parameters in MPEG | ||
| 1224 | * streams. | ||
| 1225 | */ | ||
| 1226 | struct AVPacketList *packet_buffer; | ||
| 1227 | struct AVPacketList *packet_buffer_end; | ||
| 1228 | |||
| 1229 | /* av_seek_frame() support */ | ||
| 1230 | int64_t data_offset; /**< offset of the first packet */ | ||
| 1231 | |||
| 1232 | /** | ||
| 1233 | * Raw packets from the demuxer, prior to parsing and decoding. | ||
| 1234 | * This buffer is used for buffering packets until the codec can | ||
| 1235 | * be identified, as parsing cannot be done without knowing the | ||
| 1236 | * codec. | ||
| 1237 | */ | ||
| 1238 | struct AVPacketList *raw_packet_buffer; | ||
| 1239 | struct AVPacketList *raw_packet_buffer_end; | ||
| 1240 | /** | ||
| 1241 | * Packets split by the parser get queued here. | ||
| 1242 | */ | ||
| 1243 | struct AVPacketList *parse_queue; | ||
| 1244 | struct AVPacketList *parse_queue_end; | ||
| 1245 | /** | ||
| 1246 | * Remaining size available for raw_packet_buffer, in bytes. | ||
| 1247 | */ | ||
| 1248 | #define RAW_PACKET_BUFFER_SIZE 2500000 | ||
| 1249 | int raw_packet_buffer_remaining_size; | ||
| 1250 | |||
| 1251 | /** | ||
| 1252 | * Offset to remap timestamps to be non-negative. | ||
| 1253 | * Expressed in timebase units. | ||
| 1254 | */ | ||
| 1255 | int64_t offset; | ||
| 1256 | |||
| 1257 | /** | ||
| 1258 | * Timebase for the timestamp offset. | ||
| 1259 | */ | ||
| 1260 | AVRational offset_timebase; | ||
| 1261 | |||
| 1262 | /** | 1213 | /** |
| 1263 | * An opaque field for libavformat internal usage. | 1214 | * An opaque field for libavformat internal usage. |
| 1264 | * Must not be accessed in any way by callers. | 1215 | * Must not be accessed in any way by callers. |
| @@ -398,7 +398,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, · 397 unmodified lines | |||
| 398 | const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height, | 398 | const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height, |
| 399 | c->vst->codec->pix_fmt); | 399 | c->vst->codec->pix_fmt); |
| 400 | int64_t offset; | 400 | int64_t offset; |
| 401 | int64_t size = avio_size(s->pb) - s->data_offset; | 401 | int64_t size = avio_size(s->pb) - s->internal->data_offset; |
| 402 | int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size; | 402 | int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size; |
| 403 | 403 | ||
| 404 | offset = sys->frame_size * timestamp; | 404 | offset = sys->frame_size * timestamp; |
| @@ -408,7 +408,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, · 3 unmodified lines | |||
| 408 | else if (offset < 0) | 408 | else if (offset < 0) |
| 409 | offset = 0; | 409 | offset = 0; |
| 410 | 410 | ||
| 411 | return offset + s->data_offset; | 411 | return offset + s->internal->data_offset; |
| 412 | } | 412 | } |
| 413 | 413 | ||
| 414 | void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset) | 414 | void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset) |
| @@ -49,6 +49,47 @@ struct AVFormatInternal { · 48 unmodified lines | |||
| 49 | * Muxing only. | 49 | * Muxing only. |
| 50 | */ | 50 | */ |
| 51 | int nb_interleaved_streams; | 51 | int nb_interleaved_streams; |
| 52 | |||
| 53 | /** | ||
| 54 | * This buffer is only needed when packets were already buffered but | ||
| 55 | * not decoded, for example to get the codec parameters in MPEG | ||
| 56 | * streams. | ||
| 57 | */ | ||
| 58 | struct AVPacketList *packet_buffer; | ||
| 59 | struct AVPacketList *packet_buffer_end; | ||
| 60 | |||
| 61 | /* av_seek_frame() support */ | ||
| 62 | int64_t data_offset; /**< offset of the first packet */ | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Raw packets from the demuxer, prior to parsing and decoding. | ||
| 66 | * This buffer is used for buffering packets until the codec can | ||
| 67 | * be identified, as parsing cannot be done without knowing the | ||
| 68 | * codec. | ||
| 69 | */ | ||
| 70 | struct AVPacketList *raw_packet_buffer; | ||
| 71 | struct AVPacketList *raw_packet_buffer_end; | ||
| 72 | /** | ||
| 73 | * Packets split by the parser get queued here. | ||
| 74 | */ | ||
| 75 | struct AVPacketList *parse_queue; | ||
| 76 | struct AVPacketList *parse_queue_end; | ||
| 77 | /** | ||
| 78 | * Remaining size available for raw_packet_buffer, in bytes. | ||
| 79 | */ | ||
| 80 | #define RAW_PACKET_BUFFER_SIZE 2500000 | ||
| 81 | int raw_packet_buffer_remaining_size; | ||
| 82 | |||
| 83 | /** | ||
| 84 | * Offset to remap timestamps to be non-negative. | ||
| 85 | * Expressed in timebase units. | ||
| 86 | */ | ||
| 87 | int64_t offset; | ||
| 88 | |||
| 89 | /** | ||
| 90 | * Timebase for the timestamp offset. | ||
| 91 | */ | ||
| 92 | AVRational offset_timebase; | ||
| 52 | }; | 93 | }; |
| 53 | 94 | ||
| 54 | void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem); | 95 | void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem); |
| @@ -166,7 +166,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) · 165 unmodified lines | |||
| 166 | AVIOContext *pb = s->pb; | 166 | AVIOContext *pb = s->pb; |
| 167 | int ret; | 167 | int ret; |
| 168 | 168 | ||
| 169 | if((avio_tell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size) | 169 | if((avio_tell(pb) - s->internal->data_offset + mtv->img_segment_size) % mtv->full_segment_size) |
| 170 | { | 170 | { |
| 171 | avio_skip(pb, MTV_AUDIO_PADDING_SIZE); | 171 | avio_skip(pb, MTV_AUDIO_PADDING_SIZE); |
| 172 | 172 | ||
| @@ -329,13 +329,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) · 328 unmodified lines | |||
| 329 | AVRational time_base = s->streams[pkt->stream_index]->time_base; | 329 | AVRational time_base = s->streams[pkt->stream_index]->time_base; |
| 330 | int64_t offset = 0; | 330 | int64_t offset = 0; |
| 331 | 331 | ||
| 332 | if (s->offset == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && | 332 | if (s->internal->offset == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && |
| 333 | (pkt->dts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) { | 333 | (pkt->dts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) { |
| 334 | s->offset = -pkt->dts; | 334 | s->internal->offset = -pkt->dts; |
| 335 | s->offset_timebase = time_base; | 335 | s->internal->offset_timebase = time_base; |
| 336 | } | 336 | } |
| 337 | if (s->offset != AV_NOPTS_VALUE) | 337 | if (s->internal->offset != AV_NOPTS_VALUE) |
| 338 | offset = av_rescale_q(s->offset, s->offset_timebase, time_base); | 338 | offset = av_rescale_q(s->internal->offset, s->internal->offset_timebase, time_base); |
| 339 | 339 | ||
| 340 | if (pkt->dts != AV_NOPTS_VALUE) | 340 | if (pkt->dts != AV_NOPTS_VALUE) |
| 341 | pkt->dts += offset; | 341 | pkt->dts += offset; |
| @@ -428,20 +428,20 @@ FF_ENABLE_DEPRECATION_WARNINGS · 86 unmodified lines | |||
| 428 | if (s->streams[pkt->stream_index]->last_in_packet_buffer) { | 428 | if (s->streams[pkt->stream_index]->last_in_packet_buffer) { |
| 429 | next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next); | 429 | next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next); |
| 430 | } else | 430 | } else |
| 431 | next_point = &s->packet_buffer; | 431 | next_point = &s->internal->packet_buffer; |
| 432 | 432 | ||
| 433 | if (*next_point) { | 433 | if (*next_point) { |
| 434 | if (compare(s, &s->packet_buffer_end->pkt, pkt)) { | 434 | if (compare(s, &s->internal->packet_buffer_end->pkt, pkt)) { |
| 435 | while (!compare(s, &(*next_point)->pkt, pkt)) | 435 | while (!compare(s, &(*next_point)->pkt, pkt)) |
| 436 | next_point = &(*next_point)->next; | 436 | next_point = &(*next_point)->next; |
| 437 | goto next_non_null; | 437 | goto next_non_null; |
| 438 | } else { | 438 | } else { |
| 439 | next_point = &(s->packet_buffer_end->next); | 439 | next_point = &(s->internal->packet_buffer_end->next); |
| 440 | } | 440 | } |
| 441 | } | 441 | } |
| 442 | assert(!*next_point); | 442 | assert(!*next_point); |
| 443 | 443 | ||
| 444 | s->packet_buffer_end = this_pktl; | 444 | s->internal->packet_buffer_end = this_pktl; |
| 445 | next_non_null: | 445 | next_non_null: |
| 446 | 446 | ||
| 447 | this_pktl->next = *next_point; | 447 | this_pktl->next = *next_point; |
| @@ -477,8 +477,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, · 29 unmodified lines | |||
| 477 | return ret; | 477 | return ret; |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | if (s->max_interleave_delta > 0 && s->packet_buffer && !flush) { | 480 | if (s->max_interleave_delta > 0 && s->internal->packet_buffer && !flush) { |
| 481 | AVPacket *top_pkt = &s->packet_buffer->pkt; | 481 | AVPacket *top_pkt = &s->internal->packet_buffer->pkt; |
| 482 | int64_t delta_dts = INT64_MIN; | 482 | int64_t delta_dts = INT64_MIN; |
| 483 | int64_t top_dts = av_rescale_q(top_pkt->dts, | 483 | int64_t top_dts = av_rescale_q(top_pkt->dts, |
| 484 | s->streams[top_pkt->stream_index]->time_base, | 484 | s->streams[top_pkt->stream_index]->time_base, |
| @@ -512,12 +512,12 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, · 27 unmodified lines | |||
| 512 | 512 | ||
| 513 | 513 | ||
| 514 | if (stream_count && (s->internal->nb_interleaved_streams == stream_count || flush)) { | 514 | if (stream_count && (s->internal->nb_interleaved_streams == stream_count || flush)) { |
| 515 | pktl = s->packet_buffer; | 515 | pktl = s->internal->packet_buffer; |
| 516 | *out = pktl->pkt; | 516 | *out = pktl->pkt; |
| 517 | 517 | ||
| 518 | s->packet_buffer = pktl->next; | 518 | s->internal->packet_buffer = pktl->next; |
| 519 | if (!s->packet_buffer) | 519 | if (!s->internal->packet_buffer) |
| 520 | s->packet_buffer_end = NULL; | 520 | s->internal->packet_buffer_end = NULL; |
| 521 | 521 | ||
| 522 | if (s->streams[out->stream_index]->last_in_packet_buffer == pktl) | 522 | if (s->streams[out->stream_index]->last_in_packet_buffer == pktl) |
| 523 | s->streams[out->stream_index]->last_in_packet_buffer = NULL; | 523 | s->streams[out->stream_index]->last_in_packet_buffer = NULL; |
| @@ -1838,7 +1838,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket · 1837 unmodified lines | |||
| 1838 | stream_count += !!s->streams[i]->last_in_packet_buffer; | 1838 | stream_count += !!s->streams[i]->last_in_packet_buffer; |
| 1839 | 1839 | ||
| 1840 | if (stream_count && (s->nb_streams == stream_count || flush)) { | 1840 | if (stream_count && (s->nb_streams == stream_count || flush)) { |
| 1841 | AVPacketList *pktl = s->packet_buffer; | 1841 | AVPacketList *pktl = s->internal->packet_buffer; |
| 1842 | if (s->nb_streams != stream_count) { | 1842 | if (s->nb_streams != stream_count) { |
| 1843 | AVPacketList *last = NULL; | 1843 | AVPacketList *last = NULL; |
| 1844 | // find last packet in edit unit | 1844 | // find last packet in edit unit |
| @@ -1862,20 +1862,20 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket · 17 unmodified lines | |||
| 1862 | if (last) | 1862 | if (last) |
| 1863 | last->next = NULL; | 1863 | last->next = NULL; |
| 1864 | else { | 1864 | else { |
| 1865 | s->packet_buffer = NULL; | 1865 | s->internal->packet_buffer = NULL; |
| 1866 | s->packet_buffer_end= NULL; | 1866 | s->internal->packet_buffer_end= NULL; |
| 1867 | goto out; | 1867 | goto out; |
| 1868 | } | 1868 | } |
| 1869 | pktl = s->packet_buffer; | 1869 | pktl = s->internal->packet_buffer; |
| 1870 | } | 1870 | } |
| 1871 | 1871 | ||
| 1872 | *out = pktl->pkt; | 1872 | *out = pktl->pkt; |
| 1873 | av_dlog(s, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts); | 1873 | av_dlog(s, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts); |
| 1874 | s->packet_buffer = pktl->next; | 1874 | s->internal->packet_buffer = pktl->next; |
| 1875 | if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl) | 1875 | if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl) |
| 1876 | s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL; | 1876 | s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL; |
| 1877 | if(!s->packet_buffer) | 1877 | if(!s->internal->packet_buffer) |
| 1878 | s->packet_buffer_end= NULL; | 1878 | s->internal->packet_buffer_end= NULL; |
| 1879 | av_freep(&pktl); | 1879 | av_freep(&pktl); |
| 1880 | return 1; | 1880 | return 1; |
| 1881 | } else { | 1881 | } else { |
| @@ -728,7 +728,7 @@ static int nut_read_header(AVFormatContext *s) · 727 unmodified lines | |||
| 728 | decode_info_header(nut); | 728 | decode_info_header(nut); |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | s->data_offset = pos - 8; | 731 | s->internal->data_offset = pos - 8; |
| 732 | 732 | ||
| 733 | if (bc->seekable) { | 733 | if (bc->seekable) { |
| 734 | int64_t orig_pos = avio_tell(bc); | 734 | int64_t orig_pos = avio_tell(bc); |
| @@ -414,8 +414,8 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, · 413 unmodified lines | |||
| 414 | 414 | ||
| 415 | // Update the header state for all streams and | 415 | // Update the header state for all streams and |
| 416 | // compute the data_offset. | 416 | // compute the data_offset. |
| 417 | if (!s->data_offset) | 417 | if (!s->internal->data_offset) |
| 418 | s->data_offset = os->sync_pos; | 418 | s->internal->data_offset = os->sync_pos; |
| 419 | 419 | ||
| 420 | for (i = 0; i < ogg->nstreams; i++) { | 420 | for (i = 0; i < ogg->nstreams; i++) { |
| 421 | struct ogg_stream *cur_os = ogg->streams + i; | 421 | struct ogg_stream *cur_os = ogg->streams + i; |
| @@ -423,7 +423,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, · 1 unmodified line | |||
| 423 | // if we have a partial non-header packet, its start is | 423 | // if we have a partial non-header packet, its start is |
| 424 | // obviously at or after the data start | 424 | // obviously at or after the data start |
| 425 | if (cur_os->incomplete) | 425 | if (cur_os->incomplete) |
| 426 | s->data_offset = FFMIN(s->data_offset, cur_os->sync_pos); | 426 | s->internal->data_offset = FFMIN(s->internal->data_offset, cur_os->sync_pos); |
| 427 | } | 427 | } |
| 428 | } else { | 428 | } else { |
| 429 | os->nb_header++; | 429 | os->nb_header++; |
| @@ -101,13 +101,13 @@ AVFormatContext *avformat_alloc_context(void) · 100 unmodified lines | |||
| 101 | ic = av_malloc(sizeof(AVFormatContext)); | 101 | ic = av_malloc(sizeof(AVFormatContext)); |
| 102 | if (!ic) return ic; | 102 | if (!ic) return ic; |
| 103 | avformat_get_context_defaults(ic); | 103 | avformat_get_context_defaults(ic); |
| 104 | ic->offset = AV_NOPTS_VALUE; | ||
| 105 | 104 | ||
| 106 | ic->internal = av_mallocz(sizeof(*ic->internal)); | 105 | ic->internal = av_mallocz(sizeof(*ic->internal)); |
| 107 | if (!ic->internal) { | 106 | if (!ic->internal) { |
| 108 | avformat_free_context(ic); | 107 | avformat_free_context(ic); |
| 109 | return NULL; | 108 | return NULL; |
| 110 | } | 109 | } |
| 110 | ic->internal->offset = AV_NOPTS_VALUE; | ||
| 111 | 111 | ||
| 112 | return ic; | 112 | return ic; |
| 113 | } | 113 | } |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | #include "libavutil/mathematics.h" | 22 | #include "libavutil/mathematics.h" |
| 23 | #include "avformat.h" | 23 | #include "avformat.h" |
| 24 | #include "internal.h" | ||
| 24 | #include "pcm.h" | 25 | #include "pcm.h" |
| 25 | 26 | ||
| 26 | int ff_pcm_read_seek(AVFormatContext *s, | 27 | int ff_pcm_read_seek(AVFormatContext *s, |
| @@ -50,7 +51,7 @@ int ff_pcm_read_seek(AVFormatContext *s, · 23 unmodified lines | |||
| 50 | 51 | ||
| 51 | /* recompute exact position */ | 52 | /* recompute exact position */ |
| 52 | st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); | 53 | st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); |
| 53 | if ((ret = avio_seek(s->pb, pos + s->data_offset, SEEK_SET)) < 0) | 54 | if ((ret = avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET)) < 0) |
| 54 | return ret; | 55 | return ret; |
| 55 | return 0; | 56 | return 0; |
| 56 | } | 57 | } |
| @@ -183,8 +183,8 @@ static int r3d_read_header(AVFormatContext *s) · 182 unmodified lines | |||
| 183 | return -1; | 183 | return -1; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | s->data_offset = avio_tell(s->pb); | 186 | s->internal->data_offset = avio_tell(s->pb); |
| 187 | av_dlog(s, "data offset %#"PRIx64"\n", s->data_offset); | 187 | av_dlog(s, "data offset %#"PRIx64"\n", s->internal->data_offset); |
| 188 | if (!s->pb->seekable) | 188 | if (!s->pb->seekable) |
| 189 | return 0; | 189 | return 0; |
| 190 | // find REOB/REOF/REOS to load index | 190 | // find REOB/REOF/REOS to load index |
| @@ -210,7 +210,7 @@ static int r3d_read_header(AVFormatContext *s) · 19 unmodified lines | |||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | out: | 212 | out: |
| 213 | avio_seek(s->pb, s->data_offset, SEEK_SET); | 213 | avio_seek(s->pb, s->internal->data_offset, SEEK_SET); |
| 214 | return 0; | 214 | return 0; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| @@ -238,8 +238,8 @@ static int queue_attached_pictures(AVFormatContext *s) · 237 unmodified lines | |||
| 238 | if (!copy.buf) | 238 | if (!copy.buf) |
| 239 | return AVERROR(ENOMEM); | 239 | return AVERROR(ENOMEM); |
| 240 | 240 | ||
| 241 | add_to_pktbuf(&s->raw_packet_buffer, ©, | 241 | add_to_pktbuf(&s->internal->raw_packet_buffer, ©, |
| 242 | &s->raw_packet_buffer_end); | 242 | &s->internal->raw_packet_buffer_end); |
| 243 | } | 243 | } |
| 244 | return 0; | 244 | return 0; |
| 245 | } | 245 | } |
| @@ -307,10 +307,10 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, · 61 unmodified lines | |||
| 307 | if ((ret = queue_attached_pictures(s)) < 0) | 307 | if ((ret = queue_attached_pictures(s)) < 0) |
| 308 | goto fail; | 308 | goto fail; |
| 309 | 309 | ||
| 310 | if (s->pb && !s->data_offset) | 310 | if (s->pb && !s->internal->data_offset) |
| 311 | s->data_offset = avio_tell(s->pb); | 311 | s->internal->data_offset = avio_tell(s->pb); |
| 312 | 312 | ||
| 313 | s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; | 313 | s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; |
| 314 | 314 | ||
| 315 | if (options) { | 315 | if (options) { |
| 316 | av_dict_free(options); | 316 | av_dict_free(options); |
| @@ -375,14 +375,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) · 58 unmodified lines | |||
| 375 | AVStream *st; | 375 | AVStream *st; |
| 376 | 376 | ||
| 377 | for (;;) { | 377 | for (;;) { |
| 378 | AVPacketList *pktl = s->raw_packet_buffer; | 378 | AVPacketList *pktl = s->internal->raw_packet_buffer; |
| 379 | 379 | ||
| 380 | if (pktl) { | 380 | if (pktl) { |
| 381 | *pkt = pktl->pkt; | 381 | *pkt = pktl->pkt; |
| 382 | st = s->streams[pkt->stream_index]; | 382 | st = s->streams[pkt->stream_index]; |
| 383 | if (st->codec->codec_id != AV_CODEC_ID_PROBE || | 383 | if (st->codec->codec_id != AV_CODEC_ID_PROBE || |
| 384 | !st->probe_packets || | 384 | !st->probe_packets || |
| 385 | s->raw_packet_buffer_remaining_size < pkt->size) { | 385 | s->internal->raw_packet_buffer_remaining_size < pkt->size) { |
| 386 | AVProbeData *pd; | 386 | AVProbeData *pd; |
| 387 | if (st->probe_packets) | 387 | if (st->probe_packets) |
| 388 | if ((err = probe_codec(s, st, NULL)) < 0) | 388 | if ((err = probe_codec(s, st, NULL)) < 0) |
| @@ -390,8 +390,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line | |||
| 390 | pd = &st->probe_data; | 390 | pd = &st->probe_data; |
| 391 | av_freep(&pd->buf); | 391 | av_freep(&pd->buf); |
| 392 | pd->buf_size = 0; | 392 | pd->buf_size = 0; |
| 393 | s->raw_packet_buffer = pktl->next; | 393 | s->internal->raw_packet_buffer = pktl->next; |
| 394 | s->raw_packet_buffer_remaining_size += pkt->size; | 394 | s->internal->raw_packet_buffer_remaining_size += pkt->size; |
| 395 | av_free(pktl); | 395 | av_free(pktl); |
| 396 | return 0; | 396 | return 0; |
| 397 | } | 397 | } |
| @@ -443,8 +443,9 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) · 45 unmodified lines | |||
| 443 | !st->probe_packets)) | 443 | !st->probe_packets)) |
| 444 | return ret; | 444 | return ret; |
| 445 | 445 | ||
| 446 | add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end); | 446 | add_to_pktbuf(&s->internal->raw_packet_buffer, pkt, |
| 447 | s->raw_packet_buffer_remaining_size -= pkt->size; | 447 | &s->internal->raw_packet_buffer_end); |
| 448 | s->internal->raw_packet_buffer_remaining_size -= pkt->size; | ||
| 448 | 449 | ||
| 449 | if ((err = probe_codec(s, st, pkt)) < 0) | 450 | if ((err = probe_codec(s, st, pkt)) < 0) |
| 450 | return err; | 451 | return err; |
| @@ -515,7 +516,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 64 unmodified lines | |||
| 515 | int64_t dts, int64_t pts) | 516 | int64_t dts, int64_t pts) |
| 516 | { | 517 | { |
| 517 | AVStream *st = s->streams[stream_index]; | 518 | AVStream *st = s->streams[stream_index]; |
| 518 | AVPacketList *pktl = s->packet_buffer; | 519 | AVPacketList *pktl = s->internal->packet_buffer; |
| 519 | 520 | ||
| 520 | if (st->first_dts != AV_NOPTS_VALUE || | 521 | if (st->first_dts != AV_NOPTS_VALUE || |
| 521 | dts == AV_NOPTS_VALUE || | 522 | dts == AV_NOPTS_VALUE || |
| @@ -545,7 +546,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, · 23 unmodified lines | |||
| 545 | static void update_initial_durations(AVFormatContext *s, AVStream *st, | 546 | static void update_initial_durations(AVFormatContext *s, AVStream *st, |
| 546 | int stream_index, int duration) | 547 | int stream_index, int duration) |
| 547 | { | 548 | { |
| 548 | AVPacketList *pktl = s->packet_buffer; | 549 | AVPacketList *pktl = s->internal->packet_buffer; |
| 549 | int64_t cur_dts = 0; | 550 | int64_t cur_dts = 0; |
| 550 | 551 | ||
| 551 | if (st->first_dts != AV_NOPTS_VALUE) { | 552 | if (st->first_dts != AV_NOPTS_VALUE) { |
| @@ -559,7 +560,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st, · 7 unmodified lines | |||
| 559 | cur_dts -= duration; | 560 | cur_dts -= duration; |
| 560 | } | 561 | } |
| 561 | } | 562 | } |
| 562 | pktl = s->packet_buffer; | 563 | pktl = s->internal->packet_buffer; |
| 563 | st->first_dts = cur_dts; | 564 | st->first_dts = cur_dts; |
| 564 | } else if (st->cur_dts) | 565 | } else if (st->cur_dts) |
| 565 | return; | 566 | return; |
| @@ -628,7 +629,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 62 unmodified lines | |||
| 628 | den * (int64_t) st->time_base.num, | 629 | den * (int64_t) st->time_base.num, |
| 629 | AV_ROUND_DOWN); | 630 | AV_ROUND_DOWN); |
| 630 | 631 | ||
| 631 | if (pkt->duration != 0 && s->packet_buffer) | 632 | if (pkt->duration != 0 && s->internal->packet_buffer) |
| 632 | update_initial_durations(s, st, pkt->stream_index, | 633 | update_initial_durations(s, st, pkt->stream_index, |
| 633 | pkt->duration); | 634 | pkt->duration); |
| 634 | } | 635 | } |
| @@ -691,7 +692,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, · 56 unmodified lines | |||
| 691 | num * (int64_t) st->time_base.den, | 692 | num * (int64_t) st->time_base.den, |
| 692 | den * (int64_t) st->time_base.num, | 693 | den * (int64_t) st->time_base.num, |
| 693 | AV_ROUND_DOWN); | 694 | AV_ROUND_DOWN); |
| 694 | if (duration != 0 && s->packet_buffer) | 695 | if (duration != 0 && s->internal->packet_buffer) |
| 695 | update_initial_durations(s, st, pkt->stream_index, | 696 | update_initial_durations(s, st, pkt->stream_index, |
| 696 | duration); | 697 | duration); |
| 697 | } | 698 | } |
| @@ -837,7 +838,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 139 unmodified lines | |||
| 837 | if ((ret = av_dup_packet(&out_pkt)) < 0) | 838 | if ((ret = av_dup_packet(&out_pkt)) < 0) |
| 838 | goto fail; | 839 | goto fail; |
| 839 | 840 | ||
| 840 | if (!add_to_pktbuf(&s->parse_queue, &out_pkt, &s->parse_queue_end)) { | 841 | if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) { |
| 841 | av_free_packet(&out_pkt); | 842 | av_free_packet(&out_pkt); |
| 842 | ret = AVERROR(ENOMEM); | 843 | ret = AVERROR(ENOMEM); |
| 843 | goto fail; | 844 | goto fail; |
| @@ -877,7 +878,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 33 unmodified lines | |||
| 877 | 878 | ||
| 878 | av_init_packet(pkt); | 879 | av_init_packet(pkt); |
| 879 | 880 | ||
| 880 | while (!got_packet && !s->parse_queue) { | 881 | while (!got_packet && !s->internal->parse_queue) { |
| 881 | AVStream *st; | 882 | AVStream *st; |
| 882 | AVPacket cur_pkt; | 883 | AVPacket cur_pkt; |
| 883 | 884 | ||
| @@ -946,8 +947,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 62 unmodified lines | |||
| 946 | } | 947 | } |
| 947 | } | 948 | } |
| 948 | 949 | ||
| 949 | if (!got_packet && s->parse_queue) | 950 | if (!got_packet && s->internal->parse_queue) |
| 950 | ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt); | 951 | ret = read_from_packet_buffer(&s->internal->parse_queue, &s->internal->parse_queue_end, pkt); |
| 951 | 952 | ||
| 952 | av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata); | 953 | av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata); |
| 953 | if (metadata) { | 954 | if (metadata) { |
| @@ -973,14 +974,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 19 unmodified lines | |||
| 973 | int eof = 0; | 974 | int eof = 0; |
| 974 | 975 | ||
| 975 | if (!genpts) | 976 | if (!genpts) |
| 976 | return s->packet_buffer | 977 | return s->internal->packet_buffer |
| 977 | ? read_from_packet_buffer(&s->packet_buffer, | 978 | ? read_from_packet_buffer(&s->internal->packet_buffer, |
| 978 | &s->packet_buffer_end, pkt) | 979 | &s->internal->packet_buffer_end, pkt) |
| 979 | : read_frame_internal(s, pkt); | 980 | : read_frame_internal(s, pkt); |
| 980 | 981 | ||
| 981 | for (;;) { | 982 | for (;;) { |
| 982 | int ret; | 983 | int ret; |
| 983 | AVPacketList *pktl = s->packet_buffer; | 984 | AVPacketList *pktl = s->internal->packet_buffer; |
| 984 | 985 | ||
| 985 | if (pktl) { | 986 | if (pktl) { |
| 986 | AVPacket *next_pkt = &pktl->pkt; | 987 | AVPacket *next_pkt = &pktl->pkt; |
| @@ -996,14 +997,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 9 unmodified lines | |||
| 996 | } | 997 | } |
| 997 | pktl = pktl->next; | 998 | pktl = pktl->next; |
| 998 | } | 999 | } |
| 999 | pktl = s->packet_buffer; | 1000 | pktl = s->internal->packet_buffer; |
| 1000 | } | 1001 | } |
| 1001 | 1002 | ||
| 1002 | /* read packet from packet buffer, if there is data */ | 1003 | /* read packet from packet buffer, if there is data */ |
| 1003 | if (!(next_pkt->pts == AV_NOPTS_VALUE && | 1004 | if (!(next_pkt->pts == AV_NOPTS_VALUE && |
| 1004 | next_pkt->dts != AV_NOPTS_VALUE && !eof)) | 1005 | next_pkt->dts != AV_NOPTS_VALUE && !eof)) |
| 1005 | return read_from_packet_buffer(&s->packet_buffer, | 1006 | return read_from_packet_buffer(&s->internal->packet_buffer, |
| 1006 | &s->packet_buffer_end, pkt); | 1007 | &s->internal->packet_buffer_end, pkt); |
| 1007 | } | 1008 | } |
| 1008 | 1009 | ||
| 1009 | ret = read_frame_internal(s, pkt); | 1010 | ret = read_frame_internal(s, pkt); |
| @@ -1015,8 +1016,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 5 unmodified lines | |||
| 1015 | return ret; | 1016 | return ret; |
| 1016 | } | 1017 | } |
| 1017 | 1018 | ||
| 1018 | if (av_dup_packet(add_to_pktbuf(&s->packet_buffer, pkt, | 1019 | if (av_dup_packet(add_to_pktbuf(&s->internal->packet_buffer, pkt, |
| 1019 | &s->packet_buffer_end)) < 0) | 1020 | &s->internal->packet_buffer_end)) < 0) |
| 1020 | return AVERROR(ENOMEM); | 1021 | return AVERROR(ENOMEM); |
| 1021 | } | 1022 | } |
| 1022 | } | 1023 | } |
| @@ -1024,11 +1025,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line | |||
| 1024 | /* XXX: suppress the packet queue */ | 1025 | /* XXX: suppress the packet queue */ |
| 1025 | static void flush_packet_queue(AVFormatContext *s) | 1026 | static void flush_packet_queue(AVFormatContext *s) |
| 1026 | { | 1027 | { |
| 1027 | free_packet_buffer(&s->parse_queue, &s->parse_queue_end); | 1028 | free_packet_buffer(&s->internal->parse_queue, &s->internal->parse_queue_end); |
| 1028 | free_packet_buffer(&s->packet_buffer, &s->packet_buffer_end); | 1029 | free_packet_buffer(&s->internal->packet_buffer, &s->internal->packet_buffer_end); |
| 1029 | free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end); | 1030 | free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end); |
| 1030 | 1031 | ||
| 1031 | s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; | 1032 | s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; |
| 1032 | } | 1033 | } |
| 1033 | 1034 | ||
| 1034 | /*******************************************************/ | 1035 | /*******************************************************/ |
| @@ -1287,7 +1288,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, · 252 unmodified lines | |||
| 1287 | av_dlog(s, "gen_seek: %d %"PRId64"\n", stream_index, target_ts); | 1288 | av_dlog(s, "gen_seek: %d %"PRId64"\n", stream_index, target_ts); |
| 1288 | 1289 | ||
| 1289 | if (ts_min == AV_NOPTS_VALUE) { | 1290 | if (ts_min == AV_NOPTS_VALUE) { |
| 1290 | pos_min = s->data_offset; | 1291 | pos_min = s->internal->data_offset; |
| 1291 | ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); | 1292 | ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); |
| 1292 | if (ts_min == AV_NOPTS_VALUE) | 1293 | if (ts_min == AV_NOPTS_VALUE) |
| 1293 | return -1; | 1294 | return -1; |
| @@ -1394,7 +1395,7 @@ static int seek_frame_byte(AVFormatContext *s, int stream_index, · 100 unmodified lines | |||
| 1394 | { | 1395 | { |
| 1395 | int64_t pos_min, pos_max; | 1396 | int64_t pos_min, pos_max; |
| 1396 | 1397 | ||
| 1397 | pos_min = s->data_offset; | 1398 | pos_min = s->internal->data_offset; |
| 1398 | pos_max = avio_size(s->pb) - 1; | 1399 | pos_max = avio_size(s->pb) - 1; |
| 1399 | 1400 | ||
| 1400 | if (pos < pos_min) | 1401 | if (pos < pos_min) |
| @@ -1433,7 +1434,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index, · 32 unmodified lines | |||
| 1433 | return ret; | 1434 | return ret; |
| 1434 | ff_update_cur_dts(s, st, ie->timestamp); | 1435 | ff_update_cur_dts(s, st, ie->timestamp); |
| 1435 | } else { | 1436 | } else { |
| 1436 | if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0) | 1437 | if ((ret = avio_seek(s->pb, s->internal->data_offset, SEEK_SET)) < 0) |
| 1437 | return ret; | 1438 | return ret; |
| 1438 | } | 1439 | } |
| 1439 | for (;;) { | 1440 | for (;;) { |
| @@ -2177,8 +2178,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 737 unmodified lines | |||
| 2177 | if (ic->flags & AVFMT_FLAG_NOBUFFER) { | 2178 | if (ic->flags & AVFMT_FLAG_NOBUFFER) { |
| 2178 | pkt = &pkt1; | 2179 | pkt = &pkt1; |
| 2179 | } else { | 2180 | } else { |
| 2180 | pkt = add_to_pktbuf(&ic->packet_buffer, &pkt1, | 2181 | pkt = add_to_pktbuf(&ic->internal->packet_buffer, &pkt1, |
| 2181 | &ic->packet_buffer_end); | 2182 | &ic->internal->packet_buffer_end); |
| 2182 | if ((ret = av_dup_packet(pkt)) < 0) | 2183 | if ((ret = av_dup_packet(pkt)) < 0) |
| 2183 | goto find_stream_info_err; | 2184 | goto find_stream_info_err; |
| 2184 | } | 2185 | } |
| @@ -272,7 +272,7 @@ static int vqf_read_seek(AVFormatContext *s, · 271 unmodified lines | |||
| 272 | st->cur_dts = av_rescale(pos, st->time_base.den, | 272 | st->cur_dts = av_rescale(pos, st->time_base.den, |
| 273 | st->codec->bit_rate * (int64_t)st->time_base.num); | 273 | st->codec->bit_rate * (int64_t)st->time_base.num); |
| 274 | 274 | ||
| 275 | if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->data_offset, SEEK_SET)) < 0) | 275 | if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0) |
| 276 | return ret; | 276 | return ret; |
| 277 | 277 | ||
| 278 | c->remaining_bits = -7 - ((pos-7)&7); | 278 | c->remaining_bits = -7 - ((pos-7)&7); |
| @@ -194,7 +194,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index, · 193 unmodified lines | |||
| 194 | if (!stream_index) | 194 | if (!stream_index) |
| 195 | return -1; | 195 | return -1; |
| 196 | 196 | ||
| 197 | pos_min = s->data_offset; | 197 | pos_min = s->internal->data_offset; |
| 198 | pos_max = avio_size(s->pb) - yop->frame_size; | 198 | pos_max = avio_size(s->pb) - yop->frame_size; |
| 199 | frame_count = (pos_max - pos_min) / yop->frame_size; | 199 | frame_count = (pos_max - pos_min) / yop->frame_size; |
| 200 | 200 | ||