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/yuv4mpegdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libavformat/yuv4mpegdec.c') diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c index 69dd8a3165..b24275acc1 100644 --- a/libavformat/yuv4mpegdec.c +++ b/libavformat/yuv4mpegdec.c @@ -255,7 +255,7 @@ static int yuv4_read_header(AVFormatContext *s) s->packet_size = av_image_get_buffer_size(st->codecpar->format, width, height, 1) + Y4M_FRAME_MAGIC_LEN; if ((int) s->packet_size < 0) return s->packet_size; - s->internal->data_offset = data_offset = avio_tell(pb); + ffformatcontext(s)->data_offset = data_offset = avio_tell(pb); st->duration = (avio_size(pb) - data_offset) / s->packet_size; @@ -293,7 +293,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO); } pkt->stream_index = 0; - pkt->pts = (off - s->internal->data_offset) / s->packet_size; + pkt->pts = (off - ffformatcontext(s)->data_offset) / s->packet_size; pkt->duration = 1; return 0; } @@ -309,7 +309,7 @@ static int yuv4_read_seek(AVFormatContext *s, int stream_index, return -1; pos = pts * s->packet_size; - if (avio_seek(s->pb, pos + s->internal->data_offset, SEEK_SET) < 0) + if (avio_seek(s->pb, pos + ffformatcontext(s)->data_offset, SEEK_SET) < 0) return -1; return 0; } -- cgit v1.2.3