diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-08-24 14:58:07 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-17 04:58:34 +0200 |
commit | fed02825081bd6441f865c9cfcf50e384b2392f5 (patch) | |
tree | b42f4b433b1652e4ad65bc0b5066fe3e80d5662f /libavformat/boadec.c | |
parent | dfbf41775cb58a9218a8b39b0dc6fd8de3f1ab35 (diff) | |
download | ffmpeg-fed02825081bd6441f865c9cfcf50e384b2392f5.tar.gz |
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/boadec.c')
-rw-r--r-- | libavformat/boadec.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavformat/boadec.c b/libavformat/boadec.c index 69d17763ef..536300a895 100644 --- a/libavformat/boadec.c +++ b/libavformat/boadec.c @@ -44,6 +44,8 @@ static int probe(const AVProbeData *p) static int read_header(AVFormatContext *s) { AVStream *st = avformat_new_stream(s, NULL); + uint32_t data_offset; + if (!st) return AVERROR(ENOMEM); @@ -56,14 +58,14 @@ static int read_header(AVFormatContext *s) st->codecpar->channels = avio_rl32(s->pb); if (st->codecpar->channels > FF_SANE_NB_CHANNELS || st->codecpar->channels <= 0) return AVERROR(ENOSYS); - s->internal->data_offset = avio_rl32(s->pb); + ffformatcontext(s)->data_offset = data_offset = avio_rl32(s->pb); avio_r8(s->pb); st->codecpar->block_align = avio_rl32(s->pb); if (st->codecpar->block_align > INT_MAX / FF_SANE_NB_CHANNELS || st->codecpar->block_align <= 0) return AVERROR_INVALIDDATA; st->codecpar->block_align *= st->codecpar->channels; - avio_seek(s->pb, s->internal->data_offset, SEEK_SET); + avio_seek(s->pb, data_offset, SEEK_SET); return 0; } |