[FFmpeg-devel] [PATCH 5/5] avformat/internal: Don't include avcodec.h

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Sep 21 04:35:41 EEST 2022


The general demuxing API uses parsers and decoders. Therefore
FFStream contains pointers to AVCodecContexts and
AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h.

Yet actually only a few files files really use these; and it is best
when this number stays small. Therefore this commit uses opaque
structs in lavf/internal.h for these contexts and stops including
avcodec.h.
This also avoids including lavc/codec_desc.h implicitly. All other
headers are implicitly included as now (mostly through codec.h).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavdevice/jack.c         | 1 -
 libavdevice/v4l2.c         | 1 +
 libavformat/asfenc.c       | 1 +
 libavformat/av1dec.c       | 2 +-
 libavformat/concatdec.c    | 1 +
 libavformat/dashenc.c      | 2 ++
 libavformat/demux.c        | 1 +
 libavformat/dump.c         | 3 ++-
 libavformat/flacdec.c      | 1 +
 libavformat/flvenc.c       | 1 +
 libavformat/hlsenc.c       | 2 ++
 libavformat/internal.h     | 3 +--
 libavformat/matroskaenc.c  | 1 +
 libavformat/mpegts.c       | 1 +
 libavformat/mpegtsenc.c    | 1 +
 libavformat/mxfenc.c       | 1 +
 libavformat/oggparseflac.c | 1 +
 libavformat/rawdec.c       | 6 ++----
 libavformat/riffenc.c      | 1 -
 libavformat/rtsp.c         | 1 +
 libavformat/seek.c         | 2 ++
 21 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/libavdevice/jack.c b/libavdevice/jack.c
index e34eb8961c..db056d824f 100644
--- a/libavdevice/jack.c
+++ b/libavdevice/jack.c
@@ -29,7 +29,6 @@
 #include "libavutil/fifo.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
-#include "libavcodec/avcodec.h"
 #include "libavformat/avformat.h"
 #include "libavformat/internal.h"
 #include "timefilter.h"
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index be422d7c8c..5e85d1a2b3 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -38,6 +38,7 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/time.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/codec_desc.h"
 #include "libavformat/demux.h"
 #include "libavformat/internal.h"
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index e1563b1da6..70800a6df5 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -25,6 +25,7 @@
 #include "libavutil/dict.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
+#include "libavcodec/codec_desc.h"
 #include "avformat.h"
 #include "avlanguage.h"
 #include "avio_internal.h"
diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index 350f5360d5..d4b430af7e 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -19,11 +19,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
 #include "config_components.h"
 
 #include "libavutil/common.h"
 #include "libavutil/opt.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/av1_parse.h"
 #include "libavcodec/bsf.h"
 #include "avformat.h"
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index e57da59e04..7748c20b6d 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -25,6 +25,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/timestamp.h"
+#include "libavcodec/codec_desc.h"
 #include "libavcodec/bsf.h"
 #include "avformat.h"
 #include "avio_internal.h"
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 295b01e225..a0919f6f2d 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -38,6 +38,8 @@
 #include "libavutil/time.h"
 #include "libavutil/time_internal.h"
 
+#include "libavcodec/avcodec.h"
+
 #include "av1.h"
 #include "avc.h"
 #include "avformat.h"
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 1620716716..2dfd82a63c 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -34,6 +34,7 @@
 #include "libavutil/time.h"
 #include "libavutil/timestamp.h"
 
+#include "libavcodec/avcodec.h"
 #include "libavcodec/bsf.h"
 #include "libavcodec/internal.h"
 #include "libavcodec/packet_internal.h"
diff --git a/libavformat/dump.c b/libavformat/dump.c
index cafcef36c6..225f80ac22 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -30,12 +30,13 @@
 #include "libavutil/dovi_meta.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
-#include "libavutil/avstring.h"
 #include "libavutil/replaygain.h"
 #include "libavutil/spherical.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
 
