summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-24 14:58:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-17 04:58:34 +0200
commitfed02825081bd6441f865c9cfcf50e384b2392f5 (patch)
treeb42f4b433b1652e4ad65bc0b5066fe3e80d5662f /libavformat/oggdec.c
parentdfbf41775cb58a9218a8b39b0dc6fd8de3f1ab35 (diff)
avformat: Avoid allocation for AVFormatInternal
Do this by allocating AVFormatContext together with the data that is currently in AVFormatInternal; or rather: Put AVFormatContext at the beginning of a new structure called FFFormatContext (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVFormatInternal altogether. The biggest simplifications occured in avformat_alloc_context(), where one can now simply call avformat_free_context() in case of errors. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r--libavformat/oggdec.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 5afbae2147..87f178bb7b 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -174,7 +174,7 @@ static int ogg_reset(AVFormatContext *s)
os->segp = 0;
os->incomplete = 0;
os->got_data = 0;
- if (start_pos <= s->internal->data_offset) {
+ if (start_pos <= ffformatcontext(s)->data_offset) {
os->lastpts = 0;
}
os->start_trimming = 0;
@@ -497,6 +497,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid, int probing)
static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
int64_t *fpos)
{
+ FFFormatContext *const si = ffformatcontext(s);
struct ogg *ogg = s->priv_data;
int idx, i, ret;
struct ogg_stream *os;
@@ -582,8 +583,8 @@ static int ogg_packet(AVFormatContext *s, int *sid, int *dstart, int *dsize,
// Update the header state for all streams and
// compute the data_offset.
- if (!s->internal->data_offset)
- s->internal->data_offset = os->sync_pos;
+ if (!si->data_offset)
+ si->data_offset = os->sync_pos;
for (i = 0; i < ogg->nstreams; i++) {
struct ogg_stream *cur_os = ogg->streams + i;
@@ -591,7 +592,7 @@ static int ogg_packet(AVFormatContext *s, int *sid, 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->internal->data_offset = FFMIN(s->internal->data_offset, cur_os->sync_pos);
+ si->data_offset = FFMIN(si->data_offset, cur_os->sync_pos);
}
} else {
os->nb_header++;
@@ -684,7 +685,7 @@ static int ogg_get_length(AVFormatContext *s)
if (ret < 0)
return ret;
- avio_seek (s->pb, s->internal->data_offset, SEEK_SET);
+ avio_seek (s->pb, ffformatcontext(s)->data_offset, SEEK_SET);
ogg_reset(s);
while (streams_left > 0 && !ogg_packet(s, &i, NULL, NULL, NULL)) {
int64_t pts;