ref: 4a6744a4467c58c5c848f2819cd05edeef3ef5ff
parent: ed01a596dc525801ec9d601da29ded8a82a2ccd6
author: Jean-Marc Valin <[email protected]>
date: Sun Jan 5 16:40:02 EST 2014
Some cleaning up of the synthesis code.
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -193,12 +193,22 @@
/* 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 opus_val16 *bandLogE, 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 downsample, int silence)
{
int i, c, N;
+ int bound;
const opus_int16 *eBands = m->eBands;
N = M*m->shortMdctSize;
+ bound = M*eBands[end];
+ if (downsample!=1)
+ bound = IMIN(bound, N/downsample);
celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels");
+ if (silence)
+ {
+ bound = 0;
+ start = end = 0;
+ }
c=0; do {
celt_sig * OPUS_RESTRICT f;
const celt_norm * OPUS_RESTRICT x;
@@ -252,7 +262,7 @@
} while (++j<band_end);
}
celt_assert(start <= end);
- OPUS_CLEAR(&freq[c*N+M*eBands[end]], N-M*eBands[end]);
+ OPUS_CLEAR(&freq[c*N+bound], N-bound);
} while (++c<C);
}
--- a/celt/bands.h
+++ b/celt/bands.h
@@ -59,7 +59,8 @@
* @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 opus_val16 *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, int downsample, int silence);
#define SPREAD_NONE (0)
#define SPREAD_LIGHT (1)
--- a/celt/celt_decoder.c
+++ b/celt/celt_decoder.c
@@ -421,16 +421,10 @@
}
st->rng = seed;
- denormalise_bands(mode, X, freq, plcLogE, start, effEnd, C, 1<<LM);
+ denormalise_bands(mode, X, freq, plcLogE, start, effEnd, C, 1<<LM,
+ downsample, 0);
c=0; do {
- int bound = eBands[effEnd]<<LM;
- if (downsample!=1)
- bound = IMIN(bound, N/downsample);
- for (i=bound;i<N;i++)
- freq[c*N+i] = 0;
- } while (++c<C);
- c=0; do {
OPUS_MOVE(decode_mem[c], decode_mem[c]+N,
DECODE_BUFFER_SIZE-N+(overlap>>1));
} while (++c<C);
@@ -921,22 +915,15 @@
{
for (i=0;i<C*nbEBands;i++)
oldBandE[i] = -QCONST16(28.f,DB_SHIFT);
- for (i=0;i<C*N;i++)
- freq[i] = 0;
- } else {
- /* Synthesis */
- denormalise_bands(mode, X, freq, oldBandE, start, effEnd, C, M);
}
+
+ /* Synthesis */
+ denormalise_bands(mode, X, freq, oldBandE, start, effEnd, C, M,
+ st->downsample, silence);
+
c=0; do {
OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap/2);
} while (++c<CC);
-
- c=0; do {
- int bound = M*eBands[effEnd];
- if (st->downsample!=1)
- bound = IMIN(bound, N/st->downsample);
- OPUS_CLEAR(&freq[c*N+bound], N-bound);
- } while (++c<C);
c=0; do {
out_syn[c] = decode_mem[c]+DECODE_BUFFER_SIZE-N;
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -1973,14 +1973,9 @@
start, end, oldBandE, oldLogE, oldLogE2, pulses, st->rng);
}
- if (silence)
- {
- for (i=0;i<C*N;i++)
- freq[i] = 0;
- } else {
- /* Synthesis */
- denormalise_bands(mode, X, freq, oldBandE, start, effEnd, C, M);
- }
+ /* Synthesis */
+ denormalise_bands(mode, X, freq, oldBandE, start, effEnd, C, M,
+ st->upsample, silence);
c=0; do {
OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap/2);