diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-12 05:51:12 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-15 04:56:37 +0200 |
commit | 40e6575aa3eed64cd32bf28c00ae57edc5acb25a (patch) | |
tree | 3bc6e3ebca1972cf51f04e30f227e46ff204ec05 /libavfilter | |
parent | e5f6707a7b91664491041526ef3cce7412258b89 (diff) |
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 <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavfilter')
37 files changed, 122 insertions, 86 deletions
diff --git a/libavfilter/af_afirdsp.h b/libavfilter/af_afirdsp.h index bf7d1d6f0f..4208501393 100644 --- a/libavfilter/af_afirdsp.h +++ b/libavfilter/af_afirdsp.h @@ -74,8 +74,9 @@ static av_unused void ff_afir_init(AudioFIRDSPContext *dsp) dsp->fcmul_add = fcmul_add_c; dsp->dcmul_add = dcmul_add_c; - if (ARCH_X86) - ff_afir_init_x86(dsp); +#if ARCH_X86 + ff_afir_init_x86(dsp); +#endif } #endif /* AVFILTER_AFIRDSP_H */ diff --git a/libavfilter/af_anlmdn.c b/libavfilter/af_anlmdn.c index c82be33e7c..8f01c5f8a2 100644 --- a/libavfilter/af_anlmdn.c +++ b/libavfilter/af_anlmdn.c @@ -118,8 +118,9 @@ void ff_anlmdn_init(AudioNLMDNDSPContext *dsp) dsp->compute_distance_ssd = compute_distance_ssd_c; dsp->compute_cache = compute_cache_c; - if (ARCH_X86) - ff_anlmdn_init_x86(dsp); +#if ARCH_X86 + ff_anlmdn_init_x86(dsp); +#endif } static int config_filter(AVFilterContext *ctx) diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c index 4c9b96f17e..f6e183df8d 100644 --- a/libavfilter/af_volume.c +++ b/libavfilter/af_volume.c @@ -238,8 +238,9 @@ static av_cold void volume_init(VolumeContext *vol) break; } - if (ARCH_X86) - ff_volume_init_x86(vol); +#if ARCH_X86 + ff_volume_init_x86(vol); +#endif } static int set_volume(AVFilterContext *ctx) diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index c738e6f993..33c482bd42 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -1418,8 +1418,9 @@ static int config_output(AVFilterLink *outlink) s->update_sono = update_sono_yuv; } - if (ARCH_X86) - ff_showcqt_init_x86(s); +#if ARCH_X86 + ff_showcqt_init_x86(s); +#endif if ((ret = init_cqt(s)) < 0) return ret; diff --git a/libavfilter/colorspacedsp.c b/libavfilter/colorspacedsp.c index 65ea74c584..72207ffaf3 100644 --- a/libavfilter/colorspacedsp.c +++ b/libavfilter/colorspacedsp.c @@ -143,6 +143,7 @@ void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp) dsp->multiply3x3 = multiply3x3_c; - if (ARCH_X86) - ff_colorspacedsp_x86_init(dsp); +#if ARCH_X86 + ff_colorspacedsp_x86_init(dsp); +#endif } diff --git a/libavfilter/scene_sad.c b/libavfilter/scene_sad.c index 73d3eacbfa..caf911eb5d 100644 --- a/libavfilter/scene_sad.c +++ b/libavfilter/scene_sad.c @@ -59,8 +59,9 @@ void ff_scene_sad_c(SCENE_SAD_PARAMS) ff_scene_sad_fn ff_scene_sad_get_fn(int depth) { ff_scene_sad_fn sad = NULL; - if (ARCH_X86) - sad = ff_scene_sad_get_fn_x86(depth); +#if ARCH_X86 + sad = ff_scene_sad_get_fn_x86(depth); +#endif if (!sad) { if (depth == 8) sad = ff_scene_sad_c; diff --git a/libavfilter/vf_atadenoise.c b/libavfilter/vf_atadenoise.c index 8dc51b460d..54cde782f6 100644 --- a/libavfilter/vf_atadenoise.c +++ b/libavfilter/vf_atadenoise.c @@ -433,8 +433,9 @@ static int config_input(AVFilterLink *inlink) } } - if (ARCH_X86) - ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma); +#if ARCH_X86 + ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma); +#endif return 0; } diff --git a/libavfilter/vf_blend_init.h b/libavfilter/vf_blend_init.h index 5fb2599490..f531338a54 100644 --- a/libavfilter/vf_blend_init.h +++ b/libavfilter/vf_blend_init.h @@ -194,8 +194,9 @@ static av_unused void ff_blend_init(FilterParams *param, int depth) param->blend = depth > 8 ? depth > 16 ? blend_copybottom_32 : blend_copybottom_16 : blend_copybottom_8; } - if (ARCH_X86) - ff_blend_init_x86(param, depth); +#if ARCH_X86 + ff_blend_init_x86(param, depth); +#endif } #endif /* AVFILTER_BLEND_INIT_H */ diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c index c3b7abc1b9..65c617ebb3 100644 --- a/libavfilter/vf_bwdif.c +++ b/libavfilter/vf_bwdif.c @@ -350,8 +350,9 @@ static int config_props(AVFilterLink *link) s->filter_edge = filter_edge; } - if (ARCH_X86) - ff_bwdif_init_x86(s); +#if ARCH_X86 + ff_bwdif_init_x86(s); +#endif return 0; } diff --git a/libavfilter/vf_eq.h b/libavfilter/vf_eq.h index a5756977d2..fc8d4a711a 100644 --- a/libavfilter/vf_eq.h +++ b/libavfilter/vf_eq.h @@ -123,8 +123,9 @@ void ff_eq_init_x86(EQContext *eq); static av_unused void ff_eq_init(EQContext *eq) { eq->process = process_c; - if (ARCH_X86) - ff_eq_init_x86(eq); +#if ARCH_X86 + ff_eq_init_x86(eq); +#endif } #endif /* AVFILTER_EQ_H */ diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index f116147751..49bf6cdfff 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -264,8 +264,9 @@ void ff_framerate_init(FrameRateContext *s) s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH(16); s->blend = blend_frames16_c; } - if (ARCH_X86) - ff_framerate_init_x86(s); +#if ARCH_X86 + ff_framerate_init_x86(s); +#endif } static int config_input(AVFilterLink *inlink) diff --git a/libavfilter/vf_fspp.c b/libavfilter/vf_fspp.c index 46ed514503..3e04fd01b9 100644 --- a/libavfilter/vf_fspp.c +++ b/libavfilter/vf_fspp.c @@ -525,8 +525,9 @@ static int config_input(AVFilterLink *inlink) fspp->row_idct = row_idct_c; fspp->row_fdct = row_fdct_c; - if (ARCH_X86) - ff_fspp_init_x86(fspp); +#if ARCH_X86 + ff_fspp_init_x86(fspp); +#endif return 0; } diff --git a/libavfilter/vf_gblur_init.h b/libavfilter/vf_gblur_init.h index 0fee64bc98..212db9f7a0 100644 --- a/libavfilter/vf_gblur_init.h +++ b/libavfilter/vf_gblur_init.h @@ -115,8 +115,9 @@ static av_unused void ff_gblur_init(GBlurContext *s) s->horiz_slice = horiz_slice_c; s->verti_slice = verti_slice_c; s->postscale_slice = postscale_c; - if (ARCH_X86) - ff_gblur_init_x86(s); +#if ARCH_X86 + ff_gblur_init_x86(s); +#endif } #endif /* AVFILTER_GBLUR_INIT_H */ diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c index 1ea65823c3..71a5f9c787 100644 --- a/libavfilter/vf_gradfun.c +++ b/libavfilter/vf_gradfun.c @@ -131,8 +131,9 @@ static av_cold int init(AVFilterContext *ctx) s->blur_line = ff_gradfun_blur_line_c; s->filter_line = ff_gradfun_filter_line_c; - if (ARCH_X86) - ff_gradfun_init_x86(s); +#if ARCH_X86 + ff_gradfun_init_x86(s); +#endif av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", s->strength, s->radius); diff --git a/libavfilter/vf_hflip_init.h b/libavfilter/vf_hflip_init.h index b58cfec901..d0319f463d 100644 --- a/libavfilter/vf_hflip_init.h +++ b/libavfilter/vf_hflip_init.h @@ -101,8 +101,9 @@ static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes) return AVERROR_BUG; } } - if (ARCH_X86) - ff_hflip_init_x86(s, step, nb_planes); +#if ARCH_X86 + ff_hflip_init_x86(s, step, nb_planes); +#endif return 0; } diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c index 6078bb260f..ce2b9a2974 100644 --- a/libavfilter/vf_hqdn3d.c +++ b/libavfilter/vf_hqdn3d.c @@ -278,8 +278,9 @@ static int config_input(AVFilterLink *inlink) calc_coefs(ctx); - if (ARCH_X86) - ff_hqdn3d_init_x86(s); +#if ARCH_X86 + ff_hqdn3d_init_x86(s); +#endif return 0; } diff --git a/libavfilter/vf_idet.c b/libavfilter/vf_idet.c index 9320b485d8..83d992add1 100644 --- a/libavfilter/vf_idet.c +++ b/libavfilter/vf_idet.c @@ -276,8 +276,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) idet->csp = av_pix_fmt_desc_get(link->format); if (idet->csp->comp[0].depth > 8){ idet->filter_line = (ff_idet_filter_func)ff_idet_filter_line_c_16bit; - if (ARCH_X86) - ff_idet_init_x86(idet, 1); +#if ARCH_X86 + ff_idet_init_x86(idet, 1); +#endif } if (idet->analyze_interlaced_flag) { @@ -408,8 +409,9 @@ static av_cold int init(AVFilterContext *ctx) idet->filter_line = ff_idet_filter_line_c; - if (ARCH_X86) - ff_idet_init_x86(idet, 0); +#if ARCH_X86 + ff_idet_init_x86(idet, 0); +#endif return 0; } diff --git a/libavfilter/vf_limiter.c b/libavfilter/vf_limiter.c index f7d06fec48..67b734229f 100644 --- a/libavfilter/vf_limiter.c +++ b/libavfilter/vf_limiter.c @@ -141,8 +141,9 @@ static int config_input(AVFilterLink *inlink) s->dsp.limiter = limiter16; } - if (ARCH_X86) - ff_limiter_init_x86(&s->dsp, desc->comp[0].depth); +#if ARCH_X86 + ff_limiter_init_x86(&s->dsp, desc->comp[0].depth); +#endif return 0; } diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index c7ecb7018e..358fe13e09 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -1150,9 +1150,9 @@ static int config_input(AVFilterLink *inlink) av_assert0(0); } - if (ARCH_X86) { - ff_lut3d_init_x86(lut3d, desc); - } +#if ARCH_X86 + ff_lut3d_init_x86(lut3d, desc); +#endif return 0; } diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c index de97669877..72f98703a5 100644 --- a/libavfilter/vf_maskedclamp.c +++ b/libavfilter/vf_maskedclamp.c @@ -209,8 +209,9 @@ static int config_input(AVFilterLink *inlink) else s->dsp.maskedclamp = maskedclamp16; - if (ARCH_X86) - ff_maskedclamp_init_x86(&s->dsp, s->depth); +#if ARCH_X86 + ff_maskedclamp_init_x86(&s->dsp, s->depth); +#endif return 0; } diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c index db0c516938..7adb809760 100644 --- a/libavfilter/vf_maskedmerge.c +++ b/libavfilter/vf_maskedmerge.c @@ -202,8 +202,9 @@ static int config_input(AVFilterLink *inlink) else s->maskedmerge = maskedmerge32; - if (ARCH_X86) - ff_maskedmerge_init_x86(s); +#if ARCH_X86 + ff_maskedmerge_init_x86(s); +#endif return 0; } diff --git a/libavfilter/vf_nlmeans_init.h b/libavfilter/vf_nlmeans_init.h index 04ad8801b6..06e932936b 100644 --- a/libavfilter/vf_nlmeans_init.h +++ b/libavfilter/vf_nlmeans_init.h @@ -129,11 +129,11 @@ static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp) dsp->compute_safe_ssd_integral_image = compute_safe_ssd_integral_image_c; dsp->compute_weights_line = compute_weights_line_c; - if (ARCH_AARCH64) - ff_nlmeans_init_aarch64(dsp); - - if (ARCH_X86) - ff_nlmeans_init_x86(dsp); +#if ARCH_AARCH64 + ff_nlmeans_init_aarch64(dsp); +#elif ARCH_X86 + ff_nlmeans_init_x86(dsp); +#endif } #endif /* AVFILTER_NLMEANS_INIT_H */ diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c index 0e3e72b6b5..8ed12f7409 100644 --- a/libavfilter/vf_noise.c +++ b/libavfilter/vf_noise.c @@ -305,8 +305,9 @@ static av_cold int init(AVFilterContext *ctx) n->line_noise = ff_line_noise_c; n->line_noise_avg = ff_line_noise_avg_c; - if (ARCH_X86) - ff_noise_init_x86(n); +#if ARCH_X86 + ff_noise_init_x86(n); +#endif return 0; } diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index f560d54dae..e201e07c15 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -984,9 +984,10 @@ static int config_input_main(AVFilterLink *inlink) } end: - if (ARCH_X86) - ff_overlay_init_x86(s, s->format, inlink->format, - s->alpha_format, s->main_has_alpha); +#if ARCH_X86 + ff_overlay_init_x86(s, s->format, inlink->format, + s->alpha_format, s->main_has_alpha); +#endif return 0; } diff --git a/libavfilter/vf_pp7.c b/libavfilter/vf_pp7.c index 2faa4d2c8a..b7c7cf9dde 100644 --- a/libavfilter/vf_pp7.c +++ b/libavfilter/vf_pp7.c @@ -301,8 +301,9 @@ static int config_input(AVFilterLink *inlink) pp7->dctB = dctB_c; - if (ARCH_X86) - ff_pp7_init_x86(pp7); +#if ARCH_X86 + ff_pp7_init_x86(pp7); +#endif return 0; } diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c index fdfd211401..fa2e887e9b 100644 --- a/libavfilter/vf_psnr.c +++ b/libavfilter/vf_psnr.c @@ -354,8 +354,9 @@ static int config_input_ref(AVFilterLink *inlink) s->average_max = lrint(average_max); s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit; - if (ARCH_X86) - ff_psnr_init_x86(&s->dsp, desc->comp[0].depth); +#if ARCH_X86 + ff_psnr_init_x86(&s->dsp, desc->comp[0].depth); +#endif s->score = av_calloc(s->nb_threads, sizeof(*s->score)); if (!s->score) diff --git a/libavfilter/vf_pullup.c b/libavfilter/vf_pullup.c index 1ee5eb00da..054e3f90a9 100644 --- a/libavfilter/vf_pullup.c +++ b/libavfilter/vf_pullup.c @@ -207,8 +207,9 @@ static int config_input(AVFilterLink *inlink) s->comb = comb_c; s->var = var_c; - if (ARCH_X86) - ff_pullup_init_x86(s); +#if ARCH_X86 + ff_pullup_init_x86(s); +#endif return 0; } diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c index 16140bf8b6..0d4b070cd5 100644 --- a/libavfilter/vf_removegrain.c +++ b/libavfilter/vf_removegrain.c @@ -501,8 +501,9 @@ static int config_input(AVFilterLink *inlink) } } - if (ARCH_X86) - ff_removegrain_init_x86(s); +#if ARCH_X86 + ff_removegrain_init_x86(s); +#endif return 0; } diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c index 0192676909..8442bcc597 100644 --- a/libavfilter/vf_spp.c +++ b/libavfilter/vf_spp.c @@ -343,8 +343,9 @@ static int config_input(AVFilterLink *inlink) av_opt_set_int(s->dct, "bits_per_sample", bps, 0); avcodec_dct_init(s->dct); - if (ARCH_X86) - ff_spp_init_x86(s); +#if ARCH_X86 + ff_spp_init_x86(s); +#endif s->hsub = desc->log2_chroma_w; s->vsub = desc->log2_chroma_h; diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c index bceb3288ef..37094b23f9 100644 --- a/libavfilter/vf_ssim.c +++ b/libavfilter/vf_ssim.c @@ -478,8 +478,9 @@ static int config_input_ref(AVFilterLink *inlink) s->ssim_plane = desc->comp[0].depth > 8 ? ssim_plane_16bit : ssim_plane; s->dsp.ssim_4x4_line = ssim_4x4xn_8bit; s->dsp.ssim_end_line = ssim_endn_8bit; - if (ARCH_X86) - ff_ssim_init_x86(&s->dsp); +#if ARCH_X86 + ff_ssim_init_x86(&s->dsp); +#endif s->score = av_calloc(s->nb_threads, sizeof(*s->score)); if (!s->score) diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c index 0ba18861af..71041d2fee 100644 --- a/libavfilter/vf_stereo3d.c +++ b/libavfilter/vf_stereo3d.c @@ -591,8 +591,9 @@ static int config_output(AVFilterLink *outlink) s->vsub = desc->log2_chroma_h; s->dsp.anaglyph = anaglyph; - if (ARCH_X86) - ff_stereo3d_init_x86(&s->dsp); +#if ARCH_X86 + ff_stereo3d_init_x86(&s->dsp); +#endif return 0; } diff --git a/libavfilter/vf_threshold_init.h b/libavfilter/vf_threshold_init.h index e79d2bb63d..7d160ddbb9 100644 --- a/libavfilter/vf_threshold_init.h +++ b/libavfilter/vf_threshold_init.h @@ -84,8 +84,9 @@ static av_unused void ff_threshold_init(ThresholdContext *s) s->bpc = 2; } - if (ARCH_X86) - ff_threshold_init_x86(s); +#if ARCH_X86 + ff_threshold_init_x86(s); +#endif } #endif /* AVFILTER_THRESHOLD_INIT_H */ diff --git a/libavfilter/vf_tinterlace.c b/libavfilter/vf_tinterlace.c index cda55a8c73..399adc102d 100644 --- a/libavfilter/vf_tinterlace.c +++ b/libavfilter/vf_tinterlace.c @@ -269,15 +269,17 @@ static int config_out_props(AVFilterLink *outlink) tinterlace->lowpass_line = lowpass_line_complex_c_16; else tinterlace->lowpass_line = lowpass_line_complex_c; - if (ARCH_X86) - ff_tinterlace_init_x86(tinterlace); +#if ARCH_X86 + ff_tinterlace_init_x86(tinterlace); +#endif } else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) { if (tinterlace->csp->comp[0].depth > 8) tinterlace->lowpass_line = lowpass_line_c_16; else tinterlace->lowpass_line = lowpass_line_c; - if (ARCH_X86) - ff_tinterlace_init_x86(tinterlace); +#if ARCH_X86 + ff_tinterlace_init_x86(tinterlace); +#endif } av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode, diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c index b964daeee3..469e66729f 100644 --- a/libavfilter/vf_transpose.c +++ b/libavfilter/vf_transpose.c @@ -235,13 +235,13 @@ static int config_props_output(AVFilterLink *outlink) } } - if (ARCH_X86) { - for (int i = 0; i < 4; i++) { - TransVtable *v = &s->vtables[i]; +#if ARCH_X86 + for (int i = 0; i < 4; i++) { + TransVtable *v = &s->vtables[i]; - ff_transpose_init_x86(v, s->pixsteps[i]); - } + ff_transpose_init_x86(v, s->pixsteps[i]); } +#endif av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n", diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c index 55aa05c35c..2ac9b688dc 100644 --- a/libavfilter/vf_v360.c +++ b/libavfilter/vf_v360.c @@ -389,8 +389,9 @@ void ff_v360_init(V360Context *s, int depth) break; } - if (ARCH_X86) - ff_v360_init_x86(s, depth); +#if ARCH_X86 + ff_v360_init_x86(s, depth); +#endif } /** diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c index 53631fd15b..512c8070c7 100644 --- a/libavfilter/vf_w3fdif.c +++ b/libavfilter/vf_w3fdif.c @@ -317,8 +317,9 @@ static int config_input(AVFilterLink *inlink) s->dsp.filter_scale = filter16_scale; } - if (ARCH_X86) - ff_w3fdif_init_x86(&s->dsp, depth); +#if ARCH_X86 + ff_w3fdif_init_x86(&s->dsp, depth); +#endif return 0; } diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 21f6c8544d..afa4d1d53d 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -311,8 +311,9 @@ static int config_output(AVFilterLink *outlink) s->filter_edges = filter_edges; } - if (ARCH_X86) - ff_yadif_init_x86(s); +#if ARCH_X86 + ff_yadif_init_x86(s); +#endif return 0; } |