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:
authorTimothy B. Terriberry <tterribe@xiph.org>2013-05-08 21:32:37 +0400
committerTimothy B. Terriberry <tterribe@xiph.org>2013-05-08 21:37:17 +0400
commitc152d602aa6f68b4bc9483393985511bb2d83e86 (patch)
tree7feb495f759f9d87d0b16c71996cf54ba443ca9f /silk/encode_pulses.c
parentdc58579c2c7e060084554018e9a2e8c25097a255 (diff)
Use dynamic stack allocation in the SILK encoder.
This makes all remaining large stack allocations use the vararray macros. This continues the work of 6f2d9f50 to allow compiling with NONTHREADSAFE_PSEUDOSTACK to move the memory for large buffers off the stack for devices where it is very limited. It also does this for some additional large buffers used by the PLC in the decoder.
Diffstat (limited to 'silk/encode_pulses.c')
-rw-r--r--silk/encode_pulses.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/silk/encode_pulses.c b/silk/encode_pulses.c
index b01b5853..301b5618 100644
--- a/silk/encode_pulses.c
+++ b/silk/encode_pulses.c
@@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "main.h"
+#include "stack_alloc.h"
/*********************************************/
/* Encode quantization indices of excitation */
@@ -66,14 +67,15 @@ void silk_encode_pulses(
{
opus_int i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0;
opus_int32 abs_q, minSumBits_Q5, sumBits_Q5;
- opus_int abs_pulses[ MAX_FRAME_LENGTH ];
- opus_int sum_pulses[ MAX_NB_SHELL_BLOCKS ];
- opus_int nRshifts[ MAX_NB_SHELL_BLOCKS ];
+ VARDECL( opus_int, abs_pulses );
+ VARDECL( opus_int, sum_pulses );
+ VARDECL( opus_int, nRshifts );
opus_int pulses_comb[ 8 ];
opus_int *abs_pulses_ptr;
const opus_int8 *pulses_ptr;
const opus_uint8 *cdf_ptr;
const opus_uint8 *nBits_ptr;
+ SAVE_STACK;
silk_memset( pulses_comb, 0, 8 * sizeof( opus_int ) ); /* Fixing Valgrind reported problem*/
@@ -90,6 +92,8 @@ void silk_encode_pulses(
}
/* Take the absolute value of the pulses */
+ ALLOC( abs_pulses, iter * SHELL_CODEC_FRAME_LENGTH, opus_int );
+ silk_assert( !( SHELL_CODEC_FRAME_LENGTH & 3 ) );
for( i = 0; i < iter * SHELL_CODEC_FRAME_LENGTH; i+=4 ) {
abs_pulses[i+0] = ( opus_int )silk_abs( pulses[ i + 0 ] );
abs_pulses[i+1] = ( opus_int )silk_abs( pulses[ i + 1 ] );
@@ -98,6 +102,8 @@ void silk_encode_pulses(
}
/* Calc sum pulses per shell code frame */
+ ALLOC( sum_pulses, iter, opus_int );
+ ALLOC( nRshifts, iter, opus_int );
abs_pulses_ptr = abs_pulses;
for( i = 0; i < iter; i++ ) {
nRshifts[ i ] = 0;
@@ -196,4 +202,5 @@ void silk_encode_pulses(
/* Encode signs */
/****************/
silk_encode_signs( psRangeEnc, pulses, frame_length, signalType, quantOffsetType, sum_pulses );
+ RESTORE_STACK;
}