ref: 7e983194a3ac7c775c7d370a5bf6d71bf68c2645
parent: 2799c29792ebaa7c01e22457013000fecb18169e
author: Jean-Marc Valin <[email protected]>
date: Tue Feb 1 13:00:29 EST 2011
Fixing the global stack -- and an overflow in collapse_mask
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1435,7 +1435,7 @@
#endif
/* Residual quantisation */
- ALLOC(collapse_masks, st->mode->nbEBands, unsigned char);
+ ALLOC(collapse_masks, C*st->mode->nbEBands, unsigned char);
quant_all_bands(1, st->mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks,
bandE, pulses, shortBlocks, st->spread_decision, dual_stereo, intensity, tf_res, resynth,
nbCompressedBytes*(8<<BITRES)-anti_collapse_rsv, balance, enc, LM, codedBands, &st->rng);
@@ -1585,6 +1585,7 @@
{
int j, ret, C, N;
VARDECL(celt_int16, in);
+ ALLOC_STACK;
SAVE_STACK;
if (pcm==NULL)
@@ -1612,6 +1613,7 @@
{
int j, ret, C, N;
VARDECL(celt_sig, in);
+ ALLOC_STACK;
SAVE_STACK;
if (pcm==NULL)
@@ -2341,7 +2343,7 @@
unquant_fine_energy(st->mode, st->start, st->end, oldBandE, fine_quant, dec, C);
/* Decode fixed codebook */
- ALLOC(collapse_masks, st->mode->nbEBands, unsigned char);
+ ALLOC(collapse_masks, C*st->mode->nbEBands, unsigned char);
quant_all_bands(0, st->mode, st->start, st->end, X, C==2 ? X+N : NULL, collapse_masks,
NULL, pulses, shortBlocks, spread_decision, dual_stereo, intensity, tf_res, 1,
len*(8<<BITRES)-anti_collapse_rsv, balance, dec, LM, codedBands, &st->rng);
@@ -2468,6 +2470,7 @@
{
int j, ret, C, N;
VARDECL(celt_int16, out);
+ ALLOC_STACK;
SAVE_STACK;
if (pcm==NULL)
@@ -2491,6 +2494,7 @@
{
int j, ret, C, N;
VARDECL(celt_sig, out);
+ ALLOC_STACK;
SAVE_STACK;
if (pcm==NULL)
--- a/libcelt/modes.c
+++ b/libcelt/modes.c
@@ -286,11 +286,13 @@
scanf("%d ", band_allocation+i);
}
#endif
+#ifdef CUSTOM_MODES
ALLOC_STACK;
#if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA)
if (global_stack==NULL)
goto failure;
#endif
+#endif
#ifndef CUSTOM_MODES_ONLY
for (i=0;i<TOTAL_MODES;i++)