summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-12-10 02:06:50 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-12-10 02:06:50 +0100
commita93369845783a5a63e713c143cab2c550a6ccd82 (patch)
tree582b1a0ac80490ef54f09287c5613dfdb6154ca6
parentb7d8484f272b7a5a2ed9db76d5182dbd6e3e6992 (diff)
parent30b39164256999efc8d77edc85e2e0b963c24834 (diff)
downloadffmpeg-streaming-a93369845783a5a63e713c143cab2c550a6ccd82.zip
ffmpeg-streaming-a93369845783a5a63e713c143cab2c550a6ccd82.tar.gz
Merge commit '30b39164256999efc8d77edc85e2e0b963c24834'
* commit '30b39164256999efc8d77edc85e2e0b963c24834': ac3dec: make downmix() take array of pointers to channel data Conflicts: libavcodec/ac3dsp.c libavcodec/ac3dsp.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/ac3dec.c14
-rw-r--r--libavcodec/ac3dec.h4
-rw-r--r--libavcodec/ac3dsp.c2
-rw-r--r--libavcodec/ac3dsp.h2
-rw-r--r--libavcodec/x86/ac3dsp_init.c70
5 files changed, 59 insertions, 33 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 064e60d..8e27cf7 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -160,6 +160,8 @@ static av_cold void ac3_tables_init(void)
static av_cold int ac3_decode_init(AVCodecContext *avctx)
{
AC3DecodeContext *s = avctx->priv_data;
+ int i;
+
s->avctx = avctx;
ff_ac3_common_init();
@@ -185,6 +187,12 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
+ for (i = 0; i < AC3_MAX_CHANNELS; i++) {
+ s->outptr[i] = s->output[i];
+ s->xcfptr[i] = s->transform_coeffs[i];
+ s->dlyptr[i] = s->delay[i];
+ }
+
return 0;
}
@@ -1231,18 +1239,18 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
do_imdct(s, s->channels);
if (downmix_output) {
- s->ac3dsp.downmix(s->output, s->downmix_coeffs,
+ s->ac3dsp.downmix(s->outptr, s->downmix_coeffs,
s->out_channels, s->fbw_channels, 256);
}
} else {
if (downmix_output) {
- s->ac3dsp.downmix(s->transform_coeffs + 1, s->downmix_coeffs,
+ s->ac3dsp.downmix(s->xcfptr + 1, s->downmix_coeffs,
s->out_channels, s->fbw_channels, 256);
}
if (downmix_output && !s->downmixed) {
s->downmixed = 1;
- s->ac3dsp.downmix(s->delay, s->downmix_coeffs, s->out_channels,
+ s->ac3dsp.downmix(s->dlyptr, s->downmix_coeffs, s->out_channels,
s->fbw_channels, 128);
}
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index ee27727..18640dd 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -203,6 +203,10 @@ typedef struct AC3DecodeContext {
FmtConvertContext fmt_conv; ///< optimized conversion functions
///@}
+ float *outptr[AC3_MAX_CHANNELS];
+ float *xcfptr[AC3_MAX_CHANNELS];
+ float *dlyptr[AC3_MAX_CHANNELS];
+
///@name Aligned arrays
DECLARE_ALIGNED(16, int, fixed_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< fixed-point transform coefficients
DECLARE_ALIGNED(32, float, transform_coeffs)[AC3_MAX_CHANNELS][AC3_MAX_COEFS]; ///< transform coefficients
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
index 9277411..6df3a68 100644
--- a/libavcodec/ac3dsp.c
+++ b/libavcodec/ac3dsp.c
@@ -214,7 +214,7 @@ static void ac3_sum_square_butterfly_float_c(float sum[4],
}
}
-static void ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
+static void ac3_downmix_c(float **samples, float (*matrix)[2],
int out_ch, int in_ch, int len)
{
int i, j;
diff --git a/libavcodec/ac3dsp.h b/libavcodec/ac3dsp.h
index 7269c57..bafbc89 100644
--- a/libavcodec/ac3dsp.h
+++ b/libavcodec/ac3dsp.h
@@ -132,7 +132,7 @@ typedef struct AC3DSPContext {
void (*sum_square_butterfly_float)(float sum[4], const float *coef0,
const float *coef1, int len);
- void (*downmix)(float (*samples)[256], float (*matrix)[2], int out_ch,
+ void (*downmix)(float **samples, float (*matrix)[2], int out_ch,
int in_ch, int len);
} AC3DSPContext;
diff --git a/libavcodec/x86/ac3dsp_init.c b/libavcodec/x86/ac3dsp_init.c
index e95131e..291bda9 100644
--- a/libavcodec/x86/ac3dsp_init.c
+++ b/libavcodec/x86/ac3dsp_init.c
@@ -51,25 +51,25 @@ extern void ff_ac3_extract_exponents_3dnow(uint8_t *exp, int32_t *coef, int nb_c
extern void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
-#if HAVE_SSE_INLINE
+#if HAVE_SSE_INLINE && HAVE_7REGS
#define IF1(x) x
#define IF0(x)
#define MIX5(mono, stereo) \
__asm__ volatile ( \
- "movss 0(%2), %%xmm5 \n" \
- "movss 8(%2), %%xmm6 \n" \
- "movss 24(%2), %%xmm7 \n" \
+ "movss 0(%1), %%xmm5 \n" \
+ "movss 8(%1), %%xmm6 \n" \
+ "movss 24(%1), %%xmm7 \n" \
"shufps $0, %%xmm5, %%xmm5 \n" \
"shufps $0, %%xmm6, %%xmm6 \n" \
"shufps $0, %%xmm7, %%xmm7 \n" \
"1: \n" \
- "movaps (%0, %1), %%xmm0 \n" \
- "movaps 0x400(%0, %1), %%xmm1 \n" \
- "movaps 0x800(%0, %1), %%xmm2 \n" \
- "movaps 0xc00(%0, %1), %%xmm3 \n" \
- "movaps 0x1000(%0, %1), %%xmm4 \n" \
+ "movaps (%0, %2), %%xmm0 \n" \
+ "movaps (%0, %3), %%xmm1 \n" \
+ "movaps (%0, %4), %%xmm2 \n" \
+ "movaps (%0, %5), %%xmm3 \n" \
+ "movaps (%0, %6), %%xmm4 \n" \
"mulps %%xmm5, %%xmm0 \n" \
"mulps %%xmm6, %%xmm1 \n" \
"mulps %%xmm5, %%xmm2 \n" \
@@ -80,12 +80,17 @@ extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_c
"addps %%xmm3, %%xmm0 \n" \
"addps %%xmm4, %%xmm2 \n" \
mono("addps %%xmm2, %%xmm0 \n") \
- "movaps %%xmm0, (%0, %1) \n" \
- stereo("movaps %%xmm2, 0x400(%0, %1) \n") \
+ "movaps %%xmm0, (%0, %2) \n" \
+ stereo("movaps %%xmm2, (%0, %3) \n") \
"add $16, %0 \n" \
"jl 1b \n" \
: "+&r"(i) \
- : "r"(samples[0] + len), "r"(matrix) \
+ : "r"(matrix), \
+ "r"(samples[0] + len), \
+ "r"(samples[1] + len), \
+ "r"(samples[2] + len), \
+ "r"(samples[3] + len), \
+ "r"(samples[4] + len) \
: XMM_CLOBBERS("%xmm0", "%xmm1", "%xmm2", "%xmm3", \
"%xmm4", "%xmm5", "%xmm6", "%xmm7",) \
"memory" \
@@ -93,38 +98,42 @@ extern void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_c
#define MIX_MISC(stereo) \
__asm__ volatile ( \
+ "mov %5, %2 \n" \
"1: \n" \
+ "mov -%c7(%6, %2, %c8), %3 \n" \
"movaps (%3, %0), %%xmm0 \n" \
stereo("movaps %%xmm0, %%xmm1 \n") \
"mulps %%xmm4, %%xmm0 \n" \
stereo("mulps %%xmm5, %%xmm1 \n") \
- "lea 1024(%3, %0), %1 \n" \
- "mov %5, %2 \n" \
"2: \n" \
- "movaps (%1), %%xmm2 \n" \
+ "mov (%6, %2, %c8), %1 \n" \
+ "movaps (%1, %0), %%xmm2 \n" \
stereo("movaps %%xmm2, %%xmm3 \n") \
- "mulps (%4, %2), %%xmm2 \n" \
- stereo("mulps 16(%4, %2), %%xmm3 \n") \
+ "mulps (%4, %2, 8), %%xmm2 \n" \
+ stereo("mulps 16(%4, %2, 8), %%xmm3 \n") \
"addps %%xmm2, %%xmm0 \n" \
stereo("addps %%xmm3, %%xmm1 \n") \
- "add $1024, %1 \n" \
- "add $32, %2 \n" \
+ "add $4, %2 \n" \
"jl 2b \n" \
- "movaps %%xmm0, (%3, %0) \n" \
- stereo("movaps %%xmm1, 1024(%3, %0) \n") \
+ "mov %5, %2 \n" \
+ stereo("mov (%6, %2, %c8), %1 \n") \
+ "movaps %%xmm0, (%3, %0) \n" \
+ stereo("movaps %%xmm1, (%1, %0) \n") \
"add $16, %0 \n" \
"jl 1b \n" \
- : "+&r"(i), "=&r"(j), "=&r"(k) \
- : "r"(samples[0] + len), "r"(matrix_simd + in_ch), \
- "g"((intptr_t) - 32 * (in_ch - 1)) \
+ : "+&r"(i), "=&r"(j), "=&r"(k), "=&r"(m) \
+ : "r"(matrix_simd + in_ch), \
+ "g"((intptr_t) - 4 * (in_ch - 1)), \
+ "r"(samp + in_ch), \
+ "i"(sizeof(float *)), "i"(sizeof(float *)/4) \
: "memory" \
);
-static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2],
+static void ac3_downmix_sse(float **samples, float (*matrix)[2],
int out_ch, int in_ch, int len)
{
int (*matrix_cmp)[2] = (int(*)[2])matrix;
- intptr_t i, j, k;
+ intptr_t i, j, k, m;
i = -len * sizeof(float);
if (in_ch == 5 && out_ch == 2 &&
@@ -139,6 +148,11 @@ static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2],
MIX5(IF1, IF0);
} else {
DECLARE_ALIGNED(16, float, matrix_simd)[AC3_MAX_CHANNELS][2][4];
+ float *samp[AC3_MAX_CHANNELS];
+
+ for (j = 0; j < in_ch; j++)
+ samp[j] = samples[j] + len;
+
j = 2 * in_ch * sizeof(float);
__asm__ volatile (
"1: \n"
@@ -162,7 +176,7 @@ static void ac3_downmix_sse(float (*samples)[256], float (*matrix)[2],
}
}
-#endif /* HAVE_SSE_INLINE */
+#endif /* HAVE_SSE_INLINE && HAVE_7REGS */
av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
{
@@ -205,7 +219,7 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
}
}
-#if HAVE_SSE_INLINE
+#if HAVE_SSE_INLINE && HAVE_7REGS
if (INLINE_SSE(mm_flags)) {
c->downmix = ac3_downmix_sse;
}
OpenPOWER on IntegriCloud