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/internal.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libavformat/internal.h') diff --git a/libavformat/internal.h b/libavformat/internal.h index 9d7312c0e2..8625ab8258 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -69,7 +69,12 @@ typedef struct FFFrac { } FFFrac; -struct AVFormatInternal { +typedef struct FFFormatContext { + /** + * The public context. + */ + AVFormatContext pub; + /** * Number of streams relevant for interleaving. * Muxing only. @@ -173,7 +178,12 @@ struct AVFormatInternal { * Set if chapter ids are strictly monotonic. */ int chapter_ids_monotonic; -}; +} FFFormatContext; + +static av_always_inline FFFormatContext *ffformatcontext(AVFormatContext *s) +{ + return (FFFormatContext*)s; +} struct AVStreamInternal { /** -- cgit v1.2.3