Commit 9deaec78 authored by wm4's avatar wm4 Committed by Anton Khirnov

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: 's avatarAnton Khirnov <anton@khirnov.net>
parent 1509c018
......@@ -878,7 +878,7 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
if (asf->no_resync_search)
off = 3;
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;
while (off-- > 0) {
......@@ -1361,9 +1361,9 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
start_pos[i] = pos;
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->data_offset;
s->internal->data_offset;
*ppos = pos;
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++) {
int pktnum = avio_rl32(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);
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 */
if (!pts) {
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;
}
......
......@@ -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_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.
* Must not be accessed in any way by callers.
......
......@@ -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,
c->vst->codec->pix_fmt);
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;
offset = sys->frame_size * timestamp;
......@@ -408,7 +408,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
else if (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)
......
......@@ -49,6 +49,47 @@ struct AVFormatInternal {
* Muxing only.
*/
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);
......
......@@ -166,7 +166,7 @@ static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
AVIOContext *pb = s->pb;
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);
......
......@@ -329,13 +329,13 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
AVRational time_base = s->streams[pkt->stream_index]->time_base;
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)) {
s->offset = -pkt->dts;
s->offset_timebase = time_base;
s->internal->offset = -pkt->dts;
s->internal->offset_timebase = time_base;
}
if (s->offset != AV_NOPTS_VALUE)
offset = av_rescale_q(s->offset, s->offset_timebase, time_base);
if (s->internal->offset != AV_NOPTS_VALUE)
offset = av_rescale_q(s->internal->offset, s->internal->offset_timebase, time_base);
if (pkt->dts != AV_NOPTS_VALUE)
pkt->dts += offset;
......@@ -428,20 +428,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(s->streams[pkt->stream_index]->last_in_packet_buffer->next);
} else
next_point = &s->packet_buffer;
next_point = &s->internal->packet_buffer;
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))
next_point = &(*next_point)->next;
goto next_non_null;
} else {
next_point = &(s->packet_buffer_end->next);
next_point = &(s->internal->packet_buffer_end->next);
}
}
assert(!*next_point);
s->packet_buffer_end = this_pktl;
s->internal->packet_buffer_end = this_pktl;
next_non_null:
this_pktl->next = *next_point;
......@@ -477,8 +477,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
return ret;
}
if (s->max_interleave_delta > 0 && s->packet_buffer && !flush) {
AVPacket *top_pkt = &s->packet_buffer->pkt;
if (s->max_interleave_delta > 0 && s->internal->packet_buffer && !flush) {
AVPacket *top_pkt = &s->internal->packet_buffer->pkt;
int64_t delta_dts = INT64_MIN;
int64_t top_dts = av_rescale_q(top_pkt->dts,
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)) {
pktl = s->packet_buffer;
pktl = s->internal->packet_buffer;
*out = pktl->pkt;
s->packet_buffer = pktl->next;
if (!s->packet_buffer)
s->packet_buffer_end = NULL;
s->internal->packet_buffer = pktl->next;
if (!s->internal->packet_buffer)
s->internal->packet_buffer_end = NULL;
if (s->streams[out->stream_index]->last_in_packet_buffer == pktl)
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
stream_count += !!s->streams[i]->last_in_packet_buffer;
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) {
AVPacketList *last = NULL;
// find last packet in edit unit
......@@ -1862,20 +1862,20 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
if (last)
last->next = NULL;
else {
s->packet_buffer = NULL;
s->packet_buffer_end= NULL;
s->internal->packet_buffer = NULL;
s->internal->packet_buffer_end= NULL;
goto out;
}
pktl = s->packet_buffer;
pktl = s->internal->packet_buffer;
}
*out = pktl->pkt;
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)
s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
if(!s->packet_buffer)
s->packet_buffer_end= NULL;
if(!s->internal->packet_buffer)
s->internal->packet_buffer_end= NULL;
av_freep(&pktl);
return 1;
} else {
......
......@@ -728,7 +728,7 @@ static int nut_read_header(AVFormatContext *s)
decode_info_header(nut);
}
s->data_offset = pos - 8;
s->internal->data_offset = pos - 8;
if (bc->seekable) {
int64_t orig_pos = avio_tell(bc);
......
......@@ -414,8 +414,8 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
// Update the header state for all streams and
// compute the data_offset.
if (!s->data_offset)
s->data_offset = os->sync_pos;
if (!s->internal->data_offset)
s->internal->data_offset = os->sync_pos;
for (i = 0; i < ogg->nstreams; 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
// obviously at or after the data start
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 {
os->nb_header++;
......
......@@ -101,13 +101,13 @@ AVFormatContext *avformat_alloc_context(void)
ic = av_malloc(sizeof(AVFormatContext));
if (!ic) return ic;
avformat_get_context_defaults(ic);
ic->offset = AV_NOPTS_VALUE;
ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) {
avformat_free_context(ic);
return NULL;
}
ic->internal->offset = AV_NOPTS_VALUE;
return ic;
}
......
......@@ -21,6 +21,7 @@
#include "libavutil/mathematics.h"
#include "avformat.h"
#include "internal.h"
#include "pcm.h"
int ff_pcm_read_seek(AVFormatContext *s,
......@@ -50,7 +51,7 @@ int ff_pcm_read_seek(AVFormatContext *s,
/* recompute exact position */
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 0;
}
......@@ -183,8 +183,8 @@ static int r3d_read_header(AVFormatContext *s)
return -1;
}
s->data_offset = avio_tell(s->pb);
av_dlog(s, "data offset %#"PRIx64"\n", s->data_offset);
s->internal->data_offset = avio_tell(s->pb);
av_dlog(s, "data offset %#"PRIx64"\n", s->internal->data_offset);
if (!s->pb->seekable)
return 0;
// find REOB/REOF/REOS to load index
......@@ -210,7 +210,7 @@ static int r3d_read_header(AVFormatContext *s)
}
out:
avio_seek(s->pb, s->data_offset, SEEK_SET);
avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
return 0;
}
......
This diff is collapsed.
......@@ -272,7 +272,7 @@ static int vqf_read_seek(AVFormatContext *s,
st->cur_dts = av_rescale(pos, st->time_base.den,
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;
c->remaining_bits = -7 - ((pos-7)&7);
......
......@@ -194,7 +194,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index,
if (!stream_index)
return -1;
pos_min = s->data_offset;
pos_min = s->internal->data_offset;
pos_max = avio_size(s->pb) - yop->frame_size;
frame_count = (pos_max - pos_min) / yop->frame_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment