From fed02825081bd6441f865c9cfcf50e384b2392f5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 24 Aug 2021 14:58:07 +0200 Subject: 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 --- libavformat/oggdec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'libavformat/oggdec.c') 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; -- cgit v1.2.3