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@gmail.com>
This commit is contained in:
James Almer 2024-05-07 11:33:40 -03:00
parent b6054e57cb
commit 214cbe29dc
2 changed files with 46 additions and 0 deletions

View File

@ -80,3 +80,36 @@ INIT_XMM sse
CLEAR_BLOCKS 1 CLEAR_BLOCKS 1
INIT_YMM avx INIT_YMM avx
CLEAR_BLOCKS 1 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

View File

@ -29,6 +29,11 @@ void ff_clear_block_avx(int16_t *block);
void ff_clear_blocks_sse(int16_t *blocks); void ff_clear_blocks_sse(int16_t *blocks);
void ff_clear_blocks_avx(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) av_cold void ff_blockdsp_init_x86(BlockDSPContext *c)
{ {
#if HAVE_X86ASM #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_block = ff_clear_block_sse;
c->clear_blocks = ff_clear_blocks_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)) { if (EXTERNAL_AVX_FAST(cpu_flags)) {
c->clear_block = ff_clear_block_avx; c->clear_block = ff_clear_block_avx;
c->clear_blocks = ff_clear_blocks_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 */ #endif /* HAVE_X86ASM */
} }