diff options
author | James Almer <jamrial@gmail.com> | 2014-03-01 00:32:07 -0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-03-01 15:32:40 +0100 |
commit | 64672098361361cd15d37e36f747ab44de5b80ca (patch) | |
tree | 5ef66e086ff75160e084f6676bfe9b5cd95fad51 /libavcodec | |
parent | 561bfce2033de0daf4d73bdf4232c65becbed8bf (diff) | |
download | ffmpeg-streaming-64672098361361cd15d37e36f747ab44de5b80ca.zip ffmpeg-streaming-64672098361361cd15d37e36f747ab44de5b80ca.tar.gz |
x86/synth_filter: add synth_filter_sse
Build only on x86_32 targets.
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/x86/dcadsp.asm | 43 | ||||
-rw-r--r-- | libavcodec/x86/dcadsp_init.c | 43 |
2 files changed, 57 insertions, 29 deletions
diff --git a/libavcodec/x86/dcadsp.asm b/libavcodec/x86/dcadsp.asm index 2b5a96f..63d771e 100644 --- a/libavcodec/x86/dcadsp.asm +++ b/libavcodec/x86/dcadsp.asm @@ -199,15 +199,23 @@ INIT_XMM sse DCA_LFE_FIR 0 DCA_LFE_FIR 1 -INIT_XMM sse2 +%macro SHUF 2 +%if cpuflag(sse2) + pshufd %1, %2, q0123 +%else + mova %1, %2 + shufps %1, %1, q0123 +%endif +%endmacro + %macro INNER_LOOP 1 ; reading backwards: ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i ;~ a += window[i + j] * (-synth_buf[15 - 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] %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] %endif mulps m6, [win + %1 + j + 16 * 4] @@ -224,10 +232,10 @@ INIT_XMM sse2 %endif ;~ c += window[i + j + 32] * (synth_buf[16 + 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] %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] %endif mulps m5, [win + %1 + j + 32 * 4] @@ -245,9 +253,10 @@ INIT_XMM sse2 sub j, 64 * 4 %endmacro -; void ff_synth_filter_inner_sse2(float *synth_buf, float synth_buf2[32], -; const float window[512], float out[32], -; intptr_t offset, float scale) +; void ff_synth_filter_inner_<opt>(float *synth_buf, float synth_buf2[32], +; const float window[512], float out[32], +; intptr_t offset, float scale) +%macro SYNTH_FILTER 0 cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \ synth_buf, synth_buf2, window, out, off, scale %define scale m0 @@ -258,7 +267,7 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \ %else %define OFFQ offq %endif - pshufd m0, m0, 0 + SPLATD m0 ; prepare inner counter limit 1 mov r5q, 480 sub r5q, offmp @@ -274,8 +283,8 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \ %endif .mainloop ; m1 = a m2 = b m3 = c m4 = d - pxor m3, m3 - pxor m4, m4 + xorps m3, m3 + xorps m4, m4 mova m1, [buf2 + i] mova m2, [buf2 + i + 16 * 4] %if ARCH_X86_32 @@ -292,8 +301,8 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \ %define ptr2 r7q ; must be loaded %define win r8q %define j r9q - pxor m9, m9 - pxor m10, m10 + xorps m9, m9 + xorps m10, m10 mova m7, [buf2 + i + mmsize] mova m8, [buf2 + i + mmsize + 16 * 4] lea win, [windowq + i] @@ -350,3 +359,11 @@ cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \ sub i, (ARCH_X86_64 + 1) * mmsize jge .mainloop RET +%endmacro + +%if ARCH_X86_32 +INIT_XMM sse +SYNTH_FILTER +%endif +INIT_XMM sse2 +SYNTH_FILTER diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c index 9ededac..0e84b8c 100644 --- a/libavcodec/x86/dcadsp_init.c +++ b/libavcodec/x86/dcadsp_init.c @@ -56,29 +56,40 @@ 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], - float out[32], intptr_t offset, float scale); -static void synth_filter_sse2(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_sse2(synth_buf, synth_buf2, window, - out, *synth_buf_offset, scale); +#define SYNTH_FILTER_FUNC(opt) \ +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; \ +} \ - *synth_buf_offset = (*synth_buf_offset - 32) & 511; -} +#if ARCH_X86_32 +SYNTH_FILTER_FUNC(sse) +#endif +SYNTH_FILTER_FUNC(sse2) av_cold void ff_synth_filter_init_x86(SynthFilterContext *s) { 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)) { s->synth_filter_float = synth_filter_sse2; } |