mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-28 10:22:10 +00:00
x86/synth_filter: add synth_filter_avx
Sandy Bridge Win64: 180 cycles on ff_synth_filter_inner_sse2 150 cycles on ff_synth_filter_inner_avx Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
171dd67520
commit
68c3ed936a
@ -199,11 +199,15 @@ INIT_XMM sse
|
|||||||
DCA_LFE_FIR 0
|
DCA_LFE_FIR 0
|
||||||
DCA_LFE_FIR 1
|
DCA_LFE_FIR 1
|
||||||
|
|
||||||
%macro SHUF 2
|
%macro SHUF 3
|
||||||
%if cpuflag(sse2)
|
%if cpuflag(avx)
|
||||||
pshufd %1, %2, q0123
|
mova %3, [%2 - 16]
|
||||||
|
vperm2f128 %1, %3, %3, 1
|
||||||
|
vshufps %1, %1, %1, q0123
|
||||||
|
%elif cpuflag(sse2)
|
||||||
|
pshufd %1, [%2], q0123
|
||||||
%else
|
%else
|
||||||
mova %1, %2
|
mova %1, [%2]
|
||||||
shufps %1, %1, q0123
|
shufps %1, %1, q0123
|
||||||
%endif
|
%endif
|
||||||
%endmacro
|
%endmacro
|
||||||
@ -212,43 +216,43 @@ DCA_LFE_FIR 1
|
|||||||
; reading backwards: ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i
|
; reading backwards: ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i
|
||||||
;~ a += window[i + j] * (-synth_buf[15 - i + j])
|
;~ a += window[i + j] * (-synth_buf[15 - i + j])
|
||||||
;~ b += window[i + j + 16] * (synth_buf[i + j])
|
;~ b += window[i + j + 16] * (synth_buf[i + j])
|
||||||
SHUF m5, [ptr2 + j + (15 - 3) * 4]
|
SHUF m5, ptr2 + j + (15 - 3) * 4, m6
|
||||||
mova m6, [ptr1 + j]
|
mova m6, [ptr1 + j]
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
SHUF m11, [ptr2 + j + (15 - 3) * 4 - mmsize]
|
SHUF m11, ptr2 + j + (15 - 3) * 4 - mmsize, m12
|
||||||
mova m12, [ptr1 + j + mmsize]
|
mova m12, [ptr1 + j + mmsize]
|
||||||
%endif
|
%endif
|
||||||
mulps m6, [win + %1 + j + 16 * 4]
|
mulps m6, m6, [win + %1 + j + 16 * 4]
|
||||||
mulps m5, [win + %1 + j]
|
mulps m5, m5, [win + %1 + j]
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
mulps m12, [win + %1 + j + mmsize + 16 * 4]
|
mulps m12, m12, [win + %1 + j + mmsize + 16 * 4]
|
||||||
mulps m11, [win + %1 + j + mmsize]
|
mulps m11, m11, [win + %1 + j + mmsize]
|
||||||
%endif
|
%endif
|
||||||
addps m2, m6
|
addps m2, m2, m6
|
||||||
subps m1, m5
|
subps m1, m1, m5
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
addps m8, m12
|
addps m8, m8, m12
|
||||||
subps m7, m11
|
subps m7, m7, m11
|
||||||
%endif
|
%endif
|
||||||
;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
|
;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
|
||||||
;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
|
;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
|
||||||
SHUF m6, [ptr2 + j + (31 - 3) * 4]
|
SHUF m6, ptr2 + j + (31 - 3) * 4, m5
|
||||||
mova m5, [ptr1 + j + 16 * 4]
|
mova m5, [ptr1 + j + 16 * 4]
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
SHUF m12, [ptr2 + j + (31 - 3) * 4 - mmsize]
|
SHUF m12, ptr2 + j + (31 - 3) * 4 - mmsize, m11
|
||||||
mova m11, [ptr1 + j + mmsize + 16 * 4]
|
mova m11, [ptr1 + j + mmsize + 16 * 4]
|
||||||
%endif
|
%endif
|
||||||
mulps m5, [win + %1 + j + 32 * 4]
|
mulps m5, m5, [win + %1 + j + 32 * 4]
|
||||||
mulps m6, [win + %1 + j + 48 * 4]
|
mulps m6, m6, [win + %1 + j + 48 * 4]
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
mulps m11, [win + %1 + j + mmsize + 32 * 4]
|
mulps m11, m11, [win + %1 + j + mmsize + 32 * 4]
|
||||||
mulps m12, [win + %1 + j + mmsize + 48 * 4]
|
mulps m12, m12, [win + %1 + j + mmsize + 48 * 4]
|
||||||
%endif
|
%endif
|
||||||
addps m3, m5
|
addps m3, m3, m5
|
||||||
addps m4, m6
|
addps m4, m4, m6
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
addps m9, m11
|
addps m9, m9, m11
|
||||||
addps m10, m12
|
addps m10, m10, m12
|
||||||
%endif
|
%endif
|
||||||
sub j, 64 * 4
|
sub j, 64 * 4
|
||||||
%endmacro
|
%endmacro
|
||||||
@ -261,13 +265,16 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
|
|||||||
synth_buf, synth_buf2, window, out, off, scale
|
synth_buf, synth_buf2, window, out, off, scale
|
||||||
%define scale m0
|
%define scale m0
|
||||||
%if ARCH_X86_32 || WIN64
|
%if ARCH_X86_32 || WIN64
|
||||||
movd scale, scalem
|
VBROADCASTSS m0, scalem
|
||||||
; Make sure offset is in a register and not on the stack
|
; Make sure offset is in a register and not on the stack
|
||||||
%define OFFQ r4q
|
%define OFFQ r4q
|
||||||
%else
|
%else
|
||||||
|
SPLATD xmm0
|
||||||
|
%if cpuflag(avx)
|
||||||
|
vinsertf128 m0, m0, xmm0, 1
|
||||||
|
%endif
|
||||||
%define OFFQ offq
|
%define OFFQ offq
|
||||||
%endif
|
%endif
|
||||||
SPLATD m0
|
|
||||||
; prepare inner counter limit 1
|
; prepare inner counter limit 1
|
||||||
mov r5q, 480
|
mov r5q, 480
|
||||||
sub r5q, offmp
|
sub r5q, offmp
|
||||||
@ -283,8 +290,8 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
|
|||||||
%endif
|
%endif
|
||||||
.mainloop
|
.mainloop
|
||||||
; m1 = a m2 = b m3 = c m4 = d
|
; m1 = a m2 = b m3 = c m4 = d
|
||||||
xorps m3, m3
|
xorps m3, m3, m3
|
||||||
xorps m4, m4
|
xorps m4, m4, m4
|
||||||
mova m1, [buf2 + i]
|
mova m1, [buf2 + i]
|
||||||
mova m2, [buf2 + i + 16 * 4]
|
mova m2, [buf2 + i + 16 * 4]
|
||||||
%if ARCH_X86_32
|
%if ARCH_X86_32
|
||||||
@ -301,8 +308,8 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
|
|||||||
%define ptr2 r7q ; must be loaded
|
%define ptr2 r7q ; must be loaded
|
||||||
%define win r8q
|
%define win r8q
|
||||||
%define j r9q
|
%define j r9q
|
||||||
xorps m9, m9
|
xorps m9, m9, m9
|
||||||
xorps m10, m10
|
xorps m10, m10, m10
|
||||||
mova m7, [buf2 + i + mmsize]
|
mova m7, [buf2 + i + mmsize]
|
||||||
mova m8, [buf2 + i + mmsize + 16 * 4]
|
mova m8, [buf2 + i + mmsize + 16 * 4]
|
||||||
lea win, [windowq + i]
|
lea win, [windowq + i]
|
||||||
@ -334,11 +341,11 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
|
|||||||
%endif
|
%endif
|
||||||
;~ out[i] = a * scale;
|
;~ out[i] = a * scale;
|
||||||
;~ out[i + 16] = b * scale;
|
;~ out[i + 16] = b * scale;
|
||||||
mulps m1, scale
|
mulps m1, m1, scale
|
||||||
mulps m2, scale
|
mulps m2, m2, scale
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
mulps m7, scale
|
mulps m7, m7, scale
|
||||||
mulps m8, scale
|
mulps m8, m8, scale
|
||||||
%endif
|
%endif
|
||||||
;~ synth_buf2[i] = c;
|
;~ synth_buf2[i] = c;
|
||||||
;~ synth_buf2[i + 16] = d;
|
;~ synth_buf2[i + 16] = d;
|
||||||
@ -367,3 +374,7 @@ SYNTH_FILTER
|
|||||||
%endif
|
%endif
|
||||||
INIT_XMM sse2
|
INIT_XMM sse2
|
||||||
SYNTH_FILTER
|
SYNTH_FILTER
|
||||||
|
%if HAVE_AVX_EXTERNAL
|
||||||
|
INIT_YMM avx
|
||||||
|
SYNTH_FILTER
|
||||||
|
%endif
|
||||||
|
@ -80,6 +80,7 @@ static void synth_filter_##opt(FFTContext *imdct, \
|
|||||||
SYNTH_FILTER_FUNC(sse)
|
SYNTH_FILTER_FUNC(sse)
|
||||||
#endif
|
#endif
|
||||||
SYNTH_FILTER_FUNC(sse2)
|
SYNTH_FILTER_FUNC(sse2)
|
||||||
|
SYNTH_FILTER_FUNC(avx)
|
||||||
|
|
||||||
av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
|
av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
|
||||||
{
|
{
|
||||||
@ -93,4 +94,7 @@ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
|
|||||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||||
s->synth_filter_float = synth_filter_sse2;
|
s->synth_filter_float = synth_filter_sse2;
|
||||||
}
|
}
|
||||||
|
if (EXTERNAL_AVX(cpu_flags)) {
|
||||||
|
s->synth_filter_float = synth_filter_avx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user