+#include "libavcodec/avcodec.h"
+
 #include "avformat.h"
 #include "internal.h"
 
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index eadd41fc36..b58ec03963 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/channel_layout.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/flac.h"
 #include "avformat.h"
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 5d574fa790..59be11eba8 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -24,6 +24,7 @@
 #include "libavutil/intfloat.h"
 #include "libavutil/avassert.h"
 #include "libavutil/mathematics.h"
+#include "libavcodec/codec_desc.h"
 #include "libavcodec/mpeg4audio.h"
 #include "avio.h"
 #include "avc.h"
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 6f49ae1aa2..a86fc8907f 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -43,6 +43,8 @@
 #include "libavutil/time.h"
 #include "libavutil/time_internal.h"
 
+#include "libavcodec/avcodec.h"
+
 #include "avformat.h"
 #include "avio_internal.h"
 #include "avc.h"
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 23757dc4fc..ce837fefc7 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -23,7 +23,6 @@
 
 #include <stdint.h>
 
-#include "libavcodec/avcodec.h"
 #include "libavcodec/packet_internal.h"
 
 #include "avformat.h"
@@ -221,7 +220,7 @@ typedef struct FFStream {
     /**
      * The codec context used by avformat_find_stream_info, the parser, etc.
      */
-    AVCodecContext *avctx;
+    struct AVCodecContext *avctx;
     /**
      * 1 if avctx has been initialized with the values from the codec parameters
      */
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 147f29988e..2be4f87284 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -58,6 +58,7 @@
 #include "libavutil/stereo3d.h"
 
 #include "libavcodec/av1.h"
+#include "libavcodec/codec_desc.h"
 #include "libavcodec/xiph.h"
 #include "libavcodec/mpeg4audio.h"
 
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8a3436f2be..d97702fcd7 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -32,6 +32,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/avassert.h"
 #include "libavutil/dovi_meta.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/get_bits.h"
 #include "libavcodec/opus.h"
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index c964d58c8e..5148a6aecd 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -28,6 +28,7 @@
 #include "libavutil/opt.h"
 
 #include "libavcodec/ac3_parser_internal.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/startcode.h"
 
 #include "avformat.h"
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 9a9acbfa08..58c551c83c 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -47,6 +47,7 @@
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/time_internal.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/golomb.h"
 #include "libavcodec/h264.h"
 #include "libavcodec/packet_internal.h"
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index fa7459c162..eef6e09927 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -19,6 +19,7 @@
  */
 
 #include <stdlib.h>
+#include "libavcodec/avcodec.h"
 #include "libavcodec/get_bits.h"
 #include "libavcodec/flac.h"
 #include "avformat.h"
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index 17649bc077..de804366ed 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -24,12 +24,10 @@
 
 #include "avformat.h"
 #include "internal.h"
-#include "avio_internal.h"
 #include "rawdec.h"
 #include "libavutil/opt.h"
-#include "libavutil/parseutils.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/intreadwrite.h"
+
+#include "libavcodec/avcodec.h"
 
 #define RAW_PACKET_SIZE 1024
 
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 7825c4e746..179b0f12cb 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -23,7 +23,6 @@
 #include "libavutil/dict.h"
 #include "libavutil/log.h"
 #include "libavutil/mathematics.h"
-#include "libavcodec/avcodec.h"
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
 #include "avio_internal.h"
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index f948f1d395..cfafb4be80 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -32,6 +32,7 @@
 #include "libavutil/dict.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
+#include "libavcodec/codec_desc.h"
 #include "avformat.h"
 #include "avio_internal.h"
 
diff --git a/libavformat/seek.c b/libavformat/seek.c
index 3b1c75f1b1..a236e285c0 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -25,6 +25,8 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/timestamp.h"
 
+#include "libavcodec/avcodec.h"
+
 #include "avformat.h"
 #include "avio_internal.h"
 #include "demux.h"
-- 
2.34.1



More information about the ffmpeg-devel mailing list