[FFmpeg-devel] [PATCH 4/4] libavcodec: Implementation of AAC_fixed_decoder (PS-module)
Nedeljko Babic
nedeljko.babic at imgtec.com
Wed Sep 18 15:38:33 CEST 2013
From: Mirjana Vulin <mirjana.vulin at imgtec.com>
Signed-off-by: Mirjana Vulin <mirjana.vulin at imgtec.com>
---
libavcodec/Makefile | 13 +-
libavcodec/aacps.c | 356 ++++++++++++++-----------------
libavcodec/aacps.h | 48 +++--
libavcodec/aacps_fixed.c | 210 ++++++++++++++++++
libavcodec/aacps_fixed_tablegen.c | 94 ++++++++
libavcodec/aacps_fixed_tablegen.h | 427 +++++++++++++++++++++++++++++++++++++
libavcodec/aacps_float.c | 181 ++++++++++++++++
libavcodec/aacpsdata.c | 6 +-
libavcodec/aacpsdsp.c | 258 ++++++++++++++++++++++-
libavcodec/aacpsdsp.h | 19 ++
10 files changed, 1389 insertions(+), 223 deletions(-)
create mode 100644 libavcodec/aacps_fixed.c
create mode 100644 libavcodec/aacps_fixed_tablegen.c
create mode 100644 libavcodec/aacps_fixed_tablegen.h
create mode 100644 libavcodec/aacps_float.c
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fda360f..f7a6fce 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -85,12 +85,12 @@ OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
-OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \
+OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \
aacadtsdec.o mpeg4audio.o kbdwin.o \
sbrdsp.o aacpsdsp.o
-OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o \
+OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \
aacadtsdec.o mpeg4audio.o kbdwin.o \
- sbrdsp.o
+ sbrdsp.o aacpsdsp.o
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o \
aacpsy.o aactab.o \
psymodel.o iirfilter.o \
@@ -840,6 +840,7 @@ TOOLS = fourcc2pixfmt
HOSTPROGS = aac_tablegen \
aacps_tablegen \
+ aacps_fixed_tablegen \
cbrt_tablegen \
cbrt_fixed_tablegen \
cos_tablegen \
@@ -867,7 +868,8 @@ else
$(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=0
endif
-GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aac_tables.h dv_tables.h \
+GEN_HEADERS = cbrt_tables.h cbrt_fixed_tables.h aacps_tables.h aacps_fixed_tables.h \
+ aac_tables.h dv_tables.h \
sinewin_tables.h sinewin_fixed_tables.h mpegaudio_tables.h motionpixels_tables.h \
pcm_tables.h qdm2_tables.h
GEN_HEADERS := $(addprefix $(SUBDIR), $(GEN_HEADERS))
@@ -878,7 +880,8 @@ $(GEN_HEADERS): $(SUBDIR)%_tables.h: $(SUBDIR)%_tablegen$(HOSTEXESUF)
ifdef CONFIG_HARDCODED_TABLES
$(SUBDIR)aacdec.o: $(SUBDIR)cbrt_tables.h
$(SUBDIR)aacdec_fixed.o: $(SUBDIR)cbrt_fixed_tables.h
-$(SUBDIR)aacps.o: $(SUBDIR)aacps_tables.h
+$(SUBDIR)aacps_float.o: $(SUBDIR)aacps_tables.h
+$(SUBDIR)aacps_fixed.o: $(SUBDIR)aacps_fixed_tables.h
$(SUBDIR)aactab.o: $(SUBDIR)aac_tables.h
$(SUBDIR)aactab_fixed.o: $(SUBDIR)aac_fixed_tables.h
$(SUBDIR)dv.o: $(SUBDIR)dv_tables.h
diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c
index 9abc296..a9f4ff3 100644
--- a/libavcodec/aacps.c
+++ b/libavcodec/aacps.c
@@ -21,12 +21,17 @@
#include <stdint.h>
#include "libavutil/common.h"
-#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "avcodec.h"
#include "get_bits.h"
#include "aacps.h"
+#if CONFIG_AAC_FIXED
+#include "aacps_fixed_tablegen.h"
+#include "dsputil.h"
+#else
+#include "libavutil/internal.h"
#include "aacps_tablegen.h"
+#endif /* CONFIG_AAC_FIXED */
#include "aacpsdata.c"
#define PS_BASELINE 0 ///< Operate in Baseline PS mode
@@ -118,6 +123,8 @@ READ_PAR_DATA(iid, huff_offset[table_idx], 0, FFABS(ps->iid_par[e][b]) > 7
READ_PAR_DATA(icc, huff_offset[table_idx], 0, ps->icc_par[e][b] > 7U)
READ_PAR_DATA(ipdopd, 0, 0x07, 0)
+static void AAC_RENAME(stereo_processing)(PSContext *ps, INTFLOAT (*l)[32][2], INTFLOAT (*r)[32][2], int is34);
+
static int ps_read_extension_data(GetBitContext *gb, PSContext *ps, int ps_extension_id)
{
int e;
@@ -148,7 +155,7 @@ static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist)
}
}
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
+int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb_host, PSContext *ps, int bits_left)
{
int e;
int bit_count_start = get_bits_count(gb_host);
@@ -302,9 +309,38 @@ err:
/** Split one subband into 2 subsubbands with a symmetric real filter.
* The filter must have its non-center even coefficients equal to zero. */
-static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[8], int len, int reverse)
+static void AAC_RENAME(hybrid2_re)(INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT filter[8], int len, int reverse)
{
int i, j;
+#if CONFIG_AAC_FIXED
+ long long accu_re, accu_im;
+
+ for (i = 0; i < len; i++, in++) {
+ int re_in; //real inphase
+ int re_op; //real out of phase
+ int im_in; //imag inphase
+ int im_op; //imag out of phase
+
+ accu_re = (long long)filter[6] * in[6][0];
+ re_in = (int)((accu_re + 0x40000000) >> 31);
+ accu_im = (long long)filter[6] * in[6][1];
+ im_in = (int)((accu_im + 0x40000000) >> 31);
+
+ accu_re = 0;
+ accu_im = 0;
+ for (j = 0; j < 6; j += 2) {
+ accu_re += (long long)filter[j+1] * (in[j+1][0] + in[12-j-1][0]);
+ accu_im += (long long)filter[j+1] * (in[j+1][1] + in[12-j-1][1]);
+ }
+ re_op = (int)((accu_re + 0x40000000) >> 31);
+ im_op = (int)((accu_im + 0x40000000) >> 31);
+
+ out[ reverse][i][0] = re_in + re_op;
+ out[ reverse][i][1] = im_in + im_op;
+ out[!reverse][i][0] = re_in - re_op;
+ out[!reverse][i][1] = im_in - im_op;
+ }
+#else
for (i = 0; i < len; i++, in++) {
float re_in = filter[6] * in[6][0]; //real inphase
float re_op = 0.0f; //real out of phase
@@ -319,17 +355,18 @@ static void hybrid2_re(float (*in)[2], float (*out)[32][2], const float filter[8
out[!reverse][i][0] = re_in - re_op;
out[!reverse][i][1] = im_in - im_op;
}
+#endif /* CONFIG_AAC_FIXED */
}
/** Split one subband into 6 subsubbands with a complex filter */
-static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], const float (*filter)[8][2], int len)
+static void hybrid6_cx(PSDSPContext *dsp, INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT (*filter)[8][2], int len)
{
int i;
int N = 8;
- LOCAL_ALIGNED_16(float, temp, [8], [2]);
+ LOCAL_ALIGNED_16(INTFLOAT, temp, [8], [2]);
for (i = 0; i < len; i++, in++) {
- dsp->hybrid_analysis(temp, in, filter, 1, N);
+ dsp->AAC_RENAME(hybrid_analysis)(temp, in, filter, 1, N);
out[0][i][0] = temp[6][0];
out[0][i][1] = temp[6][1];
out[1][i][0] = temp[7][0];
@@ -345,17 +382,17 @@ static void hybrid6_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], c
}
}
-static void hybrid4_8_12_cx(PSDSPContext *dsp, float (*in)[2], float (*out)[32][2], const float (*filter)[8][2], int N, int len)
+static void hybrid4_8_12_cx(PSDSPContext *dsp, INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], const INTFLOAT (*filter)[8][2], int N, int len)
{
int i;
for (i = 0; i < len; i++, in++) {
- dsp->hybrid_analysis(out[0] + i, in, filter, 32, N);
+ dsp->AAC_RENAME(hybrid_analysis)(out[0] + i, in, filter, 32, N);
}
}
-static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2],
- float in[5][44][2], float L[2][38][64],
+static void hybrid_analysis(PSDSPContext *dsp, INTFLOAT out[91][32][2],
+ INTFLOAT in[5][44][2], INTFLOAT L[2][38][64],
int is34, int len)
{
int i, j;
@@ -371,12 +408,12 @@ static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2],
hybrid4_8_12_cx(dsp, in[2], out+20, f34_2_4, 4, len);
hybrid4_8_12_cx(dsp, in[3], out+24, f34_2_4, 4, len);
hybrid4_8_12_cx(dsp, in[4], out+28, f34_2_4, 4, len);
- dsp->hybrid_analysis_ileave(out + 27, L, 5, len);
+ dsp->AAC_RENAME(hybrid_analysis_ileave)(out + 27, L, 5, len);
} else {
hybrid6_cx(dsp, in[0], out, f20_0_8, len);
- hybrid2_re(in[1], out+6, g1_Q2, len, 1);
- hybrid2_re(in[2], out+8, g1_Q2, len, 0);
- dsp->hybrid_analysis_ileave(out + 7, L, 3, len);
+ AAC_RENAME(hybrid2_re)(in[1], out+6, g1_Q2, len, 1);
+ AAC_RENAME(hybrid2_re)(in[2], out+8, g1_Q2, len, 0);
+ dsp->AAC_RENAME(hybrid_analysis_ileave)(out + 7, L, 3, len);
}
//update in_buf
for (i = 0; i < 5; i++) {
@@ -384,8 +421,8 @@ static void hybrid_analysis(PSDSPContext *dsp, float out[91][32][2],
}
}
-static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64],
- float in[91][32][2], int is34, int len)
+static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64],
+ INTFLOAT in[91][32][2], int is34, int len)
{
int i, n;
if (is34) {
@@ -409,7 +446,7 @@ static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64],
out[1][n][4] += in[28+i][n][1];
}
}
- dsp->hybrid_synthesis_deint(out, in + 27, 5, len);
+ dsp->AAC_RENAME(hybrid_synthesis_deint)(out, in + 27, 5, len);
} else {
for (n = 0; n < len; n++) {
out[0][n][0] = in[0][n][0] + in[1][n][0] + in[2][n][0] +
@@ -421,12 +458,12 @@ static void hybrid_synthesis(PSDSPContext *dsp, float out[2][38][64],
out[0][n][2] = in[8][n][0] + in[9][n][0];
out[1][n][2] = in[8][n][1] + in[9][n][1];
}
- dsp->hybrid_synthesis_deint(out, in + 7, 3, len);
+ dsp->AAC_RENAME(hybrid_synthesis_deint)(out, in + 7, 3, len);
}
}
/// All-pass filter decay slope
-#define DECAY_SLOPE 0.05f
+#define DECAY_SLOPE Q30(0.05f)
/// Number of frequency bands that can be addressed by the parameter index, b(k)
static const int NR_PAR_BANDS[] = { 20, 34 };
/// Number of frequency bands that can be addressed by the sub subband index, k
@@ -479,8 +516,36 @@ static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full)
}
}
-static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC])
+static void AAC_RENAME(map_val_34_to_20)(INTFLOAT par[PS_MAX_NR_IIDICC])
{
+#if CONFIG_AAC_FIXED
+ long long accu;
+
+ accu = (long long)(par[ 0] + (par[ 1]>>1)) * 1431655765;
+ par[ 0] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)((par[ 1]>>1) + par[ 2]) * 1431655765;
+ par[ 1] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)(par[ 3] + (par[ 4]>>1)) * 1431655765;
+ par[ 2] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)((par[ 4]>>1) + par[ 5]) * 1431655765;
+ par[ 3] = (int)((accu + 0x40000000) >> 31);
+ par[ 4] = ((par[ 6]>>1) + (par[ 7]>>1));
+ par[ 5] = ((par[ 8]>>1) + (par[ 9]>>1));
+ par[ 6] = par[10];
+ par[ 7] = par[11];
+ par[ 8] = ((par[12]>>1) + (par[13]>>1));
+ par[ 9] = ((par[14]>>1) + (par[15]>>1));
+ par[10] = par[16];
+ par[11] = par[17];
+ par[12] = par[18];
+ par[13] = par[19];
+ par[14] = ((par[20]>>1) + (par[21]>>1));
+ par[15] = ((par[22]>>1) + (par[23]>>1));
+ par[16] = ((par[24]>>1) + (par[25]>>1));
+ par[17] = ((par[26]>>1) + (par[27]>>1));
+ par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2));
+ par[19] = ((par[32]>>1) + (par[33]>>1));
+#else
par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f;
par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f;
par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f;
@@ -501,6 +566,7 @@ static void map_val_34_to_20(float par[PS_MAX_NR_IIDICC])
par[17] = ( par[26] + par[27]) * 0.5f;
par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f;
par[19] = ( par[32] + par[33]) * 0.5f;
+#endif /* CONFIG_AAC_FIXED */
}
static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full)
@@ -585,7 +651,7 @@ static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full)
par_mapped[ 0] = par[ 0];
}
-static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
+static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC])
{
par[33] = par[19];
par[32] = par[19];
@@ -616,14 +682,32 @@ static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
par[ 7] = par[ 4];
par[ 6] = par[ 4];
par[ 5] = par[ 3];
+#if CONFIG_AAC_FIXED
+ par[ 4] = (par[ 2] >> 1) + (par[ 3] >> 1);
+ par[ 3] = par[ 2];
+ par[ 2] = par[ 1];
+ par[ 1] = (par[ 0] >> 1) + (par[ 1] >> 1);
+ par[ 0] = par[ 0];
+#else
par[ 4] = (par[ 2] + par[ 3]) * 0.5f;
par[ 3] = par[ 2];
par[ 2] = par[ 1];
par[ 1] = (par[ 0] + par[ 1]) * 0.5f;
+#endif /* CONFIG_AAC_FIXED */
}
-static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[32][2], int is34)
+static void AAC_RENAME(decorrelation)(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34)
{
+#if CONFIG_AAC_FIXED
+ int power[34][PS_QMF_TIME_SLOTS];
+ int transient_gain[34][PS_QMF_TIME_SLOTS];
+ int *peak_decay_nrg = ps->peak_decay_nrg;
+ int *power_smooth = ps->power_smooth;
+ int *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
+ int (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
+ int (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
+ const int peak_decay_factor = 1644818582;
+#else
LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]);
LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
float *peak_decay_nrg = ps->peak_decay_nrg;
@@ -631,10 +715,11 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3
float *peak_decay_diff_smooth = ps->peak_decay_diff_smooth;
float (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay;
float (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay;
- const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
const float peak_decay_factor = 0.76592833836465f;
const float transient_impact = 1.5f;
const float a_smooth = 0.25f; ///< Smoothing coefficient
+#endif /* CONFIG_AAC_FIXED */
+ const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
int i, k, m, n;
int n0 = 0, nL = 32;
@@ -650,10 +735,37 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3
for (k = 0; k < NR_BANDS[is34]; k++) {
int i = k_to_i[k];
- ps->dsp.add_squares(power[i], s[k], nL - n0);
+ ps->dsp.AAC_RENAME(add_squares)(power[i], s[k], nL - n0);
}
//Transient detection
+#if CONFIG_AAC_FIXED
+ for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
+ for (n = n0; n < nL; n++) {
+ long long accu;
+ int decayed_peak;
+ int denom;
+
+ accu = (long long)peak_decay_factor * peak_decay_nrg[i];
+ decayed_peak = (int)((accu + 0x40000000) >> 31);
+ peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]);
+ power_smooth[i] += (power[i][n] - power_smooth[i] + 2) >> 2;
+ peak_decay_diff_smooth[i] += (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i] + 2) >> 2;
+ denom = peak_decay_diff_smooth[i] + (peak_decay_diff_smooth[i] >> 1);
+ if (denom > power_smooth[i]) {
+ int p = power_smooth[i];
+ while (denom < 0x40000000) {
+ denom <<= 1;
+ p <<= 1;
+ }
+ transient_gain[i][n] = p / (denom >> 16);
+ }
+ else {
+ transient_gain[i][n] = 1 << 16;
+ }
+ }
+ }
+#else
for (i = 0; i < NR_PAR_BANDS[is34]; i++) {
for (n = n0; n < nL; n++) {
float decayed_peak = peak_decay_factor * peak_decay_nrg[i];
@@ -667,6 +779,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3
}
}
+#endif /* CONFIG_AAC_FIXED */
//Decorrelation and transient reduction
// PS_AP_LINKS - 1
// -----
@@ -677,23 +790,37 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3
//d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z]
for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) {
int b = k_to_i[k];
+#if CONFIG_AAC_FIXED
+ int g_decay_slope;
+
+ if (k - DECAY_CUTOFF[is34] <= 0) {
+ g_decay_slope = 1 << 30;
+ }
+ else if (k - DECAY_CUTOFF[is34] >= 20) {
+ g_decay_slope = 0;
+ }
+ else {
+ g_decay_slope = (1 << 30) - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
+ }
+#else
float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]);
g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f);
+#endif /* CONFIG_AAC_FIXED */
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
for (m = 0; m < PS_AP_LINKS; m++) {
memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0]));
}
- ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k],
- phi_fract[is34][k], Q_fract_allpass[is34][k],
- transient_gain[b], g_decay_slope, nL - n0);
+ ps->dsp.AAC_RENAME(decorrelate)(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k],
+ phi_fract[is34][k], Q_fract_allpass[is34][k],
+ transient_gain[b], g_decay_slope, nL - n0);
}
for (; k < SHORT_DELAY_BAND[is34]; k++) {
int i = k_to_i[k];
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
//H = delay 14
- ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 14,
+ ps->dsp.AAC_RENAME(mul_pair_single)(out[k], delay[k] + PS_MAX_DELAY - 14,
transient_gain[i], nL - n0);
}
for (; k < NR_BANDS[is34]; k++) {
@@ -701,7 +828,7 @@ static void decorrelation(PSContext *ps, float (*out)[32][2], const float (*s)[3
memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0]));
memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0]));
//H = delay 1
- ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 1,
+ ps->dsp.AAC_RENAME(mul_pair_single)(out[k], delay[k] + PS_MAX_DELAY - 1,
transient_gain[i], nL - n0);
}
}
@@ -744,167 +871,10 @@ static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC],
}
}
-static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34)
-{
- int e, b, k;
-
- float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
- float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
- float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
- float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
- int8_t *opd_hist = ps->opd_hist;
- int8_t *ipd_hist = ps->ipd_hist;
- int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
- int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
- int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
- int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
- int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
- const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
- const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
-
- //Remapping
- if (ps->num_env_old) {
- memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
- memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
- memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
- memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
- memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
- memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
- memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
- memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
- }
-
- if (is34) {
- remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
- remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
- if (ps->enable_ipdopd) {
- remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- }
- if (!ps->is34bands_old) {
- map_val_20_to_34(H11[0][0]);
- map_val_20_to_34(H11[1][0]);
- map_val_20_to_34(H12[0][0]);
- map_val_20_to_34(H12[1][0]);
- map_val_20_to_34(H21[0][0]);
- map_val_20_to_34(H21[1][0]);
- map_val_20_to_34(H22[0][0]);
- map_val_20_to_34(H22[1][0]);
- ipdopd_reset(ipd_hist, opd_hist);
- }
- } else {
- remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
- remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
- if (ps->enable_ipdopd) {
- remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
- }
- if (ps->is34bands_old) {
- map_val_34_to_20(H11[0][0]);
- map_val_34_to_20(H11[1][0]);
- map_val_34_to_20(H12[0][0]);
- map_val_34_to_20(H12[1][0]);
- map_val_34_to_20(H21[0][0]);
- map_val_34_to_20(H21[1][0]);
- map_val_34_to_20(H22[0][0]);
- map_val_34_to_20(H22[1][0]);
- ipdopd_reset(ipd_hist, opd_hist);
- }
- }
-
- //Mixing
- for (e = 0; e < ps->num_env; e++) {
- for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
- float h11, h12, h21, h22;
- h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
- h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
- h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
- h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
-
- if (!PS_BASELINE && ps->enable_ipdopd && 2*b <= NR_PAR_BANDS[is34]) {
- //The spec say says to only run this smoother when enable_ipdopd
- //is set but the reference decoder appears to run it constantly
- float h11i, h12i, h21i, h22i;
- float ipd_adj_re, ipd_adj_im;
- int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
- int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
- float opd_re = pd_re_smooth[opd_idx];
- float opd_im = pd_im_smooth[opd_idx];
- float ipd_re = pd_re_smooth[ipd_idx];
- float ipd_im = pd_im_smooth[ipd_idx];
- opd_hist[b] = opd_idx & 0x3F;
- ipd_hist[b] = ipd_idx & 0x3F;
-
- ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
- ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
- h11i = h11 * opd_im;
- h11 = h11 * opd_re;
- h12i = h12 * ipd_adj_im;
- h12 = h12 * ipd_adj_re;
- h21i = h21 * opd_im;
- h21 = h21 * opd_re;
- h22i = h22 * ipd_adj_im;
- h22 = h22 * ipd_adj_re;
- H11[1][e+1][b] = h11i;
- H12[1][e+1][b] = h12i;
- H21[1][e+1][b] = h21i;
- H22[1][e+1][b] = h22i;
- }
- H11[0][e+1][b] = h11;
- H12[0][e+1][b] = h12;
- H21[0][e+1][b] = h21;
- H22[0][e+1][b] = h22;
- }
- for (k = 0; k < NR_BANDS[is34]; k++) {
- float h[2][4];
- float h_step[2][4];
- int start = ps->border_position[e];
- int stop = ps->border_position[e+1];
- float width = 1.f / (stop - start);
- b = k_to_i[k];
- h[0][0] = H11[0][e][b];
- h[0][1] = H12[0][e][b];
- h[0][2] = H21[0][e][b];
- h[0][3] = H22[0][e][b];
- if (!PS_BASELINE && ps->enable_ipdopd) {
- //Is this necessary? ps_04_new seems unchanged
- if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
- h[1][0] = -H11[1][e][b];
- h[1][1] = -H12[1][e][b];
- h[1][2] = -H21[1][e][b];
- h[1][3] = -H22[1][e][b];
- } else {
- h[1][0] = H11[1][e][b];
- h[1][1] = H12[1][e][b];
- h[1][2] = H21[1][e][b];
- h[1][3] = H22[1][e][b];
- }
- }
- //Interpolation
- h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width;
- h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width;
- h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width;
- h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width;
- if (!PS_BASELINE && ps->enable_ipdopd) {
- h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width;
- h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width;
- h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width;
- h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width;
- }
- ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd](
- l[k] + start + 1, r[k] + start + 1,
- h, h_step, stop - start);
- }
- }
-}
-
-int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top)
+int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top)
{
- LOCAL_ALIGNED_16(float, Lbuf, [91], [32][2]);
- LOCAL_ALIGNED_16(float, Rbuf, [91], [32][2]);
+ LOCAL_ALIGNED_16(INTFLOAT, Lbuf, [91], [32][2]);
+ LOCAL_ALIGNED_16(INTFLOAT, Rbuf, [91], [32][2]);
const int len = 32;
int is34 = ps->is34bands;
@@ -914,8 +884,8 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float
memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0]));
hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len);
- decorrelation(ps, Rbuf, Lbuf, is34);
- stereo_processing(ps, Lbuf, Rbuf, is34);
+ AAC_RENAME(decorrelation)(ps, Rbuf, Lbuf, is34);
+ AAC_RENAME(stereo_processing)(ps, Lbuf, Rbuf, is34);
hybrid_synthesis(&ps->dsp, L, Lbuf, is34, len);
hybrid_synthesis(&ps->dsp, R, Rbuf, is34, len);
@@ -931,7 +901,7 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float
#define PS_VLC_ROW(name) \
{ name ## _codes, name ## _bits, sizeof(name ## _codes), sizeof(name ## _codes[0]) }
-av_cold void ff_ps_init(void) {
+av_cold void AAC_RENAME(ff_ps_init)(void) {
// Syntax initialization
static const struct {
const void *ps_codes, *ps_bits;
@@ -963,7 +933,7 @@ av_cold void ff_ps_init(void) {
ps_tableinit();
}
-av_cold void ff_ps_ctx_init(PSContext *ps)
+av_cold void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps)
{
ff_psdsp_init(&ps->dsp);
}
diff --git a/libavcodec/aacps.h b/libavcodec/aacps.h
index 29323ff..05c7e51 100644
--- a/libavcodec/aacps.h
+++ b/libavcodec/aacps.h
@@ -28,6 +28,26 @@
#include "avcodec.h"
#include "get_bits.h"
+#ifndef CONFIG_AAC_FIXED
+#define CONFIG_AAC_FIXED 0
+#endif
+
+#if CONFIG_AAC_FIXED
+
+#define INTFLOAT int
+#define AAC_RENAME(x) x ## _fixed
+#define Q30(x) (int)((x)*1073741824.0 + 0.5)
+#define Q31(x) (int)((x)*2147483648.0 + 0.5)
+
+#else
+
+#define INTFLOAT float
+#define AAC_RENAME(x) x
+#define Q30(x) x
+#define Q31(x) x
+
+#endif /* CONFIG_AAC_FIXED */
+
#define PS_MAX_NUM_ENV 5
#define PS_MAX_NR_IIDICC 34
#define PS_MAX_NR_IPDOPD 17
@@ -61,24 +81,24 @@ typedef struct PSContext {
int is34bands;
int is34bands_old;
- DECLARE_ALIGNED(16, float, in_buf)[5][44][2];
- DECLARE_ALIGNED(16, float, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
- DECLARE_ALIGNED(16, float, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2];
- DECLARE_ALIGNED(16, float, peak_decay_nrg)[34];
- DECLARE_ALIGNED(16, float, power_smooth)[34];
- DECLARE_ALIGNED(16, float, peak_decay_diff_smooth)[34];
- DECLARE_ALIGNED(16, float, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- DECLARE_ALIGNED(16, float, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- DECLARE_ALIGNED(16, float, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
- DECLARE_ALIGNED(16, float, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
+ DECLARE_ALIGNED(16, INTFLOAT, in_buf)[5][44][2];
+ DECLARE_ALIGNED(16, INTFLOAT, delay)[PS_MAX_SSB][PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2];
+ DECLARE_ALIGNED(16, INTFLOAT, ap_delay)[PS_MAX_AP_BANDS][PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2];
+ DECLARE_ALIGNED(16, INTFLOAT, peak_decay_nrg)[34];
+ DECLARE_ALIGNED(16, INTFLOAT, power_smooth)[34];
+ DECLARE_ALIGNED(16, INTFLOAT, peak_decay_diff_smooth)[34];
+ DECLARE_ALIGNED(16, INTFLOAT, H11)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
+ DECLARE_ALIGNED(16, INTFLOAT, H12)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
+ DECLARE_ALIGNED(16, INTFLOAT, H21)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
+ DECLARE_ALIGNED(16, INTFLOAT, H22)[2][PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC];
int8_t opd_hist[PS_MAX_NR_IIDICC];
int8_t ipd_hist[PS_MAX_NR_IIDICC];
PSDSPContext dsp;
} PSContext;
-void ff_ps_init(void);
-void ff_ps_ctx_init(PSContext *ps);
-int ff_ps_read_data(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left);
-int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, float L[2][38][64], float R[2][38][64], int top);
+void AAC_RENAME(ff_ps_init)(void);
+void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps);
+int AAC_RENAME(ff_ps_read_data)(AVCodecContext *avctx, GetBitContext *gb, PSContext *ps, int bits_left);
+int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top);
#endif /* AVCODEC_PS_H */
diff --git a/libavcodec/aacps_fixed.c b/libavcodec/aacps_fixed.c
new file mode 100644
index 0000000..2f91210
--- /dev/null
+++ b/libavcodec/aacps_fixed.c
@@ -0,0 +1,210 @@
+/*
+ * MPEG-4 Parametric Stereo decoding functions
+ * Copyright (c) 2010 Alex Converse <alex.converse at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define CONFIG_AAC_FIXED 1
+
+#include "aacps.c"
+
+static void stereo_processing_fixed(PSContext *ps, int (*l)[32][2], int (*r)[32][2], int is34)
+{
+ int e, b, k;
+ long long accu;
+ int (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
+ int (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
+ int (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
+ int (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
+ int8_t *opd_hist = ps->opd_hist;
+ int8_t *ipd_hist = ps->ipd_hist;
+ int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
+ int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
+ int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
+ int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
+ const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
+ const int (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
+
+ //Remapping
+ if (ps->num_env_old) {
+ memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
+ memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
+ memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
+ memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
+ memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
+ memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
+ memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
+ memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
+ }
+
+ if (is34) {
+ remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
+ remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
+ if (ps->enable_ipdopd) {
+ remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ }
+ if (!ps->is34bands_old) {
+ map_val_20_to_34(H11[0][0]);
+ map_val_20_to_34(H11[1][0]);
+ map_val_20_to_34(H12[0][0]);
+ map_val_20_to_34(H12[1][0]);
+ map_val_20_to_34(H21[0][0]);
+ map_val_20_to_34(H21[1][0]);
+ map_val_20_to_34(H22[0][0]);
+ map_val_20_to_34(H22[1][0]);
+ ipdopd_reset(ipd_hist, opd_hist);
+ }
+ } else {
+ remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
+ remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
+ if (ps->enable_ipdopd) {
+ remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ }
+ if (ps->is34bands_old) {
+ map_val_34_to_20_fixed(H11[0][0]);
+ map_val_34_to_20_fixed(H11[1][0]);
+ map_val_34_to_20_fixed(H12[0][0]);
+ map_val_34_to_20_fixed(H12[1][0]);
+ map_val_34_to_20_fixed(H21[0][0]);
+ map_val_34_to_20_fixed(H21[1][0]);
+ map_val_34_to_20_fixed(H22[0][0]);
+ map_val_34_to_20_fixed(H22[1][0]);
+ ipdopd_reset(ipd_hist, opd_hist);
+ }
+ }
+
+ //Mixing
+ for (e = 0; e < ps->num_env; e++) {
+ for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
+ int h11, h12, h21, h22;
+
+ h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
+ h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
+ h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
+ h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
+ if (!PS_BASELINE && ps->enable_ipdopd && b < ps->nr_ipdopd_par) {
+ //The spec say says to only run this smoother when enable_ipdopd
+ //is set but the reference decoder appears to run it constantly
+ int h11i, h12i, h21i, h22i;
+ int ipd_adj_re, ipd_adj_im;
+ int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
+ int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
+ int opd_re = pd_re_smooth[opd_idx];
+ int opd_im = pd_im_smooth[opd_idx];
+ int ipd_re = pd_re_smooth[ipd_idx];
+ int ipd_im = pd_im_smooth[ipd_idx];
+ opd_hist[b] = opd_idx & 0x3F;
+ ipd_hist[b] = ipd_idx & 0x3F;
+
+ accu = (long long)opd_re*ipd_re;
+ accu += (long long)opd_im*ipd_im;
+ ipd_adj_re = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)opd_im*ipd_re;
+ accu -= (long long)opd_re*ipd_im;
+ ipd_adj_im = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h11 * opd_im;
+ h11i = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h11 * opd_re;
+ h11 = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h12 * ipd_adj_im;
+ h12i = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h12 * ipd_adj_re;
+ h12 = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h21 * opd_im;
+ h21i = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h21 * opd_re;
+ h21 = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h22 * ipd_adj_im;
+ h22i = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h22 * ipd_adj_re;
+ h22 = (int)((accu + 0x20000000) >> 30);
+ H11[1][e+1][b] = h11i;
+ H12[1][e+1][b] = h12i;
+ H21[1][e+1][b] = h21i;
+ H22[1][e+1][b] = h22i;
+ }
+ H11[0][e+1][b] = h11;
+ H12[0][e+1][b] = h12;
+ H21[0][e+1][b] = h21;
+ H22[0][e+1][b] = h22;
+ }
+ for (k = 0; k < NR_BANDS[is34]; k++) {
+ int h[2][4];
+ int h_step[2][4];
+ int start = ps->border_position[e];
+ int stop = ps->border_position[e+1];
+ int width = 1073741824 / (stop - start);
+ width <<= 1;
+ b = k_to_i[k];
+ h[0][0] = H11[0][e][b];
+ h[0][1] = H12[0][e][b];
+ h[0][2] = H21[0][e][b];
+ h[0][3] = H22[0][e][b];
+ if (!PS_BASELINE && ps->enable_ipdopd) {
+ //Is this necessary? ps_04_new seems unchanged
+ if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
+ h[1][0] = -H11[1][e][b];
+ h[1][1] = -H12[1][e][b];
+ h[1][2] = -H21[1][e][b];
+ h[1][3] = -H22[1][e][b];
+ } else {
+ h[1][0] = H11[1][e][b];
+ h[1][1] = H12[1][e][b];
+ h[1][2] = H21[1][e][b];
+ h[1][3] = H22[1][e][b];
+ }
+ }
+ //Interpolation
+ accu = (long long)H11[0][e+1][b] * width;
+ accu -= (long long)h[0][0] * width;
+ h_step[0][0] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)H12[0][e+1][b] * width;
+ accu -= (long long)h[0][1] * width;
+ h_step[0][1] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)H21[0][e+1][b] * width;
+ accu -= (long long)h[0][2] * width;
+ h_step[0][2] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)H22[0][e+1][b] * width;
+ accu -= (long long)h[0][3] * width;
+ h_step[0][3] = (int)((accu + 0x40000000) >> 31);
+ if (!PS_BASELINE && ps->enable_ipdopd) {
+ accu = (long long)H11[1][e+1][b] * width;
+ accu -= (long long)h[1][0] * width;
+ h_step[1][0] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)H12[1][e+1][b] * width;
+ accu -= (long long)h[1][1] * width;
+ h_step[1][1] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)H21[1][e+1][b] * width;
+ accu -= (long long)h[1][2] * width;
+ h_step[1][2] = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)H22[1][e+1][b] * width;
+ accu -= (long long)h[1][3] * width;
+ h_step[1][3] = (int)((accu + 0x40000000) >> 31);
+ }
+ ps->dsp.stereo_interpolate_fixed[!PS_BASELINE && ps->enable_ipdopd](
+ l[k] + start + 1, r[k] + start + 1,
+ h, h_step, stop - start);
+ }
+ }
+}
diff --git a/libavcodec/aacps_fixed_tablegen.c b/libavcodec/aacps_fixed_tablegen.c
new file mode 100644
index 0000000..b2fda6e
--- /dev/null
+++ b/libavcodec/aacps_fixed_tablegen.c
@@ -0,0 +1,94 @@
+/*
+ * Generate a header file for hardcoded Parametric Stereo tables
+ *
+ * Copyright (c) 2010 Alex Converse <alex.converse at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#define CONFIG_HARDCODED_TABLES 0
+
+#include "aacps_fixed_tablegen.h"
+#include "tableprint.h"
+
+void write_int32_t_3d_array (const void *p, int b, int c, int d)
+{
+ int i;
+ const int32_t *f = p;
+ for (i = 0; i < b; i++) {
+ printf("{\n");
+ write_uint32_t_2d_array(f, c, d);
+ printf("},\n");
+ f += c * d;
+ }
+}
+
+void write_int32_t_4d_array (const void *p, int a, int b, int c, int d)
+{
+ int i;
+ const int32_t *f = p;
+ for (i = 0; i < a; i++) {
+ printf("{\n");
+ write_int32_t_3d_array(f, b, c, d);
+ printf("},\n");
+ f += b * c * d;
+ }
+}
+
+int main(void)
+{
+ ps_tableinit();
+
+ write_fileheader();
+
+ printf("static const int32_t pd_re_smooth[8*8*8] = {\n");
+ write_int32_t_array(pd_re_smooth, 8*8*8);
+ printf("};\n");
+ printf("static const int32_t pd_im_smooth[8*8*8] = {\n");
+ write_int32_t_array(pd_im_smooth, 8*8*8);
+ printf("};\n");
+
+ printf("static const int32_t HA[46][8][4] = {\n");
+ write_int32_t_3d_array(HA, 46, 8, 4);
+ printf("};\n");
+ printf("static const int32_t HB[46][8][4] = {\n");
+ write_int32_t_3d_array(HB, 46, 8, 4);
+ printf("};\n");
+
+ printf("static const DECLARE_ALIGNED(16, int32_t, f20_0_8)[8][8][2] = {\n");
+ write_int32_t_3d_array(f20_0_8, 8, 8, 2);
+ printf("};\n");
+ printf("static const DECLARE_ALIGNED(16, int32_t, f34_0_12)[12][8][2] = {\n");
+ write_int32_t_3d_array(f34_0_12, 12, 8, 2);
+ printf("};\n");
+ printf("static const DECLARE_ALIGNED(16, int32_t, f34_1_8)[8][8][2] = {\n");
+ write_int32_t_3d_array(f34_1_8, 8, 8, 2);
+ printf("};\n");
+ printf("static const DECLARE_ALIGNED(16, int32_t, f34_2_4)[4][8][2] = {\n");
+ write_int32_t_3d_array(f34_2_4, 4, 8, 2);
+ printf("};\n");
+
+ printf("static const DECLARE_ALIGNED(16, int32_t, Q_fract_allpass)[2][50][3][2] = {\n");
+ write_int32_t_4d_array(Q_fract_allpass, 2, 50, 3, 2);
+ printf("};\n");
+ printf("static const DECLARE_ALIGNED(16, int32_t, phi_fract)[2][50][2] = {\n");
+ write_int32_t_3d_array(phi_fract, 2, 50, 2);
+ printf("};\n");
+
+ return 0;
+}
diff --git a/libavcodec/aacps_fixed_tablegen.h b/libavcodec/aacps_fixed_tablegen.h
new file mode 100644
index 0000000..b08c222
--- /dev/null
+++ b/libavcodec/aacps_fixed_tablegen.h
@@ -0,0 +1,427 @@
+/*
+ * Header file for hardcoded Parametric Stereo tables
+ *
+ * Copyright (c) 2010 Alex Converse <alex.converse at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AACPS_TABLEGEN_FIXED_H
+#define AACPS_TABLEGEN_FIXED_H
+
+#include <math.h>
+#include <stdint.h>
+
+#if CONFIG_HARDCODED_TABLES
+#define ps_tableinit()
+#include "libavcodec/aacps_fixed_tables.h"
+#else
+#include "libavutil/common.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/mem.h"
+
+#include "float_emu.h"
+#include "float_emu_tab.c"
+#define NR_ALLPASS_BANDS20 30
+#define NR_ALLPASS_BANDS34 50
+#define PS_AP_LINKS 3
+#define Q30(x) (int)((x)*1073741824.0 + 0.5)
+#define Q31(x) (int)((x)*2147483648.0 + 0.5)
+static int pd_re_smooth[8*8*8];
+static int pd_im_smooth[8*8*8];
+static int HA[46][8][4];
+static int HB[46][8][4];
+static DECLARE_ALIGNED(16, int, f20_0_8) [ 8][8][2];
+static DECLARE_ALIGNED(16, int, f34_0_12)[12][8][2];
+static DECLARE_ALIGNED(16, int, f34_1_8) [ 8][8][2];
+static DECLARE_ALIGNED(16, int, f34_2_4) [ 4][8][2];
+static DECLARE_ALIGNED(16, int, Q_fract_allpass)[2][50][3][2];
+static DECLARE_ALIGNED(16, int, phi_fract)[2][50][2];
+
+static const int g0_Q8[] = {
+ Q31(0.00746082949812f), Q31(0.02270420949825f), Q31(0.04546865930473f), Q31(0.07266113929591f),
+ Q31(0.09885108575264f), Q31(0.11793710567217f), Q31(0.125f)
+};
+
+static const int g0_Q12[] = {
+ Q31(0.04081179924692f), Q31(0.03812810994926f), Q31(0.05144908135699f), Q31(0.06399831151592f),
+ Q31(0.07428313801106f), Q31(0.08100347892914f), Q31(0.08333333333333f)
+};
+
+static const int g1_Q8[] = {
+ Q31(0.01565675600122f), Q31(0.03752716391991f), Q31(0.05417891378782f), Q31(0.08417044116767f),
+ Q31(0.10307344158036f), Q31(0.12222452249753f), Q31(0.125f)
+};
+
+static const int g2_Q4[] = {
+ Q31(-0.05908211155639f), Q31(-0.04871498374946f), Q31(0.0f), Q31(0.07778723915851f),
+ Q31( 0.16486303567403f), Q31( 0.23279856662996f), Q31(0.25f)
+};
+
+static const int sintbl_4[4] = { 0, 1073741824, 0, -1073741824 };
+static const int costbl_4[4] = { 1073741824, 0, -1073741824, 0 };
+static const int sintbl_8[8] = { 0, 759250125, 1073741824, 759250125,
+ 0, -759250125, -1073741824, -759250125 };
+static const int costbl_8[8] = { 1073741824, 759250125, 0, -759250125,
+ -1073741824, -759250125, 0, 759250125 };
+static const int sintbl_12[12] = { 0, 536870912, 929887697, 1073741824,
+ 929887697, 536870912, 0, -536870912,
+ -929887697, -1073741824, -929887697, -536870912 };
+static const int costbl_12[12] = { 1073741824, 929887697, 536870912, 0,
+ -536870912, -929887697, -1073741824, -929887697,
+ -536870912, 0, 536870912, 929887697 };
+
+static void make_filters_from_proto(int (*filter)[8][2], const int *proto, int bands)
+{
+
+ const int *sinptr, *cosptr;
+ int s, c, sinhalf, coshalf;
+ int q, n;
+ long long accu;
+
+ if (bands == 4) {
+ sinptr = sintbl_4;
+ cosptr = costbl_4;
+ sinhalf = 759250125;
+ coshalf = 759250125;
+ } else if (bands == 8) {
+ sinptr = sintbl_8;
+ cosptr = costbl_8;
+ sinhalf = 410903207;
+ coshalf = 992008094;
+ } else {
+ sinptr = sintbl_12;
+ cosptr = costbl_12;
+ sinhalf = 277904834;
+ coshalf = 1037154959;
+ }
+
+ for (q = 0; q < bands; q++) {
+ for (n = 0; n < 7; n++) {
+ int theta = (q*(n-6) + (n>>1) - 3) % bands;
+
+ if (theta < 0)
+ theta += bands;
+ s = sinptr[theta];
+ c = cosptr[theta];
+
+ if (n & 1) {
+ accu = (long long)c * coshalf;
+ accu -= (long long)s * sinhalf;
+ theta = (int)((accu + 0x20000000) >> 30);
+
+ accu = (long long)s * coshalf;
+ accu += (long long)c * sinhalf;
+ s = (int)((accu + 0x20000000) >> 30);
+ c = theta;
+ }
+ accu = (long long)proto[n] * c;
+ filter[q][n][0] = (int)((accu + 0x20000000) >> 30);
+
+ accu = (long long)proto[n] * s;
+ filter[q][n][1] = -(int)((accu + 0x20000000) >> 30);
+ }
+ }
+}
+
+static void ps_tableinit(void)
+{
+ static const int ipdopd_sin[] = { Q30(0), Q30(M_SQRT1_2), Q30(1), Q30( M_SQRT1_2), Q30( 0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2) };
+ static const int ipdopd_cos[] = { Q30(1), Q30(M_SQRT1_2), Q30(0), Q30(-M_SQRT1_2), Q30(-1), Q30(-M_SQRT1_2), Q30( 0), Q30( M_SQRT1_2) };
+ int pd0, pd1, pd2;
+ int idx;
+
+ static const int alpha_tab[] =
+ {
+ Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI),
+ Q30(1.4455626011f/M_PI), Q30(1.4531552792f/M_PI), Q30(1.4648091793f/M_PI), Q30(1.4945238829f/M_PI), Q30(1.5239057541f/M_PI), Q30(1.5644006729f/M_PI),
+ Q30(1.3738563061f/M_PI), Q30(1.3851221800f/M_PI), Q30(1.4026404619f/M_PI), Q30(1.4484288692f/M_PI), Q30(1.4949874878f/M_PI), Q30(1.5604078770f/M_PI),
+ Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI),
+ Q30(1.1507037878f/M_PI), Q30(1.1669205427f/M_PI), Q30(1.1938756704f/M_PI), Q30(1.2754167318f/M_PI), Q30(1.3761177063f/M_PI), Q30(1.5429240465f/M_PI),
+ Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI),
+ Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI),
+ Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI),
+ Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI),
+ Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI),
+ Q30(0.4200925827f/M_PI), Q30(0.4038758278f/M_PI), Q30(0.3769206405f/M_PI), Q30(0.2953795493f/M_PI), Q30(0.1946786791f/M_PI), Q30(0.0278722942f/M_PI),
+ Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI),
+ Q30(0.1969399750f/M_PI), Q30(0.1856741160f/M_PI), Q30(0.1681558639f/M_PI), Q30(0.1223674342f/M_PI), Q30(0.0758088827f/M_PI), Q30(0.0103884479f/M_PI),
+ Q30(0.1252337098f/M_PI), Q30(0.1176410317f/M_PI), Q30(0.1059871912f/M_PI), Q30(0.0762724727f/M_PI), Q30(0.0468905345f/M_PI), Q30(0.0063956482f/M_PI),
+ Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI),
+ Q30(1.5676341057f/M_PI), Q30(1.5678333044f/M_PI), Q30(1.5681363344f/M_PI), Q30(1.5688960552f/M_PI), Q30(1.5696337223f/M_PI), Q30(1.5706381798f/M_PI),
+ Q30(1.5651730299f/M_PI), Q30(1.5655272007f/M_PI), Q30(1.5660660267f/M_PI), Q30(1.5674170256f/M_PI), Q30(1.5687289238f/M_PI), Q30(1.5705151558f/M_PI),
+ Q30(1.5607966185f/M_PI), Q30(1.5614265203f/M_PI), Q30(1.5623844862f/M_PI), Q30(1.5647867918f/M_PI), Q30(1.5671195984f/M_PI), Q30(1.5702962875f/M_PI),
+ Q30(1.5530153513f/M_PI), Q30(1.5541347265f/M_PI), Q30(1.5558375120f/M_PI), Q30(1.5601085424f/M_PI), Q30(1.5642569065f/M_PI), Q30(1.5699069500f/M_PI),
+ Q30(1.5391840935f/M_PI), Q30(1.5411708355f/M_PI), Q30(1.5441943407f/M_PI), Q30(1.5517836809f/M_PI), Q30(1.5591609478f/M_PI), Q30(1.5692136288f/M_PI),
+ Q30(1.5146213770f/M_PI), Q30(1.5181334019f/M_PI), Q30(1.5234849453f/M_PI), Q30(1.5369486809f/M_PI), Q30(1.5500687361f/M_PI), Q30(1.5679757595f/M_PI),
+ Q30(1.4915299416f/M_PI), Q30(1.4964480400f/M_PI), Q30(1.5039558411f/M_PI), Q30(1.5229074955f/M_PI), Q30(1.5414420366f/M_PI), Q30(1.5667995214f/M_PI),
+ Q30(1.4590617418f/M_PI), Q30(1.4658898115f/M_PI), Q30(1.4763505459f/M_PI), Q30(1.5029321909f/M_PI), Q30(1.5291173458f/M_PI), Q30(1.5651149750f/M_PI),
+ Q30(1.4136143923f/M_PI), Q30(1.4229322672f/M_PI), Q30(1.4373078346f/M_PI), Q30(1.4743183851f/M_PI), Q30(1.5113102198f/M_PI), Q30(1.5626684427f/M_PI),
+ Q30(1.3505556583f/M_PI), Q30(1.3628427982f/M_PI), Q30(1.3820509911f/M_PI), Q30(1.4327841997f/M_PI), Q30(1.4850014448f/M_PI), Q30(1.5590143204f/M_PI),
+ Q30(1.2645189762f/M_PI), Q30(1.2796478271f/M_PI), Q30(1.3038636446f/M_PI), Q30(1.3710125685f/M_PI), Q30(1.4443849325f/M_PI), Q30(1.5532352924f/M_PI),
+ Q30(1.1919227839f/M_PI), Q30(1.2081253529f/M_PI), Q30(1.2346779108f/M_PI), Q30(1.3123005629f/M_PI), Q30(1.4034168720f/M_PI), Q30(1.5471596718f/M_PI),
+ Q30(1.1061993837f/M_PI), Q30(1.1219338179f/M_PI), Q30(1.1484941244f/M_PI), Q30(1.2320860624f/M_PI), Q30(1.3421301842f/M_PI), Q30(1.5373806953f/M_PI),
+ Q30(1.0079245567f/M_PI), Q30(1.0208238363f/M_PI), Q30(1.0433073044f/M_PI), Q30(1.1208510399f/M_PI), Q30(1.2424604893f/M_PI), Q30(1.5185726881f/M_PI),
+ Q30(0.8995233774f/M_PI), Q30(0.9069069624f/M_PI), Q30(0.9201194048f/M_PI), Q30(0.9698365927f/M_PI), Q30(1.0671583414f/M_PI), Q30(1.4647934437f/M_PI),
+ Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI), Q30(0.7853981853f/M_PI),
+ Q30(0.6712729335f/M_PI), Q30(0.6638893485f/M_PI), Q30(0.6506769061f/M_PI), Q30(0.6009597182f/M_PI), Q30(0.5036380291f/M_PI), Q30(0.1060028747f/M_PI),
+ Q30(0.5628717542f/M_PI), Q30(0.5499725342f/M_PI), Q30(0.5274890065f/M_PI), Q30(0.4499453008f/M_PI), Q30(0.3283358216f/M_PI), Q30(0.0522236861f/M_PI),
+ Q30(0.4645969570f/M_PI), Q30(0.4488625824f/M_PI), Q30(0.4223022461f/M_PI), Q30(0.3387103081f/M_PI), Q30(0.2286661267f/M_PI), Q30(0.0334156826f/M_PI),
+ Q30(0.3788735867f/M_PI), Q30(0.3626709878f/M_PI), Q30(0.3361184299f/M_PI), Q30(0.2584958076f/M_PI), Q30(0.1673794836f/M_PI), Q30(0.0236366931f/M_PI),
+ Q30(0.3062773645f/M_PI), Q30(0.2911485136f/M_PI), Q30(0.2669326365f/M_PI), Q30(0.1997837722f/M_PI), Q30(0.1264114529f/M_PI), Q30(0.0175609849f/M_PI),
+ Q30(0.2202406377f/M_PI), Q30(0.2079535723f/M_PI), Q30(0.1887452900f/M_PI), Q30(0.1380121708f/M_PI), Q30(0.0857949182f/M_PI), Q30(0.0117820343f/M_PI),
+ Q30(0.1571819335f/M_PI), Q30(0.1478640437f/M_PI), Q30(0.1334884763f/M_PI), Q30(0.0964778885f/M_PI), Q30(0.0594860613f/M_PI), Q30(0.0081279324f/M_PI),
+ Q30(0.1117345318f/M_PI), Q30(0.1049065739f/M_PI), Q30(0.0944457650f/M_PI), Q30(0.0678641573f/M_PI), Q30(0.0416790098f/M_PI), Q30(0.0056813755f/M_PI),
+ Q30(0.0792663917f/M_PI), Q30(0.0743482932f/M_PI), Q30(0.0668405443f/M_PI), Q30(0.0478888862f/M_PI), Q30(0.0293543357f/M_PI), Q30(0.0039967746f/M_PI),
+ Q30(0.0561749674f/M_PI), Q30(0.0526629239f/M_PI), Q30(0.0473113805f/M_PI), Q30(0.0338476151f/M_PI), Q30(0.0207276177f/M_PI), Q30(0.0028205961f/M_PI),
+ Q30(0.0316122435f/M_PI), Q30(0.0296254847f/M_PI), Q30(0.0266019460f/M_PI), Q30(0.0190126132f/M_PI), Q30(0.0116353342f/M_PI), Q30(0.0015827164f/M_PI),
+ Q30(0.0177809205f/M_PI), Q30(0.0166615788f/M_PI), Q30(0.0149587989f/M_PI), Q30(0.0106877899f/M_PI), Q30(0.0065393616f/M_PI), Q30(0.0008894200f/M_PI),
+ Q30(0.0099996664f/M_PI), Q30(0.0093698399f/M_PI), Q30(0.0084118480f/M_PI), Q30(0.0060095116f/M_PI), Q30(0.0036767013f/M_PI), Q30(0.0005000498f/M_PI),
+ Q30(0.0056233541f/M_PI), Q30(0.0052691097f/M_PI), Q30(0.0047303112f/M_PI), Q30(0.0033792770f/M_PI), Q30(0.0020674451f/M_PI), Q30(0.0002811795f/M_PI),
+ Q30(0.0031622672f/M_PI), Q30(0.0029630491f/M_PI), Q30(0.0026600463f/M_PI), Q30(0.0019002859f/M_PI), Q30(0.0011625893f/M_PI), Q30(0.0001581155f/M_PI)
+ };
+
+ static const int gamma_tab[] =
+ {
+ Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1315985769f/M_PI), Q30(0.2072522491f/M_PI), Q30(0.3188187480f/M_PI), Q30(0.3825501204f/M_PI), Q30(0.4193951190f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0672341362f/M_PI), Q30(0.1045235619f/M_PI), Q30(0.1558904350f/M_PI), Q30(0.1824723780f/M_PI), Q30(0.1966800541f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0433459543f/M_PI), Q30(0.0672172382f/M_PI), Q30(0.0997167900f/M_PI), Q30(0.1162951663f/M_PI), Q30(0.1250736862f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1784276664f/M_PI), Q30(0.2856673002f/M_PI), Q30(0.4630723596f/M_PI), Q30(0.5971632004f/M_PI), Q30(0.7603877187f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1736015975f/M_PI), Q30(0.2773745656f/M_PI), Q30(0.4461984038f/M_PI), Q30(0.5666890144f/M_PI), Q30(0.6686112881f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1603866369f/M_PI), Q30(0.2549437582f/M_PI), Q30(0.4029446840f/M_PI), Q30(0.4980689585f/M_PI), Q30(0.5615641475f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1418247074f/M_PI), Q30(0.2240308374f/M_PI), Q30(0.3474813402f/M_PI), Q30(0.4202919006f/M_PI), Q30(0.4637607038f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1212290376f/M_PI), Q30(0.1903949380f/M_PI), Q30(0.2907958031f/M_PI), Q30(0.3466993868f/M_PI), Q30(0.3782821596f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.1011129096f/M_PI), Q30(0.1580764502f/M_PI), Q30(0.2387557179f/M_PI), Q30(0.2820728719f/M_PI), Q30(0.3058380187f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0747506917f/M_PI), Q30(0.1163287833f/M_PI), Q30(0.1738867164f/M_PI), Q30(0.2038587779f/M_PI), Q30(0.2199459076f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0541138873f/M_PI), Q30(0.0839984417f/M_PI), Q30(0.1248718798f/M_PI), Q30(0.1458375156f/M_PI), Q30(0.1569785923f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0387469754f/M_PI), Q30(0.0600636788f/M_PI), Q30(0.0890387669f/M_PI), Q30(0.1037906483f/M_PI), Q30(0.1115923747f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0275881495f/M_PI), Q30(0.0427365713f/M_PI), Q30(0.0632618815f/M_PI), Q30(0.0736731067f/M_PI), Q30(0.0791663304f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0195873566f/M_PI), Q30(0.0303316917f/M_PI), Q30(0.0448668823f/M_PI), Q30(0.0522258915f/M_PI), Q30(0.0561044961f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0110366223f/M_PI), Q30(0.0170863140f/M_PI), Q30(0.0252620988f/M_PI), Q30(0.0293955617f/M_PI), Q30(0.0315726399f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0062100487f/M_PI), Q30(0.0096135242f/M_PI), Q30(0.0142110568f/M_PI), Q30(0.0165348612f/M_PI), Q30(0.0177587029f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0034913034f/M_PI), Q30(0.0054070661f/M_PI), Q30(0.0079917293f/M_PI), Q30(0.0092999367f/M_PI), Q30(0.0099875759f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0019607407f/M_PI), Q30(0.0030395309f/M_PI), Q30(0.0044951206f/M_PI), Q30(0.0052305623f/M_PI), Q30(0.0056152637f/M_PI),
+ Q30(0.0000000000f/M_PI), Q30(0.0011053939f/M_PI), Q30(0.0017089852f/M_PI), Q30(0.0025254129f/M_PI), Q30(0.0029398468f/M_PI), Q30(0.0031597170f/M_PI)
+ };
+
+ static const int iid_par_dequant_c1[] = {
+ //iid_par_dequant_default
+ Q30(1.41198278375959f), Q30(1.40313815268360f), Q30(1.38687670404960f), Q30(1.34839972492648f),
+ Q30(1.29124937110028f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1),
+ Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.57677990744575f), Q30(0.42640143271122f),
+ Q30(0.27671828230984f), Q30(0.17664462766713f), Q30(0.07940162697653f),
+ //iid_par_dequant_fine
+ Q30(1.41420649135832f), Q30(1.41419120222364f), Q30(1.41414285699784f), Q30(1.41399000859438f),
+ Q30(1.41350698548044f), Q30(1.41198278375959f), Q30(1.40977302262355f), Q30(1.40539479488545f),
+ Q30(1.39677960498402f), Q30(1.38005309967827f), Q30(1.34839972492648f), Q30(1.31392017367631f),
+ Q30(1.26431008149654f), Q30(1.19603741667993f), Q30(1.10737240362323f), Q30(1),
+ Q30(0.87961716655242f), Q30(0.75464859232732f), Q30(0.63365607219232f), Q30(0.52308104267543f),
+ Q30(0.42640143271122f), Q30(0.30895540465965f), Q30(0.22137464873077f), Q30(0.15768788954414f),
+ Q30(0.11198225164225f), Q30(0.07940162697653f), Q30(0.04469901562677f), Q30(0.02514469318284f),
+ Q30(0.01414142856998f), Q30(0.00795258154731f), Q30(0.00447211359449f),
+ };
+
+ static const int acos_icc_invq[] = {
+ Q31(0), Q31(0.178427635f/M_PI), Q31(0.28566733f/M_PI), Q31(0.46307236f/M_PI), Q31(0.59716315f/M_PI), Q31(0.78539816f/M_PI), Q31(1.10030855f/M_PI), Q31(1.57079633f/M_PI)
+ };
+ int iid, icc;
+
+ int k, m;
+ static const int8_t f_center_20[] = {
+ -3, -1, 1, 3, 5, 7, 10, 14, 18, 22,
+ };
+ static const int32_t f_center_34[] = {
+ Q31( 2/768.0),Q31( 6/768.0),Q31(10/768.0),Q31(14/768.0),Q31( 18/768.0),Q31( 22/768.0),Q31( 26/768.0),Q31(30/768.0),
+ Q31( 34/768.0),Q31(-10/768.0),Q31(-6/768.0),Q31(-2/768.0),Q31( 51/768.0),Q31( 57/768.0),Q31( 15/768.0),Q31(21/768.0),
+ Q31( 27/768.0),Q31( 33/768.0),Q31(39/768.0),Q31(45/768.0),Q31( 54/768.0),Q31( 66/768.0),Q31( 78/768.0),Q31(42/768.0),
+ Q31(102/768.0),Q31( 66/768.0),Q31(78/768.0),Q31(90/768.0),Q31(102/768.0),Q31(114/768.0),Q31(126/768.0),Q31(90/768.0)
+ };
+ static const int fractional_delay_links[] = { Q31(0.43f), Q31(0.75f), Q31(0.347f) };
+ const int fractional_delay_gain = Q31(0.39f);
+ long long accu;
+
+ for (pd0 = 0; pd0 < 8; pd0++) {
+ int pd0_re = (ipdopd_cos[pd0]+2)>>2;
+ int pd0_im = (ipdopd_sin[pd0]+2)>>2;
+ for (pd1 = 0; pd1 < 8; pd1++) {
+ int pd1_re = ipdopd_cos[pd1] >> 1;
+ int pd1_im = ipdopd_sin[pd1] >> 1;
+ for (pd2 = 0; pd2 < 8; pd2++) {
+ int shift, round;
+ int pd2_re = ipdopd_cos[pd2];
+ int pd2_im = ipdopd_sin[pd2];
+ int re_smooth = pd0_re + pd1_re + pd2_re;
+ int im_smooth = pd0_im + pd1_im + pd2_im;
+
+ aac_float_t pd_mag = int2float(((ipdopd_cos[(pd0-pd1)&7]+8)>>4) + ((ipdopd_cos[(pd0-pd2)&7]+4)>>3) +
+ ((ipdopd_cos[(pd1-pd2)&7]+2)>>2) + 0x15000000, 2);
+ pd_mag = float_div(FLOAT_1, float_sqrt(pd_mag));
+ shift = 30 - pd_mag.expo;
+ round = 1 << (shift-1);
+ accu = (long long)re_smooth * pd_mag.mant;
+ pd_re_smooth[pd0*64+pd1*8+pd2] = (int)((accu + round) >> shift);
+ accu = (long long)im_smooth * pd_mag.mant;
+ pd_im_smooth[pd0*64+pd1*8+pd2] = (int)((accu + round) >> shift);
+ }
+ }
+ }
+
+ idx = 0;
+ for (iid = 0; iid < 46; iid++) {
+ int c1, c2;
+
+ c1 = iid_par_dequant_c1[iid];
+ if (iid < 15)
+ c2 = iid_par_dequant_c1[14-iid];
+ else
+ c2 = iid_par_dequant_c1[60-iid];
+
+ for (icc = 0; icc < 8; icc++) {
+ /*if (PS_BASELINE || ps->icc_mode < 3)*/{
+ int alpha, beta;
+ int ca, sa, cb, sb;
+
+ alpha = acos_icc_invq[icc];
+ accu = (long long)alpha * 1518500250;
+ beta = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)beta * (c1 - c2);
+ alpha >>= 1;
+ beta = (int)((accu + 0x40000000) >> 31);
+ aac_fixed_sincos(beta + alpha, &sa, &ca);
+ aac_fixed_sincos(beta - alpha, &sb, &cb);
+
+ accu = (long long)c2 * ca;
+ HA[iid][icc][0] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)c1 * cb;
+ HA[iid][icc][1] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)c2 * sa;
+ HA[iid][icc][2] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)c1 * sb;
+ HA[iid][icc][3] = (int)((accu + 0x20000000) >> 30);
+ } /* else */ {
+ int alpha_int, gamma_int;
+ int alpha_c_int, alpha_s_int, gamma_c_int, gamma_s_int;
+
+ alpha_int = alpha_tab[idx];
+ gamma_int = gamma_tab[idx];
+
+ aac_fixed_sincos(alpha_int, &alpha_s_int, &alpha_c_int);
+ aac_fixed_sincos(gamma_int, &gamma_s_int, &gamma_c_int);
+
+ accu = (long long)alpha_c_int * 1518500250;
+ alpha_c_int = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)alpha_s_int * 1518500250;
+ alpha_s_int = (int)((accu + 0x20000000) >> 30);
+
+ accu = (long long)alpha_c_int * gamma_c_int;
+ HB[iid][icc][0] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)alpha_s_int * gamma_c_int;
+ HB[iid][icc][1] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)alpha_s_int * gamma_s_int;
+ HB[iid][icc][2] = -(int)((accu + 0x20000000) >> 30);
+ accu = (long long)alpha_c_int * gamma_s_int;
+ HB[iid][icc][3] = (int)((accu + 0x20000000) >> 30);
+ }
+
+ if (icc < 5 || icc > 6)
+ idx++;
+ }
+ }
+
+ for (k = 0; k < NR_ALLPASS_BANDS20; k++) {
+ int theta, f_center;
+ int c, s;
+
+ if (k < FF_ARRAY_ELEMS(f_center_20))
+ f_center = f_center_20[k];
+ else
+ f_center = (k << 3) - 52;
+
+ for (m = 0; m < PS_AP_LINKS; m++) {
+ accu = (long long)fractional_delay_links[m] * f_center;
+ theta = (int)((accu + 8) >> 4);
+ aac_fixed_sincos(-theta, &s, &c);
+ Q_fract_allpass[0][k][m][0] = c;
+ Q_fract_allpass[0][k][m][1] = s;
+ }
+
+ accu = (long long)fractional_delay_gain * f_center;
+ theta = (int)((accu + 8) >> 4);
+ aac_fixed_sincos(-theta, &s, &c);
+ phi_fract[0][k][0] = c;
+ phi_fract[0][k][1] = s;
+ }
+
+ for (k = 0; k < NR_ALLPASS_BANDS34; k++) {
+ int theta, f_center;
+ int c, s;
+
+ if (k < FF_ARRAY_ELEMS(f_center_34))
+ f_center = f_center_34[k];
+ else
+ f_center = (k << 26) - (53 << 25);
+
+ for (m = 0; m < PS_AP_LINKS; m++) {
+ accu = (long long)fractional_delay_links[m] * f_center;
+ theta = (int)((accu + 0x10000000) >> 27);
+ aac_fixed_sincos(-theta, &s, &c);
+ Q_fract_allpass[1][k][m][0] = c;
+ Q_fract_allpass[1][k][m][1] = s;
+ }
+
+ accu = (long long)fractional_delay_gain * f_center;
+ theta = (int)((accu + 0x10000000) >> 27);
+ aac_fixed_sincos(-theta, &s, &c);
+ phi_fract[1][k][0] = c;
+ phi_fract[1][k][1] = s;
+ }
+
+ make_filters_from_proto(f20_0_8, g0_Q8, 8);
+ make_filters_from_proto(f34_0_12, g0_Q12, 12);
+ make_filters_from_proto(f34_1_8, g1_Q8, 8);
+ make_filters_from_proto(f34_2_4, g2_Q4, 4);
+}
+#endif /* CONFIG_HARDCODED_TABLES */
+
+#endif /* AACPS_FIXED_TABLEGEN_H */
diff --git a/libavcodec/aacps_float.c b/libavcodec/aacps_float.c
new file mode 100644
index 0000000..dc0696b
--- /dev/null
+++ b/libavcodec/aacps_float.c
@@ -0,0 +1,181 @@
+/*
+ * MPEG-4 Parametric Stereo decoding functions
+ * Copyright (c) 2010 Alex Converse <alex.converse at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define CONFIG_AAC_FIXED 0
+
+#include "aacps.c"
+
+static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34)
+{
+ int e, b, k;
+
+ float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
+ float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
+ float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
+ float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
+ int8_t *opd_hist = ps->opd_hist;
+ int8_t *ipd_hist = ps->ipd_hist;
+ int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
+ int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
+ int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
+ int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
+ int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
+ const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
+ const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
+
+ //Remapping
+ if (ps->num_env_old) {
+ memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
+ memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
+ memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
+ memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
+ memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
+ memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
+ memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
+ memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
+ }
+
+ if (is34) {
+ remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
+ remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
+ if (ps->enable_ipdopd) {
+ remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ }
+ if (!ps->is34bands_old) {
+ map_val_20_to_34(H11[0][0]);
+ map_val_20_to_34(H11[1][0]);
+ map_val_20_to_34(H12[0][0]);
+ map_val_20_to_34(H12[1][0]);
+ map_val_20_to_34(H21[0][0]);
+ map_val_20_to_34(H21[1][0]);
+ map_val_20_to_34(H22[0][0]);
+ map_val_20_to_34(H22[1][0]);
+ ipdopd_reset(ipd_hist, opd_hist);
+ }
+ } else {
+ remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
+ remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
+ if (ps->enable_ipdopd) {
+ remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
+ }
+ if (ps->is34bands_old) {
+ map_val_34_to_20(H11[0][0]);
+ map_val_34_to_20(H11[1][0]);
+ map_val_34_to_20(H12[0][0]);
+ map_val_34_to_20(H12[1][0]);
+ map_val_34_to_20(H21[0][0]);
+ map_val_34_to_20(H21[1][0]);
+ map_val_34_to_20(H22[0][0]);
+ map_val_34_to_20(H22[1][0]);
+ ipdopd_reset(ipd_hist, opd_hist);
+ }
+ }
+
+ //Mixing
+ for (e = 0; e < ps->num_env; e++) {
+ for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
+ float h11, h12, h21, h22;
+ h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
+ h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
+ h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
+ h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
+
+ if (!PS_BASELINE && ps->enable_ipdopd && 2*b <= NR_PAR_BANDS[is34]) {
+ //The spec say says to only run this smoother when enable_ipdopd
+ //is set but the reference decoder appears to run it constantly
+ float h11i, h12i, h21i, h22i;
+ float ipd_adj_re, ipd_adj_im;
+ int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
+ int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
+ float opd_re = pd_re_smooth[opd_idx];
+ float opd_im = pd_im_smooth[opd_idx];
+ float ipd_re = pd_re_smooth[ipd_idx];
+ float ipd_im = pd_im_smooth[ipd_idx];
+ opd_hist[b] = opd_idx & 0x3F;
+ ipd_hist[b] = ipd_idx & 0x3F;
+
+ ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
+ ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
+ h11i = h11 * opd_im;
+ h11 = h11 * opd_re;
+ h12i = h12 * ipd_adj_im;
+ h12 = h12 * ipd_adj_re;
+ h21i = h21 * opd_im;
+ h21 = h21 * opd_re;
+ h22i = h22 * ipd_adj_im;
+ h22 = h22 * ipd_adj_re;
+ H11[1][e+1][b] = h11i;
+ H12[1][e+1][b] = h12i;
+ H21[1][e+1][b] = h21i;
+ H22[1][e+1][b] = h22i;
+ }
+ H11[0][e+1][b] = h11;
+ H12[0][e+1][b] = h12;
+ H21[0][e+1][b] = h21;
+ H22[0][e+1][b] = h22;
+ }
+ for (k = 0; k < NR_BANDS[is34]; k++) {
+ float h[2][4];
+ float h_step[2][4];
+ int start = ps->border_position[e];
+ int stop = ps->border_position[e+1];
+ float width = 1.f / (stop - start);
+ b = k_to_i[k];
+ h[0][0] = H11[0][e][b];
+ h[0][1] = H12[0][e][b];
+ h[0][2] = H21[0][e][b];
+ h[0][3] = H22[0][e][b];
+ if (!PS_BASELINE && ps->enable_ipdopd) {
+ //Is this necessary? ps_04_new seems unchanged
+ if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
+ h[1][0] = -H11[1][e][b];
+ h[1][1] = -H12[1][e][b];
+ h[1][2] = -H21[1][e][b];
+ h[1][3] = -H22[1][e][b];
+ } else {
+ h[1][0] = H11[1][e][b];
+ h[1][1] = H12[1][e][b];
+ h[1][2] = H21[1][e][b];
+ h[1][3] = H22[1][e][b];
+ }
+ }
+ //Interpolation
+ h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width;
+ h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width;
+ h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width;
+ h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width;
+ if (!PS_BASELINE && ps->enable_ipdopd) {
+ h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width;
+ h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width;
+ h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width;
+ h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width;
+ }
+ ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd](
+ l[k] + start + 1, r[k] + start + 1,
+ h, h_step, stop - start);
+ }
+ }
+}
diff --git a/libavcodec/aacpsdata.c b/libavcodec/aacpsdata.c
index 7431cae..5c1a1b0 100644
--- a/libavcodec/aacpsdata.c
+++ b/libavcodec/aacpsdata.c
@@ -157,7 +157,7 @@ static const int8_t k_to_i_34[] = {
33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
};
-static const float g1_Q2[] = {
- 0.0f, 0.01899487526049f, 0.0f, -0.07293139167538f,
- 0.0f, 0.30596630545168f, 0.5f
+static const INTFLOAT g1_Q2[] = {
+ Q31(0.0f), Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f),
+ Q31(0.0f), Q31(0.30596630545168f), Q31(0.5f)
};
diff --git a/libavcodec/aacpsdsp.c b/libavcodec/aacpsdsp.c
index 9f62844..ae9b284 100644
--- a/libavcodec/aacpsdsp.c
+++ b/libavcodec/aacpsdsp.c
@@ -29,6 +29,18 @@ static void ps_add_squares_c(float *dst, const float (*src)[2], int n)
dst[i] += src[i][0] * src[i][0] + src[i][1] * src[i][1];
}
+static void ps_add_squares_fixed_c(int *dst, const int (*src)[2], int n)
+{
+ int i;
+ long long accu;
+
+ for (i = 0; i < n; i++) {
+ accu = (long long)src[i][0] * src[i][0];
+ accu += (long long)src[i][1] * src[i][1];
+ dst[i] += (int)((accu + 0x8000000) >> 28);
+ }
+}
+
static void ps_mul_pair_single_c(float (*dst)[2], float (*src0)[2], float *src1,
int n)
{
@@ -39,6 +51,20 @@ static void ps_mul_pair_single_c(float (*dst)[2], float (*src0)[2], float *src1,
}
}
+static void ps_mul_pair_single_fixed_c(int (*dst)[2], int (*src0)[2], int *src1,
+ int n)
+{
+ int i;
+ long long accu;
+
+ for (i = 0; i < n; i++) {
+ accu = (long long)src0[i][0] * src1[i];
+ dst[i][0] = (int)((accu + 0x8000) >> 16);
+ accu = (long long)src0[i][1] * src1[i];
+ dst[i][1] = (int)((accu + 0x8000) >> 16);
+ }
+}
+
static void ps_hybrid_analysis_c(float (*out)[2], float (*in)[2],
const float (*filter)[8][2],
int stride, int n)
@@ -64,6 +90,32 @@ static void ps_hybrid_analysis_c(float (*out)[2], float (*in)[2],
}
}
+static void ps_hybrid_analysis_fixed_c(int (*out)[2], int (*in)[2],
+ const int (*filter)[8][2],
+ int stride, int n)
+{
+ int i, j;
+ long long sum_re, sum_im;
+
+ for (i = 0; i < n; i++) {
+ sum_re = (long long)filter[i][6][0] * in[6][0];
+ sum_im = (long long)filter[i][6][0] * in[6][1];
+
+ for (j = 0; j < 6; j++) {
+ int in0_re = in[j][0];
+ int in0_im = in[j][1];
+ int in1_re = in[12-j][0];
+ int in1_im = in[12-j][1];
+ sum_re += (long long)filter[i][j][0] * (in0_re + in1_re);
+ sum_re -= (long long)filter[i][j][1] * (in0_im - in1_im);
+ sum_im += (long long)filter[i][j][0] * (in0_im + in1_im);
+ sum_im += (long long)filter[i][j][1] * (in0_re - in1_re);
+ }
+ out[i * stride][0] = (int)((sum_re + 0x40000000) >> 31);
+ out[i * stride][1] = (int)((sum_im + 0x40000000) >> 31);
+ }
+}
+
static void ps_hybrid_analysis_ileave_c(float (*out)[32][2], float L[2][38][64],
int i, int len)
{
@@ -77,6 +129,19 @@ static void ps_hybrid_analysis_ileave_c(float (*out)[32][2], float L[2][38][64],
}
}
+static void ps_hybrid_analysis_ileave_fixed_c(int (*out)[32][2], int L[2][38][64],
+ int i, int len)
+{
+ int j;
+
+ for (; i < 64; i++) {
+ for (j = 0; j < len; j++) {
+ out[i][j][0] = L[0][j][i];
+ out[i][j][1] = L[1][j][i];
+ }
+ }
+}
+
static void ps_hybrid_synthesis_deint_c(float out[2][38][64],
float (*in)[32][2],
int i, int len)
@@ -91,6 +156,20 @@ static void ps_hybrid_synthesis_deint_c(float out[2][38][64],
}
}
+static void ps_hybrid_synthesis_deint_fixed_c(int out[2][38][64],
+ int (*in)[32][2],
+ int i, int len)
+{
+ int n;
+
+ for (; i < 64; i++) {
+ for (n = 0; n < len; n++) {
+ out[0][n][i] = in[i][n][0];
+ out[1][n][i] = in[i][n][1];
+ }
+ }
+}
+
static void ps_decorrelate_c(float (*out)[2], float (*delay)[2],
float (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2],
const float phi_fract[2], float (*Q_fract)[2],
@@ -131,6 +210,68 @@ static void ps_decorrelate_c(float (*out)[2], float (*delay)[2],
}
}
+static void ps_decorrelate_fixed_c(int (*out)[2], int (*delay)[2],
+ int (*ap_delay)[PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2],
+ const int phi_fract[2], int (*Q_fract)[2],
+ const int *transient_gain,
+ int g_decay_slope,
+ int len)
+{
+ static const int a[] = { 1398954724, 1212722933, 1051282709 };
+ int ag[PS_AP_LINKS];
+ int m, n;
+ long long accu;
+
+ for (m = 0; m < PS_AP_LINKS; m++) {
+ accu = (long long)a[m] * g_decay_slope;
+ ag[m] = (int)((accu + 0x20000000) >> 30);
+ }
+
+ for (n = 0; n < len; n++) {
+ int in_re;
+ int in_im;
+
+ accu = (long long)delay[n][0] * phi_fract[0];
+ accu -= (long long)delay[n][1] * phi_fract[1];
+ in_re = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)delay[n][0] * phi_fract[1];
+ accu += (long long)delay[n][1] * phi_fract[0];
+ in_im = (int)((accu + 0x20000000) >> 30);
+ for (m = 0; m < PS_AP_LINKS; m++) {
+ int a_re;
+ int a_im;
+ int link_delay_re = ap_delay[m][n+2-m][0];
+ int link_delay_im = ap_delay[m][n+2-m][1];
+ int fractional_delay_re = Q_fract[m][0];
+ int fractional_delay_im = Q_fract[m][1];
+ int apd_re = in_re;
+ int apd_im = in_im;
+
+ accu = (long long)ag[m] * in_re;
+ a_re = (int)((accu + 0x40000000) >> 31);
+ accu = (long long)ag[m] * in_im;
+ a_im = (int)((accu + 0x40000000) >> 31);
+
+ accu = (long long)link_delay_re * fractional_delay_re;
+ accu -= (long long)link_delay_im * fractional_delay_im;
+ in_re = (int)((accu + 0x20000000) >> 30) - a_re;
+ accu = (long long)link_delay_re * fractional_delay_im;
+ accu += (long long)link_delay_im * fractional_delay_re;
+ in_im = (int)((accu + 0x20000000) >> 30) - a_im;
+
+ accu = (long long)ag[m] * in_re;
+ ap_delay[m][n+5][0] = apd_re + (int)((accu + 0x40000000) >> 31);
+ accu = (long long)ag[m] * in_im;
+ ap_delay[m][n+5][1] = apd_im + (int)((accu + 0x40000000) >> 31);
+ }
+ accu = (long long)transient_gain[n] * in_re;
+ out[n][0] = (int)((accu + 0x8000) >> 16);
+ accu = (long long)transient_gain[n] * in_im;
+ out[n][1] = (int)((accu + 0x8000) >> 16);
+ }
+}
+
+
static void ps_stereo_interpolate_c(float (*l)[2], float (*r)[2],
float h[2][4], float h_step[2][4],
int len)
@@ -162,6 +303,46 @@ static void ps_stereo_interpolate_c(float (*l)[2], float (*r)[2],
}
}
+static void ps_stereo_interpolate_fixed_c(int (*l)[2], int (*r)[2],
+ int h[2][4], int h_step[2][4],
+ int len)
+{
+ int h0 = h[0][0];
+ int h1 = h[0][1];
+ int h2 = h[0][2];
+ int h3 = h[0][3];
+ int hs0 = h_step[0][0];
+ int hs1 = h_step[0][1];
+ int hs2 = h_step[0][2];
+ int hs3 = h_step[0][3];
+ int n;
+
+ for (n = 0; n < len; n++) {
+ //l is s, r is d
+ long long accu;
+ int l_re = l[n][0];
+ int l_im = l[n][1];
+ int r_re = r[n][0];
+ int r_im = r[n][1];
+ h0 += hs0;
+ h1 += hs1;
+ h2 += hs2;
+ h3 += hs3;
+ accu = (long long)h0 * l_re;
+ accu += (long long)h2 * r_re;
+ l[n][0] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h0 * l_im;
+ accu += (long long)h2 * r_im;
+ l[n][1] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h1 * l_re;
+ accu += (long long)h3 * r_re;
+ r[n][0] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h1 * l_im;
+ accu += (long long)h3 * r_im;
+ r[n][1] = (int)((accu + 0x20000000) >> 30);
+ }
+}
+
static void ps_stereo_interpolate_ipdopd_c(float (*l)[2], float (*r)[2],
float h[2][4], float h_step[2][4],
int len)
@@ -198,16 +379,77 @@ static void ps_stereo_interpolate_ipdopd_c(float (*l)[2], float (*r)[2],
}
}
+static void ps_stereo_interpolate_ipdopd_fixed_c(int (*l)[2], int (*r)[2],
+ int h[2][4], int h_step[2][4],
+ int len)
+{
+ int h00 = h[0][0], h10 = h[1][0];
+ int h01 = h[0][1], h11 = h[1][1];
+ int h02 = h[0][2], h12 = h[1][2];
+ int h03 = h[0][3], h13 = h[1][3];
+ int hs00 = h_step[0][0], hs10 = h_step[1][0];
+ int hs01 = h_step[0][1], hs11 = h_step[1][1];
+ int hs02 = h_step[0][2], hs12 = h_step[1][2];
+ int hs03 = h_step[0][3], hs13 = h_step[1][3];
+ int n;
+
+ for (n = 0; n < len; n++) {
+ //l is s, r is d
+ long long accu;
+ int l_re = l[n][0];
+ int l_im = l[n][1];
+ int r_re = r[n][0];
+ int r_im = r[n][1];
+ h00 += hs00;
+ h01 += hs01;
+ h02 += hs02;
+ h03 += hs03;
+ h10 += hs10;
+ h11 += hs11;
+ h12 += hs12;
+ h13 += hs13;
+
+ accu = (long long)h00 * l_re;
+ accu += (long long)h02 * r_re;
+ accu -= (long long)h10 * l_im;
+ accu -= (long long)h12 * r_im;
+ l[n][0] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h00 * l_im;
+ accu += (long long)h02 * r_im;
+ accu += (long long)h10 * l_re;
+ accu += (long long)h12 * r_re;
+ l[n][1] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h01 * l_re;
+ accu += (long long)h03 * r_re;
+ accu -= (long long)h11 * l_im;
+ accu -= (long long)h13 * r_im;
+ r[n][0] = (int)((accu + 0x20000000) >> 30);
+ accu = (long long)h01 * l_im;
+ accu += (long long)h03 * r_im;
+ accu += (long long)h11 * l_re;
+ accu += (long long)h13 * r_re;
+ r[n][1] = (int)((accu + 0x20000000) >> 30);
+ }
+}
+
av_cold void ff_psdsp_init(PSDSPContext *s)
{
- s->add_squares = ps_add_squares_c;
- s->mul_pair_single = ps_mul_pair_single_c;
- s->hybrid_analysis = ps_hybrid_analysis_c;
- s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c;
- s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c;
- s->decorrelate = ps_decorrelate_c;
- s->stereo_interpolate[0] = ps_stereo_interpolate_c;
- s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c;
+ s->add_squares = ps_add_squares_c;
+ s->add_squares_fixed = ps_add_squares_fixed_c;
+ s->mul_pair_single = ps_mul_pair_single_c;
+ s->mul_pair_single_fixed = ps_mul_pair_single_fixed_c;
+ s->hybrid_analysis = ps_hybrid_analysis_c;
+ s->hybrid_analysis_fixed = ps_hybrid_analysis_fixed_c;
+ s->hybrid_analysis_ileave = ps_hybrid_analysis_ileave_c;
+ s->hybrid_analysis_ileave_fixed = ps_hybrid_analysis_ileave_fixed_c;
+ s->hybrid_synthesis_deint = ps_hybrid_synthesis_deint_c;
+ s->hybrid_synthesis_deint_fixed = ps_hybrid_synthesis_deint_fixed_c;
+ s->decorrelate = ps_decorrelate_c;
+ s->decorrelate_fixed = ps_decorrelate_fixed_c;
+ s->stereo_interpolate[0] = ps_stereo_interpolate_c;
+ s->stereo_interpolate_fixed[0] = ps_stereo_interpolate_fixed_c;
+ s->stereo_interpolate[1] = ps_stereo_interpolate_ipdopd_c;
+ s->stereo_interpolate_fixed[1] = ps_stereo_interpolate_ipdopd_fixed_c;
if (ARCH_ARM)
ff_psdsp_init_arm(s);
diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h
index 74a8af6..64c8d2d 100644
--- a/libavcodec/aacpsdsp.h
+++ b/libavcodec/aacpsdsp.h
@@ -27,24 +27,43 @@
typedef struct PSDSPContext {
void (*add_squares)(float *dst, const float (*src)[2], int n);
+ void (*add_squares_fixed)(int *dst, const int (*src)[2], int n);
void (*mul_pair_single)(float (*dst)[2], float (*src0)[2], float *src1,
int n);
+ void (*mul_pair_single_fixed)(int (*dst)[2], int (*src0)[2], int *src1,
+ int n);
void (*hybrid_analysis)(float (*out)[2], float (*in)[2],
const float (*filter)[8][2],
int stride, int n);
+ void (*hybrid_analysis_fixed)(int (*out)[2], int (*in)[2],
+ const int (*filter)[8][2],
+ int stride, int n);
void (*hybrid_analysis_ileave)(float (*out)[32][2], float L[2][38][64],
int i, int len);
+ void (*hybrid_analysis_ileave_fixed)(int (*out)[32][2], int L[2][38][64],
+ int i, int len);
void (*hybrid_synthesis_deint)(float out[2][38][64], float (*in)[32][2],
int i, int len);
+ void (*hybrid_synthesis_deint_fixed)(int out[2][38][64], int (*in)[32][2],
+ int i, int len);
void (*decorrelate)(float (*out)[2], float (*delay)[2],
float (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],
const float phi_fract[2], float (*Q_fract)[2],
const float *transient_gain,
float g_decay_slope,
int len);
+ void (*decorrelate_fixed)(int (*out)[2], int (*delay)[2],
+ int (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],
+ const int phi_fract[2], int (*Q_fract)[2],
+ const int *transient_gain,
+ int g_decay_slope,
+ int len);
void (*stereo_interpolate[2])(float (*l)[2], float (*r)[2],
float h[2][4], float h_step[2][4],
int len);
+ void (*stereo_interpolate_fixed[2])(int (*l)[2], int (*r)[2],
+ int h[2][4], int h_step[2][4],
+ int len);
} PSDSPContext;
void ff_psdsp_init(PSDSPContext *s);
--
1.7.3.4
More information about the ffmpeg-devel
mailing list