Hi,

On Fri, Jul 17, 2026 at 4:21 AM Aleksander Shveikin via ffmpeg-devel
<[email protected]> wrote:
>
> This patch converts ff_vp8_idct_dc_add4uv_mmx to ff_vp8_idct_dc_add4uv_sse2.
>
> Here are the checkasm benchmark results:
>
> vp8_idct_dc_add4uv_c:    359.9
> vp8_idct_dc_add4uv_mmx:   59.7 ( 6.02x)
> vp8_idct_dc_add4uv_sse2:  21.1 (17.06x)
>
> Signed-off-by: Aleksander Shveikin <[email protected]>
> ---
>  libavcodec/x86/vp8dsp.asm    | 22 ++++++++++------------
>  libavcodec/x86/vp8dsp_init.c |  7 ++-----
>  2 files changed, 12 insertions(+), 17 deletions(-)
>
> diff --git a/libavcodec/x86/vp8dsp.asm b/libavcodec/x86/vp8dsp.asm
> index 22356f687b..d14843e325 100644
> --- a/libavcodec/x86/vp8dsp.asm
> +++ b/libavcodec/x86/vp8dsp.asm
> @@ -937,8 +937,8 @@ cglobal vp8_idct_dc_add4y, 3, 3, 6, dst, block, stride
>  ; void ff_vp8_idct_dc_add4uv_<opt>(uint8_t *dst, int16_t block[4][16], 
> ptrdiff_t stride);
>  
> ;-----------------------------------------------------------------------------
>
> -INIT_MMX mmx
> -cglobal vp8_idct_dc_add4uv, 3, 3, 0, dst, block, stride
> +INIT_XMM sse2
> +cglobal vp8_idct_dc_add4uv, 3, 3, 8, dst, block, stride

If possible, limit the use of xmm registers to m0 to m5, so that the
callee doesn't have to save any xmm under Windows.

>      ; load data
>      movd      m0, [blockq+32*0] ; A
>      movd      m1, [blockq+32*2] ; C
> @@ -957,22 +957,20 @@ cglobal vp8_idct_dc_add4uv, 3, 3, 0, dst, block, stride
>      psubw     m6, m0
>      packuswb  m0, m0
>      packuswb  m6, m6
> -    punpcklbw m0, m0 ; AABBCCDD
> -    punpcklbw m6, m6 ; AABBCCDD
> -    movq      m1, m0
> -    movq      m7, m6
> -    punpcklbw m0, m0 ; AAAABBBB
> -    punpckhbw m1, m1 ; CCCCDDDD
> -    punpcklbw m6, m6 ; AAAABBBB
> -    punpckhbw m7, m7 ; CCCCDDDD
> +    punpcklbw m0, m0
> +    punpcklbw m6, m6
> +    punpcklbw m0, m0
> +    punpcklbw m6, m6
> +    movhlps   m1, m0
> +    movhlps   m7, m6
>
>      ; add DC
>      DEFINE_ARGS dst1, dst2, stride
>      lea    dst2q, [dst1q+strideq*2]
> -    ADD_DC    m0, m6, 0, mova
> +    ADD_DC    m0, m6, 0, movh
>      lea    dst1q, [dst1q+strideq*4]
>      lea    dst2q, [dst2q+strideq*4]
> -    ADD_DC    m1, m7, 0, mova
> +    ADD_DC    m1, m7, 0, movh
>      RET
>
>  
> ;-----------------------------------------------------------------------------
> diff --git a/libavcodec/x86/vp8dsp_init.c b/libavcodec/x86/vp8dsp_init.c
> index 828b038cdf..ded136d186 100644
> --- a/libavcodec/x86/vp8dsp_init.c
> +++ b/libavcodec/x86/vp8dsp_init.c
> @@ -169,7 +169,7 @@ void ff_vp8_idct_dc_add_sse4(uint8_t *dst, int16_t 
> block[16],
>                               ptrdiff_t stride);
>  void ff_vp8_idct_dc_add4y_sse2(uint8_t *dst, int16_t block[4][16],
>                                 ptrdiff_t stride);
> -void ff_vp8_idct_dc_add4uv_mmx(uint8_t *dst, int16_t block[2][16],
> +void ff_vp8_idct_dc_add4uv_sse2(uint8_t *dst, int16_t block[4][16],
>                                 ptrdiff_t stride);
>  void ff_vp8_luma_dc_wht_sse(int16_t block[4][4][16], int16_t dc[16]);
>  void ff_vp8_idct_add_sse(uint8_t *dst, int16_t block[16], ptrdiff_t stride);
> @@ -272,10 +272,6 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext *c)
>  {
>      int cpu_flags = av_get_cpu_flags();
>
> -    if (EXTERNAL_MMX(cpu_flags)) {
> -        c->vp8_idct_dc_add4uv = ff_vp8_idct_dc_add4uv_mmx;
> -    }
> -
>      if (EXTERNAL_SSE(cpu_flags)) {
>          c->vp8_idct_add                         = ff_vp8_idct_add_sse;
>          c->vp8_luma_dc_wht                      = ff_vp8_luma_dc_wht_sse;
> @@ -294,6 +290,7 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext *c)
>      if (EXTERNAL_SSE2(cpu_flags)) {
>          c->vp8_idct_dc_add            = ff_vp8_idct_dc_add_sse2;
>          c->vp8_idct_dc_add4y          = ff_vp8_idct_dc_add4y_sse2;
> +        c->vp8_idct_dc_add4uv         = ff_vp8_idct_dc_add4uv_sse2;
>
>          c->vp8_h_loop_filter_simple   = ff_vp8_h_loop_filter_simple_sse2;
>
> --
> 2.43.0
>
> _______________________________________________
> ffmpeg-devel mailing list -- [email protected]
> To unsubscribe send an email to [email protected]



-- 
Zuxy
Beauty is truth,
While truth is beauty.
PGP KeyID: E8555ED6
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to