PR #23039 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23039
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23039.patch

Fixes the issue reported in #23038.


>From cec19d7ddf725896dfbf79a4c308550d83eab5ec Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Thu, 7 May 2026 13:25:29 +0200
Subject: [PATCH 1/3] configure: Redo enabling cbs in lavf

Right now, the cbs_type_table (the table of all CodedBitstreamTypes
supported by CBS) is empty unless cbs_apv and cbs_av1 is enabled.
The latter are only enabled in configure if they are needed in lavc.
This means that the mov muxers (the only users of cbs-in-lavf)
don't work as they should depending upon the availability of
e.g. the av1_metadata BSF. The table being empty is also illegal C
and according to PR #23038 MSVC warns about this (as does GCC
with -pedantic) and it may even lead to an internal compiler error.

This could be fixed by simply adding a mov_muxer->cbs_av1,cbs_apv
dependency in configure, yet this would have the downside that
it would force cbs_av1 and cbs_apv to be built for lavc, too,
even though it may not be needed there. So add new configure
variables cbs_{apv,av1}_lavf and cbs_lavf to track this correctly.

Reported-by: xiaozhuai <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 configure            | 7 ++++++-
 libavformat/Makefile | 5 ++++-
 libavformat/cbs.h    | 4 ++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 9bce658932..08a112daf8 100755
--- a/configure
+++ b/configure
@@ -2746,11 +2746,14 @@ CONFIG_EXTRA="
     cabac
     cbs
     cbs_apv
+    cbs_apv_lavf
     cbs_av1
+    cbs_av1_lavf
     cbs_h264
     cbs_h265
     cbs_h266
     cbs_jpeg
+    cbs_lavf
     cbs_lcevc
     cbs_mpeg2
     cbs_vp8
@@ -3064,7 +3067,9 @@ w32threads_deps="atomics_native"
 threads_if_any="$THREADS_LIST"
 
 # subsystems
+cbs_apv_lavf_select="cbs_lavf"
 cbs_apv_select="cbs"
+cbs_av1_lavf_select="cbs_lavf"
 cbs_av1_select="cbs"
 cbs_h264_select="cbs"
 cbs_h265_select="cbs"
@@ -3963,7 +3968,7 @@ mlp_demuxer_select="mlp_parser"
 mmf_muxer_select="riffenc"
 mov_demuxer_select="iso_media riffdec"
 mov_demuxer_suggest="iamfdec zlib"
-mov_muxer_select="iso_media iso_writer riffenc rtpenc_chain vp9_superframe_bsf 
aac_adtstoasc_bsf ac3_parser"
+mov_muxer_select="cbs_apv_lavf cbs_av1_lavf iso_media iso_writer riffenc 
rtpenc_chain vp9_superframe_bsf aac_adtstoasc_bsf ac3_parser"
 mov_muxer_suggest="iamfenc"
 mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7c2fcad93e..4b22fd5d64 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -40,6 +40,9 @@ OBJS = allformats.o         \
 OBJS-$(HAVE_LIBC_MSVCRT)                 += file_open.o
 
 # subsystems
+OBJS-$(CONFIG_CBS_LAVF)                  += cbs.o
+OBJS-$(CONFIG_CBS_APV_LAVF)              += cbs_apv.o
+OBJS-$(CONFIG_CBS_AV1_LAVF)              += cbs_av1.o
 OBJS-$(CONFIG_ISO_MEDIA)                 += isom.o
 OBJS-$(CONFIG_ISO_WRITER)                += avc.o hevc.o vvc.o
 OBJS-$(CONFIG_IAMFDEC)                   += iamf_reader.o iamf_parse.o iamf.o
@@ -390,7 +393,7 @@ OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o 
mov_chan.o mov_esds.o \
 OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o \
                                             movenchint.o mov_chan.o rtp.o \
                                             movenccenc.o movenc_ttml.o 
