History

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).

Andreas Rheinhardt committed 4 years ago

Commit 40e65751 parent e5f6707131 files · +739 −568Browse files

Showing the changes to libavfilter (37 of 131 files). Show all

Unified · Split

37 files
  1. libavfilter/af_afirdsp.h +3 −2
  2. libavfilter/af_anlmdn.c +3 −2
  3. libavfilter/af_volume.c +3 −2
  4. libavfilter/avf_showcqt.c +3 −2
  5. libavfilter/colorspacedsp.c +3 −2
  6. libavfilter/scene_sad.c +3 −2
  7. libavfilter/vf_atadenoise.c +3 −2
  8. libavfilter/vf_blend_init.h +3 −2
  9. libavfilter/vf_bwdif.c +3 −2
  10. libavfilter/vf_eq.h +3 −2
  11. libavfilter/vf_framerate.c +3 −2
  12. libavfilter/vf_fspp.c +3 −2
  13. libavfilter/vf_gblur_init.h +3 −2
  14. libavfilter/vf_gradfun.c +3 −2
  15. libavfilter/vf_hflip_init.h +3 −2
  16. libavfilter/vf_hqdn3d.c +3 −2
  17. libavfilter/vf_idet.c +6 −4
  18. libavfilter/vf_limiter.c +3 −2
  19. libavfilter/vf_lut3d.c +3 −3
  20. libavfilter/vf_maskedclamp.c +3 −2
  21. libavfilter/vf_maskedmerge.c +3 −2
  22. libavfilter/vf_nlmeans_init.h +5 −5
  23. libavfilter/vf_noise.c +3 −2
  24. libavfilter/vf_overlay.c +4 −3
  25. libavfilter/vf_pp7.c +3 −2
  26. libavfilter/vf_psnr.c +3 −2
  27. libavfilter/vf_pullup.c +3 −2
  28. libavfilter/vf_removegrain.c +3 −2
  29. libavfilter/vf_spp.c +3 −2
  30. libavfilter/vf_ssim.c +3 −2
  31. libavfilter/vf_stereo3d.c +3 −2
  32. libavfilter/vf_threshold_init.h +3 −2
  33. libavfilter/vf_tinterlace.c +6 −4
  34. libavfilter/vf_transpose.c +5 −5
  35. libavfilter/vf_v360.c +3 −2
  36. libavfilter/vf_w3fdif.c +3 −2
  37. libavfilter/vf_yadif.c +3 −2
libavfilter/af_afirdsp.h+3−2
@@ -74,8 +74,9 @@ static av_unused void ff_afir_init(AudioFIRDSPContext *dsp) · 73 unmodified lines
7474 dsp->fcmul_add = fcmul_add_c;
7575 dsp->dcmul_add = dcmul_add_c;
7676
77− if (ARCH_X86)
78− ff_afir_init_x86(dsp);
77+#if ARCH_X86
78+ ff_afir_init_x86(dsp);
79+#endif
7980 }
8081
8182 #endif /* AVFILTER_AFIRDSP_H */
libavfilter/af_anlmdn.c+3−2
@@ -118,8 +118,9 @@ void ff_anlmdn_init(AudioNLMDNDSPContext *dsp) · 117 unmodified lines
118118 dsp->compute_distance_ssd = compute_distance_ssd_c;
119119 dsp->compute_cache = compute_cache_c;
120120
121− if (ARCH_X86)
122− ff_anlmdn_init_x86(dsp);
121+#if ARCH_X86
122+ ff_anlmdn_init_x86(dsp);
123+#endif
123124 }
124125
125126 static int config_filter(AVFilterContext *ctx)
libavfilter/af_volume.c+3−2
@@ -238,8 +238,9 @@ static av_cold void volume_init(VolumeContext *vol) · 237 unmodified lines
238238 break;
239239 }
240240
241− if (ARCH_X86)
242− ff_volume_init_x86(vol);
241+#if ARCH_X86
242+ ff_volume_init_x86(vol);
243+#endif
243244 }
244245
245246 static int set_volume(AVFilterContext *ctx)
libavfilter/avf_showcqt.c+3−2
@@ -1418,8 +1418,9 @@ static int config_output(AVFilterLink *outlink) · 1417 unmodified lines
14181418 s->update_sono = update_sono_yuv;
14191419 }
14201420
1421− if (ARCH_X86)
1422− ff_showcqt_init_x86(s);
1421+#if ARCH_X86
1422+ ff_showcqt_init_x86(s);
1423+#endif
14231424
14241425 if ((ret = init_cqt(s)) < 0)
14251426 return ret;
libavfilter/colorspacedsp.c+3−2
@@ -143,6 +143,7 @@ void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp) · 142 unmodified lines
143143
144144 dsp->multiply3x3 = multiply3x3_c;
145145
146− if (ARCH_X86)
147− ff_colorspacedsp_x86_init(dsp);
146+#if ARCH_X86
147+ ff_colorspacedsp_x86_init(dsp);
148+#endif
148149 }
libavfilter/scene_sad.c+3−2
@@ -59,8 +59,9 @@ void ff_scene_sad_c(SCENE_SAD_PARAMS) · 58 unmodified lines
5959 ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
6060 {
6161 ff_scene_sad_fn sad = NULL;
62− if (ARCH_X86)
63− sad = ff_scene_sad_get_fn_x86(depth);
62+#if ARCH_X86
63+ sad = ff_scene_sad_get_fn_x86(depth);
64+#endif
6465 if (!sad) {
6566 if (depth == 8)
6667 sad = ff_scene_sad_c;
libavfilter/vf_atadenoise.c+3−2
@@ -433,8 +433,9 @@ static int config_input(AVFilterLink *inlink) · 432 unmodified lines
433433 }
434434 }
435435
436− if (ARCH_X86)
437− ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma);
436+#if ARCH_X86
437+ ff_atadenoise_init_x86(&s->dsp, depth, s->algorithm, s->sigma);
438+#endif
438439
439440 return 0;
440441 }
libavfilter/vf_blend_init.h+3−2
@@ -194,8 +194,9 @@ static av_unused void ff_blend_init(FilterParams *param, int depth) · 193 unmodified lines
194194 param->blend = depth > 8 ? depth > 16 ? blend_copybottom_32 : blend_copybottom_16 : blend_copybottom_8;
195195 }
196196
197− if (ARCH_X86)
198− ff_blend_init_x86(param, depth);
197+#if ARCH_X86
198+ ff_blend_init_x86(param, depth);
199+#endif
199200 }
200201
201202 #endif /* AVFILTER_BLEND_INIT_H */
libavfilter/vf_bwdif.c+3−2
@@ -350,8 +350,9 @@ static int config_props(AVFilterLink *link) · 349 unmodified lines
350350 s->filter_edge = filter_edge;
351351 }
352352
353− if (ARCH_X86)
354− ff_bwdif_init_x86(s);
353+#if ARCH_X86
354+ ff_bwdif_init_x86(s);
355+#endif
355356
356357 return 0;
357358 }
libavfilter/vf_eq.h+3−2
@@ -123,8 +123,9 @@ void ff_eq_init_x86(EQContext *eq); · 122 unmodified lines
123123 static av_unused void ff_eq_init(EQContext *eq)
124124 {
125125 eq->process = process_c;
126− if (ARCH_X86)
127− ff_eq_init_x86(eq);
126+#if ARCH_X86
127+ ff_eq_init_x86(eq);
128+#endif
128129 }
129130
130131 #endif /* AVFILTER_EQ_H */
libavfilter/vf_framerate.c+3−2
@@ -264,8 +264,9 @@ void ff_framerate_init(FrameRateContext *s) · 263 unmodified lines
264264 s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH(16);
265265 s->blend = blend_frames16_c;
266266 }
267− if (ARCH_X86)
268− ff_framerate_init_x86(s);
267+#if ARCH_X86
268+ ff_framerate_init_x86(s);
269+#endif
269270 }
270271
271272 static int config_input(AVFilterLink *inlink)
libavfilter/vf_fspp.c+3−2
@@ -525,8 +525,9 @@ static int config_input(AVFilterLink *inlink) · 524 unmodified lines
525525 fspp->row_idct = row_idct_c;
526526 fspp->row_fdct = row_fdct_c;
527527
528− if (ARCH_X86)
529− ff_fspp_init_x86(fspp);
528+#if ARCH_X86
529+ ff_fspp_init_x86(fspp);
530+#endif
530531
531532 return 0;
532533 }
libavfilter/vf_gblur_init.h+3−2
@@ -115,8 +115,9 @@ static av_unused void ff_gblur_init(GBlurContext *s) · 114 unmodified lines
115115 s->horiz_slice = horiz_slice_c;
116116 s->verti_slice = verti_slice_c;
117117 s->postscale_slice = postscale_c;
118− if (ARCH_X86)
119− ff_gblur_init_x86(s);
118+#if ARCH_X86
119+ ff_gblur_init_x86(s);
120+#endif
120121 }
121122
122123 #endif /* AVFILTER_GBLUR_INIT_H */
libavfilter/vf_gradfun.c+3−2
@@ -131,8 +131,9 @@ static av_cold int init(AVFilterContext *ctx) · 130 unmodified lines
131131 s->blur_line = ff_gradfun_blur_line_c;
132132 s->filter_line = ff_gradfun_filter_line_c;
133133
134− if (ARCH_X86)
135− ff_gradfun_init_x86(s);
134+#if ARCH_X86
135+ ff_gradfun_init_x86(s);
136+#endif
136137
137138 av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", s->strength, s->radius);
138139
libavfilter/vf_hflip_init.h+3−2
@@ -101,8 +101,9 @@ static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes) · 100 unmodified lines
101101 return AVERROR_BUG;
102102 }
103103 }
104− if (ARCH_X86)
105− ff_hflip_init_x86(s, step, nb_planes);
104+#if ARCH_X86
105+ ff_hflip_init_x86(s, step, nb_planes);
106+#endif
106107
107108 return 0;
108109 }
libavfilter/vf_hqdn3d.c+3−2
@@ -278,8 +278,9 @@ static int config_input(AVFilterLink *inlink) · 277 unmodified lines
278278
279279 calc_coefs(ctx);
280280
281− if (ARCH_X86)
282− ff_hqdn3d_init_x86(s);
281+#if ARCH_X86
282+ ff_hqdn3d_init_x86(s);
283+#endif
283284
284285 return 0;
285286 }
libavfilter/vf_idet.c+6−4
@@ -276,8 +276,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *picref) · 275 unmodified lines
276276 idet->csp = av_pix_fmt_desc_get(link->format);
277277 if (idet->csp->comp[0].depth > 8){
278278 idet->filter_line = (ff_idet_filter_func)ff_idet_filter_line_c_16bit;
279− if (ARCH_X86)
280− ff_idet_init_x86(idet, 1);
279+#if ARCH_X86
280+ ff_idet_init_x86(idet, 1);
281+#endif
281282 }
282283
283284 if (idet->analyze_interlaced_flag) {
@@ -408,8 +409,9 @@ static av_cold int init(AVFilterContext *ctx) · 124 unmodified lines
408409
409410 idet->filter_line = ff_idet_filter_line_c;
410411
411− if (ARCH_X86)
412− ff_idet_init_x86(idet, 0);
412+#if ARCH_X86
413+ ff_idet_init_x86(idet, 0);
414+#endif
413415
414416 return 0;
415417 }
libavfilter/vf_limiter.c+3−2
@@ -141,8 +141,9 @@ static int config_input(AVFilterLink *inlink) · 140 unmodified lines
141141 s->dsp.limiter = limiter16;
142142 }
143143
144− if (ARCH_X86)
145− ff_limiter_init_x86(&s->dsp, desc->comp[0].depth);
144+#if ARCH_X86
145+ ff_limiter_init_x86(&s->dsp, desc->comp[0].depth);
146+#endif
146147
147148 return 0;
148149 }
libavfilter/vf_lut3d.c+3−3
@@ -1150,9 +1150,9 @@ static int config_input(AVFilterLink *inlink) · 1149 unmodified lines
11501150 av_assert0(0);
11511151 }
11521152
1153− if (ARCH_X86) {
1154− ff_lut3d_init_x86(lut3d, desc);
1155− }
1153+#if ARCH_X86
1154+ ff_lut3d_init_x86(lut3d, desc);
1155+#endif
11561156
11571157 return 0;
11581158 }
libavfilter/vf_maskedclamp.c+3−2
@@ -209,8 +209,9 @@ static int config_input(AVFilterLink *inlink) · 208 unmodified lines
209209 else
210210 s->dsp.maskedclamp = maskedclamp16;
211211
212− if (ARCH_X86)
213− ff_maskedclamp_init_x86(&s->dsp, s->depth);
212+#if ARCH_X86
213+ ff_maskedclamp_init_x86(&s->dsp, s->depth);
214+#endif
214215
215216 return 0;
216217 }
libavfilter/vf_maskedmerge.c+3−2
@@ -202,8 +202,9 @@ static int config_input(AVFilterLink *inlink) · 201 unmodified lines
202202 else
203203 s->maskedmerge = maskedmerge32;
204204
205− if (ARCH_X86)
206− ff_maskedmerge_init_x86(s);
205+#if ARCH_X86
206+ ff_maskedmerge_init_x86(s);
207+#endif
207208
208209 return 0;
209210 }
libavfilter/vf_nlmeans_init.h+5−5
@@ -129,11 +129,11 @@ static av_unused void ff_nlmeans_init(NLMeansDSPContext *dsp) · 128 unmodified lines
129129 dsp->compute_safe_ssd_integral_image = compute_safe_ssd_integral_image_c;
130130 dsp->compute_weights_line = compute_weights_line_c;
131131
132− if (ARCH_AARCH64)
133− ff_nlmeans_init_aarch64(dsp);
134−
135− if (ARCH_X86)
136− ff_nlmeans_init_x86(dsp);
132+#if ARCH_AARCH64
133+ ff_nlmeans_init_aarch64(dsp);
134+#elif ARCH_X86
135+ ff_nlmeans_init_x86(dsp);
136+#endif
137137 }
138138
139139 #endif /* AVFILTER_NLMEANS_INIT_H */
libavfilter/vf_noise.c+3−2
@@ -305,8 +305,9 @@ static av_cold int init(AVFilterContext *ctx) · 304 unmodified lines
305305 n->line_noise = ff_line_noise_c;
306306 n->line_noise_avg = ff_line_noise_avg_c;
307307
308− if (ARCH_X86)
309− ff_noise_init_x86(n);
308+#if ARCH_X86
309+ ff_noise_init_x86(n);
310+#endif
310311
311312 return 0;
312313 }
libavfilter/vf_overlay.c+4−3
@@ -984,9 +984,10 @@ static int config_input_main(AVFilterLink *inlink) · 983 unmodified lines
984984 }
985985
986986 end:
987− if (ARCH_X86)
988− ff_overlay_init_x86(s, s->format, inlink->format,
989− s->alpha_format, s->main_has_alpha);
987+#if ARCH_X86
988+ ff_overlay_init_x86(s, s->format, inlink->format,
989+ s->alpha_format, s->main_has_alpha);
990+#endif
990991
991992 return 0;
992993 }
libavfilter/vf_pp7.c+3−2
@@ -301,8 +301,9 @@ static int config_input(AVFilterLink *inlink) · 300 unmodified lines
301301
302302 pp7->dctB = dctB_c;
303303
304− if (ARCH_X86)
305− ff_pp7_init_x86(pp7);
304+#if ARCH_X86
305+ ff_pp7_init_x86(pp7);
306+#endif
306307
307308 return 0;
308309 }
libavfilter/vf_psnr.c+3−2
@@ -354,8 +354,9 @@ static int config_input_ref(AVFilterLink *inlink) · 353 unmodified lines
354354 s->average_max = lrint(average_max);
355355
356356 s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit;
357− if (ARCH_X86)
358− ff_psnr_init_x86(&s->dsp, desc->comp[0].depth);
357+#if ARCH_X86
358+ ff_psnr_init_x86(&s->dsp, desc->comp[0].depth);
359+#endif
359360
360361 s->score = av_calloc(s->nb_threads, sizeof(*s->score));
361362 if (!s->score)
libavfilter/vf_pullup.c+3−2
@@ -207,8 +207,9 @@ static int config_input(AVFilterLink *inlink) · 206 unmodified lines
207207 s->comb = comb_c;
208208 s->var = var_c;
209209
210− if (ARCH_X86)
211− ff_pullup_init_x86(s);
210+#if ARCH_X86
211+ ff_pullup_init_x86(s);
212+#endif
212213 return 0;
213214 }
214215
libavfilter/vf_removegrain.c+3−2
@@ -501,8 +501,9 @@ static int config_input(AVFilterLink *inlink) · 500 unmodified lines
501501 }
502502 }
503503
504− if (ARCH_X86)
505− ff_removegrain_init_x86(s);
504+#if ARCH_X86
505+ ff_removegrain_init_x86(s);
506+#endif
506507
507508 return 0;
508509 }
libavfilter/vf_spp.c+3−2
@@ -343,8 +343,9 @@ static int config_input(AVFilterLink *inlink) · 342 unmodified lines
343343 av_opt_set_int(s->dct, "bits_per_sample", bps, 0);
344344 avcodec_dct_init(s->dct);
345345
346− if (ARCH_X86)
347− ff_spp_init_x86(s);
346+#if ARCH_X86
347+ ff_spp_init_x86(s);
348+#endif
348349
349350 s->hsub = desc->log2_chroma_w;
350351 s->vsub = desc->log2_chroma_h;
libavfilter/vf_ssim.c+3−2
@@ -478,8 +478,9 @@ static int config_input_ref(AVFilterLink *inlink) · 477 unmodified lines
478478 s->ssim_plane = desc->comp[0].depth > 8 ? ssim_plane_16bit : ssim_plane;
479479 s->dsp.ssim_4x4_line = ssim_4x4xn_8bit;
480480 s->dsp.ssim_end_line = ssim_endn_8bit;
481− if (ARCH_X86)
482− ff_ssim_init_x86(&s->dsp);
481+#if ARCH_X86
482+ ff_ssim_init_x86(&s->dsp);
483+#endif
483484
484485 s->score = av_calloc(s->nb_threads, sizeof(*s->score));
485486 if (!s->score)
libavfilter/vf_stereo3d.c+3−2
@@ -591,8 +591,9 @@ static int config_output(AVFilterLink *outlink) · 590 unmodified lines
591591 s->vsub = desc->log2_chroma_h;
592592
593593 s->dsp.anaglyph = anaglyph;
594− if (ARCH_X86)
595− ff_stereo3d_init_x86(&s->dsp);
594+#if ARCH_X86
595+ ff_stereo3d_init_x86(&s->dsp);
596+#endif
596597
597598 return 0;
598599 }
libavfilter/vf_threshold_init.h+3−2
@@ -84,8 +84,9 @@ static av_unused void ff_threshold_init(ThresholdContext *s) · 83 unmodified lines
8484 s->bpc = 2;
8585 }
8686
87− if (ARCH_X86)
88− ff_threshold_init_x86(s);
87+#if ARCH_X86
88+ ff_threshold_init_x86(s);
89+#endif
8990 }
9091
9192 #endif /* AVFILTER_THRESHOLD_INIT_H */
libavfilter/vf_tinterlace.c+6−4
@@ -269,15 +269,17 @@ static int config_out_props(AVFilterLink *outlink) · 268 unmodified lines
269269 tinterlace->lowpass_line = lowpass_line_complex_c_16;
270270 else
271271 tinterlace->lowpass_line = lowpass_line_complex_c;
272− if (ARCH_X86)
273− ff_tinterlace_init_x86(tinterlace);
272+#if ARCH_X86
273+ ff_tinterlace_init_x86(tinterlace);
274+#endif
274275 } else if (tinterlace->flags & TINTERLACE_FLAG_VLPF) {
275276 if (tinterlace->csp->comp[0].depth > 8)
276277 tinterlace->lowpass_line = lowpass_line_c_16;
277278 else
278279 tinterlace->lowpass_line = lowpass_line_c;
279− if (ARCH_X86)
280− ff_tinterlace_init_x86(tinterlace);
280+#if ARCH_X86
281+ ff_tinterlace_init_x86(tinterlace);
282+#endif
281283 }
282284
283285 av_log(ctx, AV_LOG_VERBOSE, "mode:%d filter:%s h:%d -> h:%d\n", tinterlace->mode,
libavfilter/vf_transpose.c+5−5
@@ -235,13 +235,13 @@ static int config_props_output(AVFilterLink *outlink) · 234 unmodified lines
235235 }
236236 }
237237
238− if (ARCH_X86) {
239− for (int i = 0; i < 4; i++) {
240− TransVtable *v = &s->vtables[i];
238+#if ARCH_X86
239+ for (int i = 0; i < 4; i++) {
240+ TransVtable *v = &s->vtables[i];
241241
242− ff_transpose_init_x86(v, s->pixsteps[i]);
243− }
242+ ff_transpose_init_x86(v, s->pixsteps[i]);
244243 }
244+#endif
245245
246246 av_log(ctx, AV_LOG_VERBOSE,
247247 "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
libavfilter/vf_v360.c+3−2
@@ -389,8 +389,9 @@ void ff_v360_init(V360Context *s, int depth) · 388 unmodified lines
389389 break;
390390 }
391391
392− if (ARCH_X86)
393− ff_v360_init_x86(s, depth);
392+#if ARCH_X86
393+ ff_v360_init_x86(s, depth);
394+#endif
394395 }
395396
396397 /**
libavfilter/vf_w3fdif.c+3−2
@@ -317,8 +317,9 @@ static int config_input(AVFilterLink *inlink) · 316 unmodified lines
317317 s->dsp.filter_scale = filter16_scale;
318318 }
319319
320− if (ARCH_X86)
321− ff_w3fdif_init_x86(&s->dsp, depth);
320+#if ARCH_X86
321+ ff_w3fdif_init_x86(&s->dsp, depth);
322+#endif
322323
323324 return 0;
324325 }
libavfilter/vf_yadif.c+3−2
@@ -311,8 +311,9 @@ static int config_output(AVFilterLink *outlink) · 310 unmodified lines
311311 s->filter_edges = filter_edges;
312312 }
313313
314− if (ARCH_X86)
315− ff_yadif_init_x86(s);
314+#if ARCH_X86
315+ ff_yadif_init_x86(s);
316+#endif
316317
317318 return 0;
318319 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t