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>2016-07-26 03:44:17 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-07-26 19:59:52 +0300
commit263ffe04b2518ac32041d297164d29c859034ea9 (patch)
tree794d04c17b47bb2c13c8f7b955fc455ab4fc0a48
parent2511d235d06f7505fc63713e13080dee195a1159 (diff)
Properly allocation scratch space for resynth encoder
-rw-r--r--celt/bands.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/celt/bands.c b/celt/bands.c
index 869b526a..f5a88113 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -1343,6 +1343,8 @@ 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);
+ int lowband_scratch_alloc;
celt_norm *lowband_scratch;
int B;
int M;
@@ -1366,9 +1368,19 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
ALLOC(_norm, C*(M*eBands[m->nbEBands-1]-norm_offset), celt_norm);
norm = _norm;
norm2 = norm + M*eBands[m->nbEBands-1]-norm_offset;
- /* 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];
+
+ /* For decoding, we can use the last band as scratch space because we don't need that
+ scratch space for the last band and we don't care about the data there until we're
+ decoding the last band. */
+ if (encode && resynth)
+ lowband_scratch_alloc = M*(eBands[m->nbEBands]-eBands[m->nbEBands-1]);
+ else
+ lowband_scratch_alloc = ALLOC_NONE;
+ ALLOC(_lowband_scratch, lowband_scratch_alloc, celt_norm);
+ if (encode && resynth)
+ lowband_scratch = _lowband_scratch;
+ else
+ lowband_scratch = X_+M*eBands[m->nbEBands-1];
lowband_offset = 0;
ctx.bandE = bandE;