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/dsfdec.c | |
parent | dfbf41775cb58a9218a8b39b0dc6fd8de3f1ab35 (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/dsfdec.c')
-rw-r--r-- | libavformat/dsfdec.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libavformat/dsfdec.c b/libavformat/dsfdec.c index c872f98cc2..40c8210a0f 100644 --- a/libavformat/dsfdec.c +++ b/libavformat/dsfdec.c @@ -141,13 +141,13 @@ static int dsf_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; dsf->data_size = avio_rl64(pb) - 12; dsf->data_end += dsf->data_size + 12; - s->internal->data_offset = avio_tell(pb); return 0; } static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt) { + FFFormatContext *const si = ffformatcontext(s); DSFContext *dsf = s->priv_data; AVIOContext *pb = s->pb; AVStream *st = s->streams[0]; @@ -161,7 +161,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt) int last_packet = pos == (dsf->data_end - st->codecpar->block_align); if (last_packet) { - int64_t data_pos = pos - s->internal->data_offset; + int64_t data_pos = pos - si->data_offset; int64_t packet_size = dsf->audio_size - data_pos; int64_t skip_size = dsf->data_size - data_pos - packet_size; uint8_t *dst; @@ -184,7 +184,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt) pkt->pos = pos; pkt->stream_index = 0; - pkt->pts = (pos - s->internal->data_offset) / st->codecpar->channels; + pkt->pts = (pos - si->data_offset) / st->codecpar->channels; pkt->duration = packet_size / st->codecpar->channels; return 0; } @@ -194,7 +194,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt) return ret; pkt->stream_index = 0; - pkt->pts = (pos - s->internal->data_offset) / st->codecpar->channels; + pkt->pts = (pos - si->data_offset) / st->codecpar->channels; pkt->duration = st->codecpar->block_align / st->codecpar->channels; return 0; |