[FFmpeg-devel] [PATCH 08/11] dcadsp: split synth_filter_float
Christophe Gisquet
christophe.gisquet at gmail.com
Thu Feb 6 01:41:59 CET 2014
The goal is to avoid function calls within assembly which are a mess on x86.
---
libavcodec/dcadsp.c | 7 +++++--
libavcodec/synth_filter.c | 13 ++++---------
libavcodec/synth_filter.h | 8 +++-----
libavcodec/x86/fft_init.c | 23 ++++-------------------
libavcodec/x86/synth_filter.asm | 10 +++++-----
5 files changed, 21 insertions(+), 40 deletions(-)
diff --git a/libavcodec/dcadsp.c b/libavcodec/dcadsp.c
index 75a1446..80028da 100644
--- a/libavcodec/dcadsp.c
+++ b/libavcodec/dcadsp.c
@@ -73,6 +73,7 @@ static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
/* Reconstructed channel sample index */
for (subindex = 0; subindex < 8; subindex++) {
+ float *synth_buf = synth_buf_ptr + *synth_buf_offset;
/* Load in one sample from each subband and clear inactive subbands */
for (i = 0; i < sb_act; i++) {
unsigned sign = (i - 1) & 2;
@@ -80,8 +81,10 @@ static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
AV_WN32A(&raXin[i], v);
}
- synth->synth_filter_float(imdct, synth_buf_ptr, synth_buf_offset,
- synth_buf2, window, samples_out, raXin, scale);
+ imdct->imdct_half(imdct, synth_buf, raXin);
+ synth->synth_filter_float(synth_buf, synth_buf2, window,
+ samples_out, *synth_buf_offset, scale);
+ *synth_buf_offset = (*synth_buf_offset-32)&511;
samples_out += 32;
}
}
diff --git a/libavcodec/synth_filter.c b/libavcodec/synth_filter.c
index d49ffe6..f642073 100644
--- a/libavcodec/synth_filter.c
+++ b/libavcodec/synth_filter.c
@@ -21,22 +21,18 @@
#include "fft.h"
#include "synth_filter.h"
-static void synth_filter_float(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)
+static void synth_filter_float(float *synth_buf, float synth_buf2[32],
+ const float window[512],
+ float out[32], int offset, float scale)
{
- float *synth_buf= synth_buf_ptr + *synth_buf_offset;
int i, j;
- imdct->imdct_half(imdct, synth_buf, in);
-
for (i = 0; i < 16; i++){
float a= synth_buf2[i ];
float b= synth_buf2[i + 16];
float c= 0;
float d= 0;
- for (j = 0; j < 512 - *synth_buf_offset; j += 64){
+ for (j = 0; j < 512 - offset; j += 64){
a += window[i + j ]*(-synth_buf[15 - i + j ]);
b += window[i + j + 16]*( synth_buf[ i + j ]);
c += window[i + j + 32]*( synth_buf[16 + i + j ]);
@@ -53,7 +49,6 @@ static void synth_filter_float(FFTContext *imdct,
synth_buf2[i ] = c;
synth_buf2[i + 16] = d;
}
- *synth_buf_offset= (*synth_buf_offset - 32)&511;
}
av_cold void ff_synth_filter_init(SynthFilterContext *c)
diff --git a/libavcodec/synth_filter.h b/libavcodec/synth_filter.h
index b63fd77..a6fbca6 100644
--- a/libavcodec/synth_filter.h
+++ b/libavcodec/synth_filter.h
@@ -24,11 +24,9 @@
#include "fft.h"
typedef struct SynthFilterContext {
- void (*synth_filter_float)(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);
+ void (*synth_filter_float)(float *synth_buf_ptr, float synth_buf2[32],
+ const float window[512],
+ float out[32], intptr_t offset, float scale);
} SynthFilterContext;
void ff_synth_filter_init(SynthFilterContext *c);
diff --git a/libavcodec/x86/fft_init.c b/libavcodec/x86/fft_init.c
index 51c0552..8355d0b 100644
--- a/libavcodec/x86/fft_init.c
+++ b/libavcodec/x86/fft_init.c
@@ -59,31 +59,16 @@ av_cold void ff_fft_init_x86(FFTContext *s)
#if CONFIG_DCA_DECODER
# include "libavcodec/synth_filter.h"
-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);
-
- *synth_buf_offset= (*synth_buf_offset - 32)&511;
-}
+void ff_synth_filter_sse2(float *synth_buf_ptr, float synth_buf2[32],
+ const float window[512],
+ float out[32], intptr_t offset, float scale);
av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
{
int mm_flags = av_get_cpu_flags();
if (EXTERNAL_SSE2(mm_flags)) {
- s->synth_filter_float = synth_filter_sse2;
+ s->synth_filter_float = ff_synth_filter_sse2;
}
}
#endif
diff --git a/libavcodec/x86/synth_filter.asm b/libavcodec/x86/synth_filter.asm
index 831080d..0b8ffd8 100644
--- a/libavcodec/x86/synth_filter.asm
+++ b/libavcodec/x86/synth_filter.asm
@@ -69,11 +69,11 @@ 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)
-cglobal synth_filter_inner, 0,6+4*ARCH_X86_64,7+6*ARCH_X86_64, \
- synth_buf, synth_buf2, window, out, off, scale
+; void ff_synth_filter_sse2(float *synth_buf, float synth_buf2[32],
+; const float window[512], float out[32],
+; intptr_t offset, float scale)
+cglobal synth_filter, 0,6+4*ARCH_X86_64,7+6*ARCH_X86_64, \
+ synth_buf, synth_buf2, window, out, off, scale
%define scale m0
%if ARCH_X86_32 || WIN64
movd scale, scalem
--
1.8.0.msysgit.0
More information about the ffmpeg-devel
mailing list