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

Remove dependency on dead code elimination + use correct cflags for debug build 
in MSVC
See https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20763


>From 3150ac96e2437164fb3adcdbbc6bf118a6abd5e4 Mon Sep 17 00:00:00 2001
From: Piotr Pawlowski <[email protected]>
Date: Mon, 27 Oct 2025 18:40:20 +0100
Subject: [PATCH 1/2] avcodec: Fix dependency on compiler performing dead code
 elimination

---
 libavcodec/avcodec.c          |  5 +++--
 libavcodec/encode.c           | 18 +++++++++++-------
 libavcodec/x86/idctdsp_init.c |  9 ++++++---
 libavcodec/x86/mlpdsp_init.c  |  6 ++++--
 4 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index 0355b7c338..6ef506a4fc 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -438,10 +438,11 @@ av_cold void ff_codec_close(AVCodecContext *avctx)
     if (avcodec_is_open(avctx)) {
         AVCodecInternal *avci = avctx->internal;
 
-        if (CONFIG_FRAME_THREAD_ENCODER &&
-            avci->frame_thread_encoder && avctx->thread_count > 1) {
+#if CONFIG_FRAME_THREAD_ENCODER
+        if (avci->frame_thread_encoder && avctx->thread_count > 1) {
             ff_frame_thread_encoder_free(avctx);
         }
+#endif
         if (HAVE_THREADS && avci->thread_ctx)
             ff_thread_free(avctx);
         if (avci->needs_close && ffcodec(avctx->codec)->close)
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 1eca5e38c1..060e63a3d5 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -316,12 +316,16 @@ static int encode_simple_internal(AVCodecContext *avctx, 
AVPacket *avpkt)
 
     av_assert0(codec->cb_type == FF_CODEC_CB_TYPE_ENCODE);
 
-    if (CONFIG_FRAME_THREAD_ENCODER && avci->frame_thread_encoder)
+#if CONFIG_FRAME_THREAD_ENCODER
+    if (avci->frame_thread_encoder) {
         /* This will unref frame. */
         ret = ff_thread_video_encode_frame(avctx, avpkt, frame, &got_packet);
-    else {
+    } else {
         ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet);
     }
+#else
+    ret = ff_encode_encode_cb(avctx, avpkt, frame, &got_packet);
+#endif
 
     if (avci->draining && !got_packet)
         avci->draining_done = 1;
@@ -824,11 +828,11 @@ int ff_encode_preinit(AVCodecContext *avctx)
         memcpy(sd_packet->data, sd_frame->data, sd_frame->size);
     }
 
-    if (CONFIG_FRAME_THREAD_ENCODER) {
-        ret = ff_frame_thread_encoder_init(avctx);
-        if (ret < 0)
-            return ret;
-    }
+#if CONFIG_FRAME_THREAD_ENCODER
+    ret = ff_frame_thread_encoder_init(avctx);
+    if (ret < 0)
+        return ret;
+#endif
 
     return 0;
 }
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 2d165b975b..d58056ef29 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -94,8 +94,8 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, 
AVCodecContext *avctx,
         }
 #endif
 
-        if (ARCH_X86_64 &&
-            !high_bit_depth &&
+#if ARCH_X86_64
+        if (!high_bit_depth &&
             avctx->lowres == 0 &&
             (avctx->idct_algo == FF_IDCT_AUTO ||
                 avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
@@ -106,9 +106,11 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, 
AVCodecContext *avctx,
                 c->idct_add  = ff_simple_idct8_add_sse2;
                 c->perm_type = FF_IDCT_PERM_TRANSPOSE;
         }
+#endif
     }
 
-    if (ARCH_X86_64 && avctx->lowres == 0) {
+#if ARCH_X86_64
+    if (avctx->lowres == 0) {
         if (EXTERNAL_AVX(cpu_flags) &&
             !high_bit_depth &&
             (avctx->idct_algo == FF_IDCT_AUTO ||
@@ -158,4 +160,5 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, 
AVCodecContext *avctx,
             }
         }
     }
+#endif
 }
diff --git a/libavcodec/x86/mlpdsp_init.c b/libavcodec/x86/mlpdsp_init.c
index 950f996832..21a0e38143 100644
--- a/libavcodec/x86/mlpdsp_init.c
+++ b/libavcodec/x86/mlpdsp_init.c
@@ -200,8 +200,10 @@ av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c)
     if (INLINE_MMX(cpu_flags))
         c->mlp_filter_channel = mlp_filter_channel_x86;
 #endif
-    if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags))
+#if ARCH_X86_64
+    if (EXTERNAL_SSE4(cpu_flags))
         c->mlp_rematrix_channel = ff_mlp_rematrix_channel_sse4;
-    if (ARCH_X86_64 && EXTERNAL_AVX2_FAST(cpu_flags) && cpu_flags & 
AV_CPU_FLAG_BMI2)
+    if (EXTERNAL_AVX2_FAST(cpu_flags) && cpu_flags & AV_CPU_FLAG_BMI2)
         c->mlp_rematrix_channel = ff_mlp_rematrix_channel_avx2_bmi2;
+#endif // ARCH_X86_64
 }
-- 
2.49.1


>From 8b38b61a5764f0903cec6db8931dd431b14c3976 Mon Sep 17 00:00:00 2001
From: Piotr Pawlowski <[email protected]>
Date: Mon, 27 Oct 2025 18:40:55 +0100
Subject: [PATCH 2/2] configure: Use -Od for debug build in MSVC

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 3b132d07c9..62bcc30ef8 100755
--- a/configure
+++ b/configure
@@ -5263,7 +5263,7 @@ probe_cc(){
         _DEPCXXFLAGS='$(CXXFLAGS)'
         _cflags_speed="-O2"
         _cflags_size="-O1"
-        _cflags_noopt="-O1"
+        _cflags_noopt="-Od"
         if $_cc -nologo- 2>&1 | grep -q Linker; then
             _ld_o='-out:$@'
             _flags_filter=msvc_flags_link
-- 
2.49.1

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

Reply via email to