Removes the need for lowband_scratch in quant_all_bands()

This commit is contained in:
Jean-Marc Valin 2012-11-07 01:14:29 -05:00
parent 06bab45fb4
commit 5055cf8c13
2 changed files with 19 additions and 14 deletions

View file

@ -716,7 +716,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
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 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
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 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
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 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
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. */

View file

@ -2839,17 +2839,6 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
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 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
/* 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);