ref: 44092248453e1239d067b041c2915d2a2815b99d
parent: 7b5a086b4581c71e9a6c47188a285fca010a8943
author: Jean-Marc Valin <[email protected]>
date: Thu Jul 29 14:32:54 EDT 2010
Error measurement for stereo as well
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -450,7 +450,7 @@
printf ("\n");
}
-void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M)
+void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C)
{
static int init = 0;
int i;
@@ -462,12 +462,17 @@
for (i=0;i<m->nbEBands;i++)
{
int j;
- float g = bandE[i]/(1e-15+bandE0[i]);
- if (bandE0[i]<1)
+ int c;
+ float g;
+ if (bandE0[i]<1 || (C==2 && bandE0[i+m->nbEBands]<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]++;
+ for (c=0;c<C;c++)
+ {
+ g = bandE[i+c*m->nbEBands]/(1e-15+bandE0[i+c*m->nbEBands]);
+ for (j=M*m->eBands[i];j<M*m->eBands[i+1];j++)
+ MSE[i] += (g*X[j+c*N]-X0[j+c*N])*(g*X[j+c*N]-X0[j+c*N]);
+ }
+ MSECount[i]+=C;
}
nbMSEBands = m->nbEBands;
}
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -79,6 +79,10 @@
int folding_decision(const CELTMode *m, celt_norm *X, celt_word16 *average, int *last_decision, int end, int _C, int M);
+#ifdef MEASURE_NORM_MSE
+void measure_norm_mse(const CELTMode *m, float *X, float *X0, float *bandE, float *bandE0, int M, int N, int C);
+#endif
+
/** Quantisation/encoding of the residual spectrum
* @param m Mode data
* @param X Residual (normalised)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1047,11 +1047,12 @@
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++)
+ float X0[3000];
+ float bandE0[60];
+ for (c=0;c<C;c++)
+ for (i=0;i<N;i++)
+ X0[i+c*N] = X[i+c*N];
+ for (i=0;i<C*st->mode->nbEBands;i++)
bandE0[i] = bandE[i];
#endif
@@ -1061,7 +1062,7 @@
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);
+ measure_norm_mse(st->mode, X, X0, bandE, bandE0, M, N, C);
#endif
/* Re-synthesis of the coded audio if required */