OLD | NEW |
1 /* Copyright (c) 2014, Cisco Systems, INC | 1 /* Copyright (c) 2014, Cisco Systems, INC |
2 Written by XiangMingZhu WeiZhou MinPeng YanWang | 2 Written by XiangMingZhu WeiZhou MinPeng YanWang |
3 | 3 |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 | 7 |
8 - Redistributions of source code must retain the above copyright | 8 - Redistributions of source code must retain the above copyright |
9 notice, this list of conditions and the following disclaimer. | 9 notice, this list of conditions and the following disclaimer. |
10 | 10 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 opus_int32 LF_shp_Q14, /* I
*/ | 100 opus_int32 LF_shp_Q14, /* I
*/ |
101 opus_int32 Gain_Q16, /* I
*/ | 101 opus_int32 Gain_Q16, /* I
*/ |
102 opus_int Lambda_Q10, /* I
*/ | 102 opus_int Lambda_Q10, /* I
*/ |
103 opus_int offset_Q10, /* I
*/ | 103 opus_int offset_Q10, /* I
*/ |
104 opus_int length, /* I Input length
*/ | 104 opus_int length, /* I Input length
*/ |
105 opus_int subfr, /* I Subframe number
*/ | 105 opus_int subfr, /* I Subframe number
*/ |
106 opus_int shapingLPCOrder, /* I Shaping LPC filter order
*/ | 106 opus_int shapingLPCOrder, /* I Shaping LPC filter order
*/ |
107 opus_int predictLPCOrder, /* I Prediction filter order
*/ | 107 opus_int predictLPCOrder, /* I Prediction filter order
*/ |
108 opus_int warping_Q16, /* I
*/ | 108 opus_int warping_Q16, /* I
*/ |
109 opus_int nStatesDelayedDecision, /* I Number of states in deci
sion tree */ | 109 opus_int nStatesDelayedDecision, /* I Number of states in deci
sion tree */ |
110 opus_int *smpl_buf_idx, /* I Index to newest samples
in buffers */ | 110 opus_int *smpl_buf_idx, /* I/O Index to newest samples
in buffers */ |
111 opus_int decisionDelay /* I
*/ | 111 opus_int decisionDelay /* I
*/ |
112 ); | 112 ); |
113 | 113 |
114 void silk_NSQ_del_dec_sse4_1( | 114 void silk_NSQ_del_dec_sse4_1( |
115 const silk_encoder_state *psEncC, /* I
/O Encoder State */ | 115 const silk_encoder_state *psEncC, /* I
Encoder State */ |
116 silk_nsq_state *NSQ, /* I
/O NSQ state */ | 116 silk_nsq_state *NSQ, /* I
/O NSQ state */ |
117 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ | 117 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ |
118 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ | 118 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ |
119 opus_int8 pulses[], /* O
Quantized pulse signal */ | 119 opus_int8 pulses[], /* O
Quantized pulse signal */ |
120 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ | 120 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ |
121 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ | 121 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ |
122 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ | 122 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ |
123 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ | 123 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ |
124 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ | 124 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ |
125 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I
Low frequency shaping coefs */ | 125 const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I
Low frequency shaping coefs */ |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 if( i != Winner_ind ) { | 227 if( i != Winner_ind ) { |
228 psDelDec[ i ].RD_Q10 += ( silk_int32_MAX >> 4 ); | 228 psDelDec[ i ].RD_Q10 += ( silk_int32_MAX >> 4 ); |
229 silk_assert( psDelDec[ i ].RD_Q10 >= 0 ); | 229 silk_assert( psDelDec[ i ].RD_Q10 >= 0 ); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 /* Copy final part of signals from winner state to output an
d long-term filter states */ | 233 /* Copy final part of signals from winner state to output an
d long-term filter states */ |
234 psDD = &psDelDec[ Winner_ind ]; | 234 psDD = &psDelDec[ Winner_ind ]; |
235 last_smple_idx = smpl_buf_idx + decisionDelay; | 235 last_smple_idx = smpl_buf_idx + decisionDelay; |
236 for( i = 0; i < decisionDelay; i++ ) { | 236 for( i = 0; i < decisionDelay; i++ ) { |
237 last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY
_MASK; | 237 last_smple_idx = ( last_smple_idx - 1 ) % DECISION_DELAY
; |
| 238 if( last_smple_idx < 0 ) last_smple_idx += DECISION_DELA
Y; |
238 pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_R
OUND( psDD->Q_Q10[ last_smple_idx ], 10 ); | 239 pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_R
OUND( psDD->Q_Q10[ last_smple_idx ], 10 ); |
239 pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_
RSHIFT_ROUND( | 240 pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_
RSHIFT_ROUND( |
240 silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gains_Q
16[ 1 ] ), 14 ) ); | 241 silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gains_Q
16[ 1 ] ), 14 ) ); |
241 NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay
+ i ] = psDD->Shape_Q14[ last_smple_idx ]; | 242 NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay
+ i ] = psDD->Shape_Q14[ last_smple_idx ]; |
242 } | 243 } |
243 | 244 |
244 subfr = 0; | 245 subfr = 0; |
245 } | 246 } |
246 | 247 |
247 /* Rewhiten with new A coefs */ | 248 /* Rewhiten with new A coefs */ |
(...skipping 30 matching lines...) Expand all Loading... |
278 Winner_ind = k; | 279 Winner_ind = k; |
279 } | 280 } |
280 } | 281 } |
281 | 282 |
282 /* Copy final part of signals from winner state to output and long-term filt
er states */ | 283 /* Copy final part of signals from winner state to output and long-term filt
er states */ |
283 psDD = &psDelDec[ Winner_ind ]; | 284 psDD = &psDelDec[ Winner_ind ]; |
284 psIndices->Seed = psDD->SeedInit; | 285 psIndices->Seed = psDD->SeedInit; |
285 last_smple_idx = smpl_buf_idx + decisionDelay; | 286 last_smple_idx = smpl_buf_idx + decisionDelay; |
286 Gain_Q10 = silk_RSHIFT32( Gains_Q16[ psEncC->nb_subfr - 1 ], 6 ); | 287 Gain_Q10 = silk_RSHIFT32( Gains_Q16[ psEncC->nb_subfr - 1 ], 6 ); |
287 for( i = 0; i < decisionDelay; i++ ) { | 288 for( i = 0; i < decisionDelay; i++ ) { |
288 last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK; | 289 last_smple_idx = ( last_smple_idx - 1 ) % DECISION_DELAY; |
| 290 if( last_smple_idx < 0 ) last_smple_idx += DECISION_DELAY; |
289 pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q1
0[ last_smple_idx ], 10 ); | 291 pulses[ i - decisionDelay ] = (opus_int8)silk_RSHIFT_ROUND( psDD->Q_Q1
0[ last_smple_idx ], 10 ); |
290 pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( | 292 pxq[ i - decisionDelay ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( |
291 silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gain_Q10 ), 8 ) ); | 293 silk_SMULWW( psDD->Xq_Q14[ last_smple_idx ], Gain_Q10 ), 8 ) ); |
292 NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->S
hape_Q14[ last_smple_idx ]; | 294 NSQ->sLTP_shp_Q14[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->S
hape_Q14[ last_smple_idx ]; |
293 } | 295 } |
294 silk_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC
_BUF_LENGTH * sizeof( opus_int32 ) ); | 296 silk_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC
_BUF_LENGTH * sizeof( opus_int32 ) ); |
295 silk_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) ); | 297 silk_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) ); |
296 | 298 |
297 /* Update states */ | 299 /* Update states */ |
298 NSQ->sLF_AR_shp_Q14 = psDD->LF_AR_Q14; | 300 NSQ->sLF_AR_shp_Q14 = psDD->LF_AR_Q14; |
299 NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; | 301 NSQ->lagPrev = pitchL[ psEncC->nb_subfr - 1 ]; |
300 | 302 |
301 /* Save quantized speech signal */ | 303 /* Save quantized speech signal */ |
302 /* DEBUG_STORE_DATA( enc.pcm, &NSQ->xq[psEncC->ltp_mem_length], psEncC->fram
e_length * sizeof( opus_int16 ) ) */ | |
303 silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int16 ) ); | 304 silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int16 ) ); |
304 silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int32 ) ); | 305 silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int32 ) ); |
305 RESTORE_STACK; | 306 RESTORE_STACK; |
306 } | 307 } |
307 | 308 |
308 /******************************************/ | 309 /******************************************/ |
309 /* Noise shape quantizer for one subframe */ | 310 /* Noise shape quantizer for one subframe */ |
310 /******************************************/ | 311 /******************************************/ |
311 static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_sse4_1( | 312 static OPUS_INLINE void silk_noise_shape_quantizer_del_dec_sse4_1( |
312 silk_nsq_state *NSQ, /* I/O NSQ state
*/ | 313 silk_nsq_state *NSQ, /* I/O NSQ state
*/ |
(...skipping 13 matching lines...) Expand all Loading... |
326 opus_int32 LF_shp_Q14, /* I
*/ | 327 opus_int32 LF_shp_Q14, /* I
*/ |
327 opus_int32 Gain_Q16, /* I
*/ | 328 opus_int32 Gain_Q16, /* I
*/ |
328 opus_int Lambda_Q10, /* I
*/ | 329 opus_int Lambda_Q10, /* I
*/ |
329 opus_int offset_Q10, /* I
*/ | 330 opus_int offset_Q10, /* I
*/ |
330 opus_int length, /* I Input length
*/ | 331 opus_int length, /* I Input length
*/ |
331 opus_int subfr, /* I Subframe number
*/ | 332 opus_int subfr, /* I Subframe number
*/ |
332 opus_int shapingLPCOrder, /* I Shaping LPC filter order
*/ | 333 opus_int shapingLPCOrder, /* I Shaping LPC filter order
*/ |
333 opus_int predictLPCOrder, /* I Prediction filter order
*/ | 334 opus_int predictLPCOrder, /* I Prediction filter order
*/ |
334 opus_int warping_Q16, /* I
*/ | 335 opus_int warping_Q16, /* I
*/ |
335 opus_int nStatesDelayedDecision, /* I Number of states in deci
sion tree */ | 336 opus_int nStatesDelayedDecision, /* I Number of states in deci
sion tree */ |
336 opus_int *smpl_buf_idx, /* I Index to newest samples
in buffers */ | 337 opus_int *smpl_buf_idx, /* I/O Index to newest samples
in buffers */ |
337 opus_int decisionDelay /* I
*/ | 338 opus_int decisionDelay /* I
*/ |
338 ) | 339 ) |
339 { | 340 { |
340 opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; | 341 opus_int i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx; |
341 opus_int32 Winner_rand_state; | 342 opus_int32 Winner_rand_state; |
342 opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; | 343 opus_int32 LTP_pred_Q14, LPC_pred_Q14, n_AR_Q14, n_LTP_Q14; |
343 opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10
; | 344 opus_int32 n_LF_Q14, r_Q10, rr_Q10, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10
; |
344 opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; | 345 opus_int32 q1_Q0, q1_Q10, q2_Q10, exc_Q14, LPC_exc_Q14, xq_Q14, Gain_Q10; |
345 opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; | 346 opus_int32 tmp1, tmp2, sLF_AR_shp_Q14; |
346 opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; | 347 opus_int32 *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); | 632 xq_Q14 = silk_ADD32( LPC_exc_Q14, LPC_pred_Q14 ); |
632 | 633 |
633 /* Update states */ | 634 /* Update states */ |
634 sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); | 635 sLF_AR_shp_Q14 = silk_SUB32( xq_Q14, n_AR_Q14 ); |
635 psSS[ 1 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); | 636 psSS[ 1 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 ); |
636 psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; | 637 psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14; |
637 psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; | 638 psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14; |
638 psSS[ 1 ].xq_Q14 = xq_Q14; | 639 psSS[ 1 ].xq_Q14 = xq_Q14; |
639 } | 640 } |
640 } | 641 } |
641 *smpl_buf_idx = ( *smpl_buf_idx - 1 ) & DECISION_DELAY_MASK;
/* Index to newest samples */ | 642 *smpl_buf_idx = ( *smpl_buf_idx - 1 ) % DECISION_DELAY; |
642 last_smple_idx = ( *smpl_buf_idx + decisionDelay ) & DECISION_DELAY_MASK
; /* Index to decisionDelay old samples */ | 643 if( *smpl_buf_idx < 0 ) *smpl_buf_idx += DECISION_DELAY; |
| 644 last_smple_idx = ( *smpl_buf_idx + decisionDelay ) % DECISION_DELAY; |
643 | 645 |
644 /* Find winner */ | 646 /* Find winner */ |
645 RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; | 647 RDmin_Q10 = psSampleState[ 0 ][ 0 ].RD_Q10; |
646 Winner_ind = 0; | 648 Winner_ind = 0; |
647 for( k = 1; k < nStatesDelayedDecision; k++ ) { | 649 for( k = 1; k < nStatesDelayedDecision; k++ ) { |
648 if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { | 650 if( psSampleState[ k ][ 0 ].RD_Q10 < RDmin_Q10 ) { |
649 RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; | 651 RDmin_Q10 = psSampleState[ k ][ 0 ].RD_Q10; |
650 Winner_ind = k; | 652 Winner_ind = k; |
651 } | 653 } |
652 } | 654 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 psDD->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sAR2_
Q14[ i ] ); | 850 psDD->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->sAR2_
Q14[ i ] ); |
849 } | 851 } |
850 for( i = 0; i < DECISION_DELAY; i++ ) { | 852 for( i = 0; i < DECISION_DELAY; i++ ) { |
851 psDD->Pred_Q15[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Pred
_Q15[ i ] ); | 853 psDD->Pred_Q15[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Pred
_Q15[ i ] ); |
852 psDD->Shape_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Shap
e_Q14[ i ] ); | 854 psDD->Shape_Q14[ i ] = silk_SMULWW( gain_adj_Q16, psDD->Shap
e_Q14[ i ] ); |
853 } | 855 } |
854 } | 856 } |
855 } | 857 } |
856 } | 858 } |
857 } | 859 } |
OLD | NEW |