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 /libavcodec/idctdsp.c | |
parent | e5f6707a7b91664491041526ef3cce7412258b89 (diff) | |
download | ffmpeg-40e6575aa3eed64cd32bf28c00ae57edc5acb25a.tar.gz |
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 'libavcodec/idctdsp.c')
-rw-r--r-- | libavcodec/idctdsp.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/libavcodec/idctdsp.c b/libavcodec/idctdsp.c index df3aeb0676..9035003b72 100644 --- a/libavcodec/idctdsp.c +++ b/libavcodec/idctdsp.c @@ -53,10 +53,11 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, { int i; - if (ARCH_X86) - if (ff_init_scantable_permutation_x86(idct_permutation, - perm_type)) - return; +#if ARCH_X86 + if (ff_init_scantable_permutation_x86(idct_permutation, + perm_type)) + return; +#endif switch (perm_type) { case FF_IDCT_PERM_NONE: @@ -238,7 +239,7 @@ static void ff_jref_idct1_add(uint8_t *dest, ptrdiff_t line_size, int16_t *block av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) { - const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; + av_unused const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8; if (avctx->lowres==1) { c->idct_put = ff_jref_idct4_put; @@ -303,20 +304,21 @@ av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx) if (CONFIG_MPEG4_DECODER && avctx->idct_algo == FF_IDCT_XVID) ff_xvid_idct_init(c, avctx); - if (ARCH_AARCH64) - ff_idctdsp_init_aarch64(c, avctx, high_bit_depth); - if (ARCH_ALPHA) - ff_idctdsp_init_alpha(c, avctx, high_bit_depth); - if (ARCH_ARM) - ff_idctdsp_init_arm(c, avctx, high_bit_depth); - if (ARCH_PPC) - ff_idctdsp_init_ppc(c, avctx, high_bit_depth); - if (ARCH_X86) - ff_idctdsp_init_x86(c, avctx, high_bit_depth); - if (ARCH_MIPS) - ff_idctdsp_init_mips(c, avctx, high_bit_depth); - if (ARCH_LOONGARCH) - ff_idctdsp_init_loongarch(c, avctx, high_bit_depth); +#if ARCH_AARCH64 + ff_idctdsp_init_aarch64(c, avctx, high_bit_depth); +#elif ARCH_ALPHA + ff_idctdsp_init_alpha(c, avctx, high_bit_depth); +#elif ARCH_ARM + ff_idctdsp_init_arm(c, avctx, high_bit_depth); +#elif ARCH_PPC + ff_idctdsp_init_ppc(c, avctx, high_bit_depth); +#elif ARCH_X86 + ff_idctdsp_init_x86(c, avctx, high_bit_depth); +#elif ARCH_MIPS + ff_idctdsp_init_mips(c, avctx, high_bit_depth); +#elif ARCH_LOONGARCH + ff_idctdsp_init_loongarch(c, avctx, high_bit_depth); +#endif ff_init_scantable_permutation(c->idct_permutation, c->perm_type); |