summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2013-06-16 20:24:52 -0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2013-06-16 20:24:52 -0400
commitee2506b2c7e9a0ef05eb489ed554d38d9b71a3e5 (patch)
treef1d8d49018a369b4d9bdf42a5ea5a94d90c40e90
parent3afc6ffff068cd9696de7fc3b88a0cd3ab79940a (diff)
downloadopus-ee2506b2c7e9a0ef05eb489ed554d38d9b71a3e5.tar.gz
Moves log2Amp inside denormalise_bands() and get rid of bandE[]
Also get rid of the MSE measurement code which is outdated and no longer useful
-rw-r--r--celt/bands.c54
-rw-r--r--celt/bands.h2
-rw-r--r--celt/celt_decoder.c15
-rw-r--r--celt/celt_encoder.c17
-rw-r--r--celt/quant_bands.c19
-rw-r--r--celt/tests/test_unit_mathops.c2
6 files changed, 17 insertions, 92 deletions
diff --git a/celt/bands.c b/celt/bands.c
index 62f0ee73..ae77ed71 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -40,6 +40,7 @@
#include "os_support.h"
#include "mathops.h"
#include "rate.h"
+#include "quant_bands.h"
int hysteresis_decision(opus_val16 val, const opus_val16 *thresholds, const opus_val16 *hysteresis, int N, int prev)
{
@@ -188,7 +189,7 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel
/* De-normalise the energy to produce the synthesis from the unit-energy bands */
void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
- celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int start, int end, int C, int M)
+ celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandLogE, int start, int end, int C, int M)
{
int i, c, N;
const opus_int16 *eBands = m->eBands;
@@ -204,7 +205,12 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
for (i=start;i<end;i++)
{
int j, band_end;
- opus_val32 g = SHR32(bandE[i+c*m->nbEBands],1);
+ celt_ener bandE;
+ opus_val32 g;
+ opus_val16 lg;
+ lg = ADD16(bandLogE[i+c*m->nbEBands], SHL16((opus_val16)eMeans[i],6));
+ bandE = PSHR32(celt_exp2(lg),4);
+ g = SHR32(bandE,1);
j=M*eBands[i];
band_end = M*eBands[i+1];
do {
@@ -502,50 +508,6 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
return 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 ("%g ", MSE[i]/MSECount[i]);
- }
- printf ("\n");
-}
-
-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;
- if (!init)
- {
- atexit(dump_norm_mse);
- init = 1;
- }
- for (i=0;i<m->nbEBands;i++)
- {
- int j;
- int c;
- float g;
- if (bandE0[i]<10 || (C==2 && bandE0[i+m->nbEBands]<1))
- continue;
- c=0; do {
- 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]);
- } while (++c<C);
- MSECount[i]+=C;
- }
- nbMSEBands = m->nbEBands;
-}
-
-#endif
-
/* Indexing table for converting from natural Hadamard to ordery Hadamard
This is essentially a bit-reversed Gray, on top of which we've added
an inversion of the order because we want the DC at the end rather than
diff --git a/celt/bands.h b/celt/bands.h
index ee588a64..96ba52a6 100644
--- a/celt/bands.h
+++ b/celt/bands.h
@@ -59,7 +59,7 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel
* @param bandE Square root of the energy for each band
*/
void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
- celt_sig * OPUS_RESTRICT freq, const celt_ener *bandE, int start, int end, int C, int M);
+ celt_sig * OPUS_RESTRICT freq, const opus_val16 *bandE, int start, int end, int C, int M);
#define SPREAD_NONE (0)
#define SPREAD_LIGHT (1)
diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c
index 1b243cd1..01f2868d 100644
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -375,8 +375,8 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
/* Noise-based PLC/CNG */
celt_sig *freq;
VARDECL(celt_norm, X);
- VARDECL(celt_ener, bandE);
opus_uint32 seed;
+ opus_val16 *plcLogE;
int end;
int effEnd;
@@ -387,10 +387,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
deemphasis scratch buffer. */
freq = scratch;
ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
- ALLOC(bandE, nbEBands*C, celt_ener);
if (loss_count >= 5)
- log2Amp(mode, start, end, bandE, backgroundLogE, C);
+ plcLogE = backgroundLogE;
else {
/* Energy decay */
opus_val16 decay = loss_count==0 ?
@@ -400,7 +399,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
for (i=start;i<end;i++)
oldBandE[c*nbEBands+i] -= decay;
} while (++c<C);
- log2Amp(mode, start, end, bandE, oldBandE, C);
+ plcLogE = oldBandE;
}
seed = st->rng;
for (c=0;c<C;c++)
@@ -422,7 +421,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
}
st->rng = seed;
- denormalise_bands(mode, X, freq, bandE, start, effEnd, C, 1<<LM);
+ denormalise_bands(mode, X, freq, plcLogE, start, effEnd, C, 1<<LM);
c=0; do {
int bound = eBands[effEnd]<<LM;
@@ -659,7 +658,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
ec_dec _dec;
VARDECL(celt_sig, freq);
VARDECL(celt_norm, X);
- VARDECL(celt_ener, bandE);
VARDECL(int, fine_quant);
VARDECL(int, pulses);
VARDECL(int, cap);
@@ -913,9 +911,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
anti_collapse(mode, X, collapse_masks, LM, C, N,
st->start, st->end, oldBandE, oldLogE, oldLogE2, pulses, st->rng);
- ALLOC(bandE, nbEBands*C, celt_ener);
-
- log2Amp(mode, st->start, st->end, bandE, oldBandE, C);
ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */
if (silence)
@@ -926,7 +921,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
freq[i] = 0;
} else {
/* Synthesis */
- denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
+ denormalise_bands(mode, X, freq, oldBandE, st->start, effEnd, C, M);
}
c=0; do {
OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2);
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index 59b77f49..fb3e3cef 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1849,17 +1849,6 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
quant_fine_energy(mode, st->start, st->end, oldBandE, error, fine_quant, enc, C);
-#ifdef MEASURE_NORM_MSE
- float X0[3000];
- float bandE0[60];
- c=0; do
- for (i=0;i<N;i++)
- X0[i+c*N] = X[i+c*N];
- while (++c<C);
- for (i=0;i<C*nbEBands;i++)
- bandE0[i] = bandE[i];
-#endif
-
/* Residual quantisation */
ALLOC(collapse_masks, C*nbEBands, unsigned char);
quant_all_bands(1, mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks,
@@ -1893,17 +1882,13 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
st->start, st->end, oldBandE, oldLogE, oldLogE2, pulses, st->rng);
}
- log2Amp(mode, st->start, st->end, bandE, oldBandE, C);
if (silence)
{
for (i=0;i<C*N;i++)
freq[i] = 0;
} else {
-#ifdef MEASURE_NORM_MSE
- measure_norm_mse(mode, X, X0, bandE, bandE0, M, N, C);
-#endif
/* Synthesis */
- denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
+ denormalise_bands(mode, X, freq, oldBandE, st->start, effEnd, C, M);
}
c=0; do {
diff --git a/celt/quant_bands.c b/celt/quant_bands.c
index 48196bde..79685e17 100644
--- a/celt/quant_bands.c
+++ b/celt/quant_bands.c
@@ -536,25 +536,6 @@ void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *
}
}
-void log2Amp(const CELTMode *m, int start, int end,
- celt_ener *eBands, const opus_val16 *oldEBands, int C)
-{
- int c, i;
- c=0;
- do {
- for (i=0;i<start;i++)
- eBands[i+c*m->nbEBands] = 0;
- for (;i<end;i++)
- {
- opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands],
- SHL16((opus_val16)eMeans[i],6));
- eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4);
- }
- for (;i<m->nbEBands;i++)
- eBands[i+c*m->nbEBands] = 0;
- } while (++c < C);
-}
-
void amp2Log2(const CELTMode *m, int effEnd, int end,
celt_ener *bandE, opus_val16 *bandLogE, int C)
{
diff --git a/celt/tests/test_unit_mathops.c b/celt/tests/test_unit_mathops.c
index c11f0adc..4bb780e6 100644
--- a/celt/tests/test_unit_mathops.c
+++ b/celt/tests/test_unit_mathops.c
@@ -41,6 +41,8 @@
#include "entdec.c"
#include "entcode.c"
#include "bands.c"
+#include "quant_bands.c"
+#include "laplace.c"
#include "vq.c"
#include "cwrs.c"
#include <stdio.h>