This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 5e09a6a68a3cb5b180736f14ce19dbb5308cd7c7 Author: Zuxy Meng <[email protected]> AuthorDate: Fri Aug 21 22:04:57 2026 -0700 Commit: Zuxy Meng <[email protected]> CommitDate: Fri Sep 4 20:58:15 2026 -0700 avcodec/x86/h264_weight: Remove MMX SSE2/SSSE3 impl. of MMX weight/bi-weight functions. Identical or slightly better performance: biweight_4x16_8_mmxext: 26.3 ( 2.37x) biweight_4x16_8_sse2: 24.4 ( 2.54x) biweight_4x16_8_ssse3: 19.7 ( 3.13x) weight_4x16_8_mmxext: 20.0 ( 2.34x) weight_4x16_8_sse2: 19.5 ( 2.33x) Signed-off-by: Zuxy Meng <[email protected]> --- libavcodec/x86/h264_weight.asm | 79 +++++++++++++++++++++++++----------------- libavcodec/x86/h264dsp_init.c | 13 +++---- tests/checkasm/h264dsp.c | 9 +++-- 3 files changed, 55 insertions(+), 46 deletions(-) diff --git a/libavcodec/x86/h264_weight.asm b/libavcodec/x86/h264_weight.asm index 5524f3e28c..acd6cfbfdd 100644 --- a/libavcodec/x86/h264_weight.asm +++ b/libavcodec/x86/h264_weight.asm @@ -44,21 +44,21 @@ SECTION .text movd m6, r3d pslld m5, m6 psrld m5, 1 -%if mmsize == 16 pshuflw m3, m3, 0 pshuflw m5, m5, 0 punpcklqdq m3, m3 punpcklqdq m5, m5 -%else - pshufw m3, m3, 0 - pshufw m5, m5, 0 -%endif pxor m7, m7 %endmacro -%macro WEIGHT_OP 2 +%macro WEIGHT_OP 3 +%if %3 == 4 + movd m0, [r0+%1] + movd m1, [r0+%2] +%else movh m0, [r0+%1] movh m1, [r0+%2] +%endif punpcklbw m0, m7 punpcklbw m1, m7 pmullw m0, m3 @@ -70,11 +70,11 @@ SECTION .text packuswb m0, m1 %endmacro -%macro WEIGHT_FUNC_MM 2 -cglobal h264_weight_%1, 6, 6, %2 +%macro WEIGHT_FUNC_MM 1 +cglobal h264_weight_%1, 6, 6, 8 WEIGHT_SETUP .nextrow: - WEIGHT_OP 0, mmsize/2 + WEIGHT_OP 0, mmsize/2, %1 mova [r0], m0 add r0, r1 dec r2d @@ -83,21 +83,22 @@ cglobal h264_weight_%1, 6, 6, %2 %endmacro INIT_XMM sse2 -WEIGHT_FUNC_MM 16, 8 +WEIGHT_FUNC_MM 16 -%macro WEIGHT_FUNC_HALF_MM 2 -cglobal h264_weight_%1, 6, 6, %2 +%macro WEIGHT_FUNC_HALF_MM 1 +cglobal h264_weight_%1, 6, 6, 8 WEIGHT_SETUP sar r2d, 1 lea r3, [r1*2] .nextrow: - WEIGHT_OP 0, r1 + WEIGHT_OP 0, r1, %1 +%if %1 > 4 movh [r0], m0 -%if mmsize == 16 movhps [r0+r1], m0 %else - psrlq m0, 32 - movh [r0+r1], m0 + movd [r0], m0 + psrldq m0, 8 + movd [r0+r1], m0 %endif add r0, r3 dec r2d @@ -105,10 +106,10 @@ cglobal h264_weight_%1, 6, 6, %2 RET %endmacro -INIT_MMX mmxext -WEIGHT_FUNC_HALF_MM 4, 0 INIT_XMM sse2 -WEIGHT_FUNC_HALF_MM 8, 8 +WEIGHT_FUNC_HALF_MM 4 +INIT_XMM sse2 +WEIGHT_FUNC_HALF_MM 8 %macro BIWEIGHT_SETUP 0 %if ARCH_X86_64 @@ -149,18 +150,12 @@ WEIGHT_FUNC_HALF_MM 8, 8 punpcklqdq m5, m5 %else -%if mmsize == 16 pshuflw m3, m3, 0 pshuflw m4, m4, 0 pshuflw m5, m5, 0 punpcklqdq m3, m3 punpcklqdq m4, m4 punpcklqdq m5, m5 -%else - pshufw m3, m3, 0 - pshufw m4, m4, 0 - pshufw m5, m5, 0 -%endif pxor m7, m7 %endif %endmacro @@ -206,6 +201,28 @@ BIWEIGHT_FUNC_MM 16, 8 cglobal h264_biweight_%1, 7, 8, %2 BIWEIGHT_SETUP movifnidn r3d, r3m +%if %1 == 4 + ; for 4 with sse2, process 1 row at a time +.nextrow: + movd m0, [r0] + movd m1, [r1] +%if cpuflag(ssse3) + punpcklbw m0, m1 + pmaddubsw m0, m4 +%else + punpcklbw m0, m7 + punpcklbw m1, m7 + pmullw m0, m3 + pmullw m1, m4 + paddsw m0, m1 +%endif + paddsw m0, m5 + psraw m0, m6 + packuswb m0, m0 + movd [r0], m0 + add r0, r2 + add r1, r2 +%else sar r3d, 1 lea r4, [r2*2] .nextrow: @@ -213,21 +230,19 @@ cglobal h264_biweight_%1, 7, 8, %2 BIWEIGHT_STEPA 1, 2, r2 BIWEIGHT_STEPB movh [r0], m0 -%if mmsize == 16 movhps [r0+r2], m0 -%else - psrlq m0, 32 - movh [r0+r2], m0 -%endif add r0, r4 add r1, r4 +%endif dec r3d jnz .nextrow RET %endmacro -INIT_MMX mmxext -BIWEIGHT_FUNC_HALF_MM 4, 0 +INIT_XMM sse2 +BIWEIGHT_FUNC_HALF_MM 4, 8 +INIT_XMM ssse3 +BIWEIGHT_FUNC_HALF_MM 4, 7 INIT_XMM sse2 BIWEIGHT_FUNC_HALF_MM 8, 8 diff --git a/libavcodec/x86/h264dsp_init.c b/libavcodec/x86/h264dsp_init.c index d853219fb1..654316c2af 100644 --- a/libavcodec/x86/h264dsp_init.c +++ b/libavcodec/x86/h264dsp_init.c @@ -140,10 +140,6 @@ void ff_h264_biweight_ ## W ## _ ## OPT(uint8_t *dst, uint8_t *src, \ int log2_denom, int weightd, \ int weights, int offset); -#define H264_BIWEIGHT_MMX(W) \ - H264_WEIGHT(W, mmxext) \ - H264_BIWEIGHT(W, mmxext) - #define H264_BIWEIGHT_SSE(W) \ H264_WEIGHT(W, sse2) \ H264_BIWEIGHT(W, sse2) \ @@ -151,7 +147,7 @@ void ff_h264_biweight_ ## W ## _ ## OPT(uint8_t *dst, uint8_t *src, \ H264_BIWEIGHT_SSE(16) H264_BIWEIGHT_SSE(8) -H264_BIWEIGHT_MMX(4) +H264_BIWEIGHT_SSE(4) #define H264_WEIGHT_10(W, DEPTH, OPT) \ void ff_h264_weight_ ## W ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \ @@ -198,10 +194,6 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, } if (EXTERNAL_MMXEXT(cpu_flags)) { c->idct8_dc_add = ff_h264_idct8_dc_add_8_mmxext; - - c->weight_pixels_tab[2] = ff_h264_weight_4_mmxext; - - c->biweight_pixels_tab[2] = ff_h264_biweight_4_mmxext; } if (EXTERNAL_SSE2(cpu_flags)) { c->idct8_add = ff_h264_idct8_add_8_sse2; @@ -215,9 +207,11 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, c->weight_pixels_tab[0] = ff_h264_weight_16_sse2; c->weight_pixels_tab[1] = ff_h264_weight_8_sse2; + c->weight_pixels_tab[2] = ff_h264_weight_4_sse2; c->biweight_pixels_tab[0] = ff_h264_biweight_16_sse2; c->biweight_pixels_tab[1] = ff_h264_biweight_8_sse2; + c->biweight_pixels_tab[2] = ff_h264_biweight_4_sse2; c->v_loop_filter_luma = ff_deblock_v_luma_8_sse2; c->h_loop_filter_luma = ff_deblock_h_luma_8_sse2; @@ -244,6 +238,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, if (EXTERNAL_SSSE3(cpu_flags)) { c->biweight_pixels_tab[0] = ff_h264_biweight_16_ssse3; c->biweight_pixels_tab[1] = ff_h264_biweight_8_ssse3; + c->biweight_pixels_tab[2] = ff_h264_biweight_4_ssse3; } if (EXTERNAL_AVX(cpu_flags)) { c->v_loop_filter_luma = ff_deblock_v_luma_8_avx; diff --git a/tests/checkasm/h264dsp.c b/tests/checkasm/h264dsp.c index cc2d7524da..30478f2956 100644 --- a/tests/checkasm/h264dsp.c +++ b/tests/checkasm/h264dsp.c @@ -510,8 +510,8 @@ static void check_weight(void) LOCAL_ALIGNED_16(uint8_t, dst0, [32 * 32 * 2]); LOCAL_ALIGNED_16(uint8_t, dst1, [32 * 32 * 2]); H264DSPContext h; - declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, ptrdiff_t stride, - int height, int log2_denom, int weight, int offset); + declare_func(void, uint8_t *dst, ptrdiff_t stride, int height, + int log2_denom, int weight, int offset); for (int bit_depth = 8; bit_depth <= 10; bit_depth += 2) { ff_h264dsp_init(&h, bit_depth, 1); @@ -562,9 +562,8 @@ static void check_biweight(void) LOCAL_ALIGNED_16(uint8_t, src0, [32 * 32 * 2]); LOCAL_ALIGNED_16(uint8_t, src1, [32 * 32 * 2]); H264DSPContext h; - declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, - ptrdiff_t stride, int height, int log2_denom, - int weightd, int weights, int offset); + declare_func(void, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int height, + int log2_denom, int weightd, int weights, int offset); for (int bit_depth = 8; bit_depth <= 10; bit_depth += 2) { uint32_t mask = pixel_mask[bit_depth - 8]; -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
