[FFmpeg-cvslog] x86/blockdsp: add sse2 and avx2 versions of fill_block_tab

James Almer git at videolan.org
Thu May 9 03:16:03 EEST 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue May  7 11:33:40 2024 -0300| [214cbe29dc2c6aceb2167131137caa41cbd9f7b6] | committer: James Almer

x86/blockdsp: add sse2 and avx2 versions of fill_block_tab

blockdsp.fill_block_tab[0]_c: 34.1
blockdsp.fill_block_tab[0]_sse2: 11.1
blockdsp.fill_block_tab[0]_avx2: 10.1
blockdsp.fill_block_tab[1]_c: 10.1
blockdsp.fill_block_tab[1]_sse2: 6.1
blockdsp.fill_block_tab[1]_avx2: 5.6

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=214cbe29dc2c6aceb2167131137caa41cbd9f7b6
---

 libavcodec/x86/blockdsp.asm    | 33 +++++++++++++++++++++++++++++++++
 libavcodec/x86/blockdsp_init.c | 13 +++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/libavcodec/x86/blockdsp.asm b/libavcodec/x86/blockdsp.asm
index e380308d4a..cccc9a801a 100644
--- a/libavcodec/x86/blockdsp.asm
+++ b/libavcodec/x86/blockdsp.asm
@@ -80,3 +80,36 @@ INIT_XMM sse
 CLEAR_BLOCKS 1
 INIT_YMM avx
 CLEAR_BLOCKS 1
+
+;-----------------------------------------
+; void ff_fill_block_tab_%1(uint8_t *block, uint8_t value,
+;                           ptrdiff_t line_size, int h);
+;-----------------------------------------
+%macro FILL_BLOCK_TAB 2
+cglobal fill_block_tab_%1, 4, 5, 1, block, value, stride, h, stride3
+    lea stride3q, [strideq + strideq * 2]
+%if cpuflag(avx2)
+    movd m0, valued
+    vpbroadcastb m0, m0
+%else
+    SPLATB_REG m0, value, x
+%endif
+.loop:
+    mov%2 [blockq], m0
+    mov%2 [blockq + strideq], m0
+    mov%2 [blockq + strideq * 2], m0
+    mov%2 [blockq + stride3q], m0
+    lea blockq, [blockq + strideq * 4]
+    sub hd, 4
+    jg .loop
+    RET
+%endmacro
+
+INIT_XMM sse2
+FILL_BLOCK_TAB 8, q
+FILL_BLOCK_TAB 16, a
+%if HAVE_AVX2_EXTERNAL
+INIT_XMM avx2
+FILL_BLOCK_TAB 8, q
+FILL_BLOCK_TAB 16, a
+%endif
diff --git a/libavcodec/x86/blockdsp_init.c b/libavcodec/x86/blockdsp_init.c
index 996124114f..37f3bb6a84 100644
--- a/libavcodec/x86/blockdsp_init.c
+++ b/libavcodec/x86/blockdsp_init.c
@@ -29,6 +29,11 @@ void ff_clear_block_avx(int16_t *block);
 void ff_clear_blocks_sse(int16_t *blocks);
 void ff_clear_blocks_avx(int16_t *blocks);
 
+void ff_fill_block_tab_16_sse2(uint8_t *block, uint8_t value, ptrdiff_t line_size, int h);
+void ff_fill_block_tab_8_sse2(uint8_t *block, uint8_t value, ptrdiff_t line_size, int h);
+void ff_fill_block_tab_16_avx2(uint8_t *block, uint8_t value, ptrdiff_t line_size, int h);
+void ff_fill_block_tab_8_avx2(uint8_t *block, uint8_t value, ptrdiff_t line_size, int h);
+
 av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
 {
 #if HAVE_X86ASM
@@ -38,9 +43,17 @@ av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
         c->clear_block  = ff_clear_block_sse;
         c->clear_blocks = ff_clear_blocks_sse;
     }
+    if (EXTERNAL_SSE2(cpu_flags)) {
+        c->fill_block_tab[0] = ff_fill_block_tab_16_sse2;
+        c->fill_block_tab[1] = ff_fill_block_tab_8_sse2;
+    }
     if (EXTERNAL_AVX_FAST(cpu_flags)) {
         c->clear_block  = ff_clear_block_avx;
         c->clear_blocks = ff_clear_blocks_avx;
     }
+    if (EXTERNAL_AVX2(cpu_flags)) {
+        c->fill_block_tab[0] = ff_fill_block_tab_16_avx2;
+        c->fill_block_tab[1] = ff_fill_block_tab_8_avx2;
+    }
 #endif /* HAVE_X86ASM */
 }



More information about the ffmpeg-cvslog mailing list