lavf: move internal fields from public to internal context

This is not an API change; the fields were explicitly declared private
before.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
wm4 2015-02-06 14:53:40 +01:00 committed by Anton Khirnov
parent 1509c018bd
commit 9deaec7828
15 changed files with 122 additions and 128 deletions

View File

@ -878,7 +878,7 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
if (asf->no_resync_search) if (asf->no_resync_search)
off = 3; off = 3;
else if (s->packet_size > 0) else if (s->packet_size > 0)
off = (avio_tell(pb) - s->data_offset) % s->packet_size + 3; off = (avio_tell(pb) - s->internal->data_offset) % s->packet_size + 3;
c = d = e = -1; c = d = e = -1;
while (off-- > 0) { while (off-- > 0) {
@ -1361,9 +1361,9 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
start_pos[i] = pos; start_pos[i] = pos;
if (s->packet_size > 0) if (s->packet_size > 0)
pos = (pos + s->packet_size - 1 - s->data_offset) / pos = (pos + s->packet_size - 1 - s->internal->data_offset) /
s->packet_size * s->packet_size + s->packet_size * s->packet_size +
s->data_offset; s->internal->data_offset;
*ppos = pos; *ppos = pos;
avio_seek(s->pb, pos, SEEK_SET); avio_seek(s->pb, pos, SEEK_SET);
@ -1437,7 +1437,7 @@ static int asf_build_simple_index(AVFormatContext *s, int stream_index)
for (i = 0; i < ict; i++) { for (i = 0; i < ict; i++) {
int pktnum = avio_rl32(s->pb); int pktnum = avio_rl32(s->pb);
int pktct = avio_rl16(s->pb); int pktct = avio_rl16(s->pb);
int64_t pos = s->data_offset + s->packet_size * (int64_t)pktnum; int64_t pos = s->internal->data_offset + s->packet_size * (int64_t)pktnum;
int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0); int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
if (pos != last_pos) { if (pos != last_pos) {
@ -1480,7 +1480,7 @@ static int asf_read_seek(AVFormatContext *s, int stream_index,
/* explicitly handle the case of seeking to 0 */ /* explicitly handle the case of seeking to 0 */
if (!pts) { if (!pts) {
asf_reset_header(s); asf_reset_header(s);
avio_seek(s->pb, s->data_offset, SEEK_SET); avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
return 0; return 0;
} }

View File

@ -1210,55 +1210,6 @@ typedef struct AVFormatContext {
#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
#define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0 #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0
/*****************************************************************
* All fields below this line are not part of the public API. They
* may not be used outside of libavformat and can be changed and
* removed at will.
* New public fields should be added right above.
*****************************************************************
*/
/**
* This buffer is only needed when packets were already buffered but
* not decoded, for example to get the codec parameters in MPEG
* streams.
*/
struct AVPacketList *packet_buffer;
struct AVPacketList *packet_buffer_end;
/* av_seek_frame() support */
int64_t data_offset; /**< offset of the first packet */
/**
* Raw packets from the demuxer, prior to parsing and decoding.
* This buffer is used for buffering packets until the codec can
* be identified, as parsing cannot be done without knowing the
* codec.
*/
struct AVPacketList *raw_packet_buffer;
struct AVPacketList *raw_packet_buffer_end;
/**
* Packets split by the parser get queued here.
*/
struct AVPacketList *parse_queue;
struct AVPacketList *parse_queue_end;
/**
* Remaining size available for raw_packet_buffer, in bytes.
*/
#define RAW_PACKET_BUFFER_SIZE 2500000
int raw_packet_buffer_remaining_size;
/**
* Offset to remap timestamps to be non-negative.
* Expressed in timebase units.
*/
int64_t offset;
/**
* Timebase for the timestamp offset.
*/
AVRational offset_timebase;
/** /**
* An opaque field for libavformat internal usage. * An opaque field for libavformat internal usage.
* Must not be accessed in any way by callers. * Must not be accessed in any way by callers.

View File

@ -398,7 +398,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height, const AVDVProfile *sys = av_dv_codec_profile(c->vst->codec->width, c->vst->codec->height,
c->vst->codec->pix_fmt); c->vst->codec->pix_fmt);
int64_t offset; int64_t offset;
int64_t size = avio_size(s->pb) - s->data_offset; int64_t size = avio_size(s->pb) - s->internal->data_offset;
int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size; int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size;
offset = sys->frame_size * timestamp; offset = sys->frame_size * timestamp;
@ -408,7 +408,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
else if (offset < 0) else if (offset < 0)
offset = 0; offset = 0;
return offset + s->data_offset; return offset + s->internal->data_offset;
} }
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset) void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)

View File

@ -49,6 +49,47 @@ struct AVFormatInternal {
* Muxing only. * Muxing only.
*/ */
int nb_interleaved_streams; int nb_interleaved_streams;
/**
* This buffer is only needed when packets were already buffered but
* not decoded, for example to get the codec parameters in MPEG
* streams.
*/
struct AVPacketList *packet_buffer;
struct AVPacketList *packet_buffer_end;
/* av_seek_frame() support */
int64_t data_offset; /**< offset of the first packet */
/**
* Raw packets from the demuxer, prior to parsing and decoding.
* This buffer is used for buffering packets until the codec can
* be identified, as parsing cannot be done without knowing the
* codec.
*/
struct AVPacketList *raw_packet_buffer;
struct AVPacketList *raw_packet_buffer_end;
/**
* Packets split by the parser get queued here.
*/
struct AVPacketList *parse_queue;
struct AVPacketList *parse_queue_end;
/**
* Remaining size available for raw_packet_buffer, in bytes.
*/
#define RAW_PACKET_BUFFER_SIZE 2500000
int raw_packet_buffer_remaining_size;
/**
* Offset to remap timestamps to be non-negative.
* Expressed in timebase units.
*/
int64_t offset;
/**
* Timebase for the timestamp offset.
*/
AVRational offset_timebase;
}; };
void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem); void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);

View File

@ -166,7 +166,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
int ret; int ret;
if((avio_tell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size) if((avio_tell(pb) - s->internal->data_offset + mtv->img_segment_size) % mtv->full_segment_size)
{ {
avio_skip(pb, MTV_AUDIO_PADDING_SIZE); avio_skip(pb, MTV_AUDIO_PADDING_SIZE);

View File

@ -329,13 +329,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
AVRational time_base = s->streams[pkt->stream_index]->time_base; AVRational time_base = s->streams[pkt->stream_index]->time_base;
int64_t offset = 0; int64_t offset = 0;
if (s->offset == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && if (s->internal->offset == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE &&
(pkt->dts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) { (pkt->dts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) {
s->offset = -pkt->dts; s->internal->offset = -pkt->dts;
s->offset_timebase = time_base; s->internal->offset_timebase = time_base;
} }
if (s->offset != AV_NOPTS_VALUE) if (s->internal->offset != AV_NOPTS_VALUE)
offset = av_rescale_q(s->offset, s->offset_timebase, time_base); offset = av_rescale_q(s->internal->offset, s->internal->offset_timebase, time_base);
if (pkt->dts != AV_NOPTS_VALUE) if (pkt->dts != AV_NOPTS_VALUE)
pkt->dts += offset; pkt->dts += offset;
@ -428,20 +428,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (s->streams[pkt->stream_index]->last_in_packet_buffer) { if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next); next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next);
} else } else
next_point = &s->packet_buffer; next_point = &s->internal->packet_buffer;
if (*next_point) { if (*next_point) {
if (compare(s, &s->packet_buffer_end->pkt, pkt)) { if (compare(s, &s->internal->packet_buffer_end->pkt, pkt)) {
while (!compare(s, &(*next_point)->pkt, pkt)) while (!compare(s, &(*next_point)->pkt, pkt))
next_point = &(*next_point)->next; next_point = &(*next_point)->next;
goto next_non_null; goto next_non_null;
} else { } else {
next_point = &(s->packet_buffer_end->next); next_point = &(s->internal->packet_buffer_end->next);
} }
} }
assert(!*next_point); assert(!*next_point);
s->packet_buffer_end = this_pktl; s->internal->packet_buffer_end = this_pktl;
next_non_null: next_non_null:
this_pktl->next = *next_point; this_pktl->next = *next_point;
@ -477,8 +477,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
return ret; return ret;
} }
if (s->max_interleave_delta > 0 && s->packet_buffer && !flush) { if (s->max_interleave_delta > 0 && s->internal->packet_buffer && !flush) {
AVPacket *top_pkt = &s->packet_buffer->pkt; AVPacket *top_pkt = &s->internal->packet_buffer->pkt;
int64_t delta_dts = INT64_MIN; int64_t delta_dts = INT64_MIN;
int64_t top_dts = av_rescale_q(top_pkt->dts, int64_t top_dts = av_rescale_q(top_pkt->dts,
s->streams[top_pkt->stream_index]->time_base, s->streams[top_pkt->stream_index]->time_base,
@ -512,12 +512,12 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
if (stream_count && (s->internal->nb_interleaved_streams == stream_count || flush)) { if (stream_count && (s->internal->nb_interleaved_streams == stream_count || flush)) {
pktl = s->packet_buffer; pktl = s->internal->packet_buffer;
*out = pktl->pkt; *out = pktl->pkt;
s->packet_buffer = pktl->next; s->internal->packet_buffer = pktl->next;
if (!s->packet_buffer) if (!s->internal->packet_buffer)
s->packet_buffer_end = NULL; s->internal->packet_buffer_end = NULL;
if (s->streams[out->stream_index]->last_in_packet_buffer == pktl) if (s->streams[out->stream_index]->last_in_packet_buffer == pktl)
s->streams[out->stream_index]->last_in_packet_buffer = NULL; s->streams[out->stream_index]->last_in_packet_buffer = NULL;

View File

@ -1838,7 +1838,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
stream_count += !!s->streams[i]->last_in_packet_buffer; stream_count += !!s->streams[i]->last_in_packet_buffer;
if (stream_count && (s->nb_streams == stream_count || flush)) { if (stream_count && (s->nb_streams == stream_count || flush)) {
AVPacketList *pktl = s->packet_buffer; AVPacketList *pktl = s->internal->packet_buffer;
if (s->nb_streams != stream_count) { if (s->nb_streams != stream_count) {
AVPacketList *last = NULL; AVPacketList *last = NULL;
// find last packet in edit unit // find last packet in edit unit
@ -1862,20 +1862,20 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
if (last) if (last)
last->next = NULL; last->next = NULL;
else { else {
s->packet_buffer = NULL; s->internal->packet_buffer = NULL;
s->packet_buffer_end= NULL; s->internal->packet_buffer_end= NULL;
goto out; goto out;
} }
pktl = s->packet_buffer; pktl = s->internal->packet_buffer;
} }
*out = pktl->pkt; *out = pktl->pkt;
av_dlog(s, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts); av_dlog(s, "out st:%d dts:%"PRId64"\n", (*out).stream_index, (*out).dts);
s->packet_buffer = pktl->next; s->internal->packet_buffer = pktl->next;
if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl) if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL; s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
if(!s->packet_buffer) if(!s->internal->packet_buffer)
s->packet_buffer_end= NULL; s->internal->packet_buffer_end= NULL;
av_freep(&pktl); av_freep(&pktl);
return 1; return 1;
} else { } else {

View File

@ -728,7 +728,7 @@ static int nut_read_header(AVFormatContext *s)
decode_info_header(nut); decode_info_header(nut);
} }
s->data_offset = pos - 8; s->internal->data_offset = pos - 8;
if (bc->seekable) { if (bc->seekable) {
int64_t orig_pos = avio_tell(bc); int64_t orig_pos = avio_tell(bc);

View File

@ -414,8 +414,8 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
// Update the header state for all streams and // Update the header state for all streams and
// compute the data_offset. // compute the data_offset.
if (!s->data_offset) if (!s->internal->data_offset)
s->data_offset = os->sync_pos; s->internal->data_offset = os->sync_pos;
for (i = 0; i < ogg->nstreams; i++) { for (i = 0; i < ogg->nstreams; i++) {
struct ogg_stream *cur_os = ogg->streams + i; struct ogg_stream *cur_os = ogg->streams + i;
@ -423,7 +423,7 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
// if we have a partial non-header packet, its start is // if we have a partial non-header packet, its start is
// obviously at or after the data start // obviously at or after the data start
if (cur_os->incomplete) if (cur_os->incomplete)
s->data_offset = FFMIN(s->data_offset, cur_os->sync_pos); s->internal->data_offset = FFMIN(s->internal->data_offset, cur_os->sync_pos);
} }
} else { } else {
os->nb_header++; os->nb_header++;

View File

@ -101,13 +101,13 @@ AVFormatContext *avformat_alloc_context(void)
ic = av_malloc(sizeof(AVFormatContext)); ic = av_malloc(sizeof(AVFormatContext));
if (!ic) return ic; if (!ic) return ic;
avformat_get_context_defaults(ic); avformat_get_context_defaults(ic);
ic->offset = AV_NOPTS_VALUE;
ic->internal = av_mallocz(sizeof(*ic->internal)); ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) { if (!ic->internal) {
avformat_free_context(ic); avformat_free_context(ic);
return NULL; return NULL;
} }
ic->internal->offset = AV_NOPTS_VALUE;
return ic; return ic;
} }

View File

@ -21,6 +21,7 @@
#include "libavutil/mathematics.h" #include "libavutil/mathematics.h"
#include "avformat.h" #include "avformat.h"
#include "internal.h"
#include "pcm.h" #include "pcm.h"
int ff_pcm_read_seek(AVFormatContext *s, int ff_pcm_read_seek(AVFormatContext *s,
@ -50,7 +51,7 @@ int ff_pcm_read_seek(AVFormatContext *s,
/* recompute exact position */ /* recompute exact position */
st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num);
if ((ret = avio_seek(s->pb, pos + s->data_offset, SEEK_SET)) < 0) if ((ret = avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET)) < 0)
return ret; return ret;
return 0; return 0;
} }

View File

@ -183,8 +183,8 @@ static int r3d_read_header(AVFormatContext *s)
return -1; return -1;
} }
s->data_offset = avio_tell(s->pb); s->internal->data_offset = avio_tell(s->pb);
av_dlog(s, "data offset %#"PRIx64"\n", s->data_offset); av_dlog(s, "data offset %#"PRIx64"\n", s->internal->data_offset);
if (!s->pb->seekable) if (!s->pb->seekable)
return 0; return 0;
// find REOB/REOF/REOS to load index // find REOB/REOF/REOS to load index
@ -210,7 +210,7 @@ static int r3d_read_header(AVFormatContext *s)
} }
out: out:
avio_seek(s->pb, s->data_offset, SEEK_SET); avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
return 0; return 0;
} }

