PR #21034 opened by Amyspark (amyspark) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21034 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21034.patch
Hi all, This is a MR following up on https://code.ffmpeg.org/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c, which addressed some DCE issues with MSVC. The commits here address the remaining cases I found during my tests with FFmpeg 5.x, 7.1 and 8.0. Please note that there are different approaches based on when I'd written the code -- for most cases I preferred a single wrapping with `#if HAVE_X86ASM`, while for the smaller ones I addressed them case-by-case with `#if HAVE_<instruction set>_EXTERNAL`. I'm happy to edit this MR with the correct approach once reviewed. All feedback is appreciated. >From 2353f750ff96d2263c4624e5b42e59861482f780 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:22:27 -0300 Subject: [PATCH 1/7] avcodec/x86: replace DCE with macros to guard usage of undefined functions See e.g. https://github.com/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c Signed-off-by: L. E. Segovia <[email protected]> --- libavcodec/x86/fdctdsp_init.c | 2 + libavcodec/x86/flacdsp_init.c | 8 +++- libavcodec/x86/hevc/dsp_init.c | 72 ++++++++++++++-------------- libavcodec/x86/idctdsp_init.c | 9 ++-- libavcodec/x86/mlpdsp_init.c | 6 ++- libavfilter/x86/colorspacedsp_init.c | 4 +- libavfilter/x86/vf_atadenoise_init.c | 6 ++- libavfilter/x86/vf_ssim_init.c | 4 +- libavfilter/x86/vf_w3fdif_init.c | 4 +- 9 files changed, 67 insertions(+), 48 deletions(-) diff --git a/libavcodec/x86/fdctdsp_init.c b/libavcodec/x86/fdctdsp_init.c index 107912afc8..9958b32466 100644 --- a/libavcodec/x86/fdctdsp_init.c +++ b/libavcodec/x86/fdctdsp_init.c @@ -32,8 +32,10 @@ av_cold void ff_fdctdsp_init_x86(FDCTDSPContext *c, AVCodecContext *avctx, if (!high_bit_depth) { if ((dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX)) { +#if HAVE_INLINE_SSE2 if (INLINE_SSE2(cpu_flags)) c->fdct = ff_fdct_sse2; +#endif } } #endif diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c index fa993d3466..89335bcb70 100644 --- a/libavcodec/x86/flacdsp_init.c +++ b/libavcodec/x86/flacdsp_init.c @@ -105,15 +105,19 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int } if (EXTERNAL_AVX(cpu_flags)) { if (fmt == AV_SAMPLE_FMT_S16) { - if (ARCH_X86_64 && channels == 8) +#if ARCH_X86_64 + if (channels == 8) c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx; +#endif } 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) +#if ARCH_X86_64 + else if (channels == 8) c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx; +#endif } } if (EXTERNAL_XOP(cpu_flags)) { diff --git a/libavcodec/x86/hevc/dsp_init.c b/libavcodec/x86/hevc/dsp_init.c index f1558b7e3e..a02a57a9ac 100644 --- a/libavcodec/x86/hevc/dsp_init.c +++ b/libavcodec/x86/hevc/dsp_init.c @@ -821,13 +821,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_sse2; - if (ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_sse2; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_sse2; +#if ARCH_X86_64 + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_sse2; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_sse2; - c->idct[2] = ff_hevc_idct_16x16_8_sse2; - c->idct[3] = ff_hevc_idct_32x32_8_sse2; - } + c->idct[2] = ff_hevc_idct_16x16_8_sse2; + c->idct[3] = ff_hevc_idct_32x32_8_sse2; +#endif SAO_BAND_INIT(8, sse2); c->idct_dc[0] = ff_hevc_idct_4x4_dc_8_sse2; @@ -842,13 +842,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->add_residual[2] = ff_hevc_add_residual_16_8_sse2; c->add_residual[3] = ff_hevc_add_residual_32_8_sse2; } +#if HAVE_SSSE3_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSSE3(cpu_flags)) { - if(ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_ssse3; - } + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_ssse3; SAO_EDGE_INIT(8, ssse3); } +#endif #if HAVE_SSE4_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSE4(cpu_flags)) { @@ -866,13 +866,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) if (EXTERNAL_AVX(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_avx; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_avx; - if (ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_avx; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_avx; +#if ARCH_X86_64 + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_avx; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_8_avx; - c->idct[2] = ff_hevc_idct_16x16_8_avx; - c->idct[3] = ff_hevc_idct_32x32_8_avx; - } + c->idct[2] = ff_hevc_idct_16x16_8_avx; + c->idct[3] = ff_hevc_idct_32x32_8_avx; +#endif SAO_BAND_INIT(8, avx); c->idct[0] = ff_hevc_idct_4x4_8_avx; @@ -997,13 +997,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_sse2; - if (ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_sse2; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_sse2; +#if ARCH_X86_64 + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_sse2; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_sse2; - c->idct[2] = ff_hevc_idct_16x16_10_sse2; - c->idct[3] = ff_hevc_idct_32x32_10_sse2; - } + c->idct[2] = ff_hevc_idct_16x16_10_sse2; + c->idct[3] = ff_hevc_idct_32x32_10_sse2; +#endif SAO_BAND_INIT(10, sse2); SAO_EDGE_INIT(10, sse2); @@ -1039,13 +1039,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) if (EXTERNAL_AVX(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_avx; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_avx; - if (ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_avx; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_avx; +#if ARCH_X86_64 + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_avx; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_avx; - c->idct[2] = ff_hevc_idct_16x16_10_avx; - c->idct[3] = ff_hevc_idct_32x32_10_avx; - } + c->idct[2] = ff_hevc_idct_16x16_10_avx; + c->idct[3] = ff_hevc_idct_32x32_10_avx; +#endif c->idct[0] = ff_hevc_idct_4x4_10_avx; c->idct[1] = ff_hevc_idct_8x8_10_avx; @@ -1216,10 +1216,10 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2; - if (ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2; - } +#if ARCH_X86_64 + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2; +#endif SAO_BAND_INIT(12, sse2); SAO_EDGE_INIT(12, sse2); @@ -1248,10 +1248,10 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) if (EXTERNAL_AVX(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_avx; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_avx; - if (ARCH_X86_64) { - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_avx; - c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_avx; - } +#if ARCH_X86_64 + c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_avx; + c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_avx; +#endif SAO_BAND_INIT(12, avx); } if (EXTERNAL_AVX2(cpu_flags)) { diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c index 9c7f235b3f..fce62e5590 100644 --- a/libavcodec/x86/idctdsp_init.c +++ b/libavcodec/x86/idctdsp_init.c @@ -83,8 +83,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 || @@ -95,9 +95,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 || @@ -147,4 +149,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..333a685f47 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 } diff --git a/libavfilter/x86/colorspacedsp_init.c b/libavfilter/x86/colorspacedsp_init.c index b5006ac295..f01db4baf4 100644 --- a/libavfilter/x86/colorspacedsp_init.c +++ b/libavfilter/x86/colorspacedsp_init.c @@ -80,7 +80,8 @@ void ff_colorspacedsp_x86_init(ColorSpaceDSPContext *dsp) { int cpu_flags = av_get_cpu_flags(); - if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags)) { +#if ARCH_X86_64 + if (EXTERNAL_SSE2(cpu_flags)) { #define assign_yuv2yuv_fns(ss) \ dsp->yuv2yuv[BPP_8 ][BPP_8 ][SS_##ss] = ff_yuv2yuv_##ss##p8to8_sse2; \ dsp->yuv2yuv[BPP_8 ][BPP_10][SS_##ss] = ff_yuv2yuv_##ss##p8to10_sse2; \ @@ -116,4 +117,5 @@ void ff_colorspacedsp_x86_init(ColorSpaceDSPContext *dsp) dsp->multiply3x3 = ff_multiply3x3_sse2; } +#endif } diff --git a/libavfilter/x86/vf_atadenoise_init.c b/libavfilter/x86/vf_atadenoise_init.c index e7a653f191..eb621e172c 100644 --- a/libavfilter/x86/vf_atadenoise_init.c +++ b/libavfilter/x86/vf_atadenoise_init.c @@ -39,12 +39,14 @@ av_cold void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int al int cpu_flags = av_get_cpu_flags(); for (int p = 0; p < 4; p++) { - if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL && sigma[p] == INT16_MAX) { +#if ARCH_X86_64 + if (EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL && sigma[p] == INT16_MAX) { dsp->filter_row[p] = ff_atadenoise_filter_row8_sse4; } - if (ARCH_X86_64 && EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == SERIAL && sigma[p] == INT16_MAX) { + if (EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == SERIAL && sigma[p] == INT16_MAX) { dsp->filter_row[p] = ff_atadenoise_filter_row8_serial_sse4; } +#endif } } diff --git a/libavfilter/x86/vf_ssim_init.c b/libavfilter/x86/vf_ssim_init.c index cbaa20ef16..6f2305430c 100644 --- a/libavfilter/x86/vf_ssim_init.c +++ b/libavfilter/x86/vf_ssim_init.c @@ -34,8 +34,10 @@ void ff_ssim_init_x86(SSIMDSPContext *dsp) { int cpu_flags = av_get_cpu_flags(); - if (ARCH_X86_64 && EXTERNAL_SSSE3(cpu_flags)) +#if ARCH_X86_64 + if (EXTERNAL_SSSE3(cpu_flags)) dsp->ssim_4x4_line = ff_ssim_4x4_line_ssse3; +#endif if (EXTERNAL_SSE4(cpu_flags)) dsp->ssim_end_line = ff_ssim_end_line_sse4; if (EXTERNAL_XOP(cpu_flags)) diff --git a/libavfilter/x86/vf_w3fdif_init.c b/libavfilter/x86/vf_w3fdif_init.c index 16202fba76..6d677d651d 100644 --- a/libavfilter/x86/vf_w3fdif_init.c +++ b/libavfilter/x86/vf_w3fdif_init.c @@ -56,7 +56,9 @@ av_cold void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth) dsp->filter_scale = ff_w3fdif_scale_sse2; } - if (ARCH_X86_64 && EXTERNAL_SSE2(cpu_flags) && depth <= 8) { +#if ARCH_X86_64 + if (EXTERNAL_SSE2(cpu_flags) && depth <= 8) { dsp->filter_complex_high = ff_w3fdif_complex_high_sse2; } +#endif } -- 2.49.1 >From badcacba46b113369205911d4addf370f8199908 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:27:14 -0300 Subject: [PATCH 2/7] fftools: replace DCE with macros to guard CONFIG clauses Signed-off-by: L. E. Segovia <[email protected]> --- fftools/ffprobe.c | 15 ++++++++++----- fftools/opt_common.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 89b8dd3802..cbb717fc45 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2614,9 +2614,9 @@ static void ffprobe_show_program_version(AVTextFormatContext *tfc) av_bprint_finalize(&pbuf, NULL); } -#define SHOW_LIB_VERSION(libname, LIBNAME) \ - do { \ - if (CONFIG_##LIBNAME) { \ +#define SHOW_LIB_VERSION_0(libname, LIBNAME) +#define SHOW_LIB_VERSION_1(libname, LIBNAME) \ + do { \ unsigned int version = libname##_version(); \ avtext_print_section_header(tfc, NULL, SECTION_ID_LIBRARY_VERSION); \ print_str("name", "lib" #libname); \ @@ -2626,8 +2626,13 @@ static void ffprobe_show_program_version(AVTextFormatContext *tfc) print_int("version", version); \ print_str("ident", LIB##LIBNAME##_IDENT); \ avtext_print_section_footer(tfc); \ - } \ - } while (0) + } while(0) +#define SHOW_LIB_VERSION_2(cfg, libname, LIBNAME) \ + SHOW_LIB_VERSION_ ## cfg(libname, LIBNAME) +#define SHOW_LIB_VERSION_3(cfg, libname, LIBNAME) \ + SHOW_LIB_VERSION_2(cfg, libname, LIBNAME) +#define SHOW_LIB_VERSION(libname, LIBNAME) \ + SHOW_LIB_VERSION_3(CONFIG_ ## LIBNAME, libname, LIBNAME) static void ffprobe_show_library_versions(AVTextFormatContext *tfc) { diff --git a/fftools/opt_common.c b/fftools/opt_common.c index 2c1f956551..ee88eaaa2f 100644 --- a/fftools/opt_common.c +++ b/fftools/opt_common.c @@ -152,8 +152,9 @@ static int warned_cfg = 0; #define SHOW_CONFIG 4 #define SHOW_COPYRIGHT 8 -#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ - if (CONFIG_##LIBNAME) { \ +#define PRINT_LIB_INFO_0(libname, LIBNAME, flags, level) +#define PRINT_LIB_INFO_1(libname, LIBNAME, flags, level) \ + { \ const char *indent = flags & INDENT? " " : ""; \ if (flags & SHOW_VERSION) { \ unsigned int version = libname##_version(); \ @@ -181,6 +182,13 @@ static int warned_cfg = 0; } \ } \ +#define PRINT_LIB_INFO_2(cfg, libname, LIBNAME, flags, level) \ + PRINT_LIB_INFO_ ## cfg(libname, LIBNAME, flags, level) +#define PRINT_LIB_INFO_3(cfg, libname, LIBNAME, flags, level) \ + PRINT_LIB_INFO_2(cfg, libname, LIBNAME, flags, level) +#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ + PRINT_LIB_INFO_3(CONFIG_ ## LIBNAME, libname, LIBNAME, flags, level) + static void print_all_libs_info(int flags, int level) { PRINT_LIB_INFO(avutil, AVUTIL, flags, level); -- 2.49.1 >From 2e1591e6ed87f5b2b2f8b3411ae2bef7a27bb5b5 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:53:22 -0300 Subject: [PATCH 3/7] swscale/x86: replace DCE with macros to guard usage of undefined functions In this case, replace long blocks of EXTERNAL checks with a single HAVE_X86ASM. If that's present, the rest of the macros will be set. See e.g. https://github.com/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c Signed-off-by: L. E. Segovia <[email protected]> --- libswscale/x86/rgb2rgb.c | 4 +++- libswscale/x86/swscale.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libswscale/x86/rgb2rgb.c b/libswscale/x86/rgb2rgb.c index 48a73bd0b2..d4db863f52 100644 --- a/libswscale/x86/rgb2rgb.c +++ b/libswscale/x86/rgb2rgb.c @@ -2422,7 +2422,7 @@ DEINTERLEAVE_BYTES(avx) av_cold void rgb2rgb_init_x86(void) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_INLINE_ASM if (INLINE_MMXEXT(cpu_flags)) @@ -2439,6 +2439,7 @@ av_cold void rgb2rgb_init_x86(void) deinterleaveBytes = deinterleave_bytes_sse2; } #endif +#if HAVE_SSSE3_EXTERNAL if (EXTERNAL_SSSE3(cpu_flags)) { shuffle_bytes_0321 = ff_shuffle_bytes_0321_ssse3; shuffle_bytes_2103 = ff_shuffle_bytes_2103_ssse3; @@ -2450,6 +2451,7 @@ av_cold void rgb2rgb_init_x86(void) shuffle_bytes_2130 = ff_shuffle_bytes_2130_ssse3; shuffle_bytes_1203 = ff_shuffle_bytes_1203_ssse3; } +#endif #if HAVE_AVX_EXTERNAL if (EXTERNAL_AVX(cpu_flags)) { deinterleaveBytes = deinterleave_bytes_avx; diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index 85faf92c56..3c2b9d0579 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -473,7 +473,8 @@ RANGE_CONVERT_FUNCS_DECL(avx2, 16) av_cold void ff_sws_init_range_convert_x86(SwsInternal *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_AVX2_FAST(cpu_flags)) { if (c->dstBpc <= 14) { RANGE_CONVERT_FUNCS(avx2, 8); @@ -485,11 +486,12 @@ av_cold void ff_sws_init_range_convert_x86(SwsInternal *c) } else if (EXTERNAL_SSE4(cpu_flags) && c->dstBpc > 14) { RANGE_CONVERT_FUNCS(sse4, 16); } +#endif } av_cold void ff_sws_init_swscale_x86(SwsInternal *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_MMXEXT_INLINE if (INLINE_MMXEXT(cpu_flags)) @@ -569,6 +571,7 @@ switch(c->dstBpc){ \ else ASSIGN_SCALE_FUNC2(hscalefn, X8, opt1, opt2); \ break; \ } +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2); @@ -851,4 +854,5 @@ switch(c->dstBpc){ \ } #endif +#endif /* HAVE_X86ASM */ } -- 2.49.1 >From 8fa4edce1ce98b2b12f63fac4c851d64c23fd3bd Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:53:22 -0300 Subject: [PATCH 4/7] swresample/x86: replace DCE with macros to guard usage of undefined functions In this case, replace long blocks of EXTERNAL checks with a single HAVE_X86ASM. If that's present, the rest of the macros will be set. See e.g. https://github.com/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c Signed-off-by: L. E. Segovia <[email protected]> --- libswresample/x86/audio_convert_init.c | 2 ++ libswresample/x86/resample_init.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/libswresample/x86/audio_convert_init.c b/libswresample/x86/audio_convert_init.c index f6d36f9ca6..d9eb43e1d5 100644 --- a/libswresample/x86/audio_convert_init.c +++ b/libswresample/x86/audio_convert_init.c @@ -52,6 +52,7 @@ av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac, ac->simd_f = ff_int32_to_int16_a_ ## cap;\ } +#if HAVE_X86ASM MULTI_CAPS_FUNC(SSE2, sse2) if(EXTERNAL_SSE(mm_flags)) { @@ -172,4 +173,5 @@ MULTI_CAPS_FUNC(SSE2, sse2) if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP) ac->simd_f = ff_float_to_int32_a_avx2; } +#endif /* HAVE_X86ASM */ } diff --git a/libswresample/x86/resample_init.c b/libswresample/x86/resample_init.c index 5e12f2bddf..8bf266e9e4 100644 --- a/libswresample/x86/resample_init.c +++ b/libswresample/x86/resample_init.c @@ -51,6 +51,7 @@ av_cold void swri_resample_dsp_x86_init(ResampleContext *c) switch(c->format){ case AV_SAMPLE_FMT_S16P: +#if HAVE_X86ASM if (EXTERNAL_SSE2(mm_flags)) { c->dsp.resample_linear = ff_resample_linear_int16_sse2; c->dsp.resample_common = ff_resample_common_int16_sse2; @@ -59,8 +60,10 @@ av_cold void swri_resample_dsp_x86_init(ResampleContext *c) c->dsp.resample_linear = ff_resample_linear_int16_xop; c->dsp.resample_common = ff_resample_common_int16_xop; } +#endif /* HAVE_X86ASM */ break; case AV_SAMPLE_FMT_FLTP: +#if HAVE_X86ASM if (EXTERNAL_SSE(mm_flags)) { c->dsp.resample_linear = ff_resample_linear_float_sse; c->dsp.resample_common = ff_resample_common_float_sse; @@ -77,8 +80,10 @@ av_cold void swri_resample_dsp_x86_init(ResampleContext *c) c->dsp.resample_linear = ff_resample_linear_float_fma4; c->dsp.resample_common = ff_resample_common_float_fma4; } +#endif /* HAVE_X86ASM */ break; case AV_SAMPLE_FMT_DBLP: +#if HAVE_X86ASM if (EXTERNAL_SSE2(mm_flags)) { c->dsp.resample_linear = ff_resample_linear_double_sse2; c->dsp.resample_common = ff_resample_common_double_sse2; @@ -91,6 +96,7 @@ av_cold void swri_resample_dsp_x86_init(ResampleContext *c) c->dsp.resample_linear = ff_resample_linear_double_fma3; c->dsp.resample_common = ff_resample_common_double_fma3; } +#endif /* HAVE_X86ASM */ break; } } -- 2.49.1 >From 16a2789566d8020710ed594d4cd03163c06503dd Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:53:22 -0300 Subject: [PATCH 5/7] avutil/x86: replace DCE with macros to guard usage of undefined functions In this case, replace long blocks of EXTERNAL checks with a single HAVE_X86ASM. If that's present, the rest of the macros will be set. See e.g. https://github.com/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c Signed-off-by: L. E. Segovia <[email protected]> --- libavutil/x86/aes_init.c | 4 +++- libavutil/x86/fixed_dsp_init.c | 4 +++- libavutil/x86/float_dsp_init.c | 4 +++- libavutil/x86/imgutils_init.c | 7 +++++-- libavutil/x86/lls_init.c | 4 +++- libavutil/x86/pixelutils_init.c | 5 ++++- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/libavutil/x86/aes_init.c b/libavutil/x86/aes_init.c index f825e0799c..28a0c1f864 100644 --- a/libavutil/x86/aes_init.c +++ b/libavutil/x86/aes_init.c @@ -37,8 +37,9 @@ void ff_aes_encrypt_14_aesni(AVAES *a, uint8_t *dst, const uint8_t *src, void ff_init_aes_x86(AVAES *a, int decrypt) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_AESNI_EXTERNAL if (EXTERNAL_AESNI(cpu_flags)) { if (a->rounds == 10) a->crypt = decrypt ? ff_aes_decrypt_10_aesni : ff_aes_encrypt_10_aesni; @@ -47,4 +48,5 @@ void ff_init_aes_x86(AVAES *a, int decrypt) else if (a->rounds == 14) a->crypt = decrypt ? ff_aes_decrypt_14_aesni : ff_aes_encrypt_14_aesni; } +#endif } diff --git a/libavutil/x86/fixed_dsp_init.c b/libavutil/x86/fixed_dsp_init.c index 3dd508a4f4..d555b8bf1e 100644 --- a/libavutil/x86/fixed_dsp_init.c +++ b/libavutil/x86/fixed_dsp_init.c @@ -25,9 +25,11 @@ void ff_butterflies_fixed_sse2(int *restrict src0, int *restrict src1, int len); av_cold void ff_fixed_dsp_init_x86(AVFixedDSPContext *fdsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { fdsp->butterflies_fixed = ff_butterflies_fixed_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavutil/x86/float_dsp_init.c b/libavutil/x86/float_dsp_init.c index 6cf0b4a277..0cdffe4aa3 100644 --- a/libavutil/x86/float_dsp_init.c +++ b/libavutil/x86/float_dsp_init.c @@ -80,8 +80,9 @@ void ff_butterflies_float_sse(float *restrict src0, float *restrict src1, int le av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { fdsp->vector_fmul = ff_vector_fmul_sse; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse; @@ -117,4 +118,5 @@ av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_fma3; fdsp->scalarproduct_float = ff_scalarproduct_float_fma3; } +#endif /* HAVE_X86ASM */ } diff --git a/libavutil/x86/imgutils_init.c b/libavutil/x86/imgutils_init.c index 91a16cf594..b44e46a117 100644 --- a/libavutil/x86/imgutils_init.c +++ b/libavutil/x86/imgutils_init.c @@ -19,6 +19,7 @@ #include <stddef.h> #include <stdint.h> +#include "libavutil/attributes.h" #include "libavutil/cpu.h" #include "libavutil/error.h" #include "libavutil/imgutils_internal.h" @@ -34,14 +35,16 @@ int ff_image_copy_plane_uc_from_x86(uint8_t *dst, ptrdiff_t dst_linesize, const uint8_t *src, ptrdiff_t src_linesize, ptrdiff_t bytewidth, int height) { - int cpu_flags = av_get_cpu_flags(); - ptrdiff_t bw_aligned = FFALIGN(bytewidth, 64); + av_unused int cpu_flags = av_get_cpu_flags(); + ptrdiff_t av_unused bw_aligned = FFALIGN(bytewidth, 64); +#if HAVE_SSE4_EXTERNAL if (EXTERNAL_SSE4(cpu_flags) && bw_aligned <= dst_linesize && bw_aligned <= src_linesize) ff_image_copy_plane_uc_from_sse4(dst, dst_linesize, src, src_linesize, bw_aligned, height); else +#endif /* HAVE_SSE4_EXTERNAL */ return AVERROR(ENOSYS); return 0; diff --git a/libavutil/x86/lls_init.c b/libavutil/x86/lls_init.c index c786376915..63c44c1583 100644 --- a/libavutil/x86/lls_init.c +++ b/libavutil/x86/lls_init.c @@ -31,7 +31,8 @@ double ff_evaluate_lls_sse2(LLSModel *m, const double *var, int order); av_cold void ff_init_lls_x86(LLSModel *m) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { m->update_lls = ff_update_lls_sse2; if (m->indep_count >= 4) @@ -43,4 +44,5 @@ av_cold void ff_init_lls_x86(LLSModel *m) if (EXTERNAL_FMA3_FAST(cpu_flags)) { m->update_lls = ff_update_lls_fma3; } +#endif /* HAVE_X86ASM */ } diff --git a/libavutil/x86/pixelutils_init.c b/libavutil/x86/pixelutils_init.c index c3c0662414..1bd3d243ec 100644 --- a/libavutil/x86/pixelutils_init.c +++ b/libavutil/x86/pixelutils_init.c @@ -18,6 +18,7 @@ #include "config.h" +#include "libavutil/attributes.h" #include "pixelutils.h" #include "cpu.h" @@ -47,7 +48,7 @@ int ff_pixelutils_sad_u_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1, void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); // The best way to use SSE2 would be to do 2 SADs in parallel, // but we'd have to modify the pixelutils API to return SIMD functions. @@ -55,6 +56,7 @@ void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned) // It's probably not faster to shuffle data around // to get two lines of 8 pixels into a single 16byte register, // so just use the MMX 8x8 version even when SSE2 is available. +#if HAVE_X86ASM if (EXTERNAL_MMXEXT(cpu_flags)) { sad[2] = ff_pixelutils_sad_8x8_mmxext; } @@ -82,4 +84,5 @@ void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned) case 2: sad[4] = ff_pixelutils_sad_a_32x32_avx2; break; // src1 aligned, src2 aligned } } +#endif /* HAVE_X86ASM */ } -- 2.49.1 >From 1631cb954b15daa120bc6b07f755d8a516077005 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:53:22 -0300 Subject: [PATCH 6/7] avcodec/x86: replace DCE with macros to guard usage of undefined functions In this case, replace long blocks of EXTERNAL checks with a single HAVE_X86ASM. If that's present, the rest of the macros will be set. See e.g. https://github.com/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c Signed-off-by: L. E. Segovia <[email protected]> --- libavcodec/x86/aacencdsp_init.c | 4 ++- libavcodec/x86/aacpsdsp_init.c | 4 ++- libavcodec/x86/ac3dsp_init.c | 8 ++++-- libavcodec/x86/apv_dsp_init.c | 4 ++- libavcodec/x86/audiodsp_init.c | 4 ++- libavcodec/x86/bswapdsp_init.c | 4 ++- libavcodec/x86/celt_pvq_init.c | 4 ++- libavcodec/x86/cfhddsp_init.c | 4 ++- libavcodec/x86/cfhdencdsp_init.c | 4 +-- libavcodec/x86/dcadsp_init.c | 4 ++- libavcodec/x86/dnxhdenc_init.c | 2 ++ libavcodec/x86/exrdsp_init.c | 4 ++- libavcodec/x86/g722dsp_init.c | 4 ++- libavcodec/x86/h263dsp_init.c | 5 ++-- libavcodec/x86/h264_intrapred_init.c | 10 ++++--- libavcodec/x86/h264chroma_init.c | 8 +++--- libavcodec/x86/hevc/dsp_init.c | 31 +++++++++++++++++++--- libavcodec/x86/huffyuvdsp_init.c | 6 +++-- libavcodec/x86/huffyuvencdsp_init.c | 4 ++- libavcodec/x86/idctdsp_init.c | 5 ++-- libavcodec/x86/jpeg2000dsp_init.c | 4 ++- libavcodec/x86/lossless_videodsp_init.c | 5 +++- libavcodec/x86/lossless_videoencdsp_init.c | 2 ++ libavcodec/x86/lpc_init.c | 4 ++- libavcodec/x86/mlpdsp_init.c | 4 +-- libavcodec/x86/mpegvideoencdsp_init.c | 4 ++- libavcodec/x86/opusdsp_init.c | 4 ++- libavcodec/x86/pixblockdsp_init.c | 4 ++- libavcodec/x86/pngdsp_init.c | 4 ++- libavcodec/x86/proresdsp_init.c | 4 +-- libavcodec/x86/rv34dsp_init.c | 4 ++- libavcodec/x86/sbcdsp_init.c | 4 ++- libavcodec/x86/sbrdsp_init.c | 4 ++- libavcodec/x86/svq1enc_init.c | 4 ++- libavcodec/x86/utvideodsp_init.c | 4 ++- libavcodec/x86/v210enc_init.c | 4 ++- libavcodec/x86/vorbisdsp_init.c | 4 ++- libavcodec/x86/vp3dsp_init.c | 4 ++- libavcodec/x86/vp6dsp_init.c | 4 ++- libavfilter/x86/vf_limiter_init.c | 1 + 40 files changed, 147 insertions(+), 52 deletions(-) diff --git a/libavcodec/x86/aacencdsp_init.c b/libavcodec/x86/aacencdsp_init.c index cf17dbf91d..98f7684a4a 100644 --- a/libavcodec/x86/aacencdsp_init.c +++ b/libavcodec/x86/aacencdsp_init.c @@ -36,8 +36,9 @@ void ff_aac_quantize_bands_avx(int *out, const float *in, const float *scaled, av_cold void ff_aacenc_dsp_init_x86(AACEncDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) s->abs_pow34 = ff_abs_pow34_sse; @@ -46,4 +47,5 @@ av_cold void ff_aacenc_dsp_init_x86(AACEncDSPContext *s) if (EXTERNAL_AVX_FAST(cpu_flags)) s->quant_bands = ff_aac_quantize_bands_avx; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/aacpsdsp_init.c b/libavcodec/x86/aacpsdsp_init.c index 221fe71bc7..894d2b8a22 100644 --- a/libavcodec/x86/aacpsdsp_init.c +++ b/libavcodec/x86/aacpsdsp_init.c @@ -51,8 +51,9 @@ void ff_ps_hybrid_analysis_ileave_sse(float (*restrict out)[32][2], float L[2][3 av_cold void ff_psdsp_init_x86(PSDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { s->add_squares = ff_ps_add_squares_sse; s->mul_pair_single = ff_ps_mul_pair_single_sse; @@ -71,4 +72,5 @@ av_cold void ff_psdsp_init_x86(PSDSPContext *s) if (EXTERNAL_FMA3(cpu_flags)) { s->hybrid_analysis = ff_ps_hybrid_analysis_fma3; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c index 353cf38f86..3f0b381935 100644 --- a/libavcodec/x86/ac3dsp_init.c +++ b/libavcodec/x86/ac3dsp_init.c @@ -36,8 +36,9 @@ void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs); av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { c->ac3_exponent_min = ff_ac3_exponent_min_sse2; c->float_to_fixed24 = ff_float_to_fixed24_sse2; @@ -52,6 +53,7 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c) if (EXTERNAL_AVX_FAST(cpu_flags)) { c->float_to_fixed24 = ff_float_to_fixed24_avx; } +#endif /* HAVE_X86ASM */ } #define DOWNMIX_FUNC_OPT(ch, opt) \ @@ -72,7 +74,7 @@ DOWNMIX_FUNCS(fma3) void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #define SET_DOWNMIX(ch, suf, SUF) \ if (ch == c->in_channels) { \ @@ -90,9 +92,11 @@ void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c) SET_DOWNMIX(5, suf, SUF) \ SET_DOWNMIX(6, suf, SUF) +#if HAVE_X86ASM SET_DOWNMIX_ALL(sse, SSE) if (!(cpu_flags & AV_CPU_FLAG_AVXSLOW)) { SET_DOWNMIX_ALL(avx, AVX) SET_DOWNMIX_ALL(fma3, FMA3) } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/apv_dsp_init.c b/libavcodec/x86/apv_dsp_init.c index 39360a0ad2..f645d5c9e3 100644 --- a/libavcodec/x86/apv_dsp_init.c +++ b/libavcodec/x86/apv_dsp_init.c @@ -34,11 +34,13 @@ void ff_apv_decode_transquant_avx2(void *output, av_cold void ff_apv_dsp_init_x86_64(APVDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2_FAST(cpu_flags)) { dsp->decode_transquant = ff_apv_decode_transquant_avx2; } +#endif } #endif /* ARCH_X86_64 */ diff --git a/libavcodec/x86/audiodsp_init.c b/libavcodec/x86/audiodsp_init.c index 68aa3b2129..722d2371f7 100644 --- a/libavcodec/x86/audiodsp_init.c +++ b/libavcodec/x86/audiodsp_init.c @@ -41,8 +41,9 @@ void ff_vector_clipf_sse(float *dst, const float *src, av_cold void ff_audiodsp_init_x86(AudioDSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) c->vector_clipf = ff_vector_clipf_sse; @@ -59,4 +60,5 @@ av_cold void ff_audiodsp_init_x86(AudioDSPContext *c) if (EXTERNAL_AVX2_FAST(cpu_flags)) c->scalarproduct_int16 = ff_scalarproduct_int16_avx2; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/bswapdsp_init.c b/libavcodec/x86/bswapdsp_init.c index 877bab1a2c..23180b8bc1 100644 --- a/libavcodec/x86/bswapdsp_init.c +++ b/libavcodec/x86/bswapdsp_init.c @@ -29,12 +29,14 @@ void ff_bswap32_buf_avx2(uint32_t *dst, const uint32_t *src, int w); av_cold void ff_bswapdsp_init_x86(BswapDSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) c->bswap_buf = ff_bswap32_buf_sse2; if (EXTERNAL_SSSE3(cpu_flags)) c->bswap_buf = ff_bswap32_buf_ssse3; if (EXTERNAL_AVX2_FAST(cpu_flags)) c->bswap_buf = ff_bswap32_buf_avx2; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/celt_pvq_init.c b/libavcodec/x86/celt_pvq_init.c index 817d000038..5b23912fb7 100644 --- a/libavcodec/x86/celt_pvq_init.c +++ b/libavcodec/x86/celt_pvq_init.c @@ -31,8 +31,9 @@ extern float ff_pvq_search_exact_avx (float *X, int *y, int K, int N); av_cold void ff_celt_pvq_init_x86(CeltPVQ *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) s->pvq_search = ff_pvq_search_approx_sse2; @@ -41,4 +42,5 @@ av_cold void ff_celt_pvq_init_x86(CeltPVQ *s) if (EXTERNAL_AVX_FAST(cpu_flags)) s->pvq_search = ff_pvq_search_exact_avx; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/cfhddsp_init.c b/libavcodec/x86/cfhddsp_init.c index c5d89561ae..a22b0944e6 100644 --- a/libavcodec/x86/cfhddsp_init.c +++ b/libavcodec/x86/cfhddsp_init.c @@ -40,8 +40,9 @@ void ff_cfhd_horiz_filter_clip12_sse2(int16_t *output, const int16_t *low, const av_cold void ff_cfhddsp_init_x86(CFHDDSPContext *c, int depth, int bayer) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { c->horiz_filter = ff_cfhd_horiz_filter_sse2; c->vert_filter = ff_cfhd_vert_filter_sse2; @@ -50,4 +51,5 @@ av_cold void ff_cfhddsp_init_x86(CFHDDSPContext *c, int depth, int bayer) if (depth == 12 && !bayer) c->horiz_filter_clip = ff_cfhd_horiz_filter_clip12_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavcodec/x86/cfhdencdsp_init.c b/libavcodec/x86/cfhdencdsp_init.c index 5cea39a80a..e501d65561 100644 --- a/libavcodec/x86/cfhdencdsp_init.c +++ b/libavcodec/x86/cfhdencdsp_init.c @@ -38,9 +38,9 @@ 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) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); -#if ARCH_X86_64 +#if HAVE_SSE2_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSE2(cpu_flags)) { c->horiz_filter = ff_cfhdenc_horiz_filter_sse2; c->vert_filter = ff_cfhdenc_vert_filter_sse2; diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c index c01bfffaba..ffd7220a35 100644 --- a/libavcodec/x86/dcadsp_init.c +++ b/libavcodec/x86/dcadsp_init.c @@ -34,8 +34,9 @@ LFE_FIR_FLOAT_FUNC(fma3) av_cold void ff_dcadsp_init_x86(DCADSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) s->lfe_fir_float[0] = ff_lfe_fir0_float_sse2; if (EXTERNAL_SSE3(cpu_flags)) @@ -46,4 +47,5 @@ av_cold void ff_dcadsp_init_x86(DCADSPContext *s) } if (EXTERNAL_FMA3(cpu_flags)) s->lfe_fir_float[0] = ff_lfe_fir0_float_fma3; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/dnxhdenc_init.c b/libavcodec/x86/dnxhdenc_init.c index 3010986b3e..b9bc7fc127 100644 --- a/libavcodec/x86/dnxhdenc_init.c +++ b/libavcodec/x86/dnxhdenc_init.c @@ -30,8 +30,10 @@ void ff_get_pixels_8x4_sym_sse2(int16_t *restrict block, const uint8_t *pixels, av_cold void ff_dnxhdenc_init_x86(DNXHDEncContext *ctx) { +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(av_get_cpu_flags())) { if (ctx->cid_table->bit_depth == 8) ctx->get_pixels_8x4_sym = ff_get_pixels_8x4_sym_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavcodec/x86/exrdsp_init.c b/libavcodec/x86/exrdsp_init.c index 63b3480d8f..f57d457e23 100644 --- a/libavcodec/x86/exrdsp_init.c +++ b/libavcodec/x86/exrdsp_init.c @@ -34,8 +34,9 @@ void ff_predictor_avx2(uint8_t *src, ptrdiff_t size); av_cold void ff_exrdsp_init_x86(ExrDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { dsp->reorder_pixels = ff_reorder_pixels_sse2; } @@ -49,4 +50,5 @@ av_cold void ff_exrdsp_init_x86(ExrDSPContext *dsp) dsp->reorder_pixels = ff_reorder_pixels_avx2; dsp->predictor = ff_predictor_avx2; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/g722dsp_init.c b/libavcodec/x86/g722dsp_init.c index 614695193b..ab05bdfd0a 100644 --- a/libavcodec/x86/g722dsp_init.c +++ b/libavcodec/x86/g722dsp_init.c @@ -28,8 +28,10 @@ void ff_g722_apply_qmf_sse2(const int16_t *prev_samples, int xout[2]); av_cold void ff_g722dsp_init_x86(G722DSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) dsp->apply_qmf = ff_g722_apply_qmf_sse2; +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavcodec/x86/h263dsp_init.c b/libavcodec/x86/h263dsp_init.c index 3dd5d132e5..2b4b6443c9 100644 --- a/libavcodec/x86/h263dsp_init.c +++ b/libavcodec/x86/h263dsp_init.c @@ -30,10 +30,11 @@ void ff_h263_v_loop_filter_sse2(uint8_t *src, int stride, int qscale); av_cold void ff_h263dsp_init_x86(H263DSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL 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; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index aa9bc721f0..a3809e30ca 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -156,12 +156,13 @@ PRED4x4(tm_vp8, 8, mmxext) PRED4x4(tm_vp8, 8, ssse3) PRED4x4(vertical_vp8, 8, mmxext) -av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, - const int bit_depth, - const int chroma_format_idc) +av_cold void ff_h264_pred_init_x86(H264PredContext *h, int av_unused codec_id, + const int av_unused bit_depth, + const int av_unused chroma_format_idc) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (bit_depth == 8) { if (EXTERNAL_MMXEXT(cpu_flags)) { if (chroma_format_idc <= 1) @@ -329,4 +330,5 @@ av_cold void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, h->pred8x8l[HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_10_avx; } } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/h264chroma_init.c b/libavcodec/x86/h264chroma_init.c index 6eb52746ad..9e10521216 100644 --- a/libavcodec/x86/h264chroma_init.c +++ b/libavcodec/x86/h264chroma_init.c @@ -53,11 +53,12 @@ CHROMA_MC(avg, 8, 10, sse2) CHROMA_MC(put, 8, 10, avx) CHROMA_MC(avg, 8, 10, avx) -av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) +av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int av_unused bit_depth) { - int high_bit_depth = bit_depth > 8; - int cpu_flags = av_get_cpu_flags(); + av_unused int high_bit_depth = bit_depth > 8; + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_MMXEXT(cpu_flags) && !high_bit_depth) { c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext; c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext; @@ -88,4 +89,5 @@ av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth) c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx; c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/hevc/dsp_init.c b/libavcodec/x86/hevc/dsp_init.c index a02a57a9ac..cc126d0564 100644 --- a/libavcodec/x86/hevc/dsp_init.c +++ b/libavcodec/x86/hevc/dsp_init.c @@ -812,12 +812,15 @@ dst ## _bi_w [idx1][idx2][idx3] = hevc_put_bi_w_ ## name ## _ ## D ## _##opt void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); if (bit_depth == 8) { +#if HAVE_MMXEXT_EXTERNAL if (EXTERNAL_MMXEXT(cpu_flags)) { c->add_residual[0] = ff_hevc_add_residual_4_8_mmxext; } +#endif +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_sse2; @@ -842,6 +845,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->add_residual[2] = ff_hevc_add_residual_16_8_sse2; c->add_residual[3] = ff_hevc_add_residual_32_8_sse2; } +#endif #if HAVE_SSSE3_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSSE3(cpu_flags)) { c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_8_ssse3; @@ -863,6 +867,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 8, sse4); } #endif +#if HAVE_AVX_EXTERNAL if (EXTERNAL_AVX(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_8_avx; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_8_avx; @@ -878,11 +883,12 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->idct[0] = ff_hevc_idct_4x4_8_avx; c->idct[1] = ff_hevc_idct_8x8_8_avx; } +#endif +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2(cpu_flags)) { c->sao_band_filter[0] = ff_hevc_sao_band_filter_8_8_avx2; c->sao_band_filter[1] = ff_hevc_sao_band_filter_16_8_avx2; } -#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2_FAST(cpu_flags)) { c->idct_dc[2] = ff_hevc_idct_16x16_dc_8_avx2; c->idct_dc[3] = ff_hevc_idct_32x32_dc_8_avx2; @@ -982,6 +988,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->add_residual[3] = ff_hevc_add_residual_32_8_avx2; } #endif /* HAVE_AVX2_EXTERNAL */ +#if HAVE_AVX512ICL_EXTERNAL if (EXTERNAL_AVX512ICL(cpu_flags) && ARCH_X86_64) { c->put_hevc_qpel[1][0][1] = ff_hevc_put_qpel_h4_8_avx512icl; c->put_hevc_qpel[3][0][1] = ff_hevc_put_qpel_h8_8_avx512icl; @@ -990,10 +997,14 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->put_hevc_qpel[9][0][1] = ff_hevc_put_qpel_h64_8_avx512icl; c->put_hevc_qpel[3][1][1] = ff_hevc_put_qpel_hv8_8_avx512icl; } +#endif } else if (bit_depth == 10) { +#if HAVE_MMXEXT_EXTERNAL if (EXTERNAL_MMXEXT(cpu_flags)) { c->add_residual[0] = ff_hevc_add_residual_4_10_mmxext; } +#endif +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_sse2; @@ -1019,10 +1030,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->add_residual[2] = ff_hevc_add_residual_16_10_sse2; c->add_residual[3] = ff_hevc_add_residual_32_10_sse2; } +#endif +#if HAVE_SSSE3_EXTERNAL if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) { c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_10_ssse3; c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_10_ssse3; } +#endif #if HAVE_SSE4_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSE4(cpu_flags)) { EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 10, sse4); @@ -1036,6 +1050,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 10, sse4); } #endif +#if HAVE_AVX_EXTERNAL if (EXTERNAL_AVX(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_avx; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_avx; @@ -1052,10 +1067,11 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) SAO_BAND_INIT(10, avx); } +#endif +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2(cpu_flags)) { c->sao_band_filter[0] = ff_hevc_sao_band_filter_8_10_avx2; } -#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2_FAST(cpu_flags)) { c->idct_dc[2] = ff_hevc_idct_16x16_dc_10_avx2; c->idct_dc[3] = ff_hevc_idct_32x32_dc_10_avx2; @@ -1213,11 +1229,11 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) } #endif /* HAVE_AVX2_EXTERNAL */ } else if (bit_depth == 12) { +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_sse2; #if ARCH_X86_64 - c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_sse2; c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_sse2; #endif SAO_BAND_INIT(12, sse2); @@ -1228,10 +1244,13 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->idct_dc[2] = ff_hevc_idct_16x16_dc_12_sse2; c->idct_dc[3] = ff_hevc_idct_32x32_dc_12_sse2; } +#endif +#if HAVE_SSSE3_EXTERNAL if (EXTERNAL_SSSE3(cpu_flags) && ARCH_X86_64) { c->hevc_v_loop_filter_luma = ff_hevc_v_loop_filter_luma_12_ssse3; c->hevc_h_loop_filter_luma = ff_hevc_h_loop_filter_luma_12_ssse3; } +#endif #if HAVE_SSE4_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSE4(cpu_flags)) { EPEL_LINKS(c->put_hevc_epel, 0, 0, pel_pixels, 12, sse4); @@ -1245,6 +1264,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) QPEL_LINKS(c->put_hevc_qpel, 1, 1, qpel_hv, 12, sse4); } #endif +#if HAVE_AVX_EXTERNAL if (EXTERNAL_AVX(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_12_avx; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_12_avx; @@ -1254,6 +1274,8 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) #endif SAO_BAND_INIT(12, avx); } +#endif +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2(cpu_flags)) { c->sao_band_filter[0] = ff_hevc_sao_band_filter_8_12_avx2; } @@ -1264,5 +1286,6 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) SAO_BAND_INIT(12, avx2); SAO_EDGE_INIT(12, avx2); } +#endif } } diff --git a/libavcodec/x86/huffyuvdsp_init.c b/libavcodec/x86/huffyuvdsp_init.c index 239d3ca313..fd366e6b2c 100644 --- a/libavcodec/x86/huffyuvdsp_init.c +++ b/libavcodec/x86/huffyuvdsp_init.c @@ -35,9 +35,10 @@ void ff_add_hfyu_median_pred_int16_mmxext(uint16_t *dst, const uint16_t *top, co av_cold void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix_fmt) { - int cpu_flags = av_get_cpu_flags(); - const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt); + av_unused int cpu_flags = av_get_cpu_flags(); + av_unused const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt); +#if HAVE_X86ASM if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) { c->add_hfyu_median_pred_int16 = ff_add_hfyu_median_pred_int16_mmxext; } @@ -50,4 +51,5 @@ av_cold void ff_huffyuvdsp_init_x86(HuffYUVDSPContext *c, enum AVPixelFormat pix if (EXTERNAL_AVX2_FAST(cpu_flags)) { c->add_int16 = ff_add_int16_avx2; } +#endif } diff --git a/libavcodec/x86/huffyuvencdsp_init.c b/libavcodec/x86/huffyuvencdsp_init.c index c9c33b75b4..e5cd8aa4a6 100644 --- a/libavcodec/x86/huffyuvencdsp_init.c +++ b/libavcodec/x86/huffyuvencdsp_init.c @@ -38,8 +38,9 @@ void ff_sub_hfyu_median_pred_int16_mmxext(uint16_t *dst, const uint16_t *src1, c av_cold void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, enum AVPixelFormat pix_fmt) { av_unused int cpu_flags = av_get_cpu_flags(); - const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt); + av_unused const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt); +#if HAVE_X86ASM if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) { c->sub_hfyu_median_pred_int16 = ff_sub_hfyu_median_pred_int16_mmxext; } @@ -51,4 +52,5 @@ av_cold void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, enum AVPixelForm if (EXTERNAL_AVX2_FAST(cpu_flags)) { c->diff_int16 = ff_diff_int16_avx2; } +#endif } diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c index fce62e5590..d1fffc2bd9 100644 --- a/libavcodec/x86/idctdsp_init.c +++ b/libavcodec/x86/idctdsp_init.c @@ -63,8 +63,9 @@ av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM 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; @@ -76,7 +77,6 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEAUTO || avctx->idct_algo == FF_IDCT_SIMPLEMMX)) { - c->idct = ff_simple_idct_sse2; c->idct_put = ff_simple_idct_put_sse2; c->idct_add = ff_simple_idct_add_sse2; c->perm_type = FF_IDCT_PERM_SIMPLE; @@ -150,4 +150,5 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, } } #endif +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/jpeg2000dsp_init.c b/libavcodec/x86/jpeg2000dsp_init.c index 7310a1d0e1..da8dd46a3b 100644 --- a/libavcodec/x86/jpeg2000dsp_init.c +++ b/libavcodec/x86/jpeg2000dsp_init.c @@ -33,7 +33,8 @@ 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(); + int av_unused cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { c->mct_decode[FF_DWT97] = ff_ict_float_sse; } @@ -57,4 +58,5 @@ av_cold void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c) if (EXTERNAL_AVX2_FAST(cpu_flags)) { c->mct_decode[FF_DWT53] = ff_rct_int_avx2; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/lossless_videodsp_init.c b/libavcodec/x86/lossless_videodsp_init.c index 5690cacaad..9c3377ada9 100644 --- a/libavcodec/x86/lossless_videodsp_init.c +++ b/libavcodec/x86/lossless_videodsp_init.c @@ -20,6 +20,7 @@ #include "config.h" #include "../lossless_videodsp.h" +#include "libavutil/attributes.h" #include "libavutil/x86/cpu.h" void ff_add_bytes_sse2(uint8_t *dst, uint8_t *src, ptrdiff_t w); @@ -44,8 +45,9 @@ void ff_add_gradient_pred_avx2(uint8_t *src, const ptrdiff_t stride, const ptrdi void ff_llviddsp_init_x86(LLVidDSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + int av_unused cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { c->add_bytes = ff_add_bytes_sse2; c->add_median_pred = ff_add_median_pred_sse2; @@ -67,4 +69,5 @@ void ff_llviddsp_init_x86(LLVidDSPContext *c) c->add_left_pred = ff_add_left_pred_unaligned_avx2; c->add_gradient_pred = ff_add_gradient_pred_avx2; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/lossless_videoencdsp_init.c b/libavcodec/x86/lossless_videoencdsp_init.c index 22a4014ef1..26cfcbb4b2 100644 --- a/libavcodec/x86/lossless_videoencdsp_init.c +++ b/libavcodec/x86/lossless_videoencdsp_init.c @@ -91,6 +91,7 @@ av_cold void ff_llvidencdsp_init_x86(LLVidEncDSPContext *c) } #endif /* HAVE_INLINE_ASM */ +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { c->diff_bytes = ff_diff_bytes_sse2; } @@ -102,4 +103,5 @@ av_cold void ff_llvidencdsp_init_x86(LLVidEncDSPContext *c) if (EXTERNAL_AVX2_FAST(cpu_flags)) { c->diff_bytes = ff_diff_bytes_avx2; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/lpc_init.c b/libavcodec/x86/lpc_init.c index f2fca53799..37632e90a3 100644 --- a/libavcodec/x86/lpc_init.c +++ b/libavcodec/x86/lpc_init.c @@ -105,16 +105,18 @@ static void lpc_compute_autocorr_sse2(const double *data, ptrdiff_t len, int lag av_cold void ff_lpc_init_x86(LPCContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_SSE2_INLINE if (INLINE_SSE2_SLOW(cpu_flags)) c->lpc_compute_autocorr = lpc_compute_autocorr_sse2; #endif +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) c->lpc_apply_welch_window = ff_lpc_apply_welch_window_sse2; if (EXTERNAL_AVX2(cpu_flags)) c->lpc_apply_welch_window = ff_lpc_apply_welch_window_avx2; +#endif } diff --git a/libavcodec/x86/mlpdsp_init.c b/libavcodec/x86/mlpdsp_init.c index 333a685f47..02d78f8476 100644 --- a/libavcodec/x86/mlpdsp_init.c +++ b/libavcodec/x86/mlpdsp_init.c @@ -195,12 +195,12 @@ static void mlp_filter_channel_x86(int32_t *state, const int32_t *coeff, av_cold void ff_mlpdsp_init_x86(MLPDSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_7REGS && HAVE_INLINE_ASM && HAVE_INLINE_ASM_NONLOCAL_LABELS if (INLINE_MMX(cpu_flags)) c->mlp_filter_channel = mlp_filter_channel_x86; #endif -#if ARCH_X86_64 +#if ARCH_X86_64 && HAVE_X86ASM if (EXTERNAL_SSE4(cpu_flags)) c->mlp_rematrix_channel = ff_mlp_rematrix_channel_sse4; if (EXTERNAL_AVX2_FAST(cpu_flags) && cpu_flags & AV_CPU_FLAG_BMI2) diff --git a/libavcodec/x86/mpegvideoencdsp_init.c b/libavcodec/x86/mpegvideoencdsp_init.c index 220c75785a..22fca28813 100644 --- a/libavcodec/x86/mpegvideoencdsp_init.c +++ b/libavcodec/x86/mpegvideoencdsp_init.c @@ -174,8 +174,9 @@ static void draw_edges_mmx(uint8_t *buf, ptrdiff_t wrap, int width, int height, av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, AVCodecContext *avctx) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { c->denoise_dct = ff_mpv_denoise_dct_sse2; c->pix_sum = ff_pix_sum16_sse2; @@ -185,6 +186,7 @@ av_cold void ff_mpegvideoencdsp_init_x86(MpegvideoEncDSPContext *c, if (EXTERNAL_XOP(cpu_flags)) { c->pix_sum = ff_pix_sum16_xop; } +#endif /* HAVE_X86ASM */ #if HAVE_INLINE_ASM diff --git a/libavcodec/x86/opusdsp_init.c b/libavcodec/x86/opusdsp_init.c index 83f7616a2e..8c1e823eab 100644 --- a/libavcodec/x86/opusdsp_init.c +++ b/libavcodec/x86/opusdsp_init.c @@ -27,10 +27,12 @@ float ff_opus_deemphasis_fma3(float *out, float *in, float coeff, const float *w av_cold void ff_opus_dsp_init_x86(OpusDSP *ctx) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); + #if HAVE_FMA3_EXTERNAL if (EXTERNAL_FMA3(cpu_flags)) { ctx->postfilter = ff_opus_postfilter_fma3; ctx->deemphasis = ff_opus_deemphasis_fma3; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/pixblockdsp_init.c b/libavcodec/x86/pixblockdsp_init.c index 650a0eb4f6..1b236cb821 100644 --- a/libavcodec/x86/pixblockdsp_init.c +++ b/libavcodec/x86/pixblockdsp_init.c @@ -30,8 +30,9 @@ void ff_diff_pixels_sse2(int16_t *restrict block, const uint8_t *s1, const uint8 av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c, unsigned high_bit_depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { if (!high_bit_depth) { c->get_pixels_unaligned = @@ -40,4 +41,5 @@ av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c, c->diff_pixels_unaligned = c->diff_pixels = ff_diff_pixels_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavcodec/x86/pngdsp_init.c b/libavcodec/x86/pngdsp_init.c index e2cd5effe3..3650f4f622 100644 --- a/libavcodec/x86/pngdsp_init.c +++ b/libavcodec/x86/pngdsp_init.c @@ -33,12 +33,14 @@ void ff_add_bytes_l2_sse2(uint8_t *dst, uint8_t *src1, av_cold void ff_pngdsp_init_x86(PNGDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_MMXEXT(cpu_flags)) dsp->add_paeth_prediction = ff_add_png_paeth_prediction_mmxext; if (EXTERNAL_SSE2(cpu_flags)) dsp->add_bytes_l2 = ff_add_bytes_l2_sse2; if (EXTERNAL_SSSE3(cpu_flags)) dsp->add_paeth_prediction = ff_add_png_paeth_prediction_ssse3; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/proresdsp_init.c b/libavcodec/x86/proresdsp_init.c index f7abbfa692..97a023a9cb 100644 --- a/libavcodec/x86/proresdsp_init.c +++ b/libavcodec/x86/proresdsp_init.c @@ -32,7 +32,7 @@ void ff_prores_idct_put_10_avx (uint16_t *dst, ptrdiff_t linesize, av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sample) { -#if ARCH_X86_64 +#if HAVE_X86ASM && ARCH_X86_64 int cpu_flags = av_get_cpu_flags(); if (bits_per_raw_sample == 10) { @@ -46,5 +46,5 @@ av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sampl dsp->idct_put = ff_prores_idct_put_10_avx; } } -#endif /* ARCH_X86_64 */ +#endif /* HAVE_X86ASM && ARCH_X86_64 */ } diff --git a/libavcodec/x86/rv34dsp_init.c b/libavcodec/x86/rv34dsp_init.c index caa5c2d653..a9020216c9 100644 --- a/libavcodec/x86/rv34dsp_init.c +++ b/libavcodec/x86/rv34dsp_init.c @@ -32,8 +32,9 @@ void ff_rv34_idct_add_mmxext(uint8_t *dst, ptrdiff_t stride, int16_t *block); av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_MMXEXT(cpu_flags)) { c->rv34_inv_transform_dc = ff_rv34_idct_dc_noround_mmxext; c->rv34_idct_add = ff_rv34_idct_add_mmxext; @@ -42,4 +43,5 @@ av_cold void ff_rv34dsp_init_x86(RV34DSPContext* c) c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse2; if (EXTERNAL_SSE4(cpu_flags)) c->rv34_idct_dc_add = ff_rv34_idct_dc_add_sse4; +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/sbcdsp_init.c b/libavcodec/x86/sbcdsp_init.c index 7416a86ac6..3b0e179964 100644 --- a/libavcodec/x86/sbcdsp_init.c +++ b/libavcodec/x86/sbcdsp_init.c @@ -42,11 +42,13 @@ void ff_sbc_calc_scalefactors_mmx(int32_t sb_sample_f[16][2][8], av_cold void ff_sbcdsp_init_x86(SBCDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_MMX_EXTERNAL 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; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c index 999f681220..e014b22591 100644 --- a/libavcodec/x86/sbrdsp_init.c +++ b/libavcodec/x86/sbrdsp_init.c @@ -57,8 +57,9 @@ void ff_sbr_autocorrelate_sse3(const float x[40][2], float phi[3][2][2]); av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + int av_unused cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { s->neg_odd_64 = ff_sbr_neg_odd_64_sse; s->sum_square = ff_sbr_sum_square_sse; @@ -82,4 +83,5 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) if (EXTERNAL_SSE3(cpu_flags)) { s->autocorrelate = ff_sbr_autocorrelate_sse3; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/svq1enc_init.c b/libavcodec/x86/svq1enc_init.c index daf573beba..72fc217b3b 100644 --- a/libavcodec/x86/svq1enc_init.c +++ b/libavcodec/x86/svq1enc_init.c @@ -29,9 +29,11 @@ int ff_ssd_int8_vs_int16_sse2(const int8_t *pix1, const int16_t *pix2, av_cold void ff_svq1enc_init_x86(SVQ1EncDSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavcodec/x86/utvideodsp_init.c b/libavcodec/x86/utvideodsp_init.c index 2b436c6c5c..87f7144de8 100644 --- a/libavcodec/x86/utvideodsp_init.c +++ b/libavcodec/x86/utvideodsp_init.c @@ -41,8 +41,9 @@ void ff_restore_rgb_planes10_avx2(uint16_t *src_r, uint16_t *src_g, uint16_t *sr av_cold void ff_utvideodsp_init_x86(UTVideoDSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + int av_unused cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { c->restore_rgb_planes = ff_restore_rgb_planes_sse2; c->restore_rgb_planes10 = ff_restore_rgb_planes10_sse2; @@ -51,4 +52,5 @@ av_cold void ff_utvideodsp_init_x86(UTVideoDSPContext *c) c->restore_rgb_planes = ff_restore_rgb_planes_avx2; c->restore_rgb_planes10 = ff_restore_rgb_planes10_avx2; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/v210enc_init.c b/libavcodec/x86/v210enc_init.c index 44f22ca7fe..5af1f77922 100644 --- a/libavcodec/x86/v210enc_init.c +++ b/libavcodec/x86/v210enc_init.c @@ -46,8 +46,9 @@ void ff_v210_planar_pack_10_avx512icl(const uint16_t *y, const uint16_t *u, av_cold void ff_v210enc_init_x86(V210EncContext *s) { - int cpu_flags = av_get_cpu_flags(); + int av_unused cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSSE3(cpu_flags)) { s->pack_line_8 = ff_v210_planar_pack_8_ssse3; s->pack_line_10 = ff_v210_planar_pack_10_ssse3; @@ -78,4 +79,5 @@ av_cold void ff_v210enc_init_x86(V210EncContext *s) s->sample_factor_10 = 4; s->pack_line_10 = ff_v210_planar_pack_10_avx512icl; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/vorbisdsp_init.c b/libavcodec/x86/vorbisdsp_init.c index 08a3bb2965..95b19eb9db 100644 --- a/libavcodec/x86/vorbisdsp_init.c +++ b/libavcodec/x86/vorbisdsp_init.c @@ -29,8 +29,10 @@ void ff_vorbis_inverse_coupling_sse(float *mag, float *ang, av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + int av_unused cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE_EXTERNAL if (EXTERNAL_SSE(cpu_flags)) dsp->vorbis_inverse_coupling = ff_vorbis_inverse_coupling_sse; +#endif /* HAVE_SSE_EXTERNAL */ } diff --git a/libavcodec/x86/vp3dsp_init.c b/libavcodec/x86/vp3dsp_init.c index 42daf99981..1cd6586d13 100644 --- a/libavcodec/x86/vp3dsp_init.c +++ b/libavcodec/x86/vp3dsp_init.c @@ -42,8 +42,9 @@ void ff_put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_MMX(cpu_flags)) { c->put_no_rnd_pixels_l2 = ff_put_vp_no_rnd_pixels8_l2_mmx; } @@ -59,4 +60,5 @@ av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c) 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; } +#endif /* HAVE_X86ASM */ } diff --git a/libavcodec/x86/vp6dsp_init.c b/libavcodec/x86/vp6dsp_init.c index db9a95767e..c8e6657436 100644 --- a/libavcodec/x86/vp6dsp_init.c +++ b/libavcodec/x86/vp6dsp_init.c @@ -30,9 +30,11 @@ void ff_vp6_filter_diag4_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride av_cold void ff_vp6dsp_init_x86(VP6DSPContext *c) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavfilter/x86/vf_limiter_init.c b/libavfilter/x86/vf_limiter_init.c index 07c733dc21..b78a07df1a 100644 --- a/libavfilter/x86/vf_limiter_init.c +++ b/libavfilter/x86/vf_limiter_init.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/x86/cpu.h" #include "libavfilter/limiter.h" -- 2.49.1 >From 599f4d715000f387a09a1562e944919f97cd6b0b Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <[email protected]> Date: Thu, 27 Nov 2025 08:53:22 -0300 Subject: [PATCH 7/7] avfilter/x86: replace DCE with macros to guard usage of undefined functions In this case, replace long blocks of EXTERNAL checks with a single HAVE_X86ASM. If that's present, the rest of the macros will be set. See e.g. https://github.com/FFmpeg/ffmpeg/commit/40b56c6536dc6e181da4025b99a1d6d3c047da3c Signed-off-by: L. E. Segovia <[email protected]> --- libavcodec/x86/jpeg2000dsp_init.c | 2 +- libavcodec/x86/lossless_videodsp_init.c | 2 +- libavcodec/x86/sbrdsp_init.c | 2 +- libavcodec/x86/utvideodsp_init.c | 2 +- libavcodec/x86/v210enc_init.c | 2 +- libavcodec/x86/vorbisdsp_init.c | 2 +- libavfilter/x86/af_afir_init.c | 4 +++- libavfilter/x86/af_anlmdn_init.c | 4 +++- libavfilter/x86/af_volume_init.c | 5 ++++- libavfilter/x86/avf_showcqt_init.c | 4 +++- libavfilter/x86/colorspacedsp_init.c | 5 +++-- libavfilter/x86/f_ebur128_init.c | 4 +++- libavfilter/x86/vf_atadenoise_init.c | 4 ++-- libavfilter/x86/vf_blackdetect_init.c | 4 +++- libavfilter/x86/vf_blend_init.c | 16 +++++++++++++--- libavfilter/x86/vf_bwdif_init.c | 4 +++- libavfilter/x86/vf_convolution_init.c | 4 ++-- libavfilter/x86/vf_framerate_init.c | 4 +++- libavfilter/x86/vf_fspp_init.c | 4 +++- libavfilter/x86/vf_gblur_init.c | 4 +++- libavfilter/x86/vf_hflip_init.c | 6 ++++-- libavfilter/x86/vf_limiter_init.c | 4 +++- libavfilter/x86/vf_maskedclamp_init.c | 4 +++- libavfilter/x86/vf_maskedmerge_init.c | 4 +++- libavfilter/x86/vf_nlmeans_init.c | 4 +++- libavfilter/x86/vf_overlay_init.c | 10 ++++++---- libavfilter/x86/vf_pp7_init.c | 4 +++- libavfilter/x86/vf_psnr_init.c | 5 ++++- libavfilter/x86/vf_removegrain_init.c | 2 ++ libavfilter/x86/vf_ssim_init.c | 5 ++++- libavfilter/x86/vf_stereo3d_init.c | 5 ++++- libavfilter/x86/vf_threshold_init.c | 4 +++- libavfilter/x86/vf_tinterlace_init.c | 4 +++- libavfilter/x86/vf_transpose_init.c | 4 +++- libavfilter/x86/vf_v360_init.c | 4 +++- libavfilter/x86/vf_w3fdif_init.c | 4 +++- libavfilter/x86/vf_yadif_init.c | 8 +++++++- 37 files changed, 118 insertions(+), 45 deletions(-) diff --git a/libavcodec/x86/jpeg2000dsp_init.c b/libavcodec/x86/jpeg2000dsp_init.c index da8dd46a3b..65cfa15de0 100644 --- a/libavcodec/x86/jpeg2000dsp_init.c +++ b/libavcodec/x86/jpeg2000dsp_init.c @@ -33,7 +33,7 @@ void ff_rct_int_avx2 (void *src0, void *src1, void *src2, int csize); av_cold void ff_jpeg2000dsp_init_x86(Jpeg2000DSPContext *c) { - int av_unused cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { c->mct_decode[FF_DWT97] = ff_ict_float_sse; diff --git a/libavcodec/x86/lossless_videodsp_init.c b/libavcodec/x86/lossless_videodsp_init.c index 9c3377ada9..34d9e9e063 100644 --- a/libavcodec/x86/lossless_videodsp_init.c +++ b/libavcodec/x86/lossless_videodsp_init.c @@ -45,7 +45,7 @@ void ff_add_gradient_pred_avx2(uint8_t *src, const ptrdiff_t stride, const ptrdi void ff_llviddsp_init_x86(LLVidDSPContext *c) { - int av_unused cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c index e014b22591..f59d39948f 100644 --- a/libavcodec/x86/sbrdsp_init.c +++ b/libavcodec/x86/sbrdsp_init.c @@ -57,7 +57,7 @@ void ff_sbr_autocorrelate_sse3(const float x[40][2], float phi[3][2][2]); av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) { - int av_unused cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { diff --git a/libavcodec/x86/utvideodsp_init.c b/libavcodec/x86/utvideodsp_init.c index 87f7144de8..92dcd72f67 100644 --- a/libavcodec/x86/utvideodsp_init.c +++ b/libavcodec/x86/utvideodsp_init.c @@ -41,7 +41,7 @@ void ff_restore_rgb_planes10_avx2(uint16_t *src_r, uint16_t *src_g, uint16_t *sr av_cold void ff_utvideodsp_init_x86(UTVideoDSPContext *c) { - int av_unused cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { diff --git a/libavcodec/x86/v210enc_init.c b/libavcodec/x86/v210enc_init.c index 5af1f77922..7935d06c3d 100644 --- a/libavcodec/x86/v210enc_init.c +++ b/libavcodec/x86/v210enc_init.c @@ -46,7 +46,7 @@ void ff_v210_planar_pack_10_avx512icl(const uint16_t *y, const uint16_t *u, av_cold void ff_v210enc_init_x86(V210EncContext *s) { - int av_unused cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_X86ASM if (EXTERNAL_SSSE3(cpu_flags)) { diff --git a/libavcodec/x86/vorbisdsp_init.c b/libavcodec/x86/vorbisdsp_init.c index 95b19eb9db..08d43a2c52 100644 --- a/libavcodec/x86/vorbisdsp_init.c +++ b/libavcodec/x86/vorbisdsp_init.c @@ -29,7 +29,7 @@ void ff_vorbis_inverse_coupling_sse(float *mag, float *ang, av_cold void ff_vorbisdsp_init_x86(VorbisDSPContext *dsp) { - int av_unused cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); #if HAVE_SSE_EXTERNAL if (EXTERNAL_SSE(cpu_flags)) diff --git a/libavfilter/x86/af_afir_init.c b/libavfilter/x86/af_afir_init.c index d573acf10b..15a89960b1 100644 --- a/libavfilter/x86/af_afir_init.c +++ b/libavfilter/x86/af_afir_init.c @@ -31,8 +31,9 @@ void ff_fcmul_add_fma3(float *sum, const float *t, const float *c, av_cold void ff_afir_init_x86(AudioFIRDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE3(cpu_flags)) { s->fcmul_add = ff_fcmul_add_sse3; } @@ -42,4 +43,5 @@ av_cold void ff_afir_init_x86(AudioFIRDSPContext *s) if (EXTERNAL_FMA3_FAST(cpu_flags)) { s->fcmul_add = ff_fcmul_add_fma3; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/af_anlmdn_init.c b/libavfilter/x86/af_anlmdn_init.c index 30eff6f644..ea039e6ca4 100644 --- a/libavfilter/x86/af_anlmdn_init.c +++ b/libavfilter/x86/af_anlmdn_init.c @@ -27,9 +27,11 @@ float ff_compute_distance_ssd_sse(const float *f1, const float *f2, av_cold void ff_anlmdn_init_x86(AudioNLMDNDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { s->compute_distance_ssd = ff_compute_distance_ssd_sse; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/af_volume_init.c b/libavfilter/x86/af_volume_init.c index 88f5a9679a..3de013d841 100644 --- a/libavfilter/x86/af_volume_init.c +++ b/libavfilter/x86/af_volume_init.c @@ -35,7 +35,9 @@ void ff_scale_samples_s32_avx(uint8_t *dst, const uint8_t *src, int len, av_cold void ff_volume_init_x86(VolumeContext *vol) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); + +#if HAVE_X86ASM enum AVSampleFormat sample_fmt = av_get_packed_sample_fmt(vol->sample_fmt); if (sample_fmt == AV_SAMPLE_FMT_S16) { @@ -57,4 +59,5 @@ av_cold void ff_volume_init_x86(VolumeContext *vol) vol->samples_align = 8; } } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/avf_showcqt_init.c b/libavfilter/x86/avf_showcqt_init.c index 2320b30239..ed9522cffe 100644 --- a/libavfilter/x86/avf_showcqt_init.c +++ b/libavfilter/x86/avf_showcqt_init.c @@ -46,8 +46,9 @@ static void permute_coeffs_01452367(float *v, int len) av_cold void ff_showcqt_init_x86(ShowCQTContext *s) { - int cpuflags = av_get_cpu_flags(); + av_unused int cpuflags = av_get_cpu_flags(); +#if HAVE_X86ASM #define SELECT_CQT_CALC(type, TYPE, align, perm) \ if (EXTERNAL_##TYPE(cpuflags)) { \ s->cqt_calc = ff_showcqt_cqt_calc_##type; \ @@ -60,4 +61,5 @@ if (EXTERNAL_##TYPE(cpuflags)) { \ SELECT_CQT_CALC(fma4, FMA4, 4, 0); // using xmm SELECT_CQT_CALC(avx, AVX_FAST, 8, 01452367); SELECT_CQT_CALC(fma3, FMA3_FAST, 8, 01452367); +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/colorspacedsp_init.c b/libavfilter/x86/colorspacedsp_init.c index f01db4baf4..6bda7b0973 100644 --- a/libavfilter/x86/colorspacedsp_init.c +++ b/libavfilter/x86/colorspacedsp_init.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/x86/cpu.h" #include "libavfilter/colorspacedsp.h" @@ -78,9 +79,9 @@ void ff_multiply3x3_sse2(int16_t *data[3], ptrdiff_t stride, int w, int h, void ff_colorspacedsp_x86_init(ColorSpaceDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); -#if ARCH_X86_64 +#if HAVE_X86ASM && ARCH_X86_64 if (EXTERNAL_SSE2(cpu_flags)) { #define assign_yuv2yuv_fns(ss) \ dsp->yuv2yuv[BPP_8 ][BPP_8 ][SS_##ss] = ff_yuv2yuv_##ss##p8to8_sse2; \ diff --git a/libavfilter/x86/f_ebur128_init.c b/libavfilter/x86/f_ebur128_init.c index 6d43b4887f..87dc8cc132 100644 --- a/libavfilter/x86/f_ebur128_init.c +++ b/libavfilter/x86/f_ebur128_init.c @@ -30,12 +30,14 @@ double ff_ebur128_find_peak_2ch_avx(double *, int, const double *, int); av_cold void ff_ebur128_init_x86(EBUR128DSPContext *dsp, int nb_channels) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_AVX_EXTERNAL if (ARCH_X86_64 && EXTERNAL_AVX(cpu_flags)) { if (nb_channels >= 2) dsp->filter_channels = ff_ebur128_filter_channels_avx; if (nb_channels == 2) dsp->find_peak = ff_ebur128_find_peak_2ch_avx; } +#endif } diff --git a/libavfilter/x86/vf_atadenoise_init.c b/libavfilter/x86/vf_atadenoise_init.c index eb621e172c..79d5730c73 100644 --- a/libavfilter/x86/vf_atadenoise_init.c +++ b/libavfilter/x86/vf_atadenoise_init.c @@ -36,10 +36,10 @@ void ff_atadenoise_filter_row8_serial_sse4(const uint8_t *src, uint8_t *dst, av_cold void ff_atadenoise_init_x86(ATADenoiseDSPContext *dsp, int depth, int algorithm, const float *sigma) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); for (int p = 0; p < 4; p++) { -#if ARCH_X86_64 +#if HAVE_X86ASM && ARCH_X86_64 if (EXTERNAL_SSE4(cpu_flags) && depth <= 8 && algorithm == PARALLEL && sigma[p] == INT16_MAX) { dsp->filter_row[p] = ff_atadenoise_filter_row8_sse4; } diff --git a/libavfilter/x86/vf_blackdetect_init.c b/libavfilter/x86/vf_blackdetect_init.c index 412922711c..02b46c794e 100644 --- a/libavfilter/x86/vf_blackdetect_init.c +++ b/libavfilter/x86/vf_blackdetect_init.c @@ -27,8 +27,10 @@ unsigned ff_blackdetect_16_avx2(const uint8_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t av_cold ff_blackdetect_fn ff_blackdetect_get_fn_x86(int depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2_FAST(cpu_flags)) return depth == 8 ? ff_blackdetect_8_avx2 : ff_blackdetect_16_avx2; +#endif return NULL; } diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c index f4e097ee3d..a540a3ac2b 100644 --- a/libavfilter/x86/vf_blend_init.c +++ b/libavfilter/x86/vf_blend_init.c @@ -102,9 +102,10 @@ BLEND_FUNC(xor_16, avx2) av_cold void ff_blend_init_x86(FilterParams *param, int depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); if (depth == 8) { +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break; @@ -127,6 +128,8 @@ av_cold void ff_blend_init_x86(FilterParams *param, int depth) case BLEND_NEGATION: param->blend = ff_blend_negation_sse2; break; } } +#endif +#if HAVE_SSSE3_EXTERNAL if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break; @@ -134,7 +137,9 @@ av_cold void ff_blend_init_x86(FilterParams *param, int depth) case BLEND_NEGATION: param->blend = ff_blend_negation_ssse3; break; } } +#endif +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_ADDITION: param->blend = ff_blend_addition_avx2; break; @@ -156,8 +161,9 @@ av_cold void ff_blend_init_x86(FilterParams *param, int depth) case BLEND_NEGATION: param->blend = ff_blend_negation_avx2; break; } } +#endif } else if (depth == 16) { -#if ARCH_X86_64 +#if HAVE_SSE2_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_ADDITION: param->blend = ff_blend_addition_16_sse2; break; @@ -168,6 +174,8 @@ av_cold void ff_blend_init_x86(FilterParams *param, int depth) case BLEND_XOR: param->blend = ff_blend_xor_16_sse2; break; } } +#endif +#if HAVE_SSE4_EXTERNAL && ARCH_X86_64 if (EXTERNAL_SSE4(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_16_sse4; break; @@ -180,6 +188,8 @@ av_cold void ff_blend_init_x86(FilterParams *param, int depth) case BLEND_PHOENIX: param->blend = ff_blend_phoenix_16_sse4; break; } } +#endif +#if HAVE_AVX2_EXTERNAL && ARCH_X86_64 if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_ADDITION: param->blend = ff_blend_addition_16_avx2; break; @@ -198,6 +208,6 @@ av_cold void ff_blend_init_x86(FilterParams *param, int depth) case BLEND_XOR: param->blend = ff_blend_xor_16_avx2; break; } } -#endif /* ARCH_X86_64 */ +#endif } } diff --git a/libavfilter/x86/vf_bwdif_init.c b/libavfilter/x86/vf_bwdif_init.c index 76b574b2a9..579c19ddbe 100644 --- a/libavfilter/x86/vf_bwdif_init.c +++ b/libavfilter/x86/vf_bwdif_init.c @@ -60,8 +60,9 @@ void ff_bwdif_filter_line_12bit_avx512icl(void *dst, const void *prev, const voi av_cold void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (bit_depth <= 8) { if (EXTERNAL_SSE2(cpu_flags)) bwdif->filter_line = ff_bwdif_filter_line_sse2; @@ -81,4 +82,5 @@ av_cold void ff_bwdif_init_x86(BWDIFDSPContext *bwdif, int bit_depth) if (ARCH_X86_64 && EXTERNAL_AVX512ICL(cpu_flags)) bwdif->filter_line = ff_bwdif_filter_line_12bit_avx512icl; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_convolution_init.c b/libavfilter/x86/vf_convolution_init.c index bff10ca1a4..8bb4c81123 100644 --- a/libavfilter/x86/vf_convolution_init.c +++ b/libavfilter/x86/vf_convolution_init.c @@ -36,7 +36,7 @@ void ff_filter_sobel_avx512icl(uint8_t *dst, int width, av_cold void ff_convolution_init_x86(ConvolutionContext *s) { -#if ARCH_X86_64 +#if ARCH_X86_64 && HAVE_SSE4_EXTERNAL int i; int cpu_flags = av_get_cpu_flags(); for (i = 0; i < 4; i++) { @@ -52,7 +52,7 @@ av_cold void ff_convolution_init_x86(ConvolutionContext *s) av_cold void ff_sobel_init_x86(ConvolutionContext *s, int depth, int nb_planes) { -#if ARCH_X86_64 +#if ARCH_X86_64 && HAVE_AVX512ICL_EXTERNAL int cpu_flags = av_get_cpu_flags(); for (int i = 0; i < nb_planes; i++) { if (depth == 8) { diff --git a/libavfilter/x86/vf_framerate_init.c b/libavfilter/x86/vf_framerate_init.c index 9d40faf0a4..c3e6ddd305 100644 --- a/libavfilter/x86/vf_framerate_init.c +++ b/libavfilter/x86/vf_framerate_init.c @@ -27,7 +27,8 @@ void ff_blend_frames16_avx2(BLEND_FUNC_PARAMS); void ff_framerate_init_x86(FrameRateContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (s->bitdepth == 8) { if (EXTERNAL_AVX2_FAST(cpu_flags)) s->blend = ff_blend_frames_avx2; @@ -39,4 +40,5 @@ void ff_framerate_init_x86(FrameRateContext *s) else if (EXTERNAL_SSE4(cpu_flags)) s->blend = ff_blend_frames16_sse4; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_fspp_init.c b/libavfilter/x86/vf_fspp_init.c index caf94b30d6..339634ad84 100644 --- a/libavfilter/x86/vf_fspp_init.c +++ b/libavfilter/x86/vf_fspp_init.c @@ -36,8 +36,9 @@ void ff_row_fdct_mmx(int16_t *data, const uint8_t *pixels, ptrdiff_t line_size, av_cold void ff_fsppdsp_init_x86(FSPPDSPContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_MMX(cpu_flags)) { s->row_idct = ff_row_idct_mmx; s->row_fdct = ff_row_fdct_mmx; @@ -48,4 +49,5 @@ av_cold void ff_fsppdsp_init_x86(FSPPDSPContext *s) s->mul_thrmat = ff_mul_thrmat_sse2; s->column_fidct = ff_column_fidct_sse2; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_gblur_init.c b/libavfilter/x86/vf_gblur_init.c index 6aabfb4106..0a108e9df7 100644 --- a/libavfilter/x86/vf_gblur_init.c +++ b/libavfilter/x86/vf_gblur_init.c @@ -40,8 +40,9 @@ void ff_verti_slice_avx512(float *buffer, int width, int height, int column_begi av_cold void ff_gblur_init_x86(GBlurContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE(cpu_flags)) { s->postscale_slice = ff_postscale_slice_sse; } @@ -71,4 +72,5 @@ av_cold void ff_gblur_init_x86(GBlurContext *s) } } #endif +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_hflip_init.c b/libavfilter/x86/vf_hflip_init.c index 0ac399b0d4..c6d7618bfb 100644 --- a/libavfilter/x86/vf_hflip_init.c +++ b/libavfilter/x86/vf_hflip_init.c @@ -30,9 +30,10 @@ void ff_hflip_short_avx2(const uint8_t *src, uint8_t *dst, int w); av_cold void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes) { - int cpu_flags = av_get_cpu_flags(); - int i; + av_unused int cpu_flags = av_get_cpu_flags(); + av_unused int i; +#if HAVE_X86ASM for (i = 0; i < nb_planes; i++) { if (step[i] == 1) { if (EXTERNAL_SSSE3(cpu_flags)) { @@ -50,4 +51,5 @@ av_cold void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes) } } } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_limiter_init.c b/libavfilter/x86/vf_limiter_init.c index b78a07df1a..9a1111d1d6 100644 --- a/libavfilter/x86/vf_limiter_init.c +++ b/libavfilter/x86/vf_limiter_init.c @@ -30,8 +30,9 @@ void ff_limiter_16bit_sse4(const uint8_t *src, uint8_t *dst, void ff_limiter_init_x86(LimiterDSPContext *dsp, int bpp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) { if (bpp <= 8) { dsp->limiter = ff_limiter_8bit_sse2; @@ -42,4 +43,5 @@ void ff_limiter_init_x86(LimiterDSPContext *dsp, int bpp) dsp->limiter = ff_limiter_16bit_sse4; } } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_maskedclamp_init.c b/libavfilter/x86/vf_maskedclamp_init.c index 2a5388abac..cdee9c77b1 100644 --- a/libavfilter/x86/vf_maskedclamp_init.c +++ b/libavfilter/x86/vf_maskedclamp_init.c @@ -34,8 +34,9 @@ void ff_maskedclamp16_sse4(const uint8_t *bsrc, uint8_t *dst, av_cold void ff_maskedclamp_init_x86(MaskedClampDSPContext *dsp, int depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags) && depth <= 8) { dsp->maskedclamp = ff_maskedclamp8_sse2; } @@ -43,4 +44,5 @@ av_cold void ff_maskedclamp_init_x86(MaskedClampDSPContext *dsp, int depth) if (EXTERNAL_SSE4(cpu_flags) && depth > 8) { dsp->maskedclamp = ff_maskedclamp16_sse4; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_maskedmerge_init.c b/libavfilter/x86/vf_maskedmerge_init.c index 73ab888083..0bff703444 100644 --- a/libavfilter/x86/vf_maskedmerge_init.c +++ b/libavfilter/x86/vf_maskedmerge_init.c @@ -32,9 +32,11 @@ void ff_maskedmerge8_sse2(const uint8_t *bsrc, const uint8_t *osrc, av_cold void ff_maskedmerge_init_x86(MaskedMergeContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags) && s->depth == 8) { s->maskedmerge = ff_maskedmerge8_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavfilter/x86/vf_nlmeans_init.c b/libavfilter/x86/vf_nlmeans_init.c index 37764d30ab..b7a700ad6b 100644 --- a/libavfilter/x86/vf_nlmeans_init.c +++ b/libavfilter/x86/vf_nlmeans_init.c @@ -33,8 +33,10 @@ void ff_compute_weights_line_avx2(const uint32_t *const iia, av_cold void ff_nlmeans_init_x86(NLMeansDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_AVX2_EXTERNAL if (ARCH_X86_64 && EXTERNAL_AVX2_FAST(cpu_flags)) dsp->compute_weights_line = ff_compute_weights_line_avx2; +#endif } diff --git a/libavfilter/x86/vf_overlay_init.c b/libavfilter/x86/vf_overlay_init.c index d1686505f8..24d6bcca6f 100644 --- a/libavfilter/x86/vf_overlay_init.c +++ b/libavfilter/x86/vf_overlay_init.c @@ -35,11 +35,12 @@ int ff_overlay_row_22_sse4(uint8_t *d, uint8_t *da, uint8_t *s, uint8_t *a, av_cold void ff_overlay_init_x86(AVFilterContext *ctx) { OverlayContext *s = ctx->priv; - const AVFilterLink *main = ctx->inputs[0]; - const AVFilterLink *overlay = ctx->inputs[0]; - int cpu_flags = av_get_cpu_flags(); - int main_has_alpha = s->main_has_alpha; + av_unused const AVFilterLink *main = ctx->inputs[0]; + av_unused const AVFilterLink *overlay = ctx->inputs[0]; + av_unused int cpu_flags = av_get_cpu_flags(); + av_unused int main_has_alpha = s->main_has_alpha; +#if HAVE_X86ASM if (EXTERNAL_SSE4(cpu_flags) && (s->format == OVERLAY_FORMAT_YUV444 || s->format == OVERLAY_FORMAT_GBRP) && @@ -65,4 +66,5 @@ av_cold void ff_overlay_init_x86(AVFilterContext *ctx) s->blend_row[1] = ff_overlay_row_22_sse4; s->blend_row[2] = ff_overlay_row_22_sse4; } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_pp7_init.c b/libavfilter/x86/vf_pp7_init.c index 165b0dd5d0..d4f00e0ee6 100644 --- a/libavfilter/x86/vf_pp7_init.c +++ b/libavfilter/x86/vf_pp7_init.c @@ -27,8 +27,10 @@ void ff_pp7_dctB_mmx(int16_t *dst, int16_t *src); av_cold void ff_pp7_init_x86(PP7Context *p) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_MMX_EXTERNAL if (EXTERNAL_MMX(cpu_flags)) p->dctB = ff_pp7_dctB_mmx; +#endif /* HAVE_MMX_EXTERNAL */ } diff --git a/libavfilter/x86/vf_psnr_init.c b/libavfilter/x86/vf_psnr_init.c index c387812204..735748783d 100644 --- a/libavfilter/x86/vf_psnr_init.c +++ b/libavfilter/x86/vf_psnr_init.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/x86/cpu.h" #include "libavfilter/psnr.h" @@ -27,8 +28,9 @@ uint64_t ff_sse_line_16bit_sse2(const uint8_t *buf, const uint8_t *ref, int w); void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) { if (bpp <= 8) { dsp->sse_line = ff_sse_line_8bit_sse2; @@ -36,4 +38,5 @@ void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp) dsp->sse_line = ff_sse_line_16bit_sse2; } } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavfilter/x86/vf_removegrain_init.c b/libavfilter/x86/vf_removegrain_init.c index 07314b3244..59fc92edbd 100644 --- a/libavfilter/x86/vf_removegrain_init.c +++ b/libavfilter/x86/vf_removegrain_init.c @@ -54,6 +54,7 @@ av_cold void ff_removegrain_init_x86(RemoveGrainContext *rg) int i; for (i = 0; i < rg->nb_planes; i++) { +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags)) switch (rg->mode[i]) { case 1: rg->fl[i] = ff_rg_fl_mode_1_sse2; break; @@ -83,6 +84,7 @@ av_cold void ff_removegrain_init_x86(RemoveGrainContext *rg) case 24: rg->fl[i] = ff_rg_fl_mode_24_sse2; break; #endif /* ARCH_x86_64 */ } +#endif /* HAVE_SSE2_EXTERNAL */ } #endif /* CONFIG_GPL */ } diff --git a/libavfilter/x86/vf_ssim_init.c b/libavfilter/x86/vf_ssim_init.c index 6f2305430c..25197023a0 100644 --- a/libavfilter/x86/vf_ssim_init.c +++ b/libavfilter/x86/vf_ssim_init.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/x86/cpu.h" #include "libavfilter/ssim.h" @@ -32,8 +33,9 @@ double ff_ssim_end_line_sse4(const int (*sum0)[4], const int (*sum1)[4], int w); void ff_ssim_init_x86(SSIMDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM #if ARCH_X86_64 if (EXTERNAL_SSSE3(cpu_flags)) dsp->ssim_4x4_line = ff_ssim_4x4_line_ssse3; @@ -42,4 +44,5 @@ void ff_ssim_init_x86(SSIMDSPContext *dsp) dsp->ssim_end_line = ff_ssim_end_line_sse4; if (EXTERNAL_XOP(cpu_flags)) dsp->ssim_4x4_line = ff_ssim_4x4_line_xop; +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_stereo3d_init.c b/libavfilter/x86/vf_stereo3d_init.c index da160a89a0..edf09619f4 100644 --- a/libavfilter/x86/vf_stereo3d_init.c +++ b/libavfilter/x86/vf_stereo3d_init.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes.h" #include "libavutil/x86/cpu.h" #include "libavfilter/stereo3d.h" @@ -29,9 +30,11 @@ void ff_anaglyph_sse4(uint8_t *dst, uint8_t *lsrc, uint8_t *rsrc, void ff_stereo3d_init_x86(Stereo3DDSPContext *dsp) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE4_EXTERNAL if (EXTERNAL_SSE4(cpu_flags)) { dsp->anaglyph = ff_anaglyph_sse4; } +#endif /* HAVE_SSE4_EXTERNAL */ } diff --git a/libavfilter/x86/vf_threshold_init.c b/libavfilter/x86/vf_threshold_init.c index 8e42296791..73c15af5e5 100644 --- a/libavfilter/x86/vf_threshold_init.c +++ b/libavfilter/x86/vf_threshold_init.c @@ -39,8 +39,9 @@ THRESHOLD_FUNC(16, avx2) av_cold void ff_threshold_init_x86(ThresholdContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (s->depth == 8) { if (EXTERNAL_SSE4(cpu_flags)) { s->threshold = ff_threshold8_sse4; @@ -56,4 +57,5 @@ av_cold void ff_threshold_init_x86(ThresholdContext *s) s->threshold = ff_threshold16_avx2; } } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_tinterlace_init.c b/libavfilter/x86/vf_tinterlace_init.c index 1c25a2bb7a..69e4c9dcc0 100644 --- a/libavfilter/x86/vf_tinterlace_init.c +++ b/libavfilter/x86/vf_tinterlace_init.c @@ -56,8 +56,9 @@ void ff_lowpass_line_complex_12_sse2(uint8_t *dstp, ptrdiff_t linesize, av_cold void ff_tinterlace_init_x86(TInterlaceContext *s) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_X86ASM if (s->csp->comp[0].depth > 8) { if (EXTERNAL_SSE2(cpu_flags)) { if (!(s->flags & TINTERLACE_FLAG_CVLPF)) @@ -89,4 +90,5 @@ av_cold void ff_tinterlace_init_x86(TInterlaceContext *s) } } } +#endif /* HAVE_X86ASM */ } diff --git a/libavfilter/x86/vf_transpose_init.c b/libavfilter/x86/vf_transpose_init.c index 95c56eab73..c25a0fa73f 100644 --- a/libavfilter/x86/vf_transpose_init.c +++ b/libavfilter/x86/vf_transpose_init.c @@ -36,8 +36,9 @@ void ff_transpose_8x8_16_sse2(uint8_t *src, av_cold void ff_transpose_init_x86(TransVtable *v, int pixstep) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags) && pixstep == 1) { v->transpose_8x8 = ff_transpose_8x8_8_sse2; } @@ -45,4 +46,5 @@ av_cold void ff_transpose_init_x86(TransVtable *v, int pixstep) if (EXTERNAL_SSE2(cpu_flags) && pixstep == 2) { v->transpose_8x8 = ff_transpose_8x8_16_sse2; } +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavfilter/x86/vf_v360_init.c b/libavfilter/x86/vf_v360_init.c index 2b2b06dd40..3f9e7de329 100644 --- a/libavfilter/x86/vf_v360_init.c +++ b/libavfilter/x86/vf_v360_init.c @@ -43,8 +43,9 @@ void ff_remap2_16bit_line_avx2(uint8_t *dst, int width, const uint8_t *src, ptrd av_cold void ff_v360_init_x86(V360Context *s, int depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_AVX2_EXTERNAL if (EXTERNAL_AVX2_FAST(cpu_flags) && s->interp == NEAREST && depth <= 8) s->remap_line = ff_remap1_8bit_line_avx2; @@ -68,4 +69,5 @@ av_cold void ff_v360_init_x86(V360Context *s, int depth) s->interp == MITCHELL) && depth <= 8) s->remap_line = ff_remap4_8bit_line_avx2; #endif +#endif /* HAVE_AVX2_EXTERNAL */ } diff --git a/libavfilter/x86/vf_w3fdif_init.c b/libavfilter/x86/vf_w3fdif_init.c index 6d677d651d..d7e113ff94 100644 --- a/libavfilter/x86/vf_w3fdif_init.c +++ b/libavfilter/x86/vf_w3fdif_init.c @@ -47,8 +47,9 @@ void ff_w3fdif_scale_sse2(uint8_t *out_pixel, const int32_t *work_pixel, av_cold void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); +#if HAVE_SSE2_EXTERNAL if (EXTERNAL_SSE2(cpu_flags) && depth <= 8) { dsp->filter_simple_low = ff_w3fdif_simple_low_sse2; dsp->filter_simple_high = ff_w3fdif_simple_high_sse2; @@ -61,4 +62,5 @@ av_cold void ff_w3fdif_init_x86(W3FDIFDSPContext *dsp, int depth) dsp->filter_complex_high = ff_w3fdif_complex_high_sse2; } #endif +#endif /* HAVE_SSE2_EXTERNAL */ } diff --git a/libavfilter/x86/vf_yadif_init.c b/libavfilter/x86/vf_yadif_init.c index 257c3f9199..1335b8b03f 100644 --- a/libavfilter/x86/vf_yadif_init.c +++ b/libavfilter/x86/vf_yadif_init.c @@ -49,26 +49,32 @@ void ff_yadif_filter_line_10bit_ssse3(void *dst, void *prev, void *cur, av_cold void ff_yadif_init_x86(YADIFContext *yadif) { - int cpu_flags = av_get_cpu_flags(); + av_unused int cpu_flags = av_get_cpu_flags(); int bit_depth = (!yadif->csp) ? 8 : yadif->csp->comp[0].depth; if (bit_depth >= 15) { +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_16bit_sse2; if (EXTERNAL_SSSE3(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_16bit_ssse3; if (EXTERNAL_SSE4(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_16bit_sse4; +#endif } else if ( bit_depth >= 9 && bit_depth <= 14) { +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_10bit_sse2; if (EXTERNAL_SSSE3(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_10bit_ssse3; +#endif } else { +#if HAVE_X86ASM if (EXTERNAL_SSE2(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_sse2; if (EXTERNAL_SSSE3(cpu_flags)) yadif->filter_line = ff_yadif_filter_line_ssse3; +#endif } } -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
