From 40e6575aa3eed64cd32bf28c00ae57edc5acb25a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 12 Jun 2022 05:51:12 +0200 Subject: all: Replace if (ARCH_FOO) checks by #if ARCH_FOO This is more spec-compliant because it does not rely on dead-code elimination by the compiler. Especially MSVC has problems with this, as can be seen in https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html or https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html This commit does not eliminate every instance where we rely on dead code elimination: It only tackles branching to the initialization of arch-specific dsp code, not e.g. all uses of CONFIG_ and HAVE_ checks. But maybe it is already enough to compile FFmpeg with MSVC with whole-programm-optimizations enabled (if one does not disable too many components). Signed-off-by: Andreas Rheinhardt --- libswresample/audioconvert.c | 10 +++++++--- libswresample/rematrix.c | 5 +++-- libswresample/resample_dsp.c | 10 +++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'libswresample') diff --git a/libswresample/audioconvert.c b/libswresample/audioconvert.c index 500aa0e5c5..1d75ba1495 100644 --- a/libswresample/audioconvert.c +++ b/libswresample/audioconvert.c @@ -176,9 +176,13 @@ AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, } } - if(HAVE_X86ASM && HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels); - if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels); - if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels); +#if ARCH_X86 && HAVE_X86ASM && HAVE_MMX + swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels); +#elif ARCH_ARM + swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels); +#elif ARCH_AARCH64 + swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels); +#endif return ctx; } diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c index 5e89b878dd..fe823dc575 100644 --- a/libswresample/rematrix.c +++ b/libswresample/rematrix.c @@ -565,8 +565,9 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->matrix_ch[i][0]= ch_in; } - if(HAVE_X86ASM && HAVE_MMX) - return swri_rematrix_init_x86(s); +#if ARCH_X86 && HAVE_X86ASM && HAVE_MMX + return swri_rematrix_init_x86(s); +#endif return 0; } diff --git a/libswresample/resample_dsp.c b/libswresample/resample_dsp.c index b2424eb6f7..611f44373f 100644 --- a/libswresample/resample_dsp.c +++ b/libswresample/resample_dsp.c @@ -68,7 +68,11 @@ void swri_resample_dsp_init(ResampleContext *c) break; } - if (ARCH_X86) swri_resample_dsp_x86_init(c); - else if (ARCH_ARM) swri_resample_dsp_arm_init(c); - else if (ARCH_AARCH64) swri_resample_dsp_aarch64_init(c); +#if ARCH_X86 + swri_resample_dsp_x86_init(c); +#elif ARCH_ARM + swri_resample_dsp_arm_init(c); +#elif ARCH_AARCH64 + swri_resample_dsp_aarch64_init(c); +#endif } -- cgit v1.2.3