ref: 5055cf8c1329dee30d5c633060fb872b53d7f40a
parent: 06bab45fb4d604e15017152209e99141a9b1955e
author: Jean-Marc Valin <[email protected]>
date: Tue Nov 6 20:14:29 EST 2012
Removes the need for lowband_scratch in quant_all_bands()
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -716,7 +716,7 @@
recombine = tf_change;
/* Band recombining to increase frequency resolution */
- if (lowband && (recombine || ((N_B&1) == 0 && tf_change<0) || B0>1))
+ if (lowband_scratch && lowband && (recombine || ((N_B&1) == 0 && tf_change<0) || B0>1))
{
int j;
for (j=0;j<N;j++)
@@ -1193,7 +1193,7 @@
const opus_int16 * OPUS_RESTRICT eBands = m->eBands;
celt_norm * OPUS_RESTRICT norm, * OPUS_RESTRICT norm2;
VARDECL(celt_norm, _norm);
- VARDECL(celt_norm, lowband_scratch);
+ celt_norm *lowband_scratch;
int B;
int M;
int lowband_offset;
@@ -1209,9 +1209,11 @@
M = 1<<LM;
B = shortBlocks ? M : 1;
ALLOC(_norm, C*M*eBands[m->nbEBands], celt_norm);
- ALLOC(lowband_scratch, M*(eBands[m->nbEBands]-eBands[m->nbEBands-1]), celt_norm);
norm = _norm;
norm2 = norm + M*eBands[m->nbEBands];
+ /* We can use the last band as scratch space because we don't need that
+ scratch space for the last band */
+ lowband_scratch = X_+M*eBands[m->nbEBands-1];
lowband_offset = 0;
for (i=start;i<end;i++)
@@ -1255,7 +1257,10 @@
X=norm;
if (Y_!=NULL)
Y = norm;
+ lowband_scratch = NULL;
}
+ if (i==end-1)
+ lowband_scratch = NULL;
/* Get a conservative estimate of the collapse_mask's for the bands we're
going to be folding from. */
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -2839,17 +2839,6 @@
return frame_size/st->downsample;
}
- 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);
-
if (dec == NULL)
{
ec_dec_init(&_dec,(unsigned char*)data,len);
@@ -2979,6 +2968,17 @@
/* Decode fixed codebook */
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);