PR #24072 opened by zuxy URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24072 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24072.patch
Convert hevc_add_residual_4_10 to use SSE2 and remove declare_func_emms in test code. hevc_add_res_4x4_10_c: 21.7 hevc_add_res_4x4_10_mmxext: 9.4 ( 2.31x) hevc_add_res_4x4_10_sse2: 9.2 ( 2.35x) Signed-off-by: Zuxy Meng <[email protected]> >From 076e07f1c52be0fc131b4516b64c7731dd578cd0 Mon Sep 17 00:00:00 2001 From: Zuxy Meng <[email protected]> Date: Mon, 10 Aug 2026 19:00:15 -0700 Subject: [PATCH] avcodec/x86/hevc/add_res: Replace MMX with SSE2 Convert hevc_add_residual_4_10 to use SSE2 and remove declare_func_emms in test code. hevc_add_res_4x4_10_c: 21.7 hevc_add_res_4x4_10_mmxext: 9.4 ( 2.31x) hevc_add_res_4x4_10_sse2: 9.2 ( 2.35x) Signed-off-by: Zuxy Meng <[email protected]> --- libavcodec/x86/hevc/add_res.asm | 24 +++++++++++++----------- libavcodec/x86/hevc/dsp.h | 2 +- libavcodec/x86/hevc/dsp_init.c | 4 +--- tests/checkasm/hevc_add_res.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libavcodec/x86/hevc/add_res.asm b/libavcodec/x86/hevc/add_res.asm index 70ae9fbc76..5558db700a 100644 --- a/libavcodec/x86/hevc/add_res.asm +++ b/libavcodec/x86/hevc/add_res.asm @@ -191,15 +191,17 @@ cglobal hevc_add_residual_32_8, 3, 5, 7 mova [%1+%3], m3 %endmacro -%macro ADD_RES_MMX_4_10 3 - mova m0, [%1+0] - mova m1, [%1+%2] - paddw m0, [%3] - paddw m1, [%3+8] +%macro ADD_RES_SSE_4_10 3 + movq m0, [%1+0] + movq m4, [%3] + paddw m0, m4 + movq m1, [%1+%2] + movq m4, [%3+8] + paddw m1, m4 CLIPW m0, m2, m3 CLIPW m1, m2, m3 - mova [%1+0], m0 - mova [%1+%2], m1 + movq [%1+0], m0 + movq [%1+%2], m1 %endmacro %macro ADD_RES_SSE_16_10 3 @@ -284,13 +286,13 @@ cglobal hevc_add_residual_32_8, 3, 5, 7 %endmacro ; void ff_hevc_add_residual_<4|8|16|32>_10(pixel *dst, const int16_t *block, ptrdiff_t stride) -INIT_MMX mmxext +INIT_XMM sse2 cglobal hevc_add_residual_4_10, 3, 3, 6 pxor m2, m2 - mova m3, [max_pixels_10] - ADD_RES_MMX_4_10 r0, r2, r1 + movq m3, [max_pixels_10] + ADD_RES_SSE_4_10 r0, r2, r1 lea r0, [r0+2*r2] - ADD_RES_MMX_4_10 r0, r2, r1+16 + ADD_RES_SSE_4_10 r0, r2, r1+16 RET INIT_XMM sse2 diff --git a/libavcodec/x86/hevc/dsp.h b/libavcodec/x86/hevc/dsp.h index 98dc8cff9a..a538da064f 100644 --- a/libavcodec/x86/hevc/dsp.h +++ b/libavcodec/x86/hevc/dsp.h @@ -174,7 +174,7 @@ void ff_hevc_add_residual_32_8_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, const int16_t *res, ptrdiff_t stride); -void ff_hevc_add_residual_4_10_mmxext(uint8_t *dst, const int16_t *res, ptrdiff_t stride); +void ff_hevc_add_residual_4_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride); void ff_hevc_add_residual_8_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride); void ff_hevc_add_residual_16_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride); void ff_hevc_add_residual_32_10_sse2(uint8_t *dst, const int16_t *res, ptrdiff_t stride); diff --git a/libavcodec/x86/hevc/dsp_init.c b/libavcodec/x86/hevc/dsp_init.c index c456ee9ed0..d65c3cf3f4 100644 --- a/libavcodec/x86/hevc/dsp_init.c +++ b/libavcodec/x86/hevc/dsp_init.c @@ -1002,9 +1002,6 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) } #endif } else if (bit_depth == 10) { - if (EXTERNAL_MMXEXT(cpu_flags)) { - c->add_residual[0] = ff_hevc_add_residual_4_10_mmxext; - } if (EXTERNAL_SSE2(cpu_flags)) { c->hevc_v_loop_filter_chroma = ff_hevc_v_loop_filter_chroma_10_sse2; c->hevc_h_loop_filter_chroma = ff_hevc_h_loop_filter_chroma_10_sse2; @@ -1027,6 +1024,7 @@ void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth) c->idct[1] = ff_hevc_idct_8x8_10_sse2; c->transform_4x4_luma = ff_hevc_transform_4x4_luma_10_sse2; + c->add_residual[0] = ff_hevc_add_residual_4_10_sse2; c->add_residual[1] = ff_hevc_add_residual_8_10_sse2; c->add_residual[2] = ff_hevc_add_residual_16_10_sse2; c->add_residual[3] = ff_hevc_add_residual_32_10_sse2; diff --git a/tests/checkasm/hevc_add_res.c b/tests/checkasm/hevc_add_res.c index 6388d5b12c..a63feff6df 100644 --- a/tests/checkasm/hevc_add_res.c +++ b/tests/checkasm/hevc_add_res.c @@ -50,7 +50,7 @@ static void compare_add_res(int size, ptrdiff_t stride, int overflow_test, int m LOCAL_ALIGNED_32(uint8_t, dst0, [32 * 32 * 2]); LOCAL_ALIGNED_32(uint8_t, dst1, [32 * 32 * 2]); - declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const int16_t *res, ptrdiff_t stride); + declare_func(void, uint8_t *dst, const int16_t *res, ptrdiff_t stride); randomize_buffers(res0, size); randomize_buffers2(dst0, size, mask); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
