summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-11-07 14:09:04 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-11-07 14:15:08 -0500
commit8b906c102b37ce74571898c8879c01b2a9088fb3 (patch)
treed3e256501a238161cdd008f96de39994e0b17a05
parent7aa593a5569a767cd12620f66fc3ed65c9379a28 (diff)
downloadopus-8b906c102b37ce74571898c8879c01b2a9088fb3.tar.gz
Changed denormalize_bands() to only work between "start" and "end"
-rw-r--r--celt/bands.c9
-rw-r--r--celt/bands.h3
-rw-r--r--celt/celt.c28
3 files changed, 11 insertions, 29 deletions
diff --git a/celt/bands.c b/celt/bands.c
index c352b7a2..8883f40a 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 47d15b6d..66b69cc7 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 1c8b65f6..b29d0db0 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);