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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 a_fix_Q16[ i ] = silk_float2int( pAR[ i ] * 65536.0f ); | 47 a_fix_Q16[ i ] = silk_float2int( pAR[ i ] * 65536.0f ); |
48 } | 48 } |
49 | 49 |
50 silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order ); | 50 silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order ); |
51 } | 51 } |
52 | 52 |
53 /* Convert LSF parameters to AR prediction filter coefficients */ | 53 /* Convert LSF parameters to AR prediction filter coefficients */ |
54 void silk_NLSF2A_FLP( | 54 void silk_NLSF2A_FLP( |
55 silk_float *pAR, /* O
LPC coefficients [ LPC_order ] */ | 55 silk_float *pAR, /* O
LPC coefficients [ LPC_order ] */ |
56 const opus_int16 *NLSF_Q15, /* I
NLSF vector [ LPC_order ] */ | 56 const opus_int16 *NLSF_Q15, /* I
NLSF vector [ LPC_order ] */ |
57 const opus_int LPC_order /* I
LPC order */ | 57 const opus_int LPC_order, /* I
LPC order */ |
| 58 int arch /* I
Run-time architecture */ |
58 ) | 59 ) |
59 { | 60 { |
60 opus_int i; | 61 opus_int i; |
61 opus_int16 a_fix_Q12[ MAX_LPC_ORDER ]; | 62 opus_int16 a_fix_Q12[ MAX_LPC_ORDER ]; |
62 | 63 |
63 silk_NLSF2A( a_fix_Q12, NLSF_Q15, LPC_order ); | 64 silk_NLSF2A( a_fix_Q12, NLSF_Q15, LPC_order, arch ); |
64 | 65 |
65 for( i = 0; i < LPC_order; i++ ) { | 66 for( i = 0; i < LPC_order; i++ ) { |
66 pAR[ i ] = ( silk_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f ); | 67 pAR[ i ] = ( silk_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f ); |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 /******************************************/ | 71 /******************************************/ |
71 /* Floating-point NLSF processing wrapper */ | 72 /* Floating-point NLSF processing wrapper */ |
72 /******************************************/ | 73 /******************************************/ |
73 void silk_process_NLSFs_FLP( | 74 void silk_process_NLSFs_FLP( |
(...skipping 21 matching lines...) Expand all Loading... |
95 void silk_NSQ_wrapper_FLP( | 96 void silk_NSQ_wrapper_FLP( |
96 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ | 97 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ |
97 silk_encoder_control_FLP *psEncCtrl, /* I/O
Encoder control FLP */ | 98 silk_encoder_control_FLP *psEncCtrl, /* I/O
Encoder control FLP */ |
98 SideInfoIndices *psIndices, /* I/O
Quantization indices */ | 99 SideInfoIndices *psIndices, /* I/O
Quantization indices */ |
99 silk_nsq_state *psNSQ, /* I/O
Noise Shaping Quantzation state */ | 100 silk_nsq_state *psNSQ, /* I/O
Noise Shaping Quantzation state */ |
100 opus_int8 pulses[], /* O
Quantized pulse signal */ | 101 opus_int8 pulses[], /* O
Quantized pulse signal */ |
101 const silk_float x[] /* I
Prefiltered input signal */ | 102 const silk_float x[] /* I
Prefiltered input signal */ |
102 ) | 103 ) |
103 { | 104 { |
104 opus_int i, j; | 105 opus_int i, j; |
105 opus_int32 x_Q3[ MAX_FRAME_LENGTH ]; | 106 opus_int16 x16[ MAX_FRAME_LENGTH ]; |
106 opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; | 107 opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; |
107 silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; | 108 silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; |
108 opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; | 109 opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; |
109 opus_int LTP_scale_Q14; | 110 opus_int LTP_scale_Q14; |
110 | 111 |
111 /* Noise shaping parameters */ | 112 /* Noise shaping parameters */ |
112 opus_int16 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; | 113 opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ]; |
113 opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coeffici
ents per int32 value */ | 114 opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ]; /* Packs two int16 coeffici
ents per int32 value */ |
114 opus_int Lambda_Q10; | 115 opus_int Lambda_Q10; |
115 opus_int Tilt_Q14[ MAX_NB_SUBFR ]; | 116 opus_int Tilt_Q14[ MAX_NB_SUBFR ]; |
116 opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ]; | 117 opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ]; |
117 | 118 |
118 /* Convert control struct to fix control struct */ | 119 /* Convert control struct to fix control struct */ |
119 /* Noise shape parameters */ | 120 /* Noise shape parameters */ |
120 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { | 121 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { |
121 for( j = 0; j < psEnc->sCmn.shapingLPCOrder; j++ ) { | 122 for( j = 0; j < psEnc->sCmn.shapingLPCOrder; j++ ) { |
122 AR2_Q13[ i * MAX_SHAPE_LPC_ORDER + j ] = silk_float2int( psEncCtrl->
AR2[ i * MAX_SHAPE_LPC_ORDER + j ] * 8192.0f ); | 123 AR_Q13[ i * MAX_SHAPE_LPC_ORDER + j ] = silk_float2int( psEncCtrl->A
R[ i * MAX_SHAPE_LPC_ORDER + j ] * 8192.0f ); |
123 } | 124 } |
124 } | 125 } |
125 | 126 |
126 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { | 127 for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { |
127 LF_shp_Q14[ i ] = silk_LSHIFT32( silk_float2int( psEncCtrl->LF_AR_shp[
i ] * 16384.0f ), 16 ) | | 128 LF_shp_Q14[ i ] = silk_LSHIFT32( silk_float2int( psEncCtrl->LF_AR_shp[
i ] * 16384.0f ), 16 ) | |
128 (opus_uint16)silk_float2int( psEncCtrl->LF_MA_shp[
i ] * 16384.0f ); | 129 (opus_uint16)silk_float2int( psEncCtrl->LF_MA_shp[
i ] * 16384.0f ); |
129 Tilt_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->Tilt[ i ]
* 16384.0f ); | 130 Tilt_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->Tilt[ i ]
* 16384.0f ); |
130 HarmShapeGain_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->HarmShapeG
ain[ i ] * 16384.0f ); | 131 HarmShapeGain_Q14[ i ] = (opus_int)silk_float2int( psEncCtrl->HarmShapeG
ain[ i ] * 16384.0f ); |
131 } | 132 } |
132 Lambda_Q10 = ( opus_int )silk_float2int( psEncCtrl->Lambda * 1024.0f ); | 133 Lambda_Q10 = ( opus_int )silk_float2int( psEncCtrl->Lambda * 1024.0f ); |
(...skipping 15 matching lines...) Expand all Loading... |
148 } | 149 } |
149 | 150 |
150 if( psIndices->signalType == TYPE_VOICED ) { | 151 if( psIndices->signalType == TYPE_VOICED ) { |
151 LTP_scale_Q14 = silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ]; | 152 LTP_scale_Q14 = silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ]; |
152 } else { | 153 } else { |
153 LTP_scale_Q14 = 0; | 154 LTP_scale_Q14 = 0; |
154 } | 155 } |
155 | 156 |
156 /* Convert input to fix */ | 157 /* Convert input to fix */ |
157 for( i = 0; i < psEnc->sCmn.frame_length; i++ ) { | 158 for( i = 0; i < psEnc->sCmn.frame_length; i++ ) { |
158 x_Q3[ i ] = silk_float2int( 8.0f * x[ i ] ); | 159 x16[ i ] = silk_float2int( x[ i ] ); |
159 } | 160 } |
160 | 161 |
161 /* Call NSQ */ | 162 /* Call NSQ */ |
162 if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 )
{ | 163 if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 )
{ |
163 silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x_Q3, pulses, PredCoef
_Q12[ 0 ], LTPCoef_Q14, | 164 silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x16, pulses, PredCoef_
Q12[ 0 ], LTPCoef_Q14, |
164 AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCt
rl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); | 165 AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtr
l->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); |
165 } else { | 166 } else { |
166 silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x_Q3, pulses, PredCoef_Q12[ 0
], LTPCoef_Q14, | 167 silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x16, pulses, PredCoef_Q12[ 0 ]
, LTPCoef_Q14, |
167 AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCt
rl->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); | 168 AR_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtr
l->pitchL, Lambda_Q10, LTP_scale_Q14, psEnc->sCmn.arch ); |
168 } | 169 } |
169 } | 170 } |
170 | 171 |
171 /***********************************************/ | 172 /***********************************************/ |
172 /* Floating-point Silk LTP quantiation wrapper */ | 173 /* Floating-point Silk LTP quantiation wrapper */ |
173 /***********************************************/ | 174 /***********************************************/ |
174 void silk_quant_LTP_gains_FLP( | 175 void silk_quant_LTP_gains_FLP( |
175 silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O
(Un-)quantized LTP gains */ | 176 silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O
Quantized LTP gains */ |
176 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O
Codebook index */ | 177 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O
Codebook index */ |
177 opus_int8 *periodicity_index, /* O
Periodicity index */ | 178 opus_int8 *periodicity_index, /* O
Periodicity index */ |
178 opus_int32 *sum_log_gain_Q7, /* I/O
Cumulative max prediction gain */ | 179 opus_int32 *sum_log_gain_Q7, /* I/O
Cumulative max prediction gain */ |
179 const silk_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /
* I Error weights */ | 180 silk_float *pred_gain_dB, /* O
LTP prediction gain */ |
180 const opus_int mu_Q10, /* I
Mu value (R/D tradeoff) */ | 181 const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ],
/* I Correlation matrix */ |
181 const opus_int lowComplexity, /* I
Flag for low complexity */ | 182 const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I
Correlation vector */ |
182 const opus_int nb_subfr, /* I
number of subframes */ | 183 const opus_int subfr_len, /* I
Number of samples per subframe */ |
| 184 const opus_int nb_subfr, /* I
Number of subframes */ |
183 int arch /* I
Run-time architecture */ | 185 int arch /* I
Run-time architecture */ |
184 ) | 186 ) |
185 { | 187 { |
186 opus_int i; | 188 opus_int i, pred_gain_dB_Q7; |
187 opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ]; | 189 opus_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ]; |
188 opus_int32 W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ]; | 190 opus_int32 XX_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ]; |
| 191 opus_int32 xX_Q17[ MAX_NB_SUBFR * LTP_ORDER ]; |
189 | 192 |
| 193 for( i = 0; i < nb_subfr * LTP_ORDER * LTP_ORDER; i++ ) { |
| 194 XX_Q17[ i ] = (opus_int32)silk_float2int( XX[ i ] * 131072.0f ); |
| 195 } |
190 for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { | 196 for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { |
191 B_Q14[ i ] = (opus_int16)silk_float2int( B[ i ] * 16384.0f ); | 197 xX_Q17[ i ] = (opus_int32)silk_float2int( xX[ i ] * 131072.0f ); |
192 } | |
193 for( i = 0; i < nb_subfr * LTP_ORDER * LTP_ORDER; i++ ) { | |
194 W_Q18[ i ] = (opus_int32)silk_float2int( W[ i ] * 262144.0f ); | |
195 } | 198 } |
196 | 199 |
197 silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7,
W_Q18, mu_Q10, lowComplexity, nb_subfr, arch ); | 200 silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7,
&pred_gain_dB_Q7, XX_Q17, xX_Q17, subfr_len, nb_subfr, arch ); |
198 | 201 |
199 for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { | 202 for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { |
200 B[ i ] = (silk_float)B_Q14[ i ] * ( 1.0f / 16384.0f ); | 203 B[ i ] = (silk_float)B_Q14[ i ] * ( 1.0f / 16384.0f ); |
201 } | 204 } |
| 205 |
| 206 *pred_gain_dB = (silk_float)pred_gain_dB_Q7 * ( 1.0f / 128.0f ); |
202 } | 207 } |
OLD | NEW |