forked from len0rd/rockbox
More unification of FIXED_POINT and FLOAT. Small refactoring.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28084 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
82c143c4e1
commit
9fb54ae32b
3 changed files with 54 additions and 78 deletions
|
|
@ -285,9 +285,10 @@ char *strchr(), *strrchr();
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define MUL_R(A,B) ((A)*(B))
|
#define MUL_R(A,B) ((A)*(B))
|
||||||
#define MUL_C(A,B) ((A)*(B))
|
#define MUL_C(A,B) ((A)*(B))
|
||||||
#define MUL_F(A,B) ((A)*(B))
|
#define MUL_F(A,B) ((A)*(B))
|
||||||
|
#define MUL_Q2(A,B) ((A)*(B))
|
||||||
|
|
||||||
/* Complex multiplication */
|
/* Complex multiplication */
|
||||||
static INLINE void ComplexMult(real_t *y1, real_t *y2,
|
static INLINE void ComplexMult(real_t *y1, real_t *y2,
|
||||||
|
|
@ -306,9 +307,10 @@ char *strchr(), *strrchr();
|
||||||
|
|
||||||
typedef float real_t;
|
typedef float real_t;
|
||||||
|
|
||||||
#define MUL_R(A,B) ((A)*(B))
|
#define MUL_R(A,B) ((A)*(B))
|
||||||
#define MUL_C(A,B) ((A)*(B))
|
#define MUL_C(A,B) ((A)*(B))
|
||||||
#define MUL_F(A,B) ((A)*(B))
|
#define MUL_F(A,B) ((A)*(B))
|
||||||
|
#define MUL_Q2(A,B) ((A)*(B))
|
||||||
|
|
||||||
#define REAL_CONST(A) ((real_t)(A))
|
#define REAL_CONST(A) ((real_t)(A))
|
||||||
#define COEF_CONST(A) ((real_t)(A))
|
#define COEF_CONST(A) ((real_t)(A))
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,11 @@
|
||||||
#include "sbr_noise.h"
|
#include "sbr_noise.h"
|
||||||
|
|
||||||
#ifdef FIXED_POINT
|
#ifdef FIXED_POINT
|
||||||
#define REAL_SCALE(A) ((A)<<REAL_BITS)
|
#define REAL_UPSCALE(A) ((A)<<REAL_BITS)
|
||||||
|
#define REAL_DOWNSCALE(A) ((A)>>REAL_BITS)
|
||||||
#else
|
#else
|
||||||
#define REAL_SCALE(A) (A)
|
#define REAL_UPSCALE(A) (A)
|
||||||
|
#define REAL_DOWNSCALE(A) (A)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* static function declarations */
|
/* static function declarations */
|
||||||
|
|
@ -156,10 +158,10 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
|
||||||
for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++)
|
for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++)
|
||||||
{
|
{
|
||||||
tmp = QMF_RE(Xsbr[i][m + sbr->kx]);
|
tmp = QMF_RE(Xsbr[i][m + sbr->kx]);
|
||||||
nrg += MUL_R(tmp, (tmp>>REAL_BITS));
|
nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp));
|
||||||
#ifndef SBR_LOW_POWER
|
#ifndef SBR_LOW_POWER
|
||||||
tmp = QMF_IM(Xsbr[i][m + sbr->kx]);
|
tmp = QMF_IM(Xsbr[i][m + sbr->kx]);
|
||||||
nrg += MUL_R(tmp, (tmp>>REAL_BITS));
|
nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,10 +194,10 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj,
|
||||||
for (j = k_l; j < k_h; j++)
|
for (j = k_l; j < k_h; j++)
|
||||||
{
|
{
|
||||||
tmp = QMF_RE(Xsbr[i][j]);
|
tmp = QMF_RE(Xsbr[i][j]);
|
||||||
nrg += MUL_R(tmp, (tmp>>REAL_BITS));
|
nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp));
|
||||||
#ifndef SBR_LOW_POWER
|
#ifndef SBR_LOW_POWER
|
||||||
tmp = QMF_IM(Xsbr[i][j]);
|
tmp = QMF_IM(Xsbr[i][j]);
|
||||||
nrg += MUL_R(tmp, (tmp>>REAL_BITS));
|
nrg += MUL_R(tmp, REAL_DOWNSCALE(tmp));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1151,7 +1153,6 @@ static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
|
||||||
real_t den = 0;
|
real_t den = 0;
|
||||||
real_t acc1 = 0;
|
real_t acc1 = 0;
|
||||||
real_t acc2 = 0;
|
real_t acc2 = 0;
|
||||||
uint8_t current_res_band_size = 0;
|
|
||||||
|
|
||||||
uint8_t ml1, ml2;
|
uint8_t ml1, ml2;
|
||||||
|
|
||||||
|
|
@ -1382,11 +1383,7 @@ static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg,
|
||||||
/* E_total_est: integer */
|
/* E_total_est: integer */
|
||||||
/* E_total: integer */
|
/* E_total: integer */
|
||||||
E_total_est += sbr->E_curr[ch][m-sbr->kx][l];
|
E_total_est += sbr->E_curr[ch][m-sbr->kx][l];
|
||||||
#ifdef FIXED_POINT
|
|
||||||
E_total += MUL_Q2(sbr->E_curr[ch][m-sbr->kx][l], adj->G_lim_boost[l][m-sbr->kx]);
|
E_total += MUL_Q2(sbr->E_curr[ch][m-sbr->kx][l], adj->G_lim_boost[l][m-sbr->kx]);
|
||||||
#else
|
|
||||||
E_total += sbr->E_curr[ch][m-sbr->kx][l] * adj->G_lim_boost[l][m-sbr->kx];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* G_target: fixed point */
|
/* G_target: fixed point */
|
||||||
|
|
@ -1414,11 +1411,7 @@ static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg,
|
||||||
MUL_C((COEF_CONST(1)-alpha), adj->G_lim_boost[l][m-sbr->kx]);
|
MUL_C((COEF_CONST(1)-alpha), adj->G_lim_boost[l][m-sbr->kx]);
|
||||||
|
|
||||||
/* acc: integer */
|
/* acc: integer */
|
||||||
#ifdef FIXED_POINT
|
|
||||||
acc += MUL_Q2(adj->G_lim_boost[l][m-sbr->kx], sbr->E_curr[ch][m-sbr->kx][l]);
|
acc += MUL_Q2(adj->G_lim_boost[l][m-sbr->kx], sbr->E_curr[ch][m-sbr->kx][l]);
|
||||||
#else
|
|
||||||
acc += adj->G_lim_boost[l][m-sbr->kx] * sbr->E_curr[ch][m-sbr->kx][l];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* acc: fixed point */
|
/* acc: fixed point */
|
||||||
|
|
@ -1430,11 +1423,7 @@ static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg,
|
||||||
}
|
}
|
||||||
for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++)
|
for(m = sbr->f_group[l][(k<<1)]; m < sbr->f_group[l][(k<<1) + 1]; m++)
|
||||||
{
|
{
|
||||||
#ifdef FIXED_POINT
|
|
||||||
adj->G_lim_boost[l][m-sbr->kx] = MUL_Q2(acc, adj->G_lim_boost[l][m-sbr->kx]);
|
adj->G_lim_boost[l][m-sbr->kx] = MUL_Q2(acc, adj->G_lim_boost[l][m-sbr->kx]);
|
||||||
#else
|
|
||||||
adj->G_lim_boost[l][m-sbr->kx] = acc * adj->G_lim_boost[l][m-sbr->kx];
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1556,33 +1545,24 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj,
|
||||||
|
|
||||||
/* the smoothed gain values are applied to Xsbr */
|
/* the smoothed gain values are applied to Xsbr */
|
||||||
/* V is defined, not calculated */
|
/* V is defined, not calculated */
|
||||||
#ifndef FIXED_POINT
|
|
||||||
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = G_filt * QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx])
|
|
||||||
+ MUL_F(Q_filt, RE(V[fIndexNoise]));
|
|
||||||
#else
|
|
||||||
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
|
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
|
||||||
+ MUL_F(Q_filt, RE(V[fIndexNoise]));
|
+ MUL_F(Q_filt, RE(V[fIndexNoise]));
|
||||||
#endif
|
|
||||||
if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42)
|
if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42)
|
||||||
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = 16428320;
|
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = 16428320;
|
||||||
#ifndef SBR_LOW_POWER
|
#ifndef SBR_LOW_POWER
|
||||||
#ifndef FIXED_POINT
|
|
||||||
QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = G_filt * QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx])
|
|
||||||
+ MUL_F(Q_filt, IM(V[fIndexNoise]));
|
|
||||||
#else
|
|
||||||
QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
|
QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL_R(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
|
||||||
+ MUL_F(Q_filt, IM(V[fIndexNoise]));
|
+ MUL_F(Q_filt, IM(V[fIndexNoise]));
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
int8_t rev = (((m + sbr->kx) & 1) ? -1 : 1);
|
int8_t rev = (((m + sbr->kx) & 1) ? -1 : 1);
|
||||||
QMF_RE(psi) = adj->S_M_boost[l][m] * phi_re[fIndexSine];
|
QMF_RE(psi) = adj->S_M_boost[l][m] * phi_re[fIndexSine];
|
||||||
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_SCALE(QMF_RE(psi));
|
QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_UPSCALE(QMF_RE(psi));
|
||||||
|
|
||||||
#ifndef SBR_LOW_POWER
|
#ifndef SBR_LOW_POWER
|
||||||
QMF_IM(psi) = rev * adj->S_M_boost[l][m] * phi_im[fIndexSine];
|
QMF_IM(psi) = rev * adj->S_M_boost[l][m] * phi_im[fIndexSine];
|
||||||
QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_SCALE(QMF_IM(psi));
|
QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += REAL_UPSCALE(QMF_IM(psi));
|
||||||
#else
|
#else
|
||||||
|
|
||||||
i_min1 = (fIndexSine - 1) & 3;
|
i_min1 = (fIndexSine - 1) & 3;
|
||||||
|
|
@ -1593,29 +1573,29 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj,
|
||||||
real_t tmp3 = 0;
|
real_t tmp3 = 0;
|
||||||
if ((m == 0) && (phi_re[i_plus1] != 0))
|
if ((m == 0) && (phi_re[i_plus1] != 0))
|
||||||
{
|
{
|
||||||
tmp1 += (phi_re[i_plus1] * MUL_F(REAL_SCALE(adj->S_M_boost[l][0]), FRAC_CONST(0.00815)));
|
tmp1 += (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][0]), FRAC_CONST(0.00815)));
|
||||||
if (sbr->M != 0)
|
if (sbr->M != 0)
|
||||||
{
|
{
|
||||||
tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_SCALE(adj->S_M_boost[l][1]), FRAC_CONST(0.00815)));
|
tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][1]), FRAC_CONST(0.00815)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0))
|
if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0))
|
||||||
{
|
{
|
||||||
tmp2 -= (phi_re[i_min1] * MUL_F(REAL_SCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815)));
|
tmp2 -= (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815)));
|
||||||
}
|
}
|
||||||
if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_plus1] != 0))
|
if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16) && (phi_re[i_plus1] != 0))
|
||||||
{
|
{
|
||||||
tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_SCALE(adj->S_M_boost[l][m + 1]), FRAC_CONST(0.00815)));
|
tmp2 -= (phi_re[i_plus1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m + 1]), FRAC_CONST(0.00815)));
|
||||||
}
|
}
|
||||||
if ((m == sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0))
|
if ((m == sbr->M - 1) && (sinusoids < 16) && (phi_re[i_min1] != 0))
|
||||||
{
|
{
|
||||||
if (m > 0)
|
if (m > 0)
|
||||||
{
|
{
|
||||||
tmp2 -= (phi_re[i_min1] * MUL_F(REAL_SCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815)));
|
tmp2 -= (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m - 1]), FRAC_CONST(0.00815)));
|
||||||
}
|
}
|
||||||
if (m + sbr->kx < 64)
|
if (m + sbr->kx < 64)
|
||||||
{
|
{
|
||||||
tmp3 += (phi_re[i_min1] * MUL_F(REAL_SCALE(adj->S_M_boost[l][m]), FRAC_CONST(0.00815)));
|
tmp3 += (phi_re[i_min1] * MUL_F(REAL_UPSCALE(adj->S_M_boost[l][m]), FRAC_CONST(0.00815)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,20 @@ typedef struct
|
||||||
real_t det;
|
real_t det;
|
||||||
} acorr_coef;
|
} acorr_coef;
|
||||||
|
|
||||||
|
/* Within auto_correlation(...) a pre-shift of >>2 is needed to avoid overflow
|
||||||
|
* when multiply-adding the FRACT-variables -- FRACT part is 31 bits. After the
|
||||||
|
* calculation has been finished the result 'ac->det' needs to be
|
||||||
|
* post-shifted by <<(4*2). This pre-/post-shifting is needed for FIXED_POINT
|
||||||
|
* only. */
|
||||||
|
#ifdef FIXED_POINT
|
||||||
|
#define ACDET_EXP 2
|
||||||
|
#define ACDET_PRE(A) (A)>>ACDET_EXP
|
||||||
|
#define ACDET_POST(A) (A)<<(4*ACDET_EXP)
|
||||||
|
#else
|
||||||
|
#define ACDET_PRE(A) (A)
|
||||||
|
#define ACDET_POST(A) (A)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SBR_LOW_POWER
|
#ifdef SBR_LOW_POWER
|
||||||
static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
|
static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
|
||||||
qmf_t buffer[MAX_NTSRHFG][64],
|
qmf_t buffer[MAX_NTSRHFG][64],
|
||||||
|
|
@ -194,41 +208,31 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac,
|
||||||
real_t tmp1, tmp2;
|
real_t tmp1, tmp2;
|
||||||
int8_t j;
|
int8_t j;
|
||||||
uint8_t offset = sbr->tHFAdj;
|
uint8_t offset = sbr->tHFAdj;
|
||||||
#ifdef FIXED_POINT
|
|
||||||
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
|
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
|
||||||
/* A pre-shift of >>2 is needed to avoid overflow when multiply-adding
|
|
||||||
* the FRACT-variables buffer -- FRACT part is 31 bits. After the
|
|
||||||
* calculation has been finished the result 'ac.det' needs to be
|
|
||||||
* post-shifted by <<(4*exp). */
|
|
||||||
const uint32_t exp = 2;
|
|
||||||
#else
|
|
||||||
const real_t rel = 1 / (1 + 1e-6f);
|
|
||||||
const uint32_t exp = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (j = offset; j < len + offset; j++)
|
for (j = offset; j < len + offset; j++)
|
||||||
{
|
{
|
||||||
real_t buf_j = QMF_RE(buffer[j ][bd]) >> exp;
|
real_t buf_j = ACDET_PRE(QMF_RE(buffer[j ][bd]));
|
||||||
real_t buf_j_1 = QMF_RE(buffer[j-1][bd]) >> exp;
|
real_t buf_j_1 = ACDET_PRE(QMF_RE(buffer[j-1][bd]));
|
||||||
real_t buf_j_2 = QMF_RE(buffer[j-2][bd]) >> exp;
|
real_t buf_j_2 = ACDET_PRE(QMF_RE(buffer[j-2][bd]));
|
||||||
|
|
||||||
r01 += MUL_F(buf_j , buf_j_1);
|
r01 += MUL_F(buf_j , buf_j_1);
|
||||||
r02 += MUL_F(buf_j , buf_j_2);
|
r02 += MUL_F(buf_j , buf_j_2);
|
||||||
r11 += MUL_F(buf_j_1, buf_j_1);
|
r11 += MUL_F(buf_j_1, buf_j_1);
|
||||||
}
|
}
|
||||||
tmp1 = QMF_RE(buffer[len+offset-1][bd]) >> exp;
|
tmp1 = ACDET_PRE(QMF_RE(buffer[len+offset-1][bd]));
|
||||||
tmp2 = QMF_RE(buffer[ offset-1][bd]) >> exp;
|
tmp2 = ACDET_PRE(QMF_RE(buffer[ offset-1][bd]));
|
||||||
RE(ac->r12) = r01 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2);
|
RE(ac->r12) = r01 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2);
|
||||||
|
|
||||||
tmp1 = QMF_RE(buffer[len+offset-2][bd]) >> exp;
|
tmp1 = ACDET_PRE(QMF_RE(buffer[len+offset-2][bd]));
|
||||||
tmp2 = QMF_RE(buffer[ offset-2][bd]) >> exp;
|
tmp2 = ACDET_PRE(QMF_RE(buffer[ offset-2][bd]));
|
||||||
RE(ac->r22) = r11 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2);
|
RE(ac->r22) = r11 - MUL_F(tmp1, tmp1) + MUL_F(tmp2, tmp2);
|
||||||
RE(ac->r01) = r01;
|
RE(ac->r01) = r01;
|
||||||
RE(ac->r02) = r02;
|
RE(ac->r02) = r02;
|
||||||
RE(ac->r11) = r11;
|
RE(ac->r11) = r11;
|
||||||
|
|
||||||
ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_F(RE(ac->r12), RE(ac->r12)), rel);
|
ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F(MUL_F(RE(ac->r12), RE(ac->r12)), rel);
|
||||||
ac->det <<= (4*exp); /* Post-shift as described above. */
|
ac->det = ACDET_POST(ac->det);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64],
|
static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTSRHFG][64],
|
||||||
|
|
@ -239,22 +243,12 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
|
||||||
real_t temp4_r, temp4_i, temp5_r, temp5_i;
|
real_t temp4_r, temp4_i, temp5_r, temp5_i;
|
||||||
int8_t j;
|
int8_t j;
|
||||||
uint8_t offset = sbr->tHFAdj;
|
uint8_t offset = sbr->tHFAdj;
|
||||||
#ifdef FIXED_POINT
|
|
||||||
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
|
const real_t rel = FRAC_CONST(0.999999); // 1 / (1 + 1e-6f);
|
||||||
/* A pre-shift of >>2 is needed to avoid overflow when multiply-adding
|
|
||||||
* the FRACT-variables buffer -- FRACT part is 31 bits. After the
|
|
||||||
* calculation has been finished the result 'ac.det' needs to be
|
|
||||||
* post-shifted by <<(4*exp). */
|
|
||||||
const uint32_t exp = 2;
|
|
||||||
#else
|
|
||||||
const real_t rel = 1 / (1 + 1e-6f);
|
|
||||||
const uint32_t exp = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
temp2_r = QMF_RE(buffer[offset-2][bd]) >> exp;
|
temp2_r = ACDET_PRE(QMF_RE(buffer[offset-2][bd]));
|
||||||
temp2_i = QMF_IM(buffer[offset-2][bd]) >> exp;
|
temp2_i = ACDET_PRE(QMF_IM(buffer[offset-2][bd]));
|
||||||
temp3_r = QMF_RE(buffer[offset-1][bd]) >> exp;
|
temp3_r = ACDET_PRE(QMF_RE(buffer[offset-1][bd]));
|
||||||
temp3_i = QMF_IM(buffer[offset-1][bd]) >> exp;
|
temp3_i = ACDET_PRE(QMF_IM(buffer[offset-1][bd]));
|
||||||
// Save these because they are needed after loop
|
// Save these because they are needed after loop
|
||||||
temp4_r = temp2_r;
|
temp4_r = temp2_r;
|
||||||
temp4_i = temp2_i;
|
temp4_i = temp2_i;
|
||||||
|
|
@ -267,8 +261,8 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
|
||||||
temp1_i = temp2_i;
|
temp1_i = temp2_i;
|
||||||
temp2_r = temp3_r;
|
temp2_r = temp3_r;
|
||||||
temp2_i = temp3_i;
|
temp2_i = temp3_i;
|
||||||
temp3_r = QMF_RE(buffer[j][bd]) >> exp;
|
temp3_r = ACDET_PRE(QMF_RE(buffer[j][bd]));
|
||||||
temp3_i = QMF_IM(buffer[j][bd]) >> exp;
|
temp3_i = ACDET_PRE(QMF_IM(buffer[j][bd]));
|
||||||
r01r += MUL_F(temp3_r, temp2_r) + MUL_F(temp3_i, temp2_i);
|
r01r += MUL_F(temp3_r, temp2_r) + MUL_F(temp3_i, temp2_i);
|
||||||
r01i += MUL_F(temp3_i, temp2_r) - MUL_F(temp3_r, temp2_i);
|
r01i += MUL_F(temp3_i, temp2_r) - MUL_F(temp3_r, temp2_i);
|
||||||
r02r += MUL_F(temp3_r, temp1_r) + MUL_F(temp3_i, temp1_i);
|
r02r += MUL_F(temp3_r, temp1_r) + MUL_F(temp3_i, temp1_i);
|
||||||
|
|
@ -289,7 +283,7 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, qmf_t buffer[MAX_NTS
|
||||||
RE(ac->r11) = r11r;
|
RE(ac->r11) = r11r;
|
||||||
|
|
||||||
ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F((MUL_F(RE(ac->r12), RE(ac->r12)) + MUL_F(IM(ac->r12), IM(ac->r12))), rel);
|
ac->det = MUL_F(RE(ac->r11), RE(ac->r22)) - MUL_F((MUL_F(RE(ac->r12), RE(ac->r12)) + MUL_F(IM(ac->r12), IM(ac->r12))), rel);
|
||||||
ac->det <<= (4*exp); /* Post-shift as described above. */
|
ac->det = ACDET_POST(ac->det);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue