Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2012-11-07 10:14:29 +0400
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-11-07 18:03:43 +0400
commit5055cf8c1329dee30d5c633060fb872b53d7f40a (patch)
treea334721b26f356f2bc611424b3232041f68cec40
parent06bab45fb4d604e15017152209e99141a9b1955e (diff)
Removes the need for lowband_scratch in quant_all_bands()
-rw-r--r--celt/bands.c11
-rw-r--r--celt/celt.c22
2 files changed, 19 insertions, 14 deletions
diff --git a/celt/bands.c b/celt/bands.c
index 531d3118..f4b6a471 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -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. */
diff --git a/celt/celt.c b/celt/celt.c
index 8c0014ce..1c8b65f6 100644
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -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);