View File

@ -238,8 +238,8 @@ static int queue_attached_pictures(AVFormatContext *s)
if (!copy.buf) if (!copy.buf)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
add_to_pktbuf(&s->raw_packet_buffer, &copy, add_to_pktbuf(&s->internal->raw_packet_buffer, &copy,
&s->raw_packet_buffer_end); &s->internal->raw_packet_buffer_end);
} }
return 0; return 0;
} }
@ -307,10 +307,10 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
if ((ret = queue_attached_pictures(s)) < 0) if ((ret = queue_attached_pictures(s)) < 0)
goto fail; goto fail;
if (s->pb && !s->data_offset) if (s->pb && !s->internal->data_offset)
s->data_offset = avio_tell(s->pb); s->internal->data_offset = avio_tell(s->pb);
s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
if (options) { if (options) {
av_dict_free(options); av_dict_free(options);
@ -375,14 +375,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
AVStream *st; AVStream *st;
for (;;) { for (;;) {
AVPacketList *pktl = s->raw_packet_buffer; AVPacketList *pktl = s->internal->raw_packet_buffer;
if (pktl) { if (pktl) {
*pkt = pktl->pkt; *pkt = pktl->pkt;
st = s->streams[pkt->stream_index]; st = s->streams[pkt->stream_index];
if (st->codec->codec_id != AV_CODEC_ID_PROBE || if (st->codec->codec_id != AV_CODEC_ID_PROBE ||
!st->probe_packets || !st->probe_packets ||
s->raw_packet_buffer_remaining_size < pkt->size) { s->internal->raw_packet_buffer_remaining_size < pkt->size) {
AVProbeData *pd; AVProbeData *pd;
if (st->probe_packets) if (st->probe_packets)
if ((err = probe_codec(s, st, NULL)) < 0) if ((err = probe_codec(s, st, NULL)) < 0)
@ -390,8 +390,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
pd = &st->probe_data; pd = &st->probe_data;
av_freep(&pd->buf); av_freep(&pd->buf);
pd->buf_size = 0; pd->buf_size = 0;
s->raw_packet_buffer = pktl->next; s->internal->raw_packet_buffer = pktl->next;
s->raw_packet_buffer_remaining_size += pkt->size; s->internal->raw_packet_buffer_remaining_size += pkt->size;
av_free(pktl); av_free(pktl);
return 0; return 0;
} }
@ -443,8 +443,9 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
!st->probe_packets)) !st->probe_packets))
return ret; return ret;
add_to_pktbuf(&s->raw_packet_buffer, pkt, &s->raw_packet_buffer_end); add_to_pktbuf(&s->internal->raw_packet_buffer, pkt,
s->raw_packet_buffer_remaining_size -= pkt->size; &s->internal->raw_packet_buffer_end);
s->internal->raw_packet_buffer_remaining_size -= pkt->size;
if ((err = probe_codec(s, st, pkt)) < 0) if ((err = probe_codec(s, st, pkt)) < 0)
return err; return err;
@ -515,7 +516,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
int64_t dts, int64_t pts) int64_t dts, int64_t pts)
{ {
AVStream *st = s->streams[stream_index]; AVStream *st = s->streams[stream_index];
AVPacketList *pktl = s->packet_buffer; AVPacketList *pktl = s->internal->packet_buffer;
if (st->first_dts != AV_NOPTS_VALUE || if (st->first_dts != AV_NOPTS_VALUE ||
dts == AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE ||
@ -545,7 +546,7 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
static void update_initial_durations(AVFormatContext *s, AVStream *st, static void update_initial_durations(AVFormatContext *s, AVStream *st,
int stream_index, int duration) int stream_index, int duration)
{ {
AVPacketList *pktl = s->packet_buffer; AVPacketList *pktl = s->internal->packet_buffer;
int64_t cur_dts = 0; int64_t cur_dts = 0;
if (st->first_dts != AV_NOPTS_VALUE) { if (st->first_dts != AV_NOPTS_VALUE) {
@ -559,7 +560,7 @@ static void update_initial_durations(AVFormatContext *s, AVStream *st,
cur_dts -= duration; cur_dts -= duration;
} }
} }
pktl = s->packet_buffer; pktl = s->internal->packet_buffer;
st->first_dts = cur_dts; st->first_dts = cur_dts;
} else if (st->cur_dts) } else if (st->cur_dts)
return; return;
@ -628,7 +629,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
den * (int64_t) st->time_base.num, den * (int64_t) st->time_base.num,
AV_ROUND_DOWN); AV_ROUND_DOWN);
if (pkt->duration != 0 && s->packet_buffer) if (pkt->duration != 0 && s->internal->packet_buffer)
update_initial_durations(s, st, pkt->stream_index, update_initial_durations(s, st, pkt->stream_index,
pkt->duration); pkt->duration);
} }
@ -691,7 +692,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
num * (int64_t) st->time_base.den, num * (int64_t) st->time_base.den,
den * (int64_t) st->time_base.num, den * (int64_t) st->time_base.num,
AV_ROUND_DOWN); AV_ROUND_DOWN);
if (duration != 0 && s->packet_buffer) if (duration != 0 && s->internal->packet_buffer)
update_initial_durations(s, st, pkt->stream_index, update_initial_durations(s, st, pkt->stream_index,
duration); duration);
} }
@ -837,7 +838,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
if ((ret = av_dup_packet(&out_pkt)) < 0) if ((ret = av_dup_packet(&out_pkt)) < 0)
goto fail; goto fail;
if (!add_to_pktbuf(&s->parse_queue, &out_pkt, &s->parse_queue_end)) { if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {
av_free_packet(&out_pkt); av_free_packet(&out_pkt);
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto fail; goto fail;
@ -877,7 +878,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
av_init_packet(pkt); av_init_packet(pkt);
while (!got_packet && !s->parse_queue) { while (!got_packet && !s->internal->parse_queue) {
AVStream *st; AVStream *st;
AVPacket cur_pkt; AVPacket cur_pkt;
@ -946,8 +947,8 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
} }
} }
if (!got_packet && s->parse_queue) if (!got_packet && s->internal->parse_queue)
ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt); ret = read_from_packet_buffer(&s->internal->parse_queue, &s->internal->parse_queue_end, pkt);
av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata); av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata);
if (metadata) { if (metadata) {
@ -973,14 +974,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
int eof = 0; int eof = 0;
if (!genpts) if (!genpts)
return s->packet_buffer return s->internal->packet_buffer
? read_from_packet_buffer(&s->packet_buffer, ? read_from_packet_buffer(&s->internal->packet_buffer,
&s->packet_buffer_end, pkt) &s->internal->packet_buffer_end, pkt)
: read_frame_internal(s, pkt); : read_frame_internal(s, pkt);
for (;;) { for (;;) {
int ret; int ret;
AVPacketList *pktl = s->packet_buffer; AVPacketList *pktl = s->internal->packet_buffer;
if (pktl) { if (pktl) {
AVPacket *next_pkt = &pktl->pkt; AVPacket *next_pkt = &pktl->pkt;
@ -996,14 +997,14 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
} }
pktl = pktl->next; pktl = pktl->next;
} }
pktl = s->packet_buffer; pktl = s->internal->packet_buffer;
} }
/* read packet from packet buffer, if there is data */ /* read packet from packet buffer, if there is data */
if (!(next_pkt->pts == AV_NOPTS_VALUE && if (!(next_pkt->pts == AV_NOPTS_VALUE &&
next_pkt->dts != AV_NOPTS_VALUE && !eof)) next_pkt->dts != AV_NOPTS_VALUE && !eof))
return read_from_packet_buffer(&s->packet_buffer, return read_from_packet_buffer(&s->internal->packet_buffer,
&s->packet_buffer_end, pkt); &s->internal->packet_buffer_end, pkt);
} }
ret = read_frame_internal(s, pkt); ret = read_frame_internal(s, pkt);
@ -1015,8 +1016,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
return ret; return ret;
} }
if (av_dup_packet(add_to_pktbuf(&s->packet_buffer, pkt, if (av_dup_packet(add_to_pktbuf(&s->internal->packet_buffer, pkt,
&s->packet_buffer_end)) < 0) &s->internal->packet_buffer_end)) < 0)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
} }
@ -1024,11 +1025,11 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt)
/* XXX: suppress the packet queue */ /* XXX: suppress the packet queue */
static void flush_packet_queue(AVFormatContext *s) static void flush_packet_queue(AVFormatContext *s)
{ {
free_packet_buffer(&s->parse_queue, &s->parse_queue_end); free_packet_buffer(&s->internal->parse_queue, &s->internal->parse_queue_end);
free_packet_buffer(&s->packet_buffer, &s->packet_buffer_end); free_packet_buffer(&s->internal->packet_buffer, &s->internal->packet_buffer_end);
free_packet_buffer(&s->raw_packet_buffer, &s->raw_packet_buffer_end); free_packet_buffer(&s->internal->raw_packet_buffer, &s->internal->raw_packet_buffer_end);
s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; s->internal->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
} }
/*******************************************************/ /*******************************************************/
@ -1287,7 +1288,7 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts,
av_dlog(s, "gen_seek: %d %"PRId64"\n", stream_index, target_ts); av_dlog(s, "gen_seek: %d %"PRId64"\n", stream_index, target_ts);
if (ts_min == AV_NOPTS_VALUE) { if (ts_min == AV_NOPTS_VALUE) {
pos_min = s->data_offset; pos_min = s->internal->data_offset;
ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX);
if (ts_min == AV_NOPTS_VALUE) if (ts_min == AV_NOPTS_VALUE)
return -1; return -1;
@ -1394,7 +1395,7 @@ static int seek_frame_byte(AVFormatContext *s, int stream_index,
{ {
int64_t pos_min, pos_max; int64_t pos_min, pos_max;
pos_min = s->data_offset; pos_min = s->internal->data_offset;
pos_max = avio_size(s->pb) - 1; pos_max = avio_size(s->pb) - 1;
if (pos < pos_min) if (pos < pos_min)
@ -1433,7 +1434,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index,
return ret; return ret;
ff_update_cur_dts(s, st, ie->timestamp); ff_update_cur_dts(s, st, ie->timestamp);
} else { } else {
if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0) if ((ret = avio_seek(s->pb, s->internal->data_offset, SEEK_SET)) < 0)
return ret; return ret;
} }
for (;;) { for (;;) {
@ -2177,8 +2178,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (ic->flags & AVFMT_FLAG_NOBUFFER) { if (ic->flags & AVFMT_FLAG_NOBUFFER) {
pkt = &pkt1; pkt = &pkt1;
} else { } else {
pkt = add_to_pktbuf(&ic->packet_buffer, &pkt1, pkt = add_to_pktbuf(&ic->internal->packet_buffer, &pkt1,
&ic->packet_buffer_end); &ic->internal->packet_buffer_end);
if ((ret = av_dup_packet(pkt)) < 0) if ((ret = av_dup_packet(pkt)) < 0)
goto find_stream_info_err; goto find_stream_info_err;
} }

View File

@ -272,7 +272,7 @@ static int vqf_read_seek(AVFormatContext *s,
st->cur_dts = av_rescale(pos, st->time_base.den, st->cur_dts = av_rescale(pos, st->time_base.den,
st->codec->bit_rate * (int64_t)st->time_base.num); st->codec->bit_rate * (int64_t)st->time_base.num);
if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->data_offset, SEEK_SET)) < 0) if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0)
return ret; return ret;
c->remaining_bits = -7 - ((pos-7)&7); c->remaining_bits = -7 - ((pos-7)&7);

View File

@ -194,7 +194,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index,
if (!stream_index) if (!stream_index)
return -1; return -1;
pos_min = s->data_offset; pos_min = s->internal->data_offset;
pos_max = avio_size(s->pb) - yop->frame_size; pos_max = avio_size(s->pb) - yop->frame_size;
frame_count = (pos_max - pos_min) / yop->frame_size; frame_count = (pos_max - pos_min) / yop->frame_size;