summaryrefslogtreecommitdiff
path: root/libavformat/hca.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/hca.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/hca.c')
-rw-r--r--libavformat/hca.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libavformat/hca.c b/libavformat/hca.c
index 86be5b1345..eaa96a9b17 100644
--- a/libavformat/hca.c
+++ b/libavformat/hca.c
@@ -45,14 +45,14 @@ static int hca_read_header(AVFormatContext *s)
uint32_t chunk;
uint16_t version;
uint32_t block_count;
- uint16_t block_size;
+ uint16_t block_size, data_offset;
int ret;
avio_skip(pb, 4);
version = avio_rb16(pb);
- s->internal->data_offset = avio_rb16(pb);
- if (s->internal->data_offset <= 8)
+ data_offset = avio_rb16(pb);
+ if (data_offset <= 8)
return AVERROR_INVALIDDATA;
st = avformat_new_stream(s, NULL);
@@ -60,7 +60,7 @@ static int hca_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
par = st->codecpar;
- ret = ff_alloc_extradata(par, s->internal->data_offset);
+ ret = ff_alloc_extradata(par, data_offset);
if (ret < 0)
return ret;
@@ -69,7 +69,7 @@ static int hca_read_header(AVFormatContext *s)
return AVERROR(EIO);
AV_WL32(par->extradata, MKTAG('H', 'C', 'A', 0));
AV_WB16(par->extradata + 4, version);
- AV_WB16(par->extradata + 6, s->internal->data_offset);
+ AV_WB16(par->extradata + 6, data_offset);
bytestream2_init(&gb, par->extradata + 8, par->extradata_size - 8);
@@ -97,7 +97,7 @@ static int hca_read_header(AVFormatContext *s)
par->block_align = block_size;
st->duration = 1024 * block_count;
- avio_seek(pb, s->internal->data_offset, SEEK_SET);
+ avio_seek(pb, data_offset, SEEK_SET);
avpriv_set_pts_info(st, 64, 1, par->sample_rate);
return 0;