mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
x86/synth_filter: add synth_filter_sse
Build only on x86_32 targets. Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
parent
b97f2c7c49
commit
2025d8026f
@ -199,15 +199,31 @@ INIT_XMM sse
|
|||||||
DCA_LFE_FIR 0
|
DCA_LFE_FIR 0
|
||||||
DCA_LFE_FIR 1
|
DCA_LFE_FIR 1
|
||||||
|
|
||||||
INIT_XMM sse2
|
%macro SETZERO 1
|
||||||
|
%if cpuflag(sse2)
|
||||||
|
pxor %1, %1
|
||||||
|
%else
|
||||||
|
xorps %1, %1, %1
|
||||||
|
%endif
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%macro SHUF 2
|
||||||
|
%if cpuflag(sse2)
|
||||||
|
pshufd %1, %2, q0123
|
||||||
|
%else
|
||||||
|
mova %1, %2
|
||||||
|
shufps %1, %1, q0123
|
||||||
|
%endif
|
||||||
|
%endmacro
|
||||||
|
|
||||||
%macro INNER_LOOP 1
|
%macro INNER_LOOP 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])
|
||||||
pshufd m5, [ptr2 + j + (15 - 3) * 4], q0123
|
SHUF m5, [ptr2 + j + (15 - 3) * 4]
|
||||||
mova m6, [ptr1 + j]
|
mova m6, [ptr1 + j]
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
pshufd m11, [ptr2 + j + (15 - 3) * 4 - mmsize], q0123
|
SHUF m11, [ptr2 + j + (15 - 3) * 4 - mmsize]
|
||||||
mova m12, [ptr1 + j + mmsize]
|
mova m12, [ptr1 + j + mmsize]
|
||||||
%endif
|
%endif
|
||||||
mulps m6, [win + %1 + j + 16 * 4]
|
mulps m6, [win + %1 + j + 16 * 4]
|
||||||
@ -224,10 +240,10 @@ INIT_XMM sse2
|
|||||||
%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])
|
||||||
pshufd m6, [ptr2 + j + (31 - 3) * 4], q0123
|
SHUF m6, [ptr2 + j + (31 - 3) * 4]
|
||||||
mova m5, [ptr1 + j + 16 * 4]
|
mova m5, [ptr1 + j + 16 * 4]
|
||||||
%if ARCH_X86_64
|
%if ARCH_X86_64
|
||||||
pshufd m12, [ptr2 + j + (31 - 3) * 4 - mmsize], q0123
|
SHUF m12, [ptr2 + j + (31 - 3) * 4 - mmsize]
|
||||||
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, [win + %1 + j + 32 * 4]
|
||||||
@ -245,20 +261,25 @@ INIT_XMM sse2
|
|||||||
sub j, 64 * 4
|
sub j, 64 * 4
|
||||||
%endmacro
|
%endmacro
|
||||||
|
|
||||||
; void ff_synth_filter_inner_sse2(float *synth_buf, float synth_buf2[32],
|
; void ff_synth_filter_inner_<opt>(float *synth_buf, float synth_buf2[32],
|
||||||
; const float window[512], float out[32],
|
; const float window[512], float out[32],
|
||||||
; intptr_t offset, float scale)
|
; intptr_t offset, float scale)
|
||||||
|
%macro SYNTH_FILTER 0
|
||||||
cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
|
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
|
||||||
|
%if cpuflag(sse2)
|
||||||
movd scale, scalem
|
movd scale, scalem
|
||||||
|
%else
|
||||||
|
movss scale, scalem
|
||||||
|
%endif
|
||||||
; 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
|
||||||
%define OFFQ offq
|
%define OFFQ offq
|
||||||
%endif
|
%endif
|
||||||
pshufd m0, m0, 0
|
SPLATD m0
|
||||||
; prepare inner counter limit 1
|
; prepare inner counter limit 1
|
||||||
mov r5q, 480
|
mov r5q, 480
|
||||||
sub r5q, offmp
|
sub r5q, offmp
|
||||||
@ -274,8 +295,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
|
||||||
pxor m3, m3
|
SETZERO m3
|
||||||
pxor m4, m4
|
SETZERO 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
|
||||||
@ -292,8 +313,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
|
||||||
pxor m9, m9
|
SETZERO m9
|
||||||
pxor m10, m10
|
SETZERO 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]
|
||||||
@ -350,3 +371,11 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
|
|||||||
sub i, (ARCH_X86_64 + 1) * mmsize
|
sub i, (ARCH_X86_64 + 1) * mmsize
|
||||||
jge .mainloop
|
jge .mainloop
|
||||||
RET
|
RET
|
||||||
|
%endmacro
|
||||||
|
|
||||||
|
%if ARCH_X86_32
|
||||||
|
INIT_XMM sse
|
||||||
|
SYNTH_FILTER
|
||||||
|
%endif
|
||||||
|
INIT_XMM sse2
|
||||||
|
SYNTH_FILTER
|
||||||
|
@ -56,25 +56,31 @@ av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ff_synth_filter_inner_sse2(float *synth_buf_ptr, float synth_buf2[32],
|
|
||||||
const float window[512],
|
#define SYNTH_FILTER_FUNC(opt) \
|
||||||
float out[32], intptr_t offset, float scale);
|
void ff_synth_filter_inner_##opt(float *synth_buf_ptr, float synth_buf2[32], \
|
||||||
|
const float window[512], \
|
||||||
|
float out[32], intptr_t offset, float scale); \
|
||||||
|
static void synth_filter_##opt(FFTContext *imdct, \
|
||||||
|
float *synth_buf_ptr, int *synth_buf_offset, \
|
||||||
|
float synth_buf2[32], const float window[512], \
|
||||||
|
float out[32], const float in[32], float scale) \
|
||||||
|
{ \
|
||||||
|
float *synth_buf= synth_buf_ptr + *synth_buf_offset; \
|
||||||
|
\
|
||||||
|
imdct->imdct_half(imdct, synth_buf, in); \
|
||||||
|
\
|
||||||
|
ff_synth_filter_inner_##opt(synth_buf, synth_buf2, window, \
|
||||||
|
out, *synth_buf_offset, scale); \
|
||||||
|
\
|
||||||
|
*synth_buf_offset = (*synth_buf_offset - 32) & 511; \
|
||||||
|
} \
|
||||||
|
|
||||||
#if HAVE_YASM
|
#if HAVE_YASM
|
||||||
static void synth_filter_sse2(FFTContext *imdct,
|
#if ARCH_X86_32
|
||||||
float *synth_buf_ptr, int *synth_buf_offset,
|
SYNTH_FILTER_FUNC(sse)
|
||||||
float synth_buf2[32], const float window[512],
|
#endif
|
||||||
float out[32], const float in[32], float scale)
|
SYNTH_FILTER_FUNC(sse2)
|
||||||
{
|
|
||||||
float *synth_buf= synth_buf_ptr + *synth_buf_offset;
|
|
||||||
|
|
||||||
imdct->imdct_half(imdct, synth_buf, in);
|
|
||||||
|
|
||||||
ff_synth_filter_inner_sse2(synth_buf, synth_buf2, window,
|
|
||||||
out, *synth_buf_offset, scale);
|
|
||||||
|
|
||||||
*synth_buf_offset = (*synth_buf_offset - 32) & 511;
|
|
||||||
}
|
|
||||||
#endif /* HAVE_YASM */
|
#endif /* HAVE_YASM */
|
||||||
|
|
||||||
av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
|
av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
|
||||||
@ -82,6 +88,11 @@ av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
|
|||||||
#if HAVE_YASM
|
#if HAVE_YASM
|
||||||
int cpu_flags = av_get_cpu_flags();
|
int cpu_flags = av_get_cpu_flags();
|
||||||
|
|
||||||
|
#if ARCH_X86_32
|
||||||
|
if (EXTERNAL_SSE(cpu_flags)) {
|
||||||
|
s->synth_filter_float = synth_filter_sse;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (EXTERNAL_SSE2(cpu_flags)) {
|
if (EXTERNAL_SSE2(cpu_flags)) {
|
||||||
s->synth_filter_float = synth_filter_sse2;
|
s->synth_filter_float = synth_filter_sse2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user