|
|
|
@ -382,8 +382,13 @@ RGB24_FUNCS 11, 13, u |
|
|
|
|
; %2-5 = rgba, bgra, argb or abgr (in individual characters) |
|
|
|
|
%macro RGB32_TO_Y_FN 5-6 |
|
|
|
|
cglobal %2%3%4%5 %+ ToY, 6, 6, %1, dst, src, u1, u2, w, table |
|
|
|
|
%if mmsize == 32 |
|
|
|
|
vbroadcasti128 m5, [rgba_Ycoeff_%2%4] |
|
|
|
|
vbroadcasti128 m6, [rgba_Ycoeff_%3%5] |
|
|
|
|
%else |
|
|
|
|
mova m5, [rgba_Ycoeff_%2%4] |
|
|
|
|
mova m6, [rgba_Ycoeff_%3%5] |
|
|
|
|
%endif |
|
|
|
|
%if %0 == 6 |
|
|
|
|
jmp mangle(private_prefix %+ _ %+ %6 %+ ToY %+ SUFFIX).body |
|
|
|
|
%else ; %0 == 6 |
|
|
|
@ -396,13 +401,21 @@ cglobal %2%3%4%5 %+ ToY, 6, 6, %1, dst, src, u1, u2, w, table |
|
|
|
|
lea srcq, [srcq+wq*2] |
|
|
|
|
add dstq, wq |
|
|
|
|
neg wq |
|
|
|
|
%if mmsize == 32 |
|
|
|
|
vbroadcasti128 m4, [rgb_Yrnd] |
|
|
|
|
%else |
|
|
|
|
mova m4, [rgb_Yrnd] |
|
|
|
|
%endif |
|
|
|
|
pcmpeqb m7, m7 |
|
|
|
|
psrlw m7, 8 ; (word) { 0x00ff } x4 |
|
|
|
|
.loop: |
|
|
|
|
; FIXME check alignment and use mova |
|
|
|
|
movu m0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3] |
|
|
|
|
movu m2, [srcq+wq*2+mmsize] ; (byte) { Bx, Gx, Rx, xx }[4-7] |
|
|
|
|
movu xm0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3] |
|
|
|
|
movu xm2, [srcq+wq*2+16] ; (byte) { Bx, Gx, Rx, xx }[4-7] |
|
|
|
|
%if mmsize == 32 |
|
|
|
|
vinserti128 m0, m0, [srcq+wq*2+32], 1 |
|
|
|
|
vinserti128 m2, m2, [srcq+wq*2+48], 1 |
|
|
|
|
%endif |
|
|
|
|
DEINTB 1, 0, 3, 2, 7 ; (word) { Gx, xx (m0/m2) or Bx, Rx (m1/m3) }[0-3]/[4-7] |
|
|
|
|
pmaddwd m1, m5 ; (dword) { Bx*BY + Rx*RY }[0-3] |
|
|
|
|
pmaddwd m0, m6 ; (dword) { Gx*GY }[0-3] |
|
|
|
@ -423,6 +436,7 @@ cglobal %2%3%4%5 %+ ToY, 6, 6, %1, dst, src, u1, u2, w, table |
|
|
|
|
add srcq, 2*mmsize - 2 |
|
|
|
|
add dstq, mmsize - 1 |
|
|
|
|
.loop2: |
|
|
|
|
INIT_XMM cpuname |
|
|
|
|
movd m0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3] |
|
|
|
|
DEINTB 1, 0, 3, 2, 7 ; (word) { Gx, xx (m0/m2) or Bx, Rx (m1/m3) }[0-3]/[4-7] |
|
|
|
|
pmaddwd m1, m5 ; (dword) { Bx*BY + Rx*RY }[0-3] |
|
|
|
@ -435,32 +449,43 @@ cglobal %2%3%4%5 %+ ToY, 6, 6, %1, dst, src, u1, u2, w, table |
|
|
|
|
add wq, 2 |
|
|
|
|
jl .loop2 |
|
|
|
|
.end: |
|
|
|
|
%if cpuflag(avx2) |
|
|
|
|
INIT_YMM cpuname |
|
|
|
|
%endif |
|
|
|
|
RET |
|
|
|
|
%endif ; %0 == 3 |
|
|
|
|
%endmacro |
|
|
|
|
|
|
|
|
|
; %1 = nr. of XMM registers |
|
|
|
|
; %2-5 = rgba, bgra, argb or abgr (in individual characters) |
|
|
|
|
%macro RGB32_TO_UV_FN 5-6 |
|
|
|
|
cglobal %2%3%4%5 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table |
|
|
|
|
; %2 = aligned/unaligned output argument |
|
|
|
|
; %3-6 = rgba, bgra, argb or abgr (in individual characters) |
|
|
|
|
%macro RGB32_TO_UV_FN 6-7 |
|
|
|
|
cglobal %3%4%5%6 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table |
|
|
|
|
%if ARCH_X86_64 |
|
|
|
|
mova m8, [rgba_Ucoeff_%2%4] |
|
|
|
|
mova m9, [rgba_Ucoeff_%3%5] |
|
|
|
|
mova m10, [rgba_Vcoeff_%2%4] |
|
|
|
|
mova m11, [rgba_Vcoeff_%3%5] |
|
|
|
|
%if mmsize == 32 |
|
|
|
|
vbroadcasti128 m8, [rgba_Ucoeff_%3%5] |
|
|
|
|
vbroadcasti128 m9, [rgba_Ucoeff_%4%6] |
|
|
|
|
vbroadcasti128 m10, [rgba_Vcoeff_%3%5] |
|
|
|
|
vbroadcasti128 m11, [rgba_Vcoeff_%4%6] |
|
|
|
|
%else |
|
|
|
|
mova m8, [rgba_Ucoeff_%3%5] |
|
|
|
|
mova m9, [rgba_Ucoeff_%4%6] |
|
|
|
|
mova m10, [rgba_Vcoeff_%3%5] |
|
|
|
|
mova m11, [rgba_Vcoeff_%4%6] |
|
|
|
|
%endif |
|
|
|
|
%define coeffU1 m8 |
|
|
|
|
%define coeffU2 m9 |
|
|
|
|
%define coeffV1 m10 |
|
|
|
|
%define coeffV2 m11 |
|
|
|
|
%else ; x86-32 |
|
|
|
|
%define coeffU1 [rgba_Ucoeff_%2%4] |
|
|
|
|
%define coeffU2 [rgba_Ucoeff_%3%5] |
|
|
|
|
%define coeffV1 [rgba_Vcoeff_%2%4] |
|
|
|
|
%define coeffV2 [rgba_Vcoeff_%3%5] |
|
|
|
|
%define coeffU1 [rgba_Ucoeff_%3%5] |
|
|
|
|
%define coeffU2 [rgba_Ucoeff_%4%6] |
|
|
|
|
%define coeffV1 [rgba_Vcoeff_%3%5] |
|
|
|
|
%define coeffV2 [rgba_Vcoeff_%4%6] |
|
|
|
|
%endif ; x86-64/32 |
|
|
|
|
%if ARCH_X86_64 && %0 == 6 |
|
|
|
|
jmp mangle(private_prefix %+ _ %+ %6 %+ ToUV %+ SUFFIX).body |
|
|
|
|
%else ; ARCH_X86_64 && %0 == 6 |
|
|
|
|
%if ARCH_X86_64 && %0 == 7 |
|
|
|
|
jmp mangle(private_prefix %+ _ %+ %7 %+ ToUV %+ SUFFIX).body |
|
|
|
|
%else ; ARCH_X86_64 && %0 == 7 |
|
|
|
|
.body: |
|
|
|
|
%if ARCH_X86_64 |
|
|
|
|
movsxd wq, dword r5m |
|
|
|
@ -475,11 +500,19 @@ cglobal %2%3%4%5 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table |
|
|
|
|
neg wq |
|
|
|
|
pcmpeqb m7, m7 |
|
|
|
|
psrlw m7, 8 ; (word) { 0x00ff } x4 |
|
|
|
|
%if mmsize == 32 |
|
|
|
|
vbroadcasti128 m6, [rgb_UVrnd] |
|
|
|
|
%else |
|
|
|
|
mova m6, [rgb_UVrnd] |
|
|
|
|
%endif |
|
|
|
|
.loop: |
|
|
|
|
; FIXME check alignment and use mova |
|
|
|
|
movu m0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3] |
|
|
|
|
movu m4, [srcq+wq*2+mmsize] ; (byte) { Bx, Gx, Rx, xx }[4-7] |
|
|
|
|
movu xm0, [srcq+wq*2+0] ; (byte) { Bx, Gx, Rx, xx }[0-3] |
|
|
|
|
movu xm4, [srcq+wq*2+16] ; (byte) { Bx, Gx, Rx, xx }[4-7] |
|
|
|
|
%if mmsize == 32 |
|
|
|
|
vinserti128 m0, m0, [srcq+wq*2+32], 1 |
|
|
|
|
vinserti128 m4, m4, [srcq+wq*2+48], 1 |
|
|
|
|
%endif |
|
|
|
|
DEINTB 1, 0, 5, 4, 7 ; (word) { Gx, xx (m0/m4) or Bx, Rx (m1/m5) }[0-3]/[4-7] |
|
|
|
|
pmaddwd m3, m1, coeffV1 ; (dword) { Bx*BV + Rx*RV }[0-3] |
|
|
|
|
pmaddwd m2, m0, coeffV2 ; (dword) { Gx*GV }[0-3] |
|
|
|
@ -503,8 +536,9 @@ cglobal %2%3%4%5 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table |
|
|
|
|
psrad m1, 9 |
|
|
|
|
packssdw m0, m4 ; (word) { U[0-7] } |
|
|
|
|
packssdw m2, m1 ; (word) { V[0-7] } |
|
|
|
|
mova [dstUq+wq], m0 |
|
|
|
|
mova [dstVq+wq], m2 |
|
|
|
|
; FIXME check alignment and use mova |
|
|
|
|
mov%2 [dstUq+wq], m0 |
|
|
|
|
mov%2 [dstVq+wq], m2 |
|
|
|
|
add wq, mmsize |
|
|
|
|
jl .loop |
|
|
|
|
sub wq, mmsize - 1 |
|
|
|
@ -513,6 +547,7 @@ cglobal %2%3%4%5 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table |
|
|
|
|
add dstUq, mmsize - 1 |
|
|
|
|
add dstVq, mmsize - 1 |
|
|
|
|
.loop2: |
|
|
|
|
INIT_XMM cpuname |
|
|
|
|
movd m0, [srcq+wq*2] ; (byte) { Bx, Gx, Rx, xx }[0-3] |
|
|
|
|
DEINTB 1, 0, 5, 4, 7 ; (word) { Gx, xx (m0/m4) or Bx, Rx (m1/m5) }[0-3]/[4-7] |
|
|
|
|
pmaddwd m3, m1, coeffV1 ; (dword) { Bx*BV + Rx*RV }[0-3] |
|
|
|
@ -532,30 +567,41 @@ cglobal %2%3%4%5 %+ ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, table |
|
|
|
|
add wq, 2 |
|
|
|
|
jl .loop2 |
|
|
|
|
.end: |
|
|
|
|
%if cpuflag(avx2) |
|
|
|
|
INIT_YMM cpuname |
|
|
|
|
%endif |
|
|
|
|
RET |
|
|
|
|
%endif ; ARCH_X86_64 && %0 == 3 |
|
|
|
|
%endif ; ARCH_X86_64 && %0 == 7 |
|
|
|
|
%endmacro |
|
|
|
|
|
|
|
|
|
; %1 = nr. of XMM registers for rgb-to-Y func |
|
|
|
|
; %2 = nr. of XMM registers for rgb-to-UV func |
|
|
|
|
%macro RGB32_FUNCS 2 |
|
|
|
|
; %3 = aligned/unaligned output argument |
|
|
|
|
%macro RGB32_FUNCS 3 |
|
|
|
|
RGB32_TO_Y_FN %1, r, g, b, a |
|
|
|
|
RGB32_TO_Y_FN %1, b, g, r, a, rgba |
|
|
|
|
RGB32_TO_Y_FN %1, a, r, g, b, rgba |
|
|
|
|
RGB32_TO_Y_FN %1, a, b, g, r, rgba |
|
|
|
|
|
|
|
|
|
RGB32_TO_UV_FN %2, r, g, b, a |
|
|
|
|
RGB32_TO_UV_FN %2, b, g, r, a, rgba |
|
|
|
|
RGB32_TO_UV_FN %2, a, r, g, b, rgba |
|
|
|
|
RGB32_TO_UV_FN %2, a, b, g, r, rgba |
|
|
|
|
RGB32_TO_UV_FN %2, %3, r, g, b, a |
|
|
|
|
RGB32_TO_UV_FN %2, %3, b, g, r, a, rgba |
|
|
|
|
RGB32_TO_UV_FN %2, %3, a, r, g, b, rgba |
|
|
|
|
RGB32_TO_UV_FN %2, %3, a, b, g, r, rgba |
|
|
|
|
%endmacro |
|
|
|
|
|
|
|
|
|
INIT_XMM sse2 |
|
|
|
|
RGB32_FUNCS 8, 12 |
|
|
|
|
RGB32_FUNCS 8, 12, a |
|
|
|
|
|
|
|
|
|
%if HAVE_AVX_EXTERNAL |
|
|
|
|
INIT_XMM avx |
|
|
|
|
RGB32_FUNCS 8, 12 |
|
|
|
|
RGB32_FUNCS 8, 12, a |
|
|
|
|
%endif |
|
|
|
|
|
|
|
|
|
%if ARCH_X86_64 |
|
|
|
|
%if HAVE_AVX2_EXTERNAL |
|
|
|
|
INIT_YMM avx2 |
|
|
|
|
RGB32_FUNCS 8, 12, u |
|
|
|
|
%endif |
|
|
|
|
%endif |
|
|
|
|
|
|
|
|
|
;----------------------------------------------------------------------------- |
|
|
|
|