ref: 00ca67bc570551e0ad5a5af6c23c8a2637deb17f
parent: c9472c6c3d2d974cac60890e772266a16157b5c0
author: menno <menno>
date: Sat Aug 2 14:07:39 EDT 2003
fixed some stuff in the frontend removed dead code
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: main.c,v 1.43 2003/07/29 08:20:11 menno Exp $
+** $Id: main.c,v 1.44 2003/08/02 18:07:39 menno Exp $
**/
#ifdef _WIN32
@@ -614,6 +614,7 @@
}
/* print some mp4 file info */
+ fprintf(stderr, "%s file info:\n", mp4file);
{
char *file_info = MP4Info(infile, MP4_INVALID_TRACK_ID);
fprintf(stderr, "%s\n", file_info);
--- a/libfaad/sbr_e_nf.c
+++ b/libfaad/sbr_e_nf.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_e_nf.c,v 1.1 2003/07/29 08:20:13 menno Exp $
+** $Id: sbr_e_nf.c,v 1.2 2003/08/02 18:07:39 menno Exp $
**/
#include "common.h"
@@ -184,37 +184,14 @@
if (sbr->bs_coupling == 0)
{
uint8_t l, k;
-#ifdef FIXED_POINT
- uint8_t amp = (sbr->amp_res[ch]) ? 0 : 1;
-#else
real_t amp = (sbr->amp_res[ch]) ? 1.0 : 0.5;
-#endif
for (l = 0; l < sbr->L_E[ch]; l++)
{
for (k = 0; k < sbr->n[sbr->f[ch][l]]; k++)
{
-#ifndef FIXED_POINT
/* +6 for the *64 */
sbr->E_orig[ch][k][l] = pow(2, sbr->E[ch][k][l]*amp + 6);
-#else
- int8_t exp;
-
- /* +6 for the *64 and -10 for the /32 in the synthesis QMF
- * since this is a energy value: (x/32)^2 = (x^2)/1024
- */
- exp = (sbr->E[ch][k][l] >> amp) + 6 - 10;
-
-// printf("%d\n", exp);
-
- if (exp < 0)
- sbr->E_orig[ch][k][l] = 0; //REAL_CONST(1) >> -exp;
- else
- sbr->E_orig[ch][k][l] = 1 << exp; //REAL_CONST(1) << exp;
-
- if (amp && (sbr->E[ch][k][l] & 1))
- sbr->E_orig[ch][k][l] = MUL(sbr->E_orig[ch][k][l], REAL_CONST(1.414213562));
-#endif
}
}
@@ -225,15 +202,7 @@
if (sbr->Q[ch][k][l] < 0 || sbr->Q[ch][k][l] > 30)
sbr->Q_orig[ch][k][l] = 0;
else {
-#ifndef FIXED_POINT
sbr->Q_orig[ch][k][l] = pow(2, NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l]);
-#else
- int8_t exp = NOISE_FLOOR_OFFSET - sbr->Q[ch][k][l];
- if (exp < 0)
- sbr->Q_orig[ch][k][l] = REAL_CONST(1) >> -exp;
- else
- sbr->Q_orig[ch][k][l] = REAL_CONST(1) << exp;
-#endif
}
}
}
@@ -243,13 +212,8 @@
void unmap_envelope_noise(sbr_info *sbr)
{
uint8_t l, k;
-#ifdef FIXED_POINT
- uint8_t amp0 = (sbr->amp_res[0]) ? 0 : 1;
- uint8_t amp1 = (sbr->amp_res[1]) ? 0 : 1;
-#else
real_t amp0 = (sbr->amp_res[0]) ? 1.0 : 0.5;
real_t amp1 = (sbr->amp_res[1]) ? 1.0 : 0.5;
-#endif
for (l = 0; l < sbr->L_E[0]; l++)
{
@@ -257,59 +221,13 @@
{
real_t l_temp, r_temp;
-#ifdef FIXED_POINT
- int8_t exp;
-
- /* +6: * 64 ; +1: * 2 ; -10: /1024 QMF */
- exp = (sbr->E[0][k][l] >> amp0) - 3;
-
-// printf("%d\n", exp);
-
- if (exp < 0)
- l_temp = REAL_CONST(1) >> -exp;
- else
- l_temp = REAL_CONST(1) << exp;
-
- if (amp0 && (sbr->E[0][k][l] & 1))
- l_temp = MUL(l_temp, REAL_CONST(1.414213562373095));
-
- /* UN_MAP removed: (x / 4096) same as (x >> 12) */
- exp = (sbr->E[1][k][l] >> amp1) - 12;
-
-// printf("%d\n", exp);
-
- if (exp < 0)
- r_temp = REAL_CONST(1) >> -exp;
- else
- r_temp = REAL_CONST(1) << exp;
-
- if (amp1 && (sbr->E[1][k][l] & 1))
- r_temp = MUL(r_temp, REAL_CONST(1.414213562373095));
-#else
/* +6: * 64 ; +1: * 2 */
l_temp = pow(2, sbr->E[0][k][l]*amp0 + 7);
/* UN_MAP removed: (x / 4096) same as (x >> 12) */
r_temp = pow(2, sbr->E[1][k][l]*amp1 - 12);
-#endif
-
-#ifdef FIXED_POINT
- {
- real_t tmp = REAL_CONST(1.0) + r_temp;
- sbr->E_orig[1][k][l] = SBR_DIV(l_temp, tmp);
- }
-#else
sbr->E_orig[1][k][l] = l_temp / (1.0 + r_temp);
-#endif
sbr->E_orig[0][k][l] = MUL(r_temp, sbr->E_orig[1][k][l]);
-
-#ifdef FIXED_POINT
- sbr->E_orig[0][k][l] >>= REAL_BITS;
- sbr->E_orig[1][k][l] >>= REAL_BITS;
-#endif
-
- //printf("%f\t%f\n", sbr->E_orig[0][k][l] /(float)(1<<REAL_BITS), sbr->E_orig[1][k][l] /(float)(1<<REAL_BITS));
- //printf("%f\t%f\n", sbr->E_orig[0][k][l]/1024., sbr->E_orig[1][k][l]/1024.);
}
}
for (l = 0; l < sbr->L_Q[0]; l++)
@@ -324,30 +242,10 @@
} else {
real_t l_temp, r_temp;
-#ifndef FIXED_POINT
l_temp = pow(2.0, NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1);
r_temp = pow(2.0, sbr->Q[1][k][l] - 12);
-#else
- int8_t exp;
- exp = NOISE_FLOOR_OFFSET - sbr->Q[0][k][l] + 1;
- if (exp < 0)
- l_temp = REAL_CONST(1) >> -exp;
- else
- l_temp = REAL_CONST(1) << exp;
-
- exp = sbr->Q[1][k][l] - 12;
- if (exp < 0)
- r_temp = REAL_CONST(1) >> -exp;
- else
- r_temp = REAL_CONST(1) << exp;
-#endif
-
-#ifdef FIXED_POINT
- sbr->Q_orig[1][k][l] = SBR_DIV(l_temp, (REAL_CONST(1.0) + r_temp));
-#else
sbr->Q_orig[1][k][l] = l_temp / (1.0 + r_temp);
-#endif
sbr->Q_orig[0][k][l] = MUL(r_temp, sbr->Q_orig[1][k][l]);
}
}
--- a/libfaad/sbr_hfadj.c
+++ b/libfaad/sbr_hfadj.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_hfadj.c,v 1.1 2003/07/29 08:20:13 menno Exp $
+** $Id: sbr_hfadj.c,v 1.2 2003/08/02 18:07:39 menno Exp $
**/
/* High Frequency adjustment */
@@ -293,256 +293,12 @@
}
}
-#ifdef FIXED_POINT
-#define step(shift) \
- if ((0x40000000l >> shift) + root <= value) \
- { \
- value -= (0x40000000l >> shift) + root; \
- root = (root >> 1) | (0x40000000l >> shift); \
- } else { \
- root = root >> 1; \
- }
-
-/* fixed point square root approximation */
-real_t sbr_sqrt(real_t value)
-{
- real_t root = 0;
-
- step( 0); step( 2); step( 4); step( 6);
- step( 8); step(10); step(12); step(14);
- step(16); step(18); step(20); step(22);
- step(24); step(26); step(28); step(30);
-
- if (root < value)
- ++root;
-
- root <<= (REAL_BITS/2);
-
- return root;
-}
-real_t sbr_sqrt_int(real_t value)
-{
- real_t root = 0;
-
- step( 0); step( 2); step( 4); step( 6);
- step( 8); step(10); step(12); step(14);
- step(16); step(18); step(20); step(22);
- step(24); step(26); step(28); step(30);
-
- if (root < value)
- ++root;
-
- return root;
-}
-#define SBR_SQRT_FIX(A) sbr_sqrt(A)
-#define SBR_SQRT_INT(A) sbr_sqrt_int(A)
-#endif
-
-#ifdef FIXED_POINT
-#define EPS (1) /* smallest number available in fixed point */
-#else
#define EPS (1e-12)
-#endif
-
-#ifdef FIXED_POINT
-#define ONE (REAL_CONST(1)>>10)
-#else
#define ONE (1)
-#endif
-#ifdef FIXED_POINT
static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
{
- uint8_t m, l, k, i;
-
- real_t Q_M_lim[64];
- real_t G_lim[64];
- real_t G_boost;
- real_t S_M[64];
- uint8_t table_map_res_to_m[64];
-
-
- for (l = 0; l < sbr->L_E[ch]; l++)
- {
- real_t delta = (l == sbr->l_A[ch] || l == sbr->prevEnvIsShort[ch]) ? 0 : 1;
-
- for (i = 0; i < sbr->n[sbr->f[ch][l]]; i++)
- {
- for (m = sbr->f_table_res[sbr->f[ch][l]][i]; m < sbr->f_table_res[sbr->f[ch][l]][i+1]; m++)
- {
- table_map_res_to_m[m - sbr->kx] = i;
- }
- }
-
- for (k = 0; k < sbr->N_L[sbr->bs_limiter_bands]; k++)
- {
- real_t G_max;
- real_t den = 0;
- real_t acc1 = 0;
- real_t acc2 = 0;
-
- for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
- m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
- {
- /* E_orig: integer */
- acc1 += sbr->E_orig[ch][table_map_res_to_m[m]][l];
- /* E_curr: integer */
- acc2 += sbr->E_curr[ch][m][l];
- }
-
- /* G_max: fixed point */
- if (acc2 == 0)
- {
- G_max = 0xFFF;
- } else {
- G_max = (((int64_t)acc1)<<REAL_BITS) / acc2;
- switch (sbr->bs_limiter_gains)
- {
- case 0: G_max >>= 1; break;
- case 2: G_max <<= 1; break;
- default: break;
- }
- }
-
- //printf("%f %d %d\n", G_max /(float)(1<<REAL_BITS), acc1, acc2);
-
- for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
- m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
- {
- real_t d, Q_M, G;
- real_t div2;
-
- /* Q_mapped: fixed point */
- /* div2: fixed point COEF */
- real_t tmp2 = adj->Q_mapped[m][l] << (COEF_BITS-REAL_BITS);
- real_t tmp = COEF_CONST(1) + tmp2;
- if (tmp == 0)
- div2 = COEF_CONST(1);
- else
- div2 = (((int64_t)tmp2 << COEF_BITS)/tmp);
-
- //printf("%f\n", div2 / (float)(1<<COEF_BITS));
-
- /* Q_M: integer */
- Q_M = MUL_R_C(sbr->E_orig[ch][table_map_res_to_m[m]][l], div2);
-
- //printf("%d\n", Q_M /* / (float)(1<<REAL_BITS)*/);
-
- if (adj->S_mapped[m][l] == 0)
- {
- real_t tmp, tmp2;
-
- S_M[m] = 0;
-
- /* d: fixed point */
- tmp2 = adj->Q_mapped[m][l] /* << (COEF_BITS-REAL_BITS)*/;
- tmp = REAL_CONST(1) + delta*tmp2;
- d = (((int64_t)REAL_CONST(1))<<REAL_BITS) / (tmp);
-
- /* G: fixed point */
- G = (((int64_t)sbr->E_orig[ch][table_map_res_to_m[m]][l])<<REAL_BITS) / (1 + sbr->E_curr[ch][m][l]);
- G = MUL(G, d);
-
- //printf("%f\n", G/(float)(1<<REAL_BITS));
-
- } else {
-
- real_t div;
-
- /* div: fixed point COEF */
- real_t tmp = COEF_CONST(1.0) + (adj->Q_mapped[m][l] << (COEF_BITS-REAL_BITS));
- real_t tmp2 = COEF_CONST(adj->S_mapped[m][l]);
- if (tmp == 0)
- div = COEF_CONST(1);
- else
- div = (((int64_t)tmp2 << COEF_BITS)/tmp);
-
- //printf("%f\n", div/(float)(1<<COEF_BITS));
-
- /* S_M: integer */
- S_M[m] = MUL_R_C(sbr->E_orig[ch][table_map_res_to_m[m]][l], div);
-
- //printf("%d\n", S_M[m]);
-
- /* G: fixed_point */
- if ((ONE + sbr->E_curr[ch][m][l]) == 0)
- G = 0xFFF; // uhm???
- else {
- real_t tmp = ONE + sbr->E_curr[ch][m][l];
- /* tmp2: fixed point */
- real_t tmp2 = (((int64_t)(sbr->E_orig[ch][table_map_res_to_m[m]][l]))<<REAL_BITS)/(tmp);
- G = MUL_R_C(tmp2, div2);
- }
-
- //printf("%f\n", G/(float)(1<<REAL_BITS));
- }
-
- /* limit the additional noise energy level */
- /* and apply the limiter */
-
- /* G_lim: fixed point */
- /* Q_M_lim: integer */
- if (G_max > G)
- {
- Q_M_lim[m] = Q_M;
- G_lim[m] = G;
- } else {
- real_t tmp;
- if (G == 0)
- tmp = 0xFFF;
- else
- tmp = SBR_DIV(G_max, G);
- Q_M_lim[m] = MUL(Q_M, tmp);
- G_lim[m] = G_max;
- }
-
- /* E_curr: integer, using MUL() is NOT OK */
- den += MUL(sbr->E_curr[ch][m][l], G_lim[m]);
- if (adj->S_index_mapped[m][l])
- den += S_M[m];
- else if (l != sbr->l_A[ch])
- den += Q_M_lim[m];
- }
-
- //printf("%d\n", den);
-
- /* G_boost: fixed point */
- if ((den + EPS) == 0)
- G_boost = REAL_CONST(2.51188643);
- else
- G_boost = (((int64_t)(acc1 + EPS))<<REAL_BITS)/(den + EPS);
- G_boost = min(G_boost, REAL_CONST(2.51188643) /* 1.584893192 ^ 2 */);
-
- for (m = sbr->f_table_lim[sbr->bs_limiter_bands][k];
- m < sbr->f_table_lim[sbr->bs_limiter_bands][k+1]; m++)
- {
- /* apply compensation to gain, noise floor sf's and sinusoid levels */
-#ifndef SBR_LOW_POWER
- /* G_lim_boost: fixed point */
- adj->G_lim_boost[l][m] = SBR_SQRT_FIX(MUL(G_lim[m], G_boost));
-#else
- /* sqrt() will be done after the aliasing reduction to save a
- * few multiplies
- */
- /* G_lim_boost: fixed point */
- adj->G_lim_boost[l][m] = MUL(G_lim[m], G_boost);
-#endif
- /* Q_M_lim_boost: integer */
- adj->Q_M_lim_boost[l][m] = SBR_SQRT_INT(MUL(Q_M_lim[m], G_boost));
-
- /* S_M_boost: integer */
- if (adj->S_index_mapped[m][l])
- adj->S_M_boost[l][m] = SBR_SQRT_INT(MUL(S_M[m], G_boost));
- else
- adj->S_M_boost[l][m] = 0;
- }
- }
- }
-}
-#else
-static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch)
-{
static real_t limGain[] = { 0.5, 1.0, 2.0, 1e10 };
uint8_t m, l, k, i;
@@ -674,7 +430,6 @@
}
}
}
-#endif
#ifdef SBR_LOW_POWER
static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch)
--- a/libfaad/sbr_hfgen.c
+++ b/libfaad/sbr_hfgen.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_hfgen.c,v 1.1 2003/07/29 08:20:13 menno Exp $
+** $Id: sbr_hfgen.c,v 1.2 2003/08/02 18:07:39 menno Exp $
**/
/* High Frequency generation */
@@ -176,34 +176,6 @@
int8_t j, jminus1, jminus2;
const real_t rel = COEF_CONST(0.9999999999999); // 1 / (1 + 1e-6f);
-#ifdef FIXED_POINT
- /*
- * For computing the covariance matrix and the filter coefficients
- * in fixed point, all values are normalised so that the fixed point
- * values don't overflow.
- */
- uint32_t max = 0;
- uint32_t pow2, exp;
-
- for (j = tHFAdj-2; j < len + tHFAdj; j++)
- {
- max = max(SBR_ABS(QMF_RE(buffer[j*32 + bd])>>REAL_BITS), max);
- }
-
- /* find the first power of 2 bigger than max to avoid division */
- pow2 = 1;
- exp = 0;
- while (max > pow2)
- {
- pow2 <<= 1;
- exp++;
- }
-
- /* give some more space */
-// if (exp > 3)
-// exp -= 3;
-#endif
-
memset(ac, 0, sizeof(acorr_coef));
for (j = tHFAdj; j < len + tHFAdj; j++)
@@ -212,20 +184,11 @@
jminus2 = jminus1 - 1;
#ifdef SBR_LOW_POWER
-#ifdef FIXED_POINT
- /* normalisation with rounding */
- RE(ac->r01) += MUL(((QMF_RE(buffer[j*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r02) += MUL(((QMF_RE(buffer[j*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r11) += MUL(((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r12) += MUL(((QMF_RE(buffer[jminus1*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
- RE(ac->r22) += MUL(((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp), ((QMF_RE(buffer[jminus2*32 + bd])+(1<<(exp-1)))>>exp));
-#else
RE(ac->r01) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
RE(ac->r11) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
RE(ac->r12) += QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
RE(ac->r22) += QMF_RE(buffer[jminus2*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
-#endif
#else
RE(ac->r01) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);