rawutils.o \
-                                            apv.o dovi_isom.o evc.o cbs.o 
cbs_av1.o cbs_apv.o
+                                            apv.o dovi_isom.o evc.o
 OBJS-$(CONFIG_MP2_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_MP3_DEMUXER)               += mp3dec.o replaygain.o
 OBJS-$(CONFIG_MP3_MUXER)                 += mp3enc.o rawenc.o id3v2enc.o
diff --git a/libavformat/cbs.h b/libavformat/cbs.h
index dffd0e9206..e4c0f33f6a 100644
--- a/libavformat/cbs.h
+++ b/libavformat/cbs.h
@@ -19,9 +19,13 @@
 #ifndef AVFORMAT_CBS_H
 #define AVFORMAT_CBS_H
 
+#include "config.h"
+
 #define CBS_PREFIX lavf_cbs
 #define CBS_WRITE 0
 #define CBS_TRACE 0
+#define CBS_APV CONFIG_CBS_APV_LAVF
+#define CBS_AV1 CONFIG_CBS_AV1_LAVF
 #define CBS_H264 0
 #define CBS_H265 0
 #define CBS_H266 0
-- 
2.52.0


>From d7d5445bf1c45c3c4566c5a7767acf20b677d212 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Thu, 7 May 2026 13:51:50 +0200
Subject: [PATCH 2/3] configure: Add missing apv_metadata->cbs_apv dependency

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 configure | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure b/configure
index 08a112daf8..23112fbd20 100755
--- a/configure
+++ b/configure
@@ -3754,6 +3754,7 @@ vvc_parser_select="cbs_h266"
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
 ahx_to_mp2_bsf_deps="lgpl_gpl"
+apv_metadata_bsf_select="cbs_apv"
 av1_frame_merge_bsf_select="cbs_av1"
 av1_frame_split_bsf_select="cbs_av1"
 av1_metadata_bsf_select="cbs_av1"
-- 
2.52.0


>From 9a496bb8af3c1e1fd5909a7c9a981a249fd9dd5c Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <[email protected]>
Date: Thu, 7 May 2026 13:54:57 +0200
Subject: [PATCH 3/3] avcodec/cbs: Move ff_cbs_all_codec_ids to cbs_bsf

Only used as AVBitStreamFilter.codec_ids. This avoids duplicating
it into lavf.

Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 libavcodec/bsf/filter_units.c  |  1 +
 libavcodec/bsf/trace_headers.c |  1 +
 libavcodec/cbs.c               | 34 ----------------------------------
 libavcodec/cbs.h               |  8 --------
 libavcodec/cbs_bsf.c           | 34 ++++++++++++++++++++++++++++++++++
 libavcodec/cbs_bsf.h           |  7 +++++++
 6 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/libavcodec/bsf/filter_units.c b/libavcodec/bsf/filter_units.c
index 696a1f37c4..2514c66fd6 100644
--- a/libavcodec/bsf/filter_units.c
+++ b/libavcodec/bsf/filter_units.c
@@ -25,6 +25,7 @@
 #include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 
 
 typedef struct FilterUnitsContext {
diff --git a/libavcodec/bsf/trace_headers.c b/libavcodec/bsf/trace_headers.c
index 8781f5f100..c026a426d9 100644
--- a/libavcodec/bsf/trace_headers.c
+++ b/libavcodec/bsf/trace_headers.c
@@ -25,6 +25,7 @@
 #include "bsf.h"
 #include "bsf_internal.h"
 #include "cbs.h"
+#include "cbs_bsf.h"
 
 
 typedef struct TraceHeadersContext {
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 7ff0f89aa5..aabddedeb2 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -63,40 +63,6 @@ static const CodedBitstreamType *const cbs_type_table[] = {
 #endif
 };
 
-const enum AVCodecID CBS_FUNC(all_codec_ids)[] = {
-#if CBS_APV
-    AV_CODEC_ID_APV,
-#endif
-#if CBS_AV1
-    AV_CODEC_ID_AV1,
-#endif
-#if CBS_H264
-    AV_CODEC_ID_H264,
-#endif
-#if CBS_H265
-    AV_CODEC_ID_H265,
-#endif
-#if CBS_H266
-    AV_CODEC_ID_H266,
-#endif
-#if CBS_LCEVC
-    AV_CODEC_ID_LCEVC,
-#endif
-#if CBS_JPEG
-    AV_CODEC_ID_MJPEG,
-#endif
-#if CBS_MPEG2
-    AV_CODEC_ID_MPEG2VIDEO,
-#endif
-#if CBS_VP8
-    AV_CODEC_ID_VP8,
-#endif
-#if CBS_VP9
-    AV_CODEC_ID_VP9,
-#endif
-    AV_CODEC_ID_NONE
-};
-
 av_cold int CBS_FUNC(init)(CodedBitstreamContext **ctx_ptr,
                         enum AVCodecID codec_id, void *log_ctx)
 {
diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h
index 8c4614479f..b56dddd842 100644
--- a/libavcodec/cbs.h
+++ b/libavcodec/cbs.h
@@ -296,14 +296,6 @@ typedef struct CodedBitstreamContext {
 } CodedBitstreamContext;
 
 
-/**
- * Table of all supported codec IDs.
- *
- * Terminated by AV_CODEC_ID_NONE.
- */
-extern const enum AVCodecID CBS_FUNC(all_codec_ids)[];
-
-
 /**
  * Create and initialise a new context for the given codec.
  */
diff --git a/libavcodec/cbs_bsf.c b/libavcodec/cbs_bsf.c
index f342e5489e..3a9dbad17c 100644
--- a/libavcodec/cbs_bsf.c
+++ b/libavcodec/cbs_bsf.c
@@ -22,6 +22,40 @@
 
 #include "libavutil/attributes.h"
 
+const enum AVCodecID ff_cbs_all_codec_ids[] = {
+#if CONFIG_CBS_APV
+    AV_CODEC_ID_APV,
+#endif
+#if CONFIG_CBS_AV1
+    AV_CODEC_ID_AV1,
+#endif
+#if CONFIG_CBS_H264
+    AV_CODEC_ID_H264,
+#endif
+#if CONFIG_CBS_H265
+    AV_CODEC_ID_H265,
+#endif
+#if CONFIG_CBS_H266
+    AV_CODEC_ID_H266,
+#endif
+#if CONFIG_CBS_LCEVC
+    AV_CODEC_ID_LCEVC,
+#endif
+#if CONFIG_CBS_JPEG
+    AV_CODEC_ID_MJPEG,
+#endif
+#if CONFIG_CBS_MPEG2
+    AV_CODEC_ID_MPEG2VIDEO,
+#endif
+#if CONFIG_CBS_VP8
+    AV_CODEC_ID_VP8,
+#endif
+#if CONFIG_CBS_VP9
+    AV_CODEC_ID_VP9,
+#endif
+    AV_CODEC_ID_NONE
+};
+
 static int cbs_bsf_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
 {
     CBSBSFContext           *ctx = bsf->priv_data;
diff --git a/libavcodec/cbs_bsf.h b/libavcodec/cbs_bsf.h
index 26bd448b87..f6f7ae05df 100644
--- a/libavcodec/cbs_bsf.h
+++ b/libavcodec/cbs_bsf.h
@@ -59,6 +59,13 @@ typedef struct CBSBSFContext {
     CodedBitstreamFragment fragment;
 } CBSBSFContext;
 
+/**
+ * Table of all supported codec IDs.
+ *
+ * Terminated by AV_CODEC_ID_NONE.
+ */
+extern const enum AVCodecID ff_cbs_all_codec_ids[];
+
 /**
  * Initialise generic CBS BSF setup.
  *
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to