[FFmpeg-cvslog] lavf: add new struct for data private to generic layer

Anton Khirnov git at videolan.org
Wed Oct 16 17:50:13 EEST 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Oct 13 10:13:46 2024 +0200| [772911d3a8bbc16c34fa9558e15b86b2fa2619a5] | committer: Anton Khirnov

lavf: add new struct for data private to generic layer

Trivial for now, will become more useful in future commits, as many
fields from FFFormatContext should not be visible to individual
(de)muxers.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=772911d3a8bbc16c34fa9558e15b86b2fa2619a5
---

 libavformat/avformat_internal.h | 10 ++++++++++
 libavformat/options.c           |  7 +++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat_internal.h b/libavformat/avformat_internal.h
index a1079fe122..ef7409658e 100644
--- a/libavformat/avformat_internal.h
+++ b/libavformat/avformat_internal.h
@@ -28,6 +28,16 @@
 #include <stdint.h>
 
 #include "avformat.h"
+#include "internal.h"
+
+typedef struct FormatContextInternal {
+    FFFormatContext fc;
+} FormatContextInternal;
+
+static av_always_inline FormatContextInternal *ff_fc_internal(AVFormatContext *s)
+{
+    return (FormatContextInternal*)s;
+}
 
 #define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
 
diff --git a/libavformat/options.c b/libavformat/options.c
index 10d6ce2d35..9e4fd5f8b2 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -161,12 +161,15 @@ static int io_close2_default(AVFormatContext *s, AVIOContext *pb)
 
 AVFormatContext *avformat_alloc_context(void)
 {
-    FFFormatContext *const si = av_mallocz(sizeof(*si));
+    FormatContextInternal *fci;
+    FFFormatContext *si;
     AVFormatContext *s;
 
-    if (!si)
+    fci = av_mallocz(sizeof(*fci));
+    if (!fci)
         return NULL;
 
+    si = &fci->fc;
     s = &si->pub;
     s->av_class = &av_format_context_class;
     s->io_open  = io_open_default;



More information about the ffmpeg-cvslog mailing list