Some cleaning up of the synthesis code.

This commit is contained in:
Jean-Marc Valin 2014-01-05 21:40:02 -05:00
parent ed01a596dc
commit 4a6744a446
4 changed files with 24 additions and 31 deletions

View file

@ -193,12 +193,22 @@ 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 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 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X,
} 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);
}

View file

@ -59,7 +59,8 @@ 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 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)

View file

@ -421,15 +421,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
}
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));
@ -921,23 +915,16 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
{
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;
} while (++c<CC);

View file

@ -1973,14 +1973,9 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
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);