From 86f8adc58e0443024f5ad992ecdb959f0d6d8d95 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Tue, 4 Nov 2025 13:56:01 +0100 Subject: [PATCH] avcodec/x86/idctdsp_init: Fix IDCT permutation for 32bit without SSE2 bfb28b5ce89f3e950214b67ea95b45e3355c2caf removed the MMX idct_put and idct_add functions, because they were overridden by SSE2 versions (which use SSE2 only for the put/add part, not the actual IDCT). This meant that for MMX, the idct functions are not set in unison, so that the permutation which is meant to apply to all three is incorrect on 32bit systems if SSE2 is unavailable/disabled. Fix this by setting the MMX version only if SSE2 is enabled. (No one complained, so apparently no one uses a new FFmpeg with non-SSE2 capable systems.) Reviewed-by: Lynne Signed-off-by: Andreas Rheinhardt --- libavcodec/x86/idctdsp_init.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/libavcodec/x86/idctdsp_init.c b/libavcodec/x86/idctdsp_init.c index 2d165b975b..281d143ade 100644 --- a/libavcodec/x86/idctdsp_init.c +++ b/libavcodec/x86/idctdsp_init.c @@ -65,18 +65,6 @@ av_cold void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, { int cpu_flags = av_get_cpu_flags(); -#if ARCH_X86_32 - if (EXTERNAL_MMX(cpu_flags)) { - if (!high_bit_depth && - avctx->lowres == 0 && - (avctx->idct_algo == FF_IDCT_AUTO || - avctx->idct_algo == FF_IDCT_SIMPLEAUTO || - avctx->idct_algo == FF_IDCT_SIMPLEMMX)) { - c->idct = ff_simple_idct_mmx; - } - } -#endif - 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; @@ -88,6 +76,7 @@ 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_mmx; c->idct_put = ff_simple_idct_put_sse2; c->idct_add = ff_simple_idct_add_sse2; c->perm_type = FF_IDCT_PERM_SIMPLE;