aboutsummaryrefslogtreecommitdiff
path: root/silk/stereo_LR_to_MS.c
diff options
context:
space:
mode:
Diffstat (limited to 'silk/stereo_LR_to_MS.c')
-rw-r--r--silk/stereo_LR_to_MS.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/silk/stereo_LR_to_MS.c b/silk/stereo_LR_to_MS.c
index 6a680e0..42906e6 100644
--- a/silk/stereo_LR_to_MS.c
+++ b/silk/stereo_LR_to_MS.c
@@ -8,11 +8,11 @@ this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-- Neither the name of Internet Society, IETF or IETF Trust, nor the
+- Neither the name of Internet Society, IETF or IETF Trust, nor the
names of specific contributors, may be used to endorse or promote
products derived from this software without specific prior written
permission.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
@@ -30,6 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "main.h"
+#include "stack_alloc.h"
/* Convert Left/Right stereo signal to adaptive Mid/Side representation */
void silk_stereo_LR_to_MS(
@@ -49,11 +50,15 @@ void silk_stereo_LR_to_MS(
opus_int n, is10msFrame, denom_Q16, delta0_Q13, delta1_Q13;
opus_int32 sum, diff, smooth_coef_Q16, pred_Q13[ 2 ], pred0_Q13, pred1_Q13;
opus_int32 LP_ratio_Q14, HP_ratio_Q14, frac_Q16, frac_3_Q16, min_mid_rate_bps, width_Q14, w_Q24, deltaw_Q24;
- opus_int16 side[ MAX_FRAME_LENGTH + 2 ];
- opus_int16 LP_mid[ MAX_FRAME_LENGTH ], HP_mid[ MAX_FRAME_LENGTH ];
- opus_int16 LP_side[ MAX_FRAME_LENGTH ], HP_side[ MAX_FRAME_LENGTH ];
+ VARDECL( opus_int16, side );
+ VARDECL( opus_int16, LP_mid );
+ VARDECL( opus_int16, HP_mid );
+ VARDECL( opus_int16, LP_side );
+ VARDECL( opus_int16, HP_side );
opus_int16 *mid = &x1[ -2 ];
+ SAVE_STACK;
+ ALLOC( side, frame_length + 2, opus_int16 );
/* Convert to basic mid/side signals */
for( n = 0; n < frame_length + 2; n++ ) {
sum = x1[ n - 2 ] + (opus_int32)x2[ n - 2 ];
@@ -69,6 +74,8 @@ void silk_stereo_LR_to_MS(
silk_memcpy( state->sSide, &side[ frame_length ], 2 * sizeof( opus_int16 ) );
/* LP and HP filter mid signal */
+ ALLOC( LP_mid, frame_length, opus_int16 );
+ ALLOC( HP_mid, frame_length, opus_int16 );
for( n = 0; n < frame_length; n++ ) {
sum = silk_RSHIFT_ROUND( silk_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 2 );
LP_mid[ n ] = sum;
@@ -76,6 +83,8 @@ void silk_stereo_LR_to_MS(
}
/* LP and HP filter side signal */
+ ALLOC( LP_side, frame_length, opus_int16 );
+ ALLOC( HP_side, frame_length, opus_int16 );
for( n = 0; n < frame_length; n++ ) {
sum = silk_RSHIFT_ROUND( silk_ADD_LSHIFT( side[ n ] + side[ n + 2 ], side[ n + 1 ], 1 ), 2 );
LP_side[ n ] = sum;
@@ -216,4 +225,5 @@ void silk_stereo_LR_to_MS(
state->pred_prev_Q13[ 0 ] = (opus_int16)pred_Q13[ 0 ];
state->pred_prev_Q13[ 1 ] = (opus_int16)pred_Q13[ 1 ];
state->width_prev_Q14 = (opus_int16)width_Q14;
+ RESTORE_STACK;
}