summaryrefslogtreecommitdiff
path: root/silk/NLSF_encode.c
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2013-05-08 10:32:37 -0700
committerTimothy B. Terriberry <tterribe@xiph.org>2013-05-08 10:37:17 -0700
commitc152d602aa6f68b4bc9483393985511bb2d83e86 (patch)
tree7feb495f759f9d87d0b16c71996cf54ba443ca9f /silk/NLSF_encode.c
parentdc58579c2c7e060084554018e9a2e8c25097a255 (diff)
downloadopus-c152d602aa6f68b4bc9483393985511bb2d83e86.tar.gz
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/NLSF_encode.c')
-rw-r--r--silk/NLSF_encode.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/silk/NLSF_encode.c b/silk/NLSF_encode.c
index 52a263d9..0f22372b 100644
--- a/silk/NLSF_encode.c
+++ b/silk/NLSF_encode.c
@@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "main.h"
+#include "stack_alloc.h"
/***********************/
/* NLSF vector encoder */
@@ -46,10 +47,10 @@ opus_int32 silk_NLSF_encode( /* O Returns
{
opus_int i, s, ind1, bestIndex, prob_Q8, bits_q7;
opus_int32 W_tmp_Q9;
- opus_int32 err_Q26[ NLSF_VQ_MAX_VECTORS ];
- opus_int32 RD_Q25[ NLSF_VQ_MAX_SURVIVORS ];
- opus_int tempIndices1[ NLSF_VQ_MAX_SURVIVORS ];
- opus_int8 tempIndices2[ NLSF_VQ_MAX_SURVIVORS * MAX_LPC_ORDER ];
+ VARDECL( opus_int32, err_Q26 );
+ VARDECL( opus_int32, RD_Q25 );
+ VARDECL( opus_int, tempIndices1 );
+ VARDECL( opus_int8, tempIndices2 );
opus_int16 res_Q15[ MAX_LPC_ORDER ];
opus_int16 res_Q10[ MAX_LPC_ORDER ];
opus_int16 NLSF_tmp_Q15[ MAX_LPC_ORDER ];
@@ -58,6 +59,7 @@ opus_int32 silk_NLSF_encode( /* O Returns
opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
opus_int16 ec_ix[ MAX_LPC_ORDER ];
const opus_uint8 *pCB_element, *iCDF_ptr;
+ SAVE_STACK;
silk_assert( nSurvivors <= NLSF_VQ_MAX_SURVIVORS );
silk_assert( signalType >= 0 && signalType <= 2 );
@@ -67,11 +69,16 @@ opus_int32 silk_NLSF_encode( /* O Returns
silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order );
/* First stage: VQ */
+ ALLOC( err_Q26, psNLSF_CB->nVectors, opus_int32 );
silk_NLSF_VQ( err_Q26, pNLSF_Q15, psNLSF_CB->CB1_NLSF_Q8, psNLSF_CB->nVectors, psNLSF_CB->order );
/* Sort the quantization errors */
+ ALLOC( tempIndices1, nSurvivors, opus_int );
silk_insertion_sort_increasing( err_Q26, tempIndices1, psNLSF_CB->nVectors, nSurvivors );
+ ALLOC( RD_Q25, nSurvivors, opus_int32 );
+ ALLOC( tempIndices2, nSurvivors * MAX_LPC_ORDER, opus_int8 );
+
/* Loop over survivors */
for( s = 0; s < nSurvivors; s++ ) {
ind1 = tempIndices1[ s ];
@@ -125,4 +132,5 @@ opus_int32 silk_NLSF_encode( /* O Returns
silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB );
return RD_Q25[ 0 ];
+ RESTORE_STACK;
}