Commit 8d2eb5fe authored by Mirjana Vulin's avatar Mirjana Vulin Committed by Michael Niedermayer

mips: optimization for float aac decoder (sbr module)

Signed-off-by: 's avatarMirjana Vulin <mvulin@mips.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 67b3fcf6
......@@ -257,8 +257,6 @@ typedef struct ChannelElement {
SpectralBandReplication sbr;
} ChannelElement;
typedef struct AACContext AACContext;
/**
* main AAC context
*/
......
......@@ -44,6 +44,10 @@
#define ENVELOPE_ADJUSTMENT_OFFSET 2
#define NOISE_FLOOR_OFFSET 6.0f
#if ARCH_MIPS
#include "mips/aacsbr_mips.h"
#endif /* ARCH_MIPS */
/**
* SBR VLC tables
*/
......@@ -87,6 +91,8 @@ static const int8_t vlc_sbr_lav[10] =
#define SBR_VLC_ROW(name) \
{ name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
static void aacsbr_func_ptr_init(AACSBRContext *c);
av_cold void ff_aac_sbr_init(void)
{
int n;
......@@ -155,6 +161,7 @@ av_cold void ff_aac_sbr_ctx_init(AACContext *ac, SpectralBandReplication *sbr)
ff_mdct_init(&sbr->mdct_ana, 7, 1, -2.0 * 32768.0);
ff_ps_ctx_init(&sbr->ps);
ff_sbrdsp_init(&sbr->dsp);
aacsbr_func_ptr_init(&sbr->c);
}
av_cold void ff_aac_sbr_ctx_close(SpectralBandReplication *sbr)
......@@ -1157,6 +1164,7 @@ static void sbr_dequant(SpectralBandReplication *sbr, int id_aac)
* @param x pointer to the beginning of the first sample window
* @param W array of complex-valued samples split into subbands
*/
#ifndef sbr_qmf_analysis
static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct,
SBRDSPContext *sbrdsp, const float *in, float *x,
float z[320], float W[2][32][32][2], int buf_idx)
......@@ -1174,11 +1182,13 @@ static void sbr_qmf_analysis(AVFloatDSPContext *dsp, FFTContext *mdct,
x += 32;
}
}
#endif
/**
* Synthesis QMF Bank (14496-3 sp04 p206) and Downsampled Synthesis QMF Bank
* (14496-3 sp04 p206)
*/
#ifndef sbr_qmf_synthesis
static void sbr_qmf_synthesis(FFTContext *mdct,
SBRDSPContext *sbrdsp, AVFloatDSPContext *dsp,
float *out, float X[2][38][64],
......@@ -1224,6 +1234,7 @@ static void sbr_qmf_synthesis(FFTContext *mdct,
out += 64 >> div;
}
}
#endif
/** High Frequency Generation (14496-3 sp04 p214+) and Inverse Filtering
* (14496-3 sp04 p214)
......@@ -1672,10 +1683,10 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
sbr_qmf_analysis(&ac->fdsp, &sbr->mdct_ana, &sbr->dsp, ch ? R : L, sbr->data[ch].analysis_filterbank_samples,
(float*)sbr->qmf_filter_scratch,
sbr->data[ch].W, sbr->data[ch].Ypos);
sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W, sbr->data[ch].Ypos);
sbr->c.sbr_lf_gen(ac, sbr, sbr->X_low, sbr->data[ch].W, sbr->data[ch].Ypos);
sbr->data[ch].Ypos ^= 1;
if (sbr->start) {
sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]);
sbr->c.sbr_hf_inverse_filter(&sbr->dsp, sbr->alpha0, sbr->alpha1, sbr->X_low, sbr->k[0]);
sbr_chirp(sbr, &sbr->data[ch]);
sbr_hf_gen(ac, sbr, sbr->X_high, sbr->X_low, sbr->alpha0, sbr->alpha1,
sbr->data[ch].bw_array, sbr->data[ch].t_env,
......@@ -1686,14 +1697,14 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
if (!err) {
sbr_env_estimate(sbr->e_curr, sbr->X_high, sbr, &sbr->data[ch]);
sbr_gain_calc(ac, sbr, &sbr->data[ch], sbr->data[ch].e_a);
sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos],
sbr->c.sbr_hf_assemble(sbr->data[ch].Y[sbr->data[ch].Ypos],
sbr->X_high, sbr, &sbr->data[ch],
sbr->data[ch].e_a);
}
}
/* synthesis */
sbr_x_gen(sbr, sbr->X[ch],
sbr->c.sbr_x_gen(sbr, sbr->X[ch],
sbr->data[ch].Y[1-sbr->data[ch].Ypos],
sbr->data[ch].Y[ sbr->data[ch].Ypos],
sbr->X_low, ch);
......@@ -1720,3 +1731,14 @@ void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
&sbr->data[1].synthesis_filterbank_samples_offset,
downsampled);
}
static void aacsbr_func_ptr_init(AACSBRContext *c)
{
c->sbr_lf_gen = sbr_lf_gen;
c->sbr_hf_assemble = sbr_hf_assemble;
c->sbr_x_gen = sbr_x_gen;
c->sbr_hf_inverse_filter = sbr_hf_inverse_filter;
if(ARCH_MIPS)
ff_aacsbr_func_ptr_init_mips(c);
}
......@@ -46,4 +46,6 @@ int ff_decode_sbr_extension(AACContext *ac, SpectralBandReplication *sbr,
void ff_sbr_apply(AACContext *ac, SpectralBandReplication *sbr, int id_aac,
float* L, float *R);
void ff_aacsbr_func_ptr_init_mips(AACSBRContext *c);
#endif /* AVCODEC_AACSBR_H */
......@@ -13,4 +13,6 @@ OBJS-$(CONFIG_FFT) += mips/fft_init_table.o
MIPSFPU-OBJS-$(CONFIG_FFT) += mips/fft_mips.o
MIPSFPU-OBJS += mips/fmtconvert_mips.o
OBJS-$(CONFIG_AC3DSP) += mips/ac3dsp_mips.o
OBJS-$(CONFIG_AAC_DECODER) += mips/aacdec_mips.o
OBJS-$(CONFIG_AAC_DECODER) += mips/aacdec_mips.o \
mips/aacsbr_mips.o \
mips/sbrdsp_mips.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -34,6 +34,8 @@
#include "aacps.h"
#include "sbrdsp.h"
typedef struct AACContext AACContext;
/**
* Spectral Band Replication header - spectrum parameters that invoke a reset if they differ from the previous header.
*/
......@@ -108,10 +110,31 @@ typedef struct SBRData {
/** @} */
} SBRData;
typedef struct SpectralBandReplication SpectralBandReplication;
/**
* aacsbr functions pointers
*/
typedef struct AACSBRContext {
int (*sbr_lf_gen)(AACContext *ac, SpectralBandReplication *sbr,
float X_low[32][40][2], const float W[2][32][32][2],
int buf_idx);
void (*sbr_hf_assemble)(float Y1[38][64][2],
const float X_high[64][40][2],
SpectralBandReplication *sbr, SBRData *ch_data,
const int e_a[2]);
int (*sbr_x_gen)(SpectralBandReplication *sbr, float X[2][38][64],
const float Y0[38][64][2], const float Y1[38][64][2],
const float X_low[32][40][2], int ch);
void (*sbr_hf_inverse_filter)(SBRDSPContext *dsp,
float (*alpha0)[2], float (*alpha1)[2],
const float X_low[32][40][2], int k0);
} AACSBRContext;
/**
* Spectral Band Replication
*/
typedef struct SpectralBandReplication {
struct SpectralBandReplication {
int sample_rate;
int start;
int reset;
......@@ -184,6 +207,7 @@ typedef struct SpectralBandReplication {
FFTContext mdct_ana;
FFTContext mdct;
SBRDSPContext dsp;
} SpectralBandReplication;
AACSBRContext c;
};
#endif /* AVCODEC_SBR_H */
......@@ -245,4 +245,6 @@ av_cold void ff_sbrdsp_init(SBRDSPContext *s)
ff_sbrdsp_init_arm(s);
if (ARCH_X86)
ff_sbrdsp_init_x86(s);
if (ARCH_MIPS)
ff_sbrdsp_init_mips(s);
}
......@@ -47,5 +47,6 @@ extern const float ff_sbr_noise_table[][2];
void ff_sbrdsp_init(SBRDSPContext *s);
void ff_sbrdsp_init_arm(SBRDSPContext *s);
void ff_sbrdsp_init_x86(SBRDSPContext *s);
void ff_sbrdsp_init_mips(SBRDSPContext *s);
#endif /* AVCODEC_SBRDSP_H */
......@@ -331,6 +331,45 @@ static void butterflies_float_mips(float *av_restrict v1, float *av_restrict v2,
: "memory"
);
}
static void vector_fmul_reverse_mips(float *dst, const float *src0, const float *src1, int len){
int i;
float temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7;
src1 += len-1;
for(i=0; i<(len>>2); i++)
{
/* loop unrolled 4 times */
__asm__ volatile(
"lwc1 %[temp0], 0(%[src0]) \n\t"
"lwc1 %[temp1], 0(%[src1]) \n\t"
"lwc1 %[temp2], 4(%[src0]) \n\t"
"lwc1 %[temp3], -4(%[src1]) \n\t"
"lwc1 %[temp4], 8(%[src0]) \n\t"
"lwc1 %[temp5], -8(%[src1]) \n\t"
"lwc1 %[temp6], 12(%[src0]) \n\t"
"lwc1 %[temp7], -12(%[src1]) \n\t"
"mul.s %[temp0], %[temp1], %[temp0] \n\t"
"mul.s %[temp2], %[temp3], %[temp2] \n\t"
"mul.s %[temp4], %[temp5], %[temp4] \n\t"
"mul.s %[temp6], %[temp7], %[temp6] \n\t"
"addiu %[src0], %[src0], 16 \n\t"
"addiu %[src1], %[src1], -16 \n\t"
"addiu %[dst], %[dst], 16 \n\t"
"swc1 %[temp0], -16(%[dst]) \n\t"
"swc1 %[temp2], -12(%[dst]) \n\t"
"swc1 %[temp4], -8(%[dst]) \n\t"
"swc1 %[temp6], -4(%[dst]) \n\t"
: [dst]"+r"(dst), [src0]"+r"(src0), [src1]"+r"(src1),
[temp0]"=&f"(temp0), [temp1]"=&f"(temp1),[temp2]"=&f"(temp2),
[temp3]"=&f"(temp3), [temp4]"=&f"(temp4), [temp5]"=&f"(temp5),
[temp6]"=&f"(temp6), [temp7]"=&f"(temp7)
:
: "memory"
);
}
}
#endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */
void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp) {
......@@ -339,5 +378,6 @@ void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp) {
fdsp->vector_fmul_scalar = vector_fmul_scalar_mips;
fdsp->vector_fmul_window = vector_fmul_window_mips;
fdsp->butterflies_float = butterflies_float_mips;
fdsp->vector_fmul_reverse = vector_fmul_reverse_mips;
#endif /* HAVE_INLINE_ASM && HAVE_MIPSFPU */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment