From 45bfe8b838275235412777dd430206d9a24eb3ee Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 4 Aug 2021 16:52:07 +0200 Subject: avformat/avio: Move internal AVIOContext fields to avio_internal.h Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt --- libavformat/thp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libavformat/thp.c') diff --git a/libavformat/thp.c b/libavformat/thp.c index 7aad24221b..7103cf4f8a 100644 --- a/libavformat/thp.c +++ b/libavformat/thp.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/intfloat.h" #include "avformat.h" +#include "avio_internal.h" #include "internal.h" typedef struct ThpDemuxContext { @@ -65,6 +66,7 @@ static int thp_read_header(AVFormatContext *s) AVStream *st; AVIOContext *pb = s->pb; int64_t fsize= avio_size(pb); + uint32_t maxsize; int i; /* Read the file header. */ @@ -79,9 +81,10 @@ static int thp_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; thp->framecnt = avio_rb32(pb); thp->first_framesz = avio_rb32(pb); - pb->maxsize = avio_rb32(pb); - if(fsize>0 && (!pb->maxsize || fsize < pb->maxsize)) - pb->maxsize= fsize; + maxsize = avio_rb32(pb); + if (fsize > 0 && (!maxsize || fsize < maxsize)) + maxsize = fsize; + ffiocontext(pb)->maxsize = fsize; thp->compoff = avio_rb32(pb); avio_rb32(pb); /* offsetDataOffset. */ -- cgit v1.2.3