diff --git a/celt/bands.c b/celt/bands.c index c352b7a2f50145abb5545648ac21716aae30c764..8883f40aad37c36a1a5ac84bc419691b4216effd 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -187,7 +187,8 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel #endif /* FIXED_POINT */ /* 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; 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; const celt_norm * OPUS_RESTRICT x; f = freq+c*N; - x = X+c*N; - for (i=0;i<end;i++) + x = X+c*N+M*eBands[start]; + for (i=0;i<M*eBands[start];i++) + *f++ = 0; + for (i=start;i<end;i++) { int j, band_end; opus_val32 g = SHR32(bandE[i+c*m->nbEBands],1); diff --git a/celt/bands.h b/celt/bands.h index 47d15b6d6665401dc9b10260359e293430ce04eb..66b69cc79e32e218f4929d32cb7622d64efd9e3c 100644 --- a/celt/bands.h +++ b/celt/bands.h @@ -58,7 +58,8 @@ void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, cel * @param X Spectrum (returned de-normalised) * @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_LIGHT (1) diff --git a/celt/celt.c b/celt/celt.c index 1c8b65f609535ec8a406877a8c55b4b555a9cdf9..b29d0db0e4e0c05b5a028cb85657d9fa3790714f 100644 --- a/celt/celt.c +++ b/celt/celt.c @@ -1987,21 +1987,12 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, } /* Synthesis */ - denormalise_bands(mode, X, freq, bandE, effEnd, C, M); + denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M); c=0; do { OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, 2*MAX_PERIOD-N+overlap); } 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) { 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; 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++) { 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); } - for (i=(eBands[st->end]<<LM);i<N;i++) - X[c*N+i] = 0; } 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 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(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, NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, 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 */ /* Synthesis */ - denormalise_bands(mode, X, freq, bandE, effEnd, C, M); + denormalise_bands(mode, X, freq, bandE, st->start, effEnd, C, M); c=0; do { OPUS_MOVE(decode_mem[c], decode_mem[c]+N, DECODE_BUFFER_SIZE-N+overlap);