From: mkver via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: mkver <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] WIP, RFC: Avoid reliance on DCE (PR #20793)
Date: Thu, 30 Oct 2025 13:29:37 -0000
Message-ID: <176183097809.81.6715215544811175390@7d278768979e> (raw)
PR #20793 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20793
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20793.patch
This patchset is a proposal to get rid of our spec-incompliant reliance on dead code elimination. The key to it is a macro IF(CONFIG, cond, code) (code is actually ...) that expands to "if (cond) { code }" if CONFIG is 1 (as a preprocessor define) and "if (0 && cond) { }" if CONFIG is 0. What is your opinion on this?
>From 88b95c6e7f52d4bc9e2a91e8a91c6a10ef3caab3 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 29 Oct 2025 19:19:49 +0100
Subject: [PATCH 01/34] avutil/x86/cpu: Remove {FMA3,AVX2,AVX}_SLOW macros
For both SSE2 and AVX, there are corresponding SLOW cpu flags,
so that for each of these instruction sets, there are four
potential states; in order of slowest to fastest, there are
a) both flags unset (instruction set unsupported),
b) only the slow flag set (instruction set supported, but so slow
that using it is not worthwhile)
c) slow flag and ordinary flag set
d) ordinary flag set
For AVX, the ordinary flag is never reset, so that the {FMA3,AVX2,AVX}_SLOW
macros are simply equivalent to the ordinary FMA3/AVX2/AVX macros
(except if one forced cpu flags). Therefore using them makes no sense
and unsurprisingly no one ever used them. So remove them.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/x86/cpu.h | 5 -----
1 file changed, 5 deletions(-)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index 00e82255b1..ff83d324a8 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -38,7 +38,6 @@
#define X86_SSE42(flags) CPUEXT(flags, SSE42)
#define X86_AVX(flags) CPUEXT(flags, AVX)
#define X86_AVX_FAST(flags) CPUEXT_FAST(flags, AVX)
-#define X86_AVX_SLOW(flags) CPUEXT_SLOW(flags, AVX)
#define X86_XOP(flags) CPUEXT(flags, XOP)
#define X86_FMA3(flags) CPUEXT(flags, FMA3)
#define X86_FMA4(flags) CPUEXT(flags, FMA4)
@@ -62,15 +61,12 @@
#define EXTERNAL_SSE42(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42)
#define EXTERNAL_AVX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX)
#define EXTERNAL_AVX_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, AVX)
-#define EXTERNAL_AVX_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, AVX)
#define EXTERNAL_XOP(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, XOP)
#define EXTERNAL_FMA3(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3)
#define EXTERNAL_FMA3_FAST(flags) CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, FMA3, AVX)
-#define EXTERNAL_FMA3_SLOW(flags) CPUEXT_SUFFIX_SLOW2(flags, _EXTERNAL, FMA3, AVX)
#define EXTERNAL_FMA4(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4)
#define EXTERNAL_AVX2(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2)
#define EXTERNAL_AVX2_FAST(flags) CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, AVX2, AVX)
-#define EXTERNAL_AVX2_SLOW(flags) CPUEXT_SUFFIX_SLOW2(flags, _EXTERNAL, AVX2, AVX)
#define EXTERNAL_AESNI(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AESNI)
#define EXTERNAL_AVX512(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512)
#define EXTERNAL_AVX512ICL(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512ICL)
@@ -91,7 +87,6 @@
#define INLINE_SSE42(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE42)
#define INLINE_AVX(flags) CPUEXT_SUFFIX(flags, _INLINE, AVX)
#define INLINE_AVX_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, AVX)
-#define INLINE_AVX_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, AVX)
#define INLINE_XOP(flags) CPUEXT_SUFFIX(flags, _INLINE, XOP)
#define INLINE_FMA3(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA3)
#define INLINE_FMA4(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA4)
--
2.49.1
>From 7787a70221bb81fc387bbe0f83e57b2945b18c55 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 29 Oct 2025 19:59:03 +0100
Subject: [PATCH 02/34] avcodec/x86/cpu: Remove SSE2_FAST macros
Some CPUs support SSE2, but only so slow that sometimes MMX(EXT)
functions are faster. The SSE2_FAST macros exist to set some
dsp functions only if they are faster than MMX(EXT).
Yet this rationale no longer applies nowadays, because MMX(EXT)
functions are removed when overridden by SSE2 functions.
Consequently, it is no longer used since
1f9ef6a8dc6e57b360cf53dd644fde1936ad3047. So remove the SSE2_FAST
macros.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/x86/cpu.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index ff83d324a8..087b941795 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -26,7 +26,6 @@
#define X86_MMXEXT(flags) CPUEXT(flags, MMXEXT)
#define X86_SSE(flags) CPUEXT(flags, SSE)
#define X86_SSE2(flags) CPUEXT(flags, SSE2)
-#define X86_SSE2_FAST(flags) CPUEXT_FAST(flags, SSE2)
#define X86_SSE2_SLOW(flags) CPUEXT_SLOW(flags, SSE2)
#define X86_SSE3(flags) CPUEXT(flags, SSE3)
#define X86_SSE3_FAST(flags) CPUEXT_FAST(flags, SSE3)
@@ -49,7 +48,6 @@
#define EXTERNAL_MMXEXT(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT)
#define EXTERNAL_SSE(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE)
#define EXTERNAL_SSE2(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE2)
-#define EXTERNAL_SSE2_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE2)
#define EXTERNAL_SSE2_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE2)
#define EXTERNAL_SSE3(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE3)
#define EXTERNAL_SSE3_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE3)
@@ -75,7 +73,6 @@
#define INLINE_MMXEXT(flags) CPUEXT_SUFFIX(flags, _INLINE, MMXEXT)
#define INLINE_SSE(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE)
#define INLINE_SSE2(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE2)
-#define INLINE_SSE2_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE2)
#define INLINE_SSE2_SLOW(flags) CPUEXT_SUFFIX_SLOW(flags, _INLINE, SSE2)
#define INLINE_SSE3(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE3)
#define INLINE_SSE3_FAST(flags) CPUEXT_SUFFIX_FAST(flags, _INLINE, SSE3)
--
2.49.1
>From 82db8b3bea694d4dafb73ce490be4e6991d00737 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 29 Oct 2025 19:42:13 +0100
Subject: [PATCH 03/34] avutil/cpu_internal: Remove CPUEXT_SUFFIX_SLOW2
Unused.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/cpu_internal.h | 4 ----
1 file changed, 4 deletions(-)
diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index 8dca62334a..af2a9ceac4 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -34,10 +34,6 @@
(HAVE_ ## cpuext ## suffix && \
((flags) & (AV_CPU_FLAG_ ## cpuext | AV_CPU_FLAG_ ## cpuext ## SLOW)))
-#define CPUEXT_SUFFIX_SLOW2(flags, suffix, cpuext, slow_cpuext) \
- (HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext) && \
- ((flags) & (AV_CPU_FLAG_ ## slow_cpuext | AV_CPU_FLAG_ ## slow_cpuext ## SLOW)))
-
#define CPUEXT_SUFFIX_FAST(flags, suffix, cpuext) CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, cpuext)
#define CPUEXT(flags, cpuext) CPUEXT_SUFFIX(flags, , cpuext)
--
2.49.1
>From 8d42504ab4c20fe76a38eb8b0492149767338db8 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 29 Oct 2025 21:00:12 +0100
Subject: [PATCH 04/34] avutil/cpu_internal: Add macros to avoid relying on DCE
These macros evaluate to "if (0 && cond) {}" if the relevant configure
condition (i.e. HAVE_SSE2_EXTERNAL) is false and to "if (cond) { code }"
if it is. They can be used to easily replace avoid most reliance on DCE;
the only exceptions to it are scenarios where "code" contains
preprocessor directives (i.e. #if blocks).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/cpu_internal.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index af2a9ceac4..7da8562cbf 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -23,6 +23,35 @@
#include "cpu.h"
+#define IF_1(cond, ...) if (cond) { __VA_ARGS__ }
+#define IF_0(cond, ...) if (0 && cond) {}
+#define IF_2(CONFIG_BOOL, cond, ...) IF_ ## CONFIG_BOOL (cond, __VA_ARGS__)
+
+#define IF(CONFIG, cond, ...) IF_2(CONFIG, (cond), __VA_ARGS__)
+
+#define IF_HAVE(FEATURE, cond, ...) IF(HAVE_ ## FEATURE, (cond), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX(flags, suffix, cpuext, ...) \
+ IF_HAVE(cpuext ## suffix, (flags) & AV_CPU_FLAG_ ## cpuext, __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_EXT(flags, suffix, cpuext, additional_cond, ...) \
+ IF_HAVE(cpuext ## suffix, ((flags) & AV_CPU_FLAG_ ## cpuext) && (additional_cond), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, slow_cpuext, ...) \
+ IF_HAVE(cpuext ## suffix, ((flags) & AV_CPU_FLAG_ ## cpuext) && \
+ !((flags) & AV_CPU_FLAG_ ## slow_cpuext ## SLOW), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_SLOW(flags, suffix, cpuext, slow_cpuext, ...) \
+ IF_HAVE(cpuext ## suffix, \
+ (flags) & (AV_CPU_FLAG_ ## cpuext | AV_CPU_FLAG_ ## cpuext ## SLOW), __VA_ARGS__)
+
+#define IF_CPUEXT_SUFFIX_FAST(flags, suffix, cpuext, ...) \
+ IF_CPUEXT_SUFFIX_FAST2(flags, suffix, cpuext, cpuext, __VA_ARGS__)
+
+#define IF_CPUEXT(flags, cpuext, ...) IF_CPUEXT_SUFFIX (flags, , cpuext, __VA_ARGS__)
+#define IF_CPUEXT_FAST(flags, cpuext, ...) IF_CPUEXT_SUFFIX_FAST(flags, , cpuext, __VA_ARGS__)
+#define IF_CPUEXT_SLOW(flags, cpuext, ...) IF_CPUEXT_SUFFIX_SLOW(flags, , cpuext, __VA_ARGS__)
+
#define CPUEXT_SUFFIX(flags, suffix, cpuext) \
(HAVE_ ## cpuext ## suffix && ((flags) & AV_CPU_FLAG_ ## cpuext))
--
2.49.1
>From 881714ed8d51c26e71b11b57251e7d0edf4b8068 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 29 Oct 2025 21:22:21 +0100
Subject: [PATCH 05/34] avutil/x86/cpu: Add macros to avoid reliance on DCE
This here mimics the existing EXTERNAL_ macros;
it would also be possible to use a macro
like IF_EXTERNAL(cpuext, flags, ...).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/x86/cpu.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/libavutil/x86/cpu.h b/libavutil/x86/cpu.h
index 087b941795..a12ffb85ee 100644
--- a/libavutil/x86/cpu.h
+++ b/libavutil/x86/cpu.h
@@ -44,6 +44,33 @@
#define X86_AESNI(flags) CPUEXT(flags, AESNI)
#define X86_AVX512(flags) CPUEXT(flags, AVX512)
+#define IF_EXTERNAL_EXTENDED(cpuext, flags, additional_cond, ...) \
+ IF_CPUEXT_SUFFIX_EXT((flags), _EXTERNAL, cpuext, (additional_cond), __VA_ARGS__)
+#define IF_EXTERNAL_MMX(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, MMX, __VA_ARGS__)
+#define IF_EXTERNAL_MMXEXT(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT, __VA_ARGS__)
+#define IF_EXTERNAL_SSE(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE, __VA_ARGS__)
+#define IF_EXTERNAL_SSE2(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE2, __VA_ARGS__)
+#define IF_EXTERNAL_SSE2_SLOW(flags, ...) IF_CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE2, __VA_ARGS__)
+#define IF_EXTERNAL_SSE3(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSE3_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSE3_SLOW(flags, ...) IF_CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSSE3(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSSE3_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, SSSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSSE3_SLOW(flags, ...) IF_CPUEXT_SUFFIX_SLOW(flags, _EXTERNAL, SSSE3, __VA_ARGS__)
+#define IF_EXTERNAL_SSE4(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE4, __VA_ARGS__)
+#define IF_EXTERNAL_SSE42(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42, __VA_ARGS__)
+#define IF_EXTERNAL_AVX(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_AVX_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST(flags, _EXTERNAL, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_XOP(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, XOP, __VA_ARGS__)
+#define IF_EXTERNAL_FMA3(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3, __VA_ARGS__)
+#define IF_EXTERNAL_FMA3_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, FMA3, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_FMA4(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4, __VA_ARGS__)
+#define IF_EXTERNAL_AVX2(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2, __VA_ARGS__)
+#define IF_EXTERNAL_AVX2_FAST(flags, ...) IF_CPUEXT_SUFFIX_FAST2(flags, _EXTERNAL, AVX2, AVX, __VA_ARGS__)
+#define IF_EXTERNAL_AESNI(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AESNI, __VA_ARGS__)
+#define IF_EXTERNAL_AVX512(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512, __VA_ARGS__)
+#define IF_EXTERNAL_AVX512ICL(flags, ...) IF_CPUEXT_SUFFIX(flags, _EXTERNAL, AVX512ICL, __VA_ARGS__)
+
#define EXTERNAL_MMX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, MMX)
#define EXTERNAL_MMXEXT(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, MMXEXT)
#define EXTERNAL_SSE(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE)
--
2.49.1
>From 57aec72a0c11d37dcc8a78f31c357094a4323ce0 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Wed, 29 Oct 2025 23:10:56 +0100
Subject: [PATCH 06/34] avcodec/x86/xvididct_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/xvididct_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/xvididct_init.c b/libavcodec/x86/xvididct_init.c
index c6c87b0c90..a98b22933c 100644
--- a/libavcodec/x86/xvididct_init.c
+++ b/libavcodec/x86/xvididct_init.c
@@ -30,11 +30,11 @@ av_cold void ff_xvid_idct_init_x86(IDCTDSPContext *c)
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_xvid_idct_put_sse2;
c->idct_add = ff_xvid_idct_add_sse2;
c->idct = ff_xvid_idct_sse2;
c->perm_type = FF_IDCT_PERM_SSE2;
- }
+ )
#endif /* HAVE_X86ASM */
}
--
2.49.1
>From 4e6d89b98f79ff3990e48b7c2b232d46b354b3b5 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 12:40:47 +0100
Subject: [PATCH 07/34] avcodec/x86/h263dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/h263dsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/h263dsp_init.c b/libavcodec/x86/h263dsp_init.c
index 3dd5d132e5..7d2fb7c710 100644
--- a/libavcodec/x86/h263dsp_init.c
+++ b/libavcodec/x86/h263dsp_init.c
@@ -32,8 +32,8 @@ av_cold void ff_h263dsp_init_x86(H263DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->h263_h_loop_filter = ff_h263_h_loop_filter_sse2;
c->h263_v_loop_filter = ff_h263_v_loop_filter_sse2;
- }
+ )
}
--
2.49.1
>From 0a9298ab1f212430ee7ef6bd688902ff278d847d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 12:42:39 +0100
Subject: [PATCH 08/34] avcodec/x86/jpeg2000dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/jpeg2000dsp_init.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/libavcodec/x86/jpeg2000dsp_init.c b/libavcodec/x86/jpeg2000dsp_init.c
index 7310a1d0e1..6cf8a55b1b 100644
--- a/libavcodec/x86/jpeg2000dsp_init.c
+++ b/libavcodec/x86/jpeg2000dsp_init.c
@@ -34,27 +34,27 @@ void ff_rct_int_avx2 (void *src0, void *src1, void *src2, int csize);
av_cold void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_sse;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->mct_decode[FF_DWT53] = ff_rct_int_sse2;
- }
+ )
- if (EXTERNAL_AVX_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX_FAST(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_avx;
- }
+ )
- if (EXTERNAL_FMA4(cpu_flags)) {
+ IF_EXTERNAL_FMA4(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_fma4;
- }
+ )
- if (EXTERNAL_FMA3_FAST(cpu_flags)) {
+ IF_EXTERNAL_FMA3_FAST(cpu_flags,
c->mct_decode[FF_DWT97] = ff_ict_float_fma3;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->mct_decode[FF_DWT53] = ff_rct_int_avx2;
- }
+ )
}
--
2.49.1
>From f0436e4c387dd28c91c5da11e06f2b848b4079cf Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 12:44:02 +0100
Subject: [PATCH 09/34] avcodec/x86/pixblockdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/pixblockdsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/pixblockdsp_init.c b/libavcodec/x86/pixblockdsp_init.c
index 650a0eb4f6..f37db645f7 100644
--- a/libavcodec/x86/pixblockdsp_init.c
+++ b/libavcodec/x86/pixblockdsp_init.c
@@ -32,12 +32,12 @@ av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
if (!high_bit_depth) {
c->get_pixels_unaligned =
c->get_pixels = ff_get_pixels_sse2;
}
c->diff_pixels_unaligned =
c->diff_pixels = ff_diff_pixels_sse2;
- }
+ )
}
--
2.49.1
>From 4a87c5bdb18d6d15e2dd4b3be3701c1c046dcbb7 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 12:45:22 +0100
Subject: [PATCH 10/34] avcodec/x86/svq1enc_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/svq1enc_init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/svq1enc_init.c b/libavcodec/x86/svq1enc_init.c
index daf573beba..4bd2e7e4df 100644
--- a/libavcodec/x86/svq1enc_init.c
+++ b/libavcodec/x86/svq1enc_init.c
@@ -18,7 +18,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
@@ -31,7 +30,7 @@ av_cold void ff_svq1enc_init_x86(SVQ1EncDSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_sse2;
- }
+ )
}
--
2.49.1
>From 687a1191004b29de3991e948ca84ceab004531af Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 12:50:24 +0100
Subject: [PATCH 11/34] avcodec/x86/apv_dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/apv_dsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/apv_dsp_init.c b/libavcodec/x86/apv_dsp_init.c
index 39360a0ad2..7bd6873616 100644
--- a/libavcodec/x86/apv_dsp_init.c
+++ b/libavcodec/x86/apv_dsp_init.c
@@ -36,9 +36,9 @@ av_cold void ff_apv_dsp_init_x86_64(APVDSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
dsp->decode_transquant = ff_apv_decode_transquant_avx2;
- }
+ )
}
#endif /* ARCH_X86_64 */
--
2.49.1
>From f73bf934872be2f74406f80336cf040e1653d9ae Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 12:51:57 +0100
Subject: [PATCH 12/34] avcodec/x86/utvideodsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/utvideodsp_init.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/utvideodsp_init.c b/libavcodec/x86/utvideodsp_init.c
index 2b436c6c5c..004549cb43 100644
--- a/libavcodec/x86/utvideodsp_init.c
+++ b/libavcodec/x86/utvideodsp_init.c
@@ -18,10 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
-#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/utvideodsp.h"
@@ -43,12 +41,12 @@ av_cold void ff_utvideodsp_init_x86(UTVideoDSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->restore_rgb_planes = ff_restore_rgb_planes_sse2;
c->restore_rgb_planes10 = ff_restore_rgb_planes10_sse2;
- }
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->restore_rgb_planes = ff_restore_rgb_planes_avx2;
c->restore_rgb_planes10 = ff_restore_rgb_planes10_avx2;
- }
+ )
}
--
2.49.1
>From e1fa1e754c5ef0a16155e7273e31dfd9423774cc Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:04:17 +0100
Subject: [PATCH 13/34] avcodec/x86/exrdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/exrdsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/exrdsp_init.c b/libavcodec/x86/exrdsp_init.c
index 63b3480d8f..77fda48295 100644
--- a/libavcodec/x86/exrdsp_init.c
+++ b/libavcodec/x86/exrdsp_init.c
@@ -36,17 +36,17 @@ av_cold void ff_exrdsp_init_x86(ExrDSPContext *dsp)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
dsp->reorder_pixels = ff_reorder_pixels_sse2;
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSSE3(cpu_flags,
dsp->predictor = ff_predictor_ssse3;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
dsp->predictor = ff_predictor_avx;
- }
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
dsp->reorder_pixels = ff_reorder_pixels_avx2;
dsp->predictor = ff_predictor_avx2;
- }
+ )
}
--
2.49.1
>From 9f6b2ab299f12ab1fb98688b24bb989caf435361 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:05:27 +0100
Subject: [PATCH 14/34] avcodec/x86/blockdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/blockdsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c
index 37f3bb6a84..fafe4c4ef0 100644
--- a/libavcodec/x86/blockdsp_init.c
+++ b/libavcodec/x86/blockdsp_init.c
@@ -39,21 +39,21 @@ av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
c->clear_block = ff_clear_block_sse;
c->clear_blocks = ff_clear_blocks_sse;
- }
- if (EXTERNAL_SSE2(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE2(cpu_flags,
c->fill_block_tab[0] = ff_fill_block_tab_16_sse2;
c->fill_block_tab[1] = ff_fill_block_tab_8_sse2;
- }
- if (EXTERNAL_AVX_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX_FAST(cpu_flags,
c->clear_block = ff_clear_block_avx;
c->clear_blocks = ff_clear_blocks_avx;
- }
- if (EXTERNAL_AVX2(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX2(cpu_flags,
c->fill_block_tab[0] = ff_fill_block_tab_16_avx2;
c->fill_block_tab[1] = ff_fill_block_tab_8_avx2;
- }
+ )
#endif /* HAVE_X86ASM */
}
--
2.49.1
>From 71731dee2486998402fabfe9d5e20a863ba88730 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:06:27 +0100
Subject: [PATCH 15/34] avcodec/x86/sbcdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/sbcdsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/sbcdsp_init.c b/libavcodec/x86/sbcdsp_init.c
index 7416a86ac6..ec32927627 100644
--- a/libavcodec/x86/sbcdsp_init.c
+++ b/libavcodec/x86/sbcdsp_init.c
@@ -44,9 +44,9 @@ av_cold void ff_sbcdsp_init_x86(SBCDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_MMX(cpu_flags)) {
+ IF_EXTERNAL_MMX(cpu_flags,
s->sbc_analyze_4 = ff_sbc_analyze_4_mmx;
s->sbc_analyze_8 = ff_sbc_analyze_8_mmx;
s->sbc_calc_scalefactors = ff_sbc_calc_scalefactors_mmx;
- }
+ )
}
--
2.49.1
>From f7dc78a394ecab7ea5322dfa2abea8cb99e85c36 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:07:35 +0100
Subject: [PATCH 16/34] avcodec/x86/vp3dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/vp3dsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/vp3dsp_init.c b/libavcodec/x86/vp3dsp_init.c
index 42daf99981..ce15f67fc8 100644
--- a/libavcodec/x86/vp3dsp_init.c
+++ b/libavcodec/x86/vp3dsp_init.c
@@ -44,19 +44,19 @@ av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_MMX(cpu_flags)) {
+ IF_EXTERNAL_MMX(cpu_flags,
c->put_no_rnd_pixels_l2 = ff_put_vp_no_rnd_pixels8_l2_mmx;
- }
+ )
- if (EXTERNAL_MMXEXT(cpu_flags)) {
+ IF_EXTERNAL_MMXEXT(cpu_flags,
c->idct_dc_add = ff_vp3_idct_dc_add_mmxext;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_vp3_idct_put_sse2;
c->idct_add = ff_vp3_idct_add_sse2;
c->v_loop_filter = c->v_loop_filter_unaligned = ff_vp3_v_loop_filter_sse2;
c->h_loop_filter = c->h_loop_filter_unaligned = ff_vp3_h_loop_filter_sse2;
- }
+ )
}
--
2.49.1
>From 80b2c9bd99a7a666a40a6dfe132e652614d7ac33 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:09:04 +0100
Subject: [PATCH 17/34] avcodec/x86/proresdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/proresdsp_init.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/proresdsp_init.c b/libavcodec/x86/proresdsp_init.c
index f7abbfa692..6c00a795eb 100644
--- a/libavcodec/x86/proresdsp_init.c
+++ b/libavcodec/x86/proresdsp_init.c
@@ -36,15 +36,15 @@ av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sampl
int cpu_flags = av_get_cpu_flags();
if (bits_per_raw_sample == 10) {
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
dsp->idct_put = ff_prores_idct_put_10_sse2;
- }
+ )
- if (EXTERNAL_AVX(cpu_flags)) {
+ IF_EXTERNAL_AVX(cpu_flags,
dsp->idct_permutation_type = FF_IDCT_PERM_TRANSPOSE;
dsp->idct_put = ff_prores_idct_put_10_avx;
- }
+ )
}
#endif /* ARCH_X86_64 */
}
--
2.49.1
>From 64c7d972d73e5f0305f78401bf01688c58a1f53b Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:09:51 +0100
Subject: [PATCH 18/34] avcodec/x86/sbrdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/sbrdsp_init.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c
index 999f681220..ff92a838ce 100644
--- a/libavcodec/x86/sbrdsp_init.c
+++ b/libavcodec/x86/sbrdsp_init.c
@@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
@@ -59,7 +58,7 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
s->neg_odd_64 = ff_sbr_neg_odd_64_sse;
s->sum_square = ff_sbr_sum_square_sse;
s->sum64x5 = ff_sbr_sum64x5_sse;
@@ -68,18 +67,18 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s)
s->qmf_post_shuffle = ff_sbr_qmf_post_shuffle_sse;
s->qmf_deint_neg = ff_sbr_qmf_deint_neg_sse;
s->autocorrelate = ff_sbr_autocorrelate_sse;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_sse2;
s->qmf_pre_shuffle = ff_sbr_qmf_pre_shuffle_sse2;
s->hf_apply_noise[0] = ff_sbr_hf_apply_noise_0_sse2;
s->hf_apply_noise[1] = ff_sbr_hf_apply_noise_1_sse2;
s->hf_apply_noise[2] = ff_sbr_hf_apply_noise_2_sse2;
s->hf_apply_noise[3] = ff_sbr_hf_apply_noise_3_sse2;
- }
+ )
- if (EXTERNAL_SSE3(cpu_flags)) {
+ IF_EXTERNAL_SSE3(cpu_flags,
s->autocorrelate = ff_sbr_autocorrelate_sse3;
- }
+ )
}
--
2.49.1
>From 17e0e0e7fb6caa542c44cd9d6a8ef25e9cc011e1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:14:27 +0100
Subject: [PATCH 19/34] avcodec/x86/takdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/takdsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/takdsp_init.c b/libavcodec/x86/takdsp_init.c
index 9553f8442c..feb4b3a52d 100644
--- a/libavcodec/x86/takdsp_init.c
+++ b/libavcodec/x86/takdsp_init.c
@@ -37,21 +37,21 @@ av_cold void ff_takdsp_init_x86(TAKDSPContext *c)
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->decorrelate_ls = ff_tak_decorrelate_ls_sse2;
c->decorrelate_sr = ff_tak_decorrelate_sr_sse2;
c->decorrelate_sm = ff_tak_decorrelate_sm_sse2;
- }
+ )
- if (EXTERNAL_SSE4(cpu_flags)) {
+ IF_EXTERNAL_SSE4(cpu_flags,
c->decorrelate_sf = ff_tak_decorrelate_sf_sse4;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->decorrelate_ls = ff_tak_decorrelate_ls_avx2;
c->decorrelate_sr = ff_tak_decorrelate_sr_avx2;
c->decorrelate_sm = ff_tak_decorrelate_sm_avx2;
c->decorrelate_sf = ff_tak_decorrelate_sf_avx2;
- }
+ )
#endif
}
--
2.49.1
>From f80e49c9c33dcf830f8e8e5fe5ed6aa94b2c4619 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:15:52 +0100
Subject: [PATCH 20/34] avcodec/x86/opusdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/opusdsp_init.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/opusdsp_init.c b/libavcodec/x86/opusdsp_init.c
index 83f7616a2e..ec15c77868 100644
--- a/libavcodec/x86/opusdsp_init.c
+++ b/libavcodec/x86/opusdsp_init.c
@@ -16,8 +16,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
-
#include "libavutil/attributes.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/opus/dsp.h"
@@ -29,8 +27,8 @@ av_cold void ff_opus_dsp_init_x86(OpusDSP *ctx)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_FMA3(cpu_flags)) {
+ IF_EXTERNAL_FMA3(cpu_flags,
ctx->postfilter = ff_opus_postfilter_fma3;
ctx->deemphasis = ff_opus_deemphasis_fma3;
- }
+ )
}
--
2.49.1
>From e4fd0918ece61ba75364637897b878e822e17d03 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:17:57 +0100
Subject: [PATCH 21/34] avcodec/x86/ac3dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/ac3dsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c
index 353cf38f86..761f96c68e 100644
--- a/libavcodec/x86/ac3dsp_init.c
+++ b/libavcodec/x86/ac3dsp_init.c
@@ -38,20 +38,20 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
c->float_to_fixed24 = ff_float_to_fixed24_sse2;
c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
c->extract_exponents = ff_ac3_extract_exponents_sse2;
- }
+ )
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ IF_EXTERNAL_SSSE3(cpu_flags,
if (!(cpu_flags & AV_CPU_FLAG_ATOM))
c->extract_exponents = ff_ac3_extract_exponents_ssse3;
- }
- if (EXTERNAL_AVX_FAST(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX_FAST(cpu_flags,
c->float_to_fixed24 = ff_float_to_fixed24_avx;
- }
+ )
}
#define DOWNMIX_FUNC_OPT(ch, opt) \
@@ -76,12 +76,12 @@ void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c)
#define SET_DOWNMIX(ch, suf, SUF) \
if (ch == c->in_channels) { \
- if (EXTERNAL_ ## SUF (cpu_flags)) { \
+ IF_EXTERNAL_ ## SUF (cpu_flags, \
if (c->out_channels == 1) \
c->downmix = ff_ac3_downmix_ ## ch ## _to_1_ ## suf; \
else \
c->downmix = ff_ac3_downmix_ ## ch ## _to_2_ ## suf; \
- } \
+ ) \
}
#define SET_DOWNMIX_ALL(suf, SUF) \
--
2.49.1
>From b8f77878751ed4b6a1ebcf57b0517d0eda8d947f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:18:56 +0100
Subject: [PATCH 22/34] avcodec/x86/vp6dsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/vp6dsp_init.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/vp6dsp_init.c b/libavcodec/x86/vp6dsp_init.c
index 83d45ec36c..fa6e6d963c 100644
--- a/libavcodec/x86/vp6dsp_init.c
+++ b/libavcodec/x86/vp6dsp_init.c
@@ -32,7 +32,7 @@ av_cold void ff_vp6dsp_init_x86(VP56DSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2;
- }
+ )
}
--
2.49.1
>From bf1c3c91e66844bd44a14664588f1befc09f36ac Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:35:33 +0100
Subject: [PATCH 23/34] avcodec/x86/flacdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/flacdsp_init.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index fa993d3466..a2df81a945 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -65,7 +65,7 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
#if HAVE_X86ASM
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->wasted32 = ff_flac_wasted_32_sse2;
if (fmt == AV_SAMPLE_FMT_S16) {
c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
@@ -76,8 +76,8 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2;
c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2;
}
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSSE3(cpu_flags,
if (fmt == AV_SAMPLE_FMT_S16) {
if (channels == 2)
c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3;
@@ -85,8 +85,9 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
- else if (ARCH_X86_64 && channels == 8)
+ else IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
+ )
} else if (fmt == AV_SAMPLE_FMT_S32) {
if (channels == 2)
c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
@@ -94,30 +95,33 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
- else if (ARCH_X86_64 && channels == 8)
+ else IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
+ )
}
- }
- if (EXTERNAL_SSE4(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE4(cpu_flags,
c->lpc16 = ff_flac_lpc_16_sse4;
c->lpc32 = ff_flac_lpc_32_sse4;
c->wasted33 = ff_flac_wasted_33_sse4;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
if (fmt == AV_SAMPLE_FMT_S16) {
- if (ARCH_X86_64 && channels == 8)
+ IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
+ )
} else if (fmt == AV_SAMPLE_FMT_S32) {
if (channels == 4)
c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
else if (channels == 6)
c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
- else if (ARCH_X86_64 && channels == 8)
+ else IF(ARCH_X86_64, channels == 8,
c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
+ )
}
- }
- if (EXTERNAL_XOP(cpu_flags)) {
+ )
+ IF_EXTERNAL_XOP(cpu_flags,
c->lpc32 = ff_flac_lpc_32_xop;
- }
+ )
#endif /* HAVE_X86ASM */
}
--
2.49.1
>From f53202fe7f9dfbb6fb6cbefe43367e13f177a9a1 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:38:51 +0100
Subject: [PATCH 24/34] avcodec/x86/huffyuvdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/huffyuvdsp_init.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/huffyuvdsp_init.c b/libavcodec/x86/huffyuvdsp_init.c
index 239d3ca313..43515735c7 100644
--- a/libavcodec/x86/huffyuvdsp_init.c
+++ b/libavcodec/x86/huffyuvdsp_init.c
@@ -18,11 +18,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/pixdesc.h"
-#include "libavutil/x86/asm.h"
#include "libavutil/x86/cpu.h"
#include "libavcodec/huffyuvdsp.h"
@@ -38,16 +36,16 @@ av_cold void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix
int cpu_flags = av_get_cpu_flags();
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
- if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) {
+ IF_EXTERNAL_EXTENDED(MMXEXT, cpu_flags, pix_desc && pix_desc->comp[0].depth<16,
c->add_hfyu_median_pred_int16 = ff_add_hfyu_median_pred_int16_mmxext;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->add_int16 = ff_add_int16_sse2;
c->add_hfyu_left_pred_bgr32 = ff_add_hfyu_left_pred_bgr32_sse2;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->add_int16 = ff_add_int16_avx2;
- }
+ )
}
--
2.49.1
>From 0c2fd3312d99c61a7e26b75b7537630c54d0b478 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:41:37 +0100
Subject: [PATCH 25/34] avcodec/x86/huffyuvencdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/huffyuvencdsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/huffyuvencdsp_init.c b/libavcodec/x86/huffyuvencdsp_init.c
index c9c33b75b4..b64d1200dc 100644
--- a/libavcodec/x86/huffyuvencdsp_init.c
+++ b/libavcodec/x86/huffyuvencdsp_init.c
@@ -40,15 +40,15 @@ av_cold void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, enum AVPixelForm
av_unused int cpu_flags = av_get_cpu_flags();
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
- if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) {
+ IF_EXTERNAL_EXTENDED(MMXEXT, cpu_flags, pix_desc && pix_desc->comp[0].depth<16,
c->sub_hfyu_median_pred_int16 = ff_sub_hfyu_median_pred_int16_mmxext;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->diff_int16 = ff_diff_int16_sse2;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->diff_int16 = ff_diff_int16_avx2;
- }
+ )
}
--
2.49.1
>From fe24a086f315a9d49d9758985f1ae03aea695a89 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:42:40 +0100
Subject: [PATCH 26/34] avcodec/x86/cfhddsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/cfhddsp_init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/cfhddsp_init.c b/libavcodec/x86/cfhddsp_init.c
index c5d89561ae..362dc91b3c 100644
--- a/libavcodec/x86/cfhddsp_init.c
+++ b/libavcodec/x86/cfhddsp_init.c
@@ -21,7 +21,6 @@
#include <stddef.h>
#include <stdint.h>
-#include "config.h"
#include "libavutil/attributes.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
@@ -42,12 +41,12 @@ av_cold void ff_cfhddsp_init_x86(CFHDDSPContext *c, int depth, int bayer)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->horiz_filter = ff_cfhd_horiz_filter_sse2;
c->vert_filter = ff_cfhd_vert_filter_sse2;
if (depth == 10 && !bayer)
c->horiz_filter_clip = ff_cfhd_horiz_filter_clip10_sse2;
if (depth == 12 && !bayer)
c->horiz_filter_clip = ff_cfhd_horiz_filter_clip12_sse2;
- }
+ )
}
--
2.49.1
>From f43d706de657212b61fede3d0f7ad86f073a4365 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:43:20 +0100
Subject: [PATCH 27/34] avcodec/x86/cfhdencdsp_init: Avoid reliance on DCE
Also avoid an unused variable warning with 32 bit builds.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/cfhdencdsp_init.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/x86/cfhdencdsp_init.c b/libavcodec/x86/cfhdencdsp_init.c
index 5cea39a80a..41d5ca1474 100644
--- a/libavcodec/x86/cfhdencdsp_init.c
+++ b/libavcodec/x86/cfhdencdsp_init.c
@@ -38,12 +38,12 @@ void ff_cfhdenc_vert_filter_sse2(const int16_t *input, int16_t *low, int16_t *hi
av_cold void ff_cfhdencdsp_init_x86(CFHDEncDSPContext *c)
{
+#if ARCH_X86_64
int cpu_flags = av_get_cpu_flags();
-#if ARCH_X86_64
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->horiz_filter = ff_cfhdenc_horiz_filter_sse2;
c->vert_filter = ff_cfhdenc_vert_filter_sse2;
- }
+ )
#endif
}
--
2.49.1
>From c44a0b3e1308293fe0eeebdb6458a025e61c1398 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:44:49 +0100
Subject: [PATCH 28/34] avcodec/x86/mpegvideoencdsp_init: Avoid reliance on DCE
Also avoid an unused variable warning with 32 bit builds.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/mpegvideoencdsp_init.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c
index bf5b722016..a6b32cd1d7 100644
--- a/libavcodec/x86/mpegvideoencdsp_init.c
+++ b/libavcodec/x86/mpegvideoencdsp_init.c
@@ -208,14 +208,14 @@ av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c,
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->pix_sum = ff_pix_sum16_sse2;
c->pix_norm1 = ff_pix_norm1_sse2;
- }
+ )
- if (EXTERNAL_XOP(cpu_flags)) {
+ IF_EXTERNAL_XOP(cpu_flags,
c->pix_sum = ff_pix_sum16_xop;
- }
+ )
#if HAVE_INLINE_ASM
--
2.49.1
>From 1fa678e0ce49da1cc1a20dea02de9b10de3cd526 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:45:49 +0100
Subject: [PATCH 29/34] avcodec/x86/lossless_videodsp_init: Avoid reliance on
DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/lossless_videodsp_init.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/libavcodec/x86/lossless_videodsp_init.c b/libavcodec/x86/lossless_videodsp_init.c
index 5690cacaad..80f87238cd 100644
--- a/libavcodec/x86/lossless_videodsp_init.c
+++ b/libavcodec/x86/lossless_videodsp_init.c
@@ -18,8 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "config.h"
-#include "../lossless_videodsp.h"
+#include "libavcodec/lossless_videodsp.h"
#include "libavutil/x86/cpu.h"
void ff_add_bytes_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t w);
@@ -46,25 +45,25 @@ void ff_llviddsp_init_x86(LLVidDSPContext *c)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->add_bytes = ff_add_bytes_sse2;
c->add_median_pred = ff_add_median_pred_sse2;
- }
+ )
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ IF_EXTERNAL_SSSE3(cpu_flags,
c->add_left_pred = ff_add_left_pred_ssse3;
c->add_left_pred_int16 = ff_add_left_pred_int16_ssse3;
c->add_gradient_pred = ff_add_gradient_pred_ssse3;
- }
+ )
- if (EXTERNAL_SSSE3_FAST(cpu_flags)) {
+ IF_EXTERNAL_SSSE3_FAST(cpu_flags,
c->add_left_pred = ff_add_left_pred_unaligned_ssse3;
c->add_left_pred_int16 = ff_add_left_pred_int16_unaligned_ssse3;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->add_bytes = ff_add_bytes_avx2;
c->add_left_pred = ff_add_left_pred_unaligned_avx2;
c->add_gradient_pred = ff_add_gradient_pred_avx2;
- }
+ )
}
--
2.49.1
>From 904439625360b1cd0c2b2fc8b9a1114d8cf74d5d Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 13:46:45 +0100
Subject: [PATCH 30/34] avcodec/x86/lossless_videoencdsp_init: Avoid reliance
on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/lossless_videoencdsp_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/x86/lossless_videoencdsp_init.c b/libavcodec/x86/lossless_videoencdsp_init.c
index 22a4014ef1..fa4b864f50 100644
--- a/libavcodec/x86/lossless_videoencdsp_init.c
+++ b/libavcodec/x86/lossless_videoencdsp_init.c
@@ -91,15 +91,15 @@ av_cold void ff_llvidencdsp_init_x86(LLVidEncDSPContext *c)
}
#endif /* HAVE_INLINE_ASM */
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->diff_bytes = ff_diff_bytes_sse2;
- }
+ )
- if (EXTERNAL_AVX(cpu_flags)) {
+ IF_EXTERNAL_AVX(cpu_flags,
c->sub_left_predict = ff_sub_left_predict_avx;
- }
+ )
- if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ IF_EXTERNAL_AVX2_FAST(cpu_flags,
c->diff_bytes = ff_diff_bytes_avx2;
- }
+ )
}
--
2.49.1
>From 09bf720331e2d12ff2beeb44ef4faf3479afcf0e Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 14:01:41 +0100
Subject: [PATCH 31/34] avcodec/x86/h264_intrapred_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/h264_intrapred_init.c | 36 ++++++++++++++--------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c
index aa9bc721f0..8d8ae758d3 100644
--- a/libavcodec/x86/h264_intrapred_init.c
+++ b/libavcodec/x86/h264_intrapred_init.c
@@ -163,7 +163,7 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
int cpu_flags = av_get_cpu_flags();
if (bit_depth == 8) {
- if (EXTERNAL_MMXEXT(cpu_flags)) {
+ IF_EXTERNAL_MMXEXT(cpu_flags,
if (chroma_format_idc <= 1)
h->pred8x8[HOR_PRED8x8 ] = ff_pred8x8_horizontal_8_mmxext;
h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_8_mmxext;
@@ -196,13 +196,13 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_8_mmxext;
h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_8_mmxext;
}
- }
+ )
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_8_sse;
- }
+ )
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_sse2;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_sse2;
h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_8_sse2;
@@ -226,9 +226,9 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_sse2;
}
}
- }
+ )
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ IF_EXTERNAL_SSSE3(cpu_flags,
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_8_ssse3;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_8_ssse3;
if (chroma_format_idc <= 1)
@@ -257,19 +257,19 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_8_ssse3;
}
}
- }
+ )
- if(EXTERNAL_AVX2(cpu_flags)){
+ IF_EXTERNAL_AVX2(cpu_flags,
if (codec_id == AV_CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_8_avx2;
}
- }
+ )
} else if (bit_depth == 10) {
- if (EXTERNAL_MMXEXT(cpu_flags)) {
+ IF_EXTERNAL_MMXEXT(cpu_flags,
h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext;
h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext;
- }
- if (EXTERNAL_SSE2(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE2(cpu_flags,
h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_sse2;
h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_sse2;
h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_sse2;
@@ -300,8 +300,8 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred16x16[LEFT_DC_PRED8x8 ] = ff_pred16x16_left_dc_10_sse2;
h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_10_sse2;
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_10_sse2;
- }
- if (EXTERNAL_SSSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSSE3(cpu_flags,
h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_ssse3;
h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_ssse3;
h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3;
@@ -311,8 +311,8 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred8x8l[DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_10_ssse3;
h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_ssse3;
h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_ssse3;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx;
h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx;
h->pred4x4[VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_10_avx;
@@ -327,6 +327,6 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id,
h->pred8x8l[DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_10_avx;
h->pred8x8l[VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_10_avx;
h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx;
- }
+ )
}
}
--
2.49.1
>From 03fa11b8c149155628df686676cd2ff2d692a692 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 14:11:59 +0100
Subject: [PATCH 32/34] avcodec/x86/idctdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/idctdsp_init.c | 60 +++++++++++++++++------------------
1 file changed, 29 insertions(+), 31 deletions(-)
diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c
index 2d165b975b..8e20989e5f 100644
--- a/libavcodec/x86/idctdsp_init.c
+++ b/libavcodec/x86/idctdsp_init.c
@@ -66,7 +66,7 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
int cpu_flags = av_get_cpu_flags();
#if ARCH_X86_32
- if (EXTERNAL_MMX(cpu_flags)) {
+ IF_EXTERNAL_MMX(cpu_flags,
if (!high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
@@ -74,88 +74,86 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx,
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
c->idct = ff_simple_idct_mmx;
}
- }
+ )
#endif
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_sse2;
c->put_pixels_clamped = ff_put_pixels_clamped_sse2;
c->add_pixels_clamped = ff_add_pixels_clamped_sse2;
-#if ARCH_X86_32
- if (!high_bit_depth &&
+ IF(ARCH_X86_32, !high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEMMX),
c->idct_put = ff_simple_idct_put_sse2;
c->idct_add = ff_simple_idct_add_sse2;
c->perm_type = FF_IDCT_PERM_SIMPLE;
- }
-#endif
-
- if (ARCH_X86_64 &&
- !high_bit_depth &&
+ )
+ IF(ARCH_X86_64, !high_bit_depth &&
avctx->lowres == 0 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
- avctx->idct_algo == FF_IDCT_SIMPLE)) {
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
+ avctx->idct_algo == FF_IDCT_SIMPLE),
c->idct = ff_simple_idct8_sse2;
c->idct_put = ff_simple_idct8_put_sse2;
c->idct_add = ff_simple_idct8_add_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
- }
+ )
+ )
- if (ARCH_X86_64 && avctx->lowres == 0) {
- if (EXTERNAL_AVX(cpu_flags) &&
+#if ARCH_X86_64
+ if (avctx->lowres == 0) {
+ IF_EXTERNAL_EXTENDED(AVX, cpu_flags,
!high_bit_depth &&
(avctx->idct_algo == FF_IDCT_AUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
- avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
- avctx->idct_algo == FF_IDCT_SIMPLE)) {
+ avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
+ avctx->idct_algo == FF_IDCT_SIMPLEMMX ||
+ avctx->idct_algo == FF_IDCT_SIMPLE),
c->idct = ff_simple_idct8_avx;
c->idct_put = ff_simple_idct8_put_avx;
c->idct_add = ff_simple_idct8_add_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
+ )
if (avctx->bits_per_raw_sample == 10 &&
avctx->codec_id != AV_CODEC_ID_MPEG4 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEAUTO ||
avctx->idct_algo == FF_IDCT_SIMPLE)) {
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_simple_idct10_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct10_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
c->idct_put = ff_simple_idct10_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct10_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
+ )
}
if (avctx->bits_per_raw_sample == 12 &&
(avctx->idct_algo == FF_IDCT_AUTO ||
avctx->idct_algo == FF_IDCT_SIMPLEMMX)) {
- if (EXTERNAL_SSE2(cpu_flags)) {
+ IF_EXTERNAL_SSE2(cpu_flags,
c->idct_put = ff_simple_idct12_put_sse2;
c->idct_add = NULL;
c->idct = ff_simple_idct12_sse2;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
c->idct_put = ff_simple_idct12_put_avx;
c->idct_add = NULL;
c->idct = ff_simple_idct12_avx;
c->perm_type = FF_IDCT_PERM_TRANSPOSE;
- }
+ )
}
}
+#endif
}
--
2.49.1
>From b1ee6b9307d25254c67481176a27c3fb8eff59bd Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 14:15:37 +0100
Subject: [PATCH 33/34] avcodec/x86/dcadsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/dcadsp_init.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index c01bfffaba..a2a8be120f 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -36,14 +36,17 @@ av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE2(cpu_flags))
+ IF_EXTERNAL_SSE2(cpu_flags,
s->lfe_fir_float[0] = ff_lfe_fir0_float_sse2;
- if (EXTERNAL_SSE3(cpu_flags))
+ )
+ IF_EXTERNAL_SSE3(cpu_flags,
s->lfe_fir_float[1] = ff_lfe_fir1_float_sse3;
- if (EXTERNAL_AVX(cpu_flags)) {
+ )
+ IF_EXTERNAL_AVX(cpu_flags,
s->lfe_fir_float[0] = ff_lfe_fir0_float_avx;
s->lfe_fir_float[1] = ff_lfe_fir1_float_avx;
- }
- if (EXTERNAL_FMA3(cpu_flags))
+ )
+ IF_EXTERNAL_FMA3(cpu_flags,
s->lfe_fir_float[0] = ff_lfe_fir0_float_fma3;
+ )
}
--
2.49.1
>From acb426b2dc11960d6f77dc7286bbc0d90a615348 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Thu, 30 Oct 2025 14:17:10 +0100
Subject: [PATCH 34/34] avcodec/x86/aacpsdsp_init: Avoid reliance on DCE
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/x86/aacpsdsp_init.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/x86/aacpsdsp_init.c b/libavcodec/x86/aacpsdsp_init.c
index 221fe71bc7..21485385df 100644
--- a/libavcodec/x86/aacpsdsp_init.c
+++ b/libavcodec/x86/aacpsdsp_init.c
@@ -53,22 +53,22 @@ av_cold void ff_psdsp_init_x86(PSDSPContext *s)
{
int cpu_flags = av_get_cpu_flags();
- if (EXTERNAL_SSE(cpu_flags)) {
+ IF_EXTERNAL_SSE(cpu_flags,
s->add_squares = ff_ps_add_squares_sse;
s->mul_pair_single = ff_ps_mul_pair_single_sse;
s->hybrid_analysis_ileave = ff_ps_hybrid_analysis_ileave_sse;
s->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_sse;
s->hybrid_analysis = ff_ps_hybrid_analysis_sse;
- }
- if (EXTERNAL_SSE3(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE3(cpu_flags,
s->add_squares = ff_ps_add_squares_sse3;
s->stereo_interpolate[0] = ff_ps_stereo_interpolate_sse3;
s->stereo_interpolate[1] = ff_ps_stereo_interpolate_ipdopd_sse3;
- }
- if (EXTERNAL_SSE4(cpu_flags)) {
+ )
+ IF_EXTERNAL_SSE4(cpu_flags,
s->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_sse4;
- }
- if (EXTERNAL_FMA3(cpu_flags)) {
+ )
+ IF_EXTERNAL_FMA3(cpu_flags,
s->hybrid_analysis = ff_ps_hybrid_analysis_fma3;
- }
+ )
}
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-10-30 13:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176183097809.81.6715215544811175390@7d278768979e \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git