OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
5 are met: | 5 are met: |
6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
(...skipping 28 matching lines...) Expand all Loading... |
39 opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain
*/ | 39 opus_int32 x_sc_Q10[], /* O input scaled with 1/Gain
*/ |
40 const opus_int16 sLTP[], /* I re-whitened LTP state in
Q0 */ | 40 const opus_int16 sLTP[], /* I re-whitened LTP state in
Q0 */ |
41 opus_int32 sLTP_Q15[], /* O LTP state matching scale
d input */ | 41 opus_int32 sLTP_Q15[], /* O LTP state matching scale
d input */ |
42 opus_int subfr, /* I subframe number
*/ | 42 opus_int subfr, /* I subframe number
*/ |
43 const opus_int LTP_scale_Q14, /* I
*/ | 43 const opus_int LTP_scale_Q14, /* I
*/ |
44 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I
*/ | 44 const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I
*/ |
45 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag
*/ | 45 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag
*/ |
46 const opus_int signal_type /* I Signal type
*/ | 46 const opus_int signal_type /* I Signal type
*/ |
47 ); | 47 ); |
48 | 48 |
| 49 #if !defined(OPUS_X86_MAY_HAVE_SSE4_1) |
49 static OPUS_INLINE void silk_noise_shape_quantizer( | 50 static OPUS_INLINE void silk_noise_shape_quantizer( |
50 silk_nsq_state *NSQ, /* I/O NSQ state
*/ | 51 silk_nsq_state *NSQ, /* I/O NSQ state
*/ |
51 opus_int signalType, /* I Signal type
*/ | 52 opus_int signalType, /* I Signal type
*/ |
52 const opus_int32 x_sc_Q10[], /* I
*/ | 53 const opus_int32 x_sc_Q10[], /* I
*/ |
53 opus_int8 pulses[], /* O
*/ | 54 opus_int8 pulses[], /* O
*/ |
54 opus_int16 xq[], /* O
*/ | 55 opus_int16 xq[], /* O
*/ |
55 opus_int32 sLTP_Q15[], /* I/O LTP state
*/ | 56 opus_int32 sLTP_Q15[], /* I/O LTP state
*/ |
56 const opus_int16 a_Q12[], /* I Short term prediction co
efs */ | 57 const opus_int16 a_Q12[], /* I Short term prediction co
efs */ |
57 const opus_int16 b_Q14[], /* I Long term prediction coe
fs */ | 58 const opus_int16 b_Q14[], /* I Long term prediction coe
fs */ |
58 const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs
*/ | 59 const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs
*/ |
59 opus_int lag, /* I Pitch lag
*/ | 60 opus_int lag, /* I Pitch lag
*/ |
60 opus_int32 HarmShapeFIRPacked_Q14, /* I
*/ | 61 opus_int32 HarmShapeFIRPacked_Q14, /* I
*/ |
61 opus_int Tilt_Q14, /* I Spectral tilt
*/ | 62 opus_int Tilt_Q14, /* I Spectral tilt
*/ |
62 opus_int32 LF_shp_Q14, /* I
*/ | 63 opus_int32 LF_shp_Q14, /* I
*/ |
63 opus_int32 Gain_Q16, /* I
*/ | 64 opus_int32 Gain_Q16, /* I
*/ |
64 opus_int Lambda_Q10, /* I
*/ | 65 opus_int Lambda_Q10, /* I
*/ |
65 opus_int offset_Q10, /* I
*/ | 66 opus_int offset_Q10, /* I
*/ |
66 opus_int length, /* I Input length
*/ | 67 opus_int length, /* I Input length
*/ |
67 opus_int shapingLPCOrder, /* I Noise shaping AR filter
order */ | 68 opus_int shapingLPCOrder, /* I Noise shaping AR filter
order */ |
68 opus_int predictLPCOrder /* I Prediction filter order
*/ | 69 opus_int predictLPCOrder /* I Prediction filter order
*/ |
69 ); | 70 ); |
| 71 #endif |
70 | 72 |
71 void silk_NSQ( | 73 void silk_NSQ_c |
| 74 ( |
72 const silk_encoder_state *psEncC, /* I
/O Encoder State */ | 75 const silk_encoder_state *psEncC, /* I
/O Encoder State */ |
73 silk_nsq_state *NSQ, /* I
/O NSQ state */ | 76 silk_nsq_state *NSQ, /* I
/O NSQ state */ |
74 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ | 77 SideInfoIndices *psIndices, /* I
/O Quantization Indices */ |
75 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ | 78 const opus_int32 x_Q3[], /* I
Prefiltered input signal */ |
76 opus_int8 pulses[], /* O
Quantized pulse signal */ | 79 opus_int8 pulses[], /* O
Quantized pulse signal */ |
77 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ | 80 const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I
Short term prediction coefs */ |
78 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ | 81 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I
Long term prediction coefs */ |
79 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ | 82 const opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /
* I Noise shaping coefs */ |
80 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ | 83 const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I
Long term shaping coefs */ |
81 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ | 84 const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I
Spectral tilt */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 /* Voiced */ | 137 /* Voiced */ |
135 lag = pitchL[ k ]; | 138 lag = pitchL[ k ]; |
136 | 139 |
137 /* Re-whitening */ | 140 /* Re-whitening */ |
138 if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 )
{ | 141 if( ( k & ( 3 - silk_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 )
{ |
139 /* Rewhiten with new A coefs */ | 142 /* Rewhiten with new A coefs */ |
140 start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrd
er - LTP_ORDER / 2; | 143 start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrd
er - LTP_ORDER / 2; |
141 silk_assert( start_idx > 0 ); | 144 silk_assert( start_idx > 0 ); |
142 | 145 |
143 silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_id
x + k * psEncC->subfr_length ], | 146 silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_id
x + k * psEncC->subfr_length ], |
144 A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLP
COrder ); | 147 A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLP
COrder, psEncC->arch ); |
145 | 148 |
146 NSQ->rewhite_flag = 1; | 149 NSQ->rewhite_flag = 1; |
147 NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; | 150 NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; |
148 } | 151 } |
149 } | 152 } |
150 | 153 |
151 silk_nsq_scale_states( psEncC, NSQ, x_Q3, x_sc_Q10, sLTP, sLTP_Q15, k, L
TP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType ); | 154 silk_nsq_scale_states( psEncC, NSQ, x_Q3, x_sc_Q10, sLTP, sLTP_Q15, k, L
TP_scale_Q14, Gains_Q16, pitchL, psIndices->signalType ); |
152 | 155 |
153 silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses
, pxq, sLTP_Q15, A_Q12, B_Q14, | 156 silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses
, pxq, sLTP_Q15, A_Q12, B_Q14, |
154 AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[
k ], Gains_Q16[ k ], Lambda_Q10, | 157 AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[
k ], Gains_Q16[ k ], Lambda_Q10, |
(...skipping 10 matching lines...) Expand all Loading... |
165 /* Save quantized speech and noise shaping signals */ | 168 /* Save quantized speech and noise shaping signals */ |
166 /* DEBUG_STORE_DATA( enc.pcm, &NSQ->xq[ psEncC->ltp_mem_length ], psEncC->fr
ame_length * sizeof( opus_int16 ) ) */ | 169 /* DEBUG_STORE_DATA( enc.pcm, &NSQ->xq[ psEncC->ltp_mem_length ], psEncC->fr
ame_length * sizeof( opus_int16 ) ) */ |
167 silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int16 ) ); | 170 silk_memmove( NSQ->xq, &NSQ->xq[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int16 ) ); |
168 silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int32 ) ); | 171 silk_memmove( NSQ->sLTP_shp_Q14, &NSQ->sLTP_shp_Q14[ psEncC->frame_length ],
psEncC->ltp_mem_length * sizeof( opus_int32 ) ); |
169 RESTORE_STACK; | 172 RESTORE_STACK; |
170 } | 173 } |
171 | 174 |
172 /***********************************/ | 175 /***********************************/ |
173 /* silk_noise_shape_quantizer */ | 176 /* silk_noise_shape_quantizer */ |
174 /***********************************/ | 177 /***********************************/ |
175 static OPUS_INLINE void silk_noise_shape_quantizer( | 178 |
| 179 #if !defined(OPUS_X86_MAY_HAVE_SSE4_1) |
| 180 static OPUS_INLINE |
| 181 #endif |
| 182 void silk_noise_shape_quantizer( |
176 silk_nsq_state *NSQ, /* I/O NSQ state
*/ | 183 silk_nsq_state *NSQ, /* I/O NSQ state
*/ |
177 opus_int signalType, /* I Signal type
*/ | 184 opus_int signalType, /* I Signal type
*/ |
178 const opus_int32 x_sc_Q10[], /* I
*/ | 185 const opus_int32 x_sc_Q10[], /* I
*/ |
179 opus_int8 pulses[], /* O
*/ | 186 opus_int8 pulses[], /* O
*/ |
180 opus_int16 xq[], /* O
*/ | 187 opus_int16 xq[], /* O
*/ |
181 opus_int32 sLTP_Q15[], /* I/O LTP state
*/ | 188 opus_int32 sLTP_Q15[], /* I/O LTP state
*/ |
182 const opus_int16 a_Q12[], /* I Short term prediction co
efs */ | 189 const opus_int16 a_Q12[], /* I Short term prediction co
efs */ |
183 const opus_int16 b_Q14[], /* I Long term prediction coe
fs */ | 190 const opus_int16 b_Q14[], /* I Long term prediction coe
fs */ |
184 const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs
*/ | 191 const opus_int16 AR_shp_Q13[], /* I Noise shaping AR coefs
*/ |
185 opus_int lag, /* I Pitch lag
*/ | 192 opus_int lag, /* I Pitch lag
*/ |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 444 |
438 /* Scale short-term prediction and shaping states */ | 445 /* Scale short-term prediction and shaping states */ |
439 for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { | 446 for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) { |
440 NSQ->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] )
; | 447 NSQ->sLPC_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] )
; |
441 } | 448 } |
442 for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { | 449 for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) { |
443 NSQ->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] )
; | 450 NSQ->sAR2_Q14[ i ] = silk_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] )
; |
444 } | 451 } |
445 } | 452 } |
446 } | 453 } |
OLD | NEW |