[FFmpeg-devel] [PATCH 8/8] x86/flacdsp: add SSE4 and AVX2 versions of wasted33

James Almer jamrial at gmail.com
Sun May 12 19:06:57 EEST 2024


flac_wasted_33_c: 214.1
flac_wasted_33_sse4: 133.6
flac_wasted_33_avx2: 93.1

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/x86/flacdsp.asm    | 24 ++++++++++++++++++++++++
 libavcodec/x86/flacdsp_init.c |  6 ++++++
 2 files changed, 30 insertions(+)

diff --git a/libavcodec/x86/flacdsp.asm b/libavcodec/x86/flacdsp.asm
index 3a940059c7..84cd4dd465 100644
--- a/libavcodec/x86/flacdsp.asm
+++ b/libavcodec/x86/flacdsp.asm
@@ -104,6 +104,30 @@ ALIGN 16
     jl .loop
     RET
 
+%macro WASTED_33 1
+cglobal flac_wasted_33, 4,4,2, decoded, residuals, wasted, len
+    shl   lend, 2
+    lea   decodedq, [decodedq+lenq*2]
+    add   residualsq, lenq
+    neg   lenq
+    movd  xm1, wastedd
+ALIGN 16
+.loop:
+    pmovsxdq  m0, [residualsq+lenq]
+    psllq m0, xm1
+    mov%1  [decodedq+lenq*2], m0
+    add lenq, mmsize / 2
+    jl .loop
+    RET
+%endmacro
+
+INIT_XMM sse4
+WASTED_33 a
+%if HAVE_AVX2_EXTERNAL
+INIT_YMM avx2
+WASTED_33 u
+%endif
+
 ;----------------------------------------------------------------------------------
 ;void ff_flac_decorrelate_[lrm]s_16_sse2(uint8_t **out, int32_t **in, int channels,
 ;                                                   int len, int shift);
diff --git a/libavcodec/x86/flacdsp_init.c b/libavcodec/x86/flacdsp_init.c
index 67aa118760..22482f8787 100644
--- a/libavcodec/x86/flacdsp_init.c
+++ b/libavcodec/x86/flacdsp_init.c
@@ -31,6 +31,8 @@ void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
                         int qlevel, int len);
 
 void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len);
+void ff_flac_wasted_33_sse4(int64_t *decoded, const int32_t *residual, int wasted, int len);
+void ff_flac_wasted_33_avx2(int64_t *decoded, const int32_t *residual, int wasted, int len);
 
 #define DECORRELATE_FUNCS(fmt, opt)                                                      \
 void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int channels,     \
@@ -100,6 +102,7 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
     if (EXTERNAL_SSE4(cpu_flags)) {
         c->lpc16 = ff_flac_lpc_16_sse4;
         c->lpc32 = ff_flac_lpc_32_sse4;
+        c->wasted33 = ff_flac_wasted_33_sse4;
     }
     if (EXTERNAL_AVX(cpu_flags)) {
         if (fmt == AV_SAMPLE_FMT_S16) {
@@ -117,5 +120,8 @@ av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
     if (EXTERNAL_XOP(cpu_flags)) {
         c->lpc32 = ff_flac_lpc_32_xop;
     }
+    if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+        c->wasted33 = ff_flac_wasted_33_avx2;
+    }
 #endif /* HAVE_X86ASM */
 }
-- 
2.45.0



More information about the ffmpeg-devel mailing list