[FFmpeg-devel] [PATCH 2/2] Don't use CMOV in MMX code

James Almer jamrial at gmail.com
Fri Sep 12 22:33:28 CEST 2014


On 12/09/14 4:50 PM, Mikulas Patocka wrote:
> There are MMX processors that don't support CMOV (pentium-mmx, amd-k6, cyrix
> 6x86). Therefore, we must not use cmov in in MMX code.
> 
> All processors supporing mmx2 also support cmov, so if a test for mmx2 succeeds,
> we can use cmov.
> 
> ---
>  libavcodec/x86/h264_idct.asm |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> Index: ffmpeg/libavcodec/x86/h264_idct.asm
> ===================================================================
> --- ffmpeg.orig/libavcodec/x86/h264_idct.asm	2014-08-25 03:59:06.376569389 +0200
> +++ ffmpeg/libavcodec/x86/h264_idct.asm	2014-08-25 18:47:46.988574579 +0200
> @@ -1063,7 +1063,13 @@ cglobal h264_luma_dc_dequant_idct, 3, 4,
>      add        t3d, 128 << 16
>      mov        t1d, 7
>      cmp        t0d, t1d
> +%if cpuflag(mmx2)
>      cmovg      t0d, t1d
> +%else
> +    jng	.skip_mov
> +    mov        t0d, t1d
> +.skip_mov:
> +%endif
>      inc        t1d
>      shr        t3d, t0b
>      sub        t1d, t0d

This is not necessary. The check for cmov-enabled CPUs is done in h264dsp_init.c 
so this function is not being used on CPUs like the ones you mentioned.

If anything, you could add a second mmx version for said CPUs, but i really doubt 
it's worth the increased binary size.


More information about the ffmpeg-devel mailing list