Commit c1687d57 authored by Gildas Bazin's avatar Gildas Bazin

* libdca/parse.c: Change output normalisation factor from 3/2 to sqrt(2)....

* libdca/parse.c: Change output normalisation factor from 3/2 to sqrt(2). Thanks to Alexander E. Patrakov for finding that this is the proper normalisation factor.
                  Fixed a bug where the output bias wasn't applied when downmixing wasn't being done.
parent 29ed059b
......@@ -59,12 +59,11 @@ void * memalign (size_t align, size_t size);
static int decode_blockcode (int code, int levels, int *values);
static void qmf_32_subbands (dca_state_t * state, int chans,
double samples_in[32][8], sample_t *samples_out,
double rScale, sample_t bias);
double samples_in[32][8], sample_t *samples_out);
static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
double *samples_in, sample_t *samples_out,
double rScale, sample_t bias );
sample_t bias);
static void pre_calc_cosmod( dca_state_t * state );
......@@ -123,7 +122,9 @@ static int syncinfo (dca_state_t * state, int * flags,
bitstream_get (state, 1);
*frame_length = (bitstream_get (state, 7) + 1) * 32;
if (*frame_length < 6 * 32) return 0;
frame_size = bitstream_get (state, 14) + 1;
if (frame_size < 96) return 0;
if (!state->word_mode) frame_size = frame_size * 8 / 14 * 2;
/* Audio channel arrangement */
......@@ -981,14 +982,7 @@ static int dca_subsubframe (dca_state_t * state)
/* 32 subbands QMF */
for (k = 0; k < state->prim_channels; k++)
{
/*static double pcm_to_float[8] =
{32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
qmf_32_subbands (state, k,
subband_samples[k],
&state->samples[256*k],
/*WTF ???*/ 32768.0*3/2/*pcm_to_float[state->source_pcm_res]*/,
0/*state->bias*/);
qmf_32_subbands (state, k, subband_samples[k], &state->samples[256*k]);
}
/* Down/Up mixing */
......@@ -1000,6 +994,10 @@ static int dca_subsubframe (dca_state_t * state)
{
dca_downmix (state->samples, state->amode, state->output, state->bias,
state->clev, state->slev);
} else if (state->bias)
{
for ( k = 0; k < 256*state->prim_channels; k++ )
state->samples[k] += state->bias;
}
/* Generate LFE samples for this subsubframe FIXME!!! */
......@@ -1011,8 +1009,7 @@ static int dca_subsubframe (dca_state_t * state)
lfe_interpolation_fir (state->lfe, 2 * state->lfe,
state->lfe_data + lfe_samples +
2 * state->lfe * subsubframe,
&state->samples[256*i_channels],
8388608.0, state->bias);
&state->samples[256*i_channels], state->bias);
/* Outputs 20bits pcm samples */
}
......@@ -1142,9 +1139,9 @@ static void pre_calc_cosmod( dca_state_t * state )
}
static void qmf_32_subbands (dca_state_t * state, int chans,
double samples_in[32][8], sample_t *samples_out,
double scale, sample_t bias)
double samples_in[32][8], sample_t *samples_out)
{
static const double scale = 1.4142135623730951 /* sqrt(2) */ * 32768.0;
const double *prCoeff;
int i, j, k;
double raXin[32];
......@@ -1211,7 +1208,7 @@ static void qmf_32_subbands (dca_state_t * state, int chans,
/* Create 32 PCM output samples */
for (i=0;i<32;i++)
samples_out[nChIndex++] = subband_fir_hist2[i] / scale + bias;
samples_out[nChIndex++] = subband_fir_hist2[i] / scale;
/* Update working arrays */
for (i=511;i>=32;i--)
......@@ -1225,7 +1222,7 @@ static void qmf_32_subbands (dca_state_t * state, int chans,
static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
double *samples_in, sample_t *samples_out,
double scale, sample_t bias)
sample_t bias)
{
/* samples_in: An array holding decimated samples.
* Samples in current subframe starts from samples_in[0],
......@@ -1235,6 +1232,7 @@ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
* samples_out: An array holding interpolated samples
*/
static const double scale = 8388608.0;
int nDeciFactor, k, J;
const double *prCoeff;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment