Changed denormalize_bands() to only work between "start" and "end"

This commit is contained in:
Jean-Marc Valin 2012-11-07 14:09:04 -05:00
parent 7aa593a556
commit 8b906c102b
3 changed files with 11 additions and 29 deletions

View file

@ -187,7 +187,8 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel
#endif /* FIXED_POINT */ #endif /* FIXED_POINT */
/* De-normalise the energy to produce the synthesis from the unit-energy bands */ /* 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 end, int C, int M) 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)
{ {
int i, c, N; int i, c, N;
const opus_int16 *eBands = m->eBands; const opus_int16 *eBands = m->eBands;
@ -197,8 +198,10 @@ void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, cel
celt_sig * OPUS_RESTRICT f; celt_sig * OPUS_RESTRICT f;
const celt_norm * OPUS_RESTRICT x; const celt_norm * OPUS_RESTRICT x;
f = freq+c*N; f = freq+c*N;
x = X+c*N; x = X+c*N+M*eBands[start];
for (i=0;i<end;i++) for (i=0;i<M*eBands[start];i++)
*f++ = 0;
for (i=start;i<end;i++)
{ {
int j, band_end; int j, band_end;
opus_val32 g = SHR32(bandE[i+c*m->nbEBands],1); opus_val32 g = SHR32(bandE[i+c*m->nbEBands],1);

View file

@ -58,7 +58,8 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel
* @param X Spectrum (returned de-normalised) * @param X Spectrum (returned de-normalised)
* @param bands Square root of the energy for each band * @param bands 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 end, int C, int M); 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);
#define SPREAD_NONE (0) #define SPREAD_NONE (0)
#define SPREAD_LIGHT (1) #define SPREAD_LIGHT (1)

View file

@ -1987,21 +1987,12 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
} }
/* Synthesis */ /* Synthesis */
denormalise_bands(mode, X, freq, bandE, effEnd, C, M); denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
c=0; do { c=0; do {
OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap); OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap);
} while (++c<CC); } while (++c<CC);
c=0; do
for (i=0;i<M*eBands[st->start];i++)
freq[c*N+i] = 0;
while (++c<C);
c=0; do
for (i=M*eBands[st->end];i<N;i++)
freq[c*N+i] = 0;
while (++c<C);
if (CC==2&&C==1) if (CC==2&&C==1)
{ {
for (i=0;i<N;i++) for (i=0;i<N;i++)
@ -2525,8 +2516,6 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
seed = st->rng; seed = st->rng;
for (c=0;c<C;c++) for (c=0;c<C;c++)
{ {
for (i=0;i<(eBands[st->start]<<LM);i++)
X[c*N+i] = 0;
for (i=st->start;i<mode->effEBands;i++) for (i=st->start;i<mode->effEBands;i++)
{ {
int j; int j;
@ -2541,12 +2530,10 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, opus_val16 * OPUS_R
} }
renormalise_vector(X+boffs, blen, Q15ONE); renormalise_vector(X+boffs, blen, Q15ONE);
} }
for (i=(eBands[st->end]<<LM);i<N;i++)
X[c*N+i] = 0;
} }
st->rng = seed; st->rng = seed;
denormalise_bands(mode, X, freq, bandE, mode->effEBands, C, 1<<LM); denormalise_bands(mode, X, freq, bandE, st->start, mode->effEBands, C, 1<<LM);
c=0; do c=0; do
for (i=0;i<eBands[st->start]<<LM;i++) for (i=0;i<eBands[st->start]<<LM;i++)
@ -2970,15 +2957,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
ALLOC(collapse_masks, C*nbEBands, unsigned char); ALLOC(collapse_masks, C*nbEBands, unsigned char);
ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
c=0; do
for (i=0;i<M*eBands[st->start];i++)
X[c*N+i] = 0;
while (++c<C);
c=0; do
for (i=M*eBands[effEnd];i<N;i++)
X[c*N+i] = 0;
while (++c<C);
quant_all_bands(0, mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks, quant_all_bands(0, mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks,
NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res,
len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->rng); len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->rng);
@ -3009,7 +2987,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
} }
ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */ ALLOC(freq, IMAX(CC,C)*N, celt_sig); /**< Interleaved signal MDCTs */
/* Synthesis */ /* Synthesis */
denormalise_bands(mode, X, freq, bandE, effEnd, C, M); denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M);
c=0; do { c=0; do {
OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap); OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap);