summaryrefslogtreecommitdiff
path: root/silk/NSQ.c
diff options
context:
space:
mode:
authorKoen Vos <koen.vos@skype.net>2012-01-31 01:51:22 -0500
committerJean-Marc Valin <jmvalin@jmvalin.ca>2012-01-31 01:51:22 -0500
commit54518c879a6541eab749bc19628f1795daaad1e3 (patch)
tree3c2d0d08b9314dcb2d316e2ec4e477a6784b970b /silk/NSQ.c
parenta26b2be2f922502b821e81e2cb084393f1ccf405 (diff)
downloadopus-54518c879a6541eab749bc19628f1795daaad1e3.tar.gz
Last part of the LPC work stabilization work discussed at the last meeting
Also adds the encoder part of commit ee8adbe701 as well as a few minor cleanups.
Diffstat (limited to 'silk/NSQ.c')
-rw-r--r--silk/NSQ.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/silk/NSQ.c b/silk/NSQ.c
index c4941ada..0c2abaf8 100644
--- a/silk/NSQ.c
+++ b/silk/NSQ.c
@@ -190,7 +190,7 @@ static inline void silk_noise_shape_quantizer(
opus_int i, j;
opus_int32 LTP_pred_Q13, LPC_pred_Q10, n_AR_Q12, n_LTP_Q13;
opus_int32 n_LF_Q12, r_Q10, rr_Q10, q1_Q0, q1_Q10, q2_Q10, rd1_Q20, rd2_Q20;
- opus_int32 dither, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10;
+ opus_int32 exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10;
opus_int32 tmp1, tmp2, sLF_AR_shp_Q14;
opus_int32 *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr;
@@ -205,9 +205,6 @@ static inline void silk_noise_shape_quantizer(
/* Generate dither */
NSQ->rand_seed = silk_RAND( NSQ->rand_seed );
- /* dither = rand_seed < 0 ? 0xFFFFFFFF : 0; */
- dither = silk_RSHIFT( NSQ->rand_seed, 31 );
-
/* Short-term prediction */
silk_assert( predictLPCOrder == 10 || predictLPCOrder == 16 );
/* Avoids introducing a bias because silk_SMLAWB() always rounds to -inf */
@@ -292,7 +289,9 @@ static inline void silk_noise_shape_quantizer(
r_Q10 = silk_SUB32( x_sc_Q10[ i ], tmp1 ); /* residual error Q10 */
/* Flip sign depending on dither */
- r_Q10 = r_Q10 ^ dither;
+ if ( NSQ->rand_seed < 0 ) {
+ r_Q10 = -r_Q10;
+ }
r_Q10 = silk_LIMIT_32( r_Q10, -(31 << 10), 30 << 10 );
/* Find two quantization level candidates and measure their rate-distortion */
@@ -333,7 +332,10 @@ static inline void silk_noise_shape_quantizer(
pulses[ i ] = (opus_int8)silk_RSHIFT_ROUND( q1_Q10, 10 );
/* Excitation */
- exc_Q14 = silk_LSHIFT( q1_Q10, 4 ) ^ dither;
+ exc_Q14 = silk_LSHIFT( q1_Q10, 4 );
+ if ( NSQ->rand_seed < 0 ) {
+ exc_Q14 = -exc_Q14;
+ }
/* Add predictions */
LPC_exc_Q14 = silk_ADD_LSHIFT32( exc_Q14, LTP_pred_Q13, 1 );