Commit 15ec7aa4 authored by James Darnley's avatar James Darnley Committed by Luca Barbato

v210: Add avx2 version of the 10-bit line encoder

Around 25% faster than the ssse3 version.
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent d29237e5
...@@ -135,13 +135,20 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, ...@@ -135,13 +135,20 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const uint16_t *v = (const uint16_t *)pic->data[2]; const uint16_t *v = (const uint16_t *)pic->data[2];
for (h = 0; h < avctx->height; h++) { for (h = 0; h < avctx->height; h++) {
uint32_t val; uint32_t val;
w = (avctx->width / 6) * 6; w = (avctx->width / (6 * s->sample_factor)) * 6 * s->sample_factor;
s->pack_line_10(y, u, v, dst, w); s->pack_line_10(y, u, v, dst, w);
y += w; y += w;
u += w >> 1; u += w >> 1;
v += w >> 1; v += w >> 1;
dst += (w / 6) * 16; dst += (w / (6 * s->sample_factor)) * 16 * s->sample_factor;
for (; w < avctx->width - 5; w += 6) {
WRITE_PIXELS(u, y, v);
WRITE_PIXELS(y, u, y);
WRITE_PIXELS(v, y, u);
WRITE_PIXELS(y, v, y);
}
if (w < avctx->width - 1) { if (w < avctx->width - 1) {
WRITE_PIXELS(u, y, v); WRITE_PIXELS(u, y, v);
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
SECTION_RODATA 32 SECTION_RODATA 32
v210_enc_min_10: times 16 dw 0x4 v210_enc_min_10: times 32 dw 0x4
v210_enc_max_10: times 16 dw 0x3fb v210_enc_max_10: times 32 dw 0x3fb
v210_enc_luma_mult_10: times 2 dw 4,1,16,4,1,16,0,0 v210_enc_luma_mult_10: times 2 dw 4,1,16,4,1,16,0,0
v210_enc_luma_shuf_10: times 2 db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11 v210_enc_luma_shuf_10: times 2 db -1,0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11
...@@ -47,7 +47,7 @@ SECTION .text ...@@ -47,7 +47,7 @@ SECTION .text
%macro v210_planar_pack_10 0 %macro v210_planar_pack_10 0
; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width) ; v210_planar_pack_10(const uint16_t *y, const uint16_t *u, const uint16_t *v, uint8_t *dst, ptrdiff_t width)
cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width cglobal v210_planar_pack_10, 5, 5, 4+cpuflag(avx2), y, u, v, dst, width
lea r0, [yq+2*widthq] lea r0, [yq+2*widthq]
add uq, widthq add uq, widthq
add vq, widthq add vq, widthq
...@@ -57,11 +57,19 @@ cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width ...@@ -57,11 +57,19 @@ cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width
mova m3, [v210_enc_max_10] mova m3, [v210_enc_max_10]
.loop .loop
movu m0, [yq+2*widthq] movu xm0, [yq+2*widthq]
%if cpuflag(avx2)
vinserti128 m0, m0, [yq+2*widthq+12], 1
%endif
CLIPW m0, m2, m3 CLIPW m0, m2, m3
movq m1, [uq+widthq] movq xm1, [uq+widthq]
movhps m1, [vq+widthq] movhps xm1, [vq+widthq]
%if cpuflag(avx2)
movq xm4, [uq+widthq+6]
movhps xm4, [vq+widthq+6]
vinserti128 m1, m1, xm4, 1
%endif
CLIPW m1, m2, m3 CLIPW m1, m2, m3
pmullw m0, [v210_enc_luma_mult_10] pmullw m0, [v210_enc_luma_mult_10]
...@@ -75,7 +83,7 @@ cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width ...@@ -75,7 +83,7 @@ cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width
movu [dstq], m0 movu [dstq], m0
add dstq, mmsize add dstq, mmsize
add widthq, 6 add widthq, (mmsize*3)/8
jl .loop jl .loop
RET RET
...@@ -85,6 +93,10 @@ cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width ...@@ -85,6 +93,10 @@ cglobal v210_planar_pack_10, 5, 5, 4, y, u, v, dst, width
INIT_XMM ssse3 INIT_XMM ssse3
v210_planar_pack_10 v210_planar_pack_10
%endif %endif
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
v210_planar_pack_10
%endif
%macro v210_planar_pack_8 0 %macro v210_planar_pack_8 0
......
...@@ -29,6 +29,9 @@ void ff_v210_planar_pack_8_avx2(const uint8_t *y, const uint8_t *u, ...@@ -29,6 +29,9 @@ void ff_v210_planar_pack_8_avx2(const uint8_t *y, const uint8_t *u,
void ff_v210_planar_pack_10_ssse3(const uint16_t *y, const uint16_t *u, void ff_v210_planar_pack_10_ssse3(const uint16_t *y, const uint16_t *u,
const uint16_t *v, uint8_t *dst, const uint16_t *v, uint8_t *dst,
ptrdiff_t width); ptrdiff_t width);
void ff_v210_planar_pack_10_avx2(const uint16_t *y, const uint16_t *u,
const uint16_t *v, uint8_t *dst,
ptrdiff_t width);
av_cold void ff_v210enc_init_x86(V210EncContext *s) av_cold void ff_v210enc_init_x86(V210EncContext *s)
{ {
...@@ -45,5 +48,6 @@ av_cold void ff_v210enc_init_x86(V210EncContext *s) ...@@ -45,5 +48,6 @@ av_cold void ff_v210enc_init_x86(V210EncContext *s)
if (EXTERNAL_AVX2(cpu_flags)) { if (EXTERNAL_AVX2(cpu_flags)) {
s->sample_factor = 2; s->sample_factor = 2;
s->pack_line_8 = ff_v210_planar_pack_8_avx2; s->pack_line_8 = ff_v210_planar_pack_8_avx2;
s->pack_line_10 = ff_v210_planar_pack_10_avx2;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment