Measuring the normalized error directly within the encoder
This commit is contained in:
parent
fd3139cccf
commit
7b5a086b45
2 changed files with 53 additions and 0 deletions
|
@ -434,6 +434,46 @@ int folding_decision(const CELTMode *m, celt_norm *X, celt_word16 *average, int
|
|||
return *last_decision;
|
||||
}
|
||||
|
||||
#ifdef MEASURE_NORM_MSE
|
||||
|
||||
float MSE[30] = {0};
|
||||
int nbMSEBands = 0;
|
||||
int MSECount[30] = {0};
|
||||
|
||||
void dump_norm_mse(void)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<nbMSEBands;i++)
|
||||
{
|
||||
printf ("%f ", MSE[i]/MSECount[i]);
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M)
|
||||
{
|
||||
static int init = 0;
|
||||
int i;
|
||||
if (!init)
|
||||
{
|
||||
atexit(dump_norm_mse);
|
||||
init = 1;
|
||||
}
|
||||
for (i=0;i<m->nbEBands;i++)
|
||||
{
|
||||
int j;
|
||||
float g = bandE[i]/(1e-15+bandE0[i]);
|
||||
if (bandE0[i]<1)
|
||||
continue;
|
||||
for (j=M*m->eBands[i];j<M*m->eBands[i+1];j++)
|
||||
MSE[i] += (g*X[j]-X0[j])*(g*X[j]-X0[j]);
|
||||
MSECount[i]++;
|
||||
}
|
||||
nbMSEBands = m->nbEBands;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void interleave_vector(celt_norm *X, int N0, int stride)
|
||||
{
|
||||
int i,j;
|
||||
|
|
|
@ -1046,11 +1046,24 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, c
|
|||
|
||||
quant_fine_energy(st->mode, st->start, st->end, bandE, st->oldBandE, error, fine_quant, enc, C);
|
||||
|
||||
#ifdef MEASURE_NORM_MSE
|
||||
float X0[1000];
|
||||
float bandE0[30];
|
||||
for (i=0;i<N;i++)
|
||||
X0[i] = X[i];
|
||||
for (i=0;i<st->mode->nbEBands;i++)
|
||||
bandE0[i] = bandE[i];
|
||||
#endif
|
||||
|
||||
/* Residual quantisation */
|
||||
quant_all_bands(1, st->mode, st->start, st->end, X, C==2 ? X+N : NULL, bandE, pulses, shortBlocks, has_fold, tf_res, resynth, nbCompressedBytes*8, enc, LM);
|
||||
|
||||
quant_energy_finalise(st->mode, st->start, st->end, bandE, st->oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_enc_tell(enc, 0), enc, C);
|
||||
|
||||
#ifdef MEASURE_NORM_MSE
|
||||
measure_norm_mse(st->mode, X, X0, bandE, bandE0, M);
|
||||
#endif
|
||||
|
||||
/* Re-synthesis of the coded audio if required */
|
||||
if (resynth)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue