summaryrefslogtreecommitdiff
path: root/libs/ffvpx/libavutil/x86
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ffvpx/libavutil/x86')
-rw-r--r--libs/ffvpx/libavutil/x86/cpu.c2
-rw-r--r--libs/ffvpx/libavutil/x86/float_dsp.asm33
-rw-r--r--libs/ffvpx/libavutil/x86/float_dsp_init.c7
-rw-r--r--libs/ffvpx/libavutil/x86/pixelutils.asm229
-rw-r--r--libs/ffvpx/libavutil/x86/pixelutils_init.c30
5 files changed, 296 insertions, 5 deletions
diff --git a/libs/ffvpx/libavutil/x86/cpu.c b/libs/ffvpx/libavutil/x86/cpu.c
index aca893174..bcd41a50a 100644
--- a/libs/ffvpx/libavutil/x86/cpu.c
+++ b/libs/ffvpx/libavutil/x86/cpu.c
@@ -127,7 +127,7 @@ int ff_get_cpu_flags_x86(void)
rval |= AV_CPU_FLAG_SSE4;
if (ecx & 0x00100000 )
rval |= AV_CPU_FLAG_SSE42;
- if (ecx & 0x01000000 )
+ if (ecx & 0x02000000 )
rval |= AV_CPU_FLAG_AESNI;
#if HAVE_AVX
/* Check OXSAVE and AVX bits */
diff --git a/libs/ffvpx/libavutil/x86/float_dsp.asm b/libs/ffvpx/libavutil/x86/float_dsp.asm
index 06d2d2cfd..517fd6363 100644
--- a/libs/ffvpx/libavutil/x86/float_dsp.asm
+++ b/libs/ffvpx/libavutil/x86/float_dsp.asm
@@ -58,6 +58,39 @@ INIT_YMM avx
VECTOR_FMUL
%endif
+;-----------------------------------------------------------------------------
+; void vector_dmul(double *dst, const double *src0, const double *src1, int len)
+;-----------------------------------------------------------------------------
+%macro VECTOR_DMUL 0
+cglobal vector_dmul, 4,4,4, dst, src0, src1, len
+ lea lend, [lenq*8 - mmsize*4]
+ALIGN 16
+.loop:
+ movaps m0, [src0q + lenq + 0*mmsize]
+ movaps m1, [src0q + lenq + 1*mmsize]
+ movaps m2, [src0q + lenq + 2*mmsize]
+ movaps m3, [src0q + lenq + 3*mmsize]
+ mulpd m0, m0, [src1q + lenq + 0*mmsize]
+ mulpd m1, m1, [src1q + lenq + 1*mmsize]
+ mulpd m2, m2, [src1q + lenq + 2*mmsize]
+ mulpd m3, m3, [src1q + lenq + 3*mmsize]
+ movaps [dstq + lenq + 0*mmsize], m0
+ movaps [dstq + lenq + 1*mmsize], m1
+ movaps [dstq + lenq + 2*mmsize], m2
+ movaps [dstq + lenq + 3*mmsize], m3
+
+ sub lenq, mmsize*4
+ jge .loop
+ RET
+%endmacro
+
+INIT_XMM sse2
+VECTOR_DMUL
+%if HAVE_AVX_EXTERNAL
+INIT_YMM avx
+VECTOR_DMUL
+%endif
+
;------------------------------------------------------------------------------
; void ff_vector_fmac_scalar(float *dst, const float *src, float mul, int len)
;------------------------------------------------------------------------------
diff --git a/libs/ffvpx/libavutil/x86/float_dsp_init.c b/libs/ffvpx/libavutil/x86/float_dsp_init.c
index 122087a19..8826e4e2c 100644
--- a/libs/ffvpx/libavutil/x86/float_dsp_init.c
+++ b/libs/ffvpx/libavutil/x86/float_dsp_init.c
@@ -29,6 +29,11 @@ void ff_vector_fmul_sse(float *dst, const float *src0, const float *src1,
void ff_vector_fmul_avx(float *dst, const float *src0, const float *src1,
int len);
+void ff_vector_dmul_sse2(double *dst, const double *src0, const double *src1,
+ int len);
+void ff_vector_dmul_avx(double *dst, const double *src0, const double *src1,
+ int len);
+
void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul,
int len);
void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul,
@@ -92,11 +97,13 @@ av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp)
fdsp->butterflies_float = ff_butterflies_float_sse;
}
if (EXTERNAL_SSE2(cpu_flags)) {
+ fdsp->vector_dmul = ff_vector_dmul_sse2;
fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_sse2;
fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_sse2;
}
if (EXTERNAL_AVX_FAST(cpu_flags)) {
fdsp->vector_fmul = ff_vector_fmul_avx;
+ fdsp->vector_dmul = ff_vector_dmul_avx;
fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx;
fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_avx;
fdsp->vector_dmac_scalar = ff_vector_dmac_scalar_avx;
diff --git a/libs/ffvpx/libavutil/x86/pixelutils.asm b/libs/ffvpx/libavutil/x86/pixelutils.asm
index 7af3007d0..36c57c5f7 100644
--- a/libs/ffvpx/libavutil/x86/pixelutils.asm
+++ b/libs/ffvpx/libavutil/x86/pixelutils.asm
@@ -104,8 +104,8 @@ cglobal pixelutils_sad_16x16, 4,4,0, src1, stride1, src2, stride2
RET
;-------------------------------------------------------------------------------
-; int ff_pixelutils_sad_16x16_sse(const uint8_t *src1, ptrdiff_t stride1,
-; const uint8_t *src2, ptrdiff_t stride2);
+; int ff_pixelutils_sad_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
+; const uint8_t *src2, ptrdiff_t stride2);
;-------------------------------------------------------------------------------
INIT_XMM sse2
cglobal pixelutils_sad_16x16, 4,4,5, src1, stride1, src2, stride2
@@ -134,8 +134,8 @@ cglobal pixelutils_sad_16x16, 4,4,5, src1, stride1, src2, stride2
RET
;-------------------------------------------------------------------------------
-; int ff_pixelutils_sad_[au]_16x16_sse(const uint8_t *src1, ptrdiff_t stride1,
-; const uint8_t *src2, ptrdiff_t stride2);
+; int ff_pixelutils_sad_[au]_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
+; const uint8_t *src2, ptrdiff_t stride2);
;-------------------------------------------------------------------------------
%macro SAD_XMM_16x16 1
INIT_XMM sse2
@@ -163,3 +163,224 @@ cglobal pixelutils_sad_%1_16x16, 4,4,3, src1, stride1, src2, stride2
SAD_XMM_16x16 a
SAD_XMM_16x16 u
+
+
+%macro PROCESS_SAD_32x4_U 0
+ movu m1, [r2]
+ movu m2, [r2 + 16]
+ movu m3, [r0]
+ movu m4, [r0 + 16]
+ psadbw m1, m3
+ psadbw m2, m4
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+
+ movu m1, [r2]
+ movu m2, [r2 + 16]
+ movu m3, [r0]
+ movu m4, [r0 + 16]
+ psadbw m1, m3
+ psadbw m2, m4
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+
+ movu m1, [r2]
+ movu m2, [r2 + 16]
+ movu m3, [r0]
+ movu m4, [r0 + 16]
+ psadbw m1, m3
+ psadbw m2, m4
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+
+ movu m1, [r2]
+ movu m2, [r2 + 16]
+ movu m3, [r0]
+ movu m4, [r0 + 16]
+ psadbw m1, m3
+ psadbw m2, m4
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+%endmacro
+
+%macro PROCESS_SAD_32x4 1
+ mov%1 m1, [r2]
+ mov%1 m2, [r2 + 16]
+ psadbw m1, [r0]
+ psadbw m2, [r0 + 16]
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+
+ mov%1 m1, [r2]
+ mov%1 m2, [r2 + 16]
+ psadbw m1, [r0]
+ psadbw m2, [r0 + 16]
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+
+ mov%1 m1, [r2]
+ mov%1 m2, [r2 + 16]
+ psadbw m1, [r0]
+ psadbw m2, [r0 + 16]
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+
+ mov%1 m1, [r2]
+ mov%1 m2, [r2 + 16]
+ psadbw m1, [r0]
+ psadbw m2, [r0 + 16]
+ paddd m1, m2
+ paddd m0, m1
+ lea r2, [r2 + r3]
+ lea r0, [r0 + r1]
+%endmacro
+
+;-----------------------------------------------------------------------------
+; int ff_pixelutils_sad_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
+; const uint8_t *src2, ptrdiff_t stride2);
+;-----------------------------------------------------------------------------
+INIT_XMM sse2
+cglobal pixelutils_sad_32x32, 4,5,5, src1, stride1, src2, stride2
+ pxor m0, m0
+ mov r4d, 4
+.loop:
+ PROCESS_SAD_32x4_U
+ PROCESS_SAD_32x4_U
+ dec r4d
+ jnz .loop
+
+ movhlps m1, m0
+ paddd m0, m1
+ movd eax, m0
+ RET
+
+;-------------------------------------------------------------------------------
+; int ff_pixelutils_sad_[au]_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
+; const uint8_t *src2, ptrdiff_t stride2);
+;-------------------------------------------------------------------------------
+%macro SAD_XMM_32x32 1
+INIT_XMM sse2
+cglobal pixelutils_sad_%1_32x32, 4,5,3, src1, stride1, src2, stride2
+ pxor m0, m0
+ mov r4d, 4
+.loop:
+ PROCESS_SAD_32x4 %1
+ PROCESS_SAD_32x4 %1
+ dec r4d
+ jnz .loop
+
+ movhlps m1, m0
+ paddd m0, m1
+ movd eax, m0
+ RET
+%endmacro
+
+SAD_XMM_32x32 a
+SAD_XMM_32x32 u
+
+%if HAVE_AVX2_EXTERNAL
+;-------------------------------------------------------------------------------
+; int ff_pixelutils_sad_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1,
+; const uint8_t *src2, ptrdiff_t stride2);
+;-------------------------------------------------------------------------------
+INIT_YMM avx2
+cglobal pixelutils_sad_32x32, 4,7,5, src1, stride1, src2, stride2
+ pxor m0, m0
+ mov r4d, 32/4
+ lea r5, [stride1q * 3]
+ lea r6, [stride2q * 3]
+
+.loop:
+ movu m1, [src1q] ; row 0 of pix0
+ movu m2, [src2q] ; row 0 of pix1
+ movu m3, [src1q + stride1q] ; row 1 of pix0
+ movu m4, [src2q + stride2q] ; row 1 of pix1
+
+ psadbw m1, m2
+ psadbw m3, m4
+ paddd m0, m1
+ paddd m0, m3
+
+ movu m1, [src1q + 2 * stride1q] ; row 2 of pix0
+ movu m2, [src2q + 2 * stride2q] ; row 2 of pix1
+ movu m3, [src1q + r5] ; row 3 of pix0
+ movu m4, [src2q + r6] ; row 3 of pix1
+
+ psadbw m1, m2
+ psadbw m3, m4
+ paddd m0, m1
+ paddd m0, m3
+
+ lea src2q, [src2q + 4 * stride2q]
+ lea src1q, [src1q + 4 * stride1q]
+
+ dec r4d
+ jnz .loop
+
+ vextracti128 xm1, m0, 1
+ paddd xm0, xm1
+ pshufd xm1, xm0, 2
+ paddd xm0, xm1
+ movd eax, xm0
+ RET
+
+;-------------------------------------------------------------------------------
+; int ff_pixelutils_sad_[au]_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1,
+; const uint8_t *src2, ptrdiff_t stride2);
+;-------------------------------------------------------------------------------
+%macro SAD_AVX2_32x32 1
+INIT_YMM avx2
+cglobal pixelutils_sad_%1_32x32, 4,7,3, src1, stride1, src2, stride2
+ pxor m0, m0
+ mov r4d, 32/4
+ lea r5, [stride1q * 3]
+ lea r6, [stride2q * 3]
+
+.loop:
+ mov%1 m1, [src2q] ; row 0 of pix1
+ psadbw m1, [src1q]
+ mov%1 m2, [src2q + stride2q] ; row 1 of pix1
+ psadbw m2, [src1q + stride1q]
+
+ paddd m0, m1
+ paddd m0, m2
+
+ mov%1 m1, [src2q + 2 * stride2q] ; row 2 of pix1
+ psadbw m1, [src1q + 2 * stride1q]
+ mov%1 m2, [src2q + r6] ; row 3 of pix1
+ psadbw m2, [src1q + r5]
+
+ paddd m0, m1
+ paddd m0, m2
+
+ lea src2q, [src2q + 4 * stride2q]
+ lea src1q, [src1q + 4 * stride1q]
+
+ dec r4d
+ jnz .loop
+
+ vextracti128 xm1, m0, 1
+ paddd xm0, xm1
+ pshufd xm1, xm0, 2
+ paddd xm0, xm1
+ movd eax, xm0
+ RET
+%endmacro
+
+SAD_AVX2_32x32 a
+SAD_AVX2_32x32 u
+%endif
diff --git a/libs/ffvpx/libavutil/x86/pixelutils_init.c b/libs/ffvpx/libavutil/x86/pixelutils_init.c
index c24a533ae..184a3a4a9 100644
--- a/libs/ffvpx/libavutil/x86/pixelutils_init.c
+++ b/libs/ffvpx/libavutil/x86/pixelutils_init.c
@@ -35,6 +35,20 @@ int ff_pixelutils_sad_a_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
int ff_pixelutils_sad_u_16x16_sse2(const uint8_t *src1, ptrdiff_t stride1,
const uint8_t *src2, ptrdiff_t stride2);
+int ff_pixelutils_sad_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
+ const uint8_t *src2, ptrdiff_t stride2);
+int ff_pixelutils_sad_a_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
+ const uint8_t *src2, ptrdiff_t stride2);
+int ff_pixelutils_sad_u_32x32_sse2(const uint8_t *src1, ptrdiff_t stride1,
+ const uint8_t *src2, ptrdiff_t stride2);
+
+int ff_pixelutils_sad_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1,
+ const uint8_t *src2, ptrdiff_t stride2);
+int ff_pixelutils_sad_a_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1,
+ const uint8_t *src2, ptrdiff_t stride2);
+int ff_pixelutils_sad_u_32x32_avx2(const uint8_t *src1, ptrdiff_t stride1,
+ const uint8_t *src2, ptrdiff_t stride2);
+
void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned)
{
int cpu_flags = av_get_cpu_flags();
@@ -61,4 +75,20 @@ void ff_pixelutils_sad_init_x86(av_pixelutils_sad_fn *sad, int aligned)
case 2: sad[3] = ff_pixelutils_sad_a_16x16_sse2; break; // src1 aligned, src2 aligned
}
}
+
+ if (EXTERNAL_SSE2(cpu_flags)) {
+ switch (aligned) {
+ case 0: sad[4] = ff_pixelutils_sad_32x32_sse2; break; // src1 unaligned, src2 unaligned
+ case 1: sad[4] = ff_pixelutils_sad_u_32x32_sse2; break; // src1 aligned, src2 unaligned
+ case 2: sad[4] = ff_pixelutils_sad_a_32x32_sse2; break; // src1 aligned, src2 aligned
+ }
+ }
+
+ if (EXTERNAL_AVX2_FAST(cpu_flags)) {
+ switch (aligned) {
+ case 0: sad[4] = ff_pixelutils_sad_32x32_avx2; break; // src1 unaligned, src2 unaligned
+ case 1: sad[4] = ff_pixelutils_sad_u_32x32_avx2; break; // src1 aligned, src2 unaligned
+ case 2: sad[4] = ff_pixelutils_sad_a_32x32_avx2; break; // src1 aligned, src2 aligned
+ }
+ }
}