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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 out0_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_RSHIFT( silk_S
MULBB( out0_Q10, quant_step_size_Q16 ), 16 ); | 78 out0_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_RSHIFT( silk_S
MULBB( out0_Q10, quant_step_size_Q16 ), 16 ); |
79 out1_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_RSHIFT( silk_S
MULBB( out1_Q10, quant_step_size_Q16 ), 16 ); | 79 out1_Q10_table[ i + NLSF_QUANT_MAX_AMPLITUDE_EXT ] = silk_RSHIFT( silk_S
MULBB( out1_Q10, quant_step_size_Q16 ), 16 ); |
80 } | 80 } |
81 | 81 |
82 silk_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) ==
0 ); /* must be power of two */ | 82 silk_assert( (NLSF_QUANT_DEL_DEC_STATES & (NLSF_QUANT_DEL_DEC_STATES-1)) ==
0 ); /* must be power of two */ |
83 | 83 |
84 nStates = 1; | 84 nStates = 1; |
85 RD_Q25[ 0 ] = 0; | 85 RD_Q25[ 0 ] = 0; |
86 prev_out_Q10[ 0 ] = 0; | 86 prev_out_Q10[ 0 ] = 0; |
87 for( i = order - 1; ; i-- ) { | 87 for( i = order - 1; i >= 0; i-- ) { |
88 rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ]; | 88 rates_Q5 = &ec_rates_Q5[ ec_ix[ i ] ]; |
89 in_Q10 = x_Q10[ i ]; | 89 in_Q10 = x_Q10[ i ]; |
90 for( j = 0; j < nStates; j++ ) { | 90 for( j = 0; j < nStates; j++ ) { |
91 pred_Q10 = silk_RSHIFT( silk_SMULBB( (opus_int16)pred_coef_Q8[ i ],
prev_out_Q10[ j ] ), 8 ); | 91 pred_Q10 = silk_RSHIFT( silk_SMULBB( (opus_int16)pred_coef_Q8[ i ],
prev_out_Q10[ j ] ), 8 ); |
92 res_Q10 = silk_SUB16( in_Q10, pred_Q10 ); | 92 res_Q10 = silk_SUB16( in_Q10, pred_Q10 ); |
93 ind_tmp = silk_RSHIFT( silk_SMULBB( inv_quant_step_size_Q6, res_Q10
), 16 ); | 93 ind_tmp = silk_RSHIFT( silk_SMULBB( inv_quant_step_size_Q6, res_Q10
), 16 ); |
94 ind_tmp = silk_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_
QUANT_MAX_AMPLITUDE_EXT-1 ); | 94 ind_tmp = silk_LIMIT( ind_tmp, -NLSF_QUANT_MAX_AMPLITUDE_EXT, NLSF_
QUANT_MAX_AMPLITUDE_EXT-1 ); |
95 ind[ j ][ i ] = (opus_int8)ind_tmp; | 95 ind[ j ][ i ] = (opus_int8)ind_tmp; |
96 | 96 |
97 /* compute outputs for ind_tmp and ind_tmp + 1 */ | 97 /* compute outputs for ind_tmp and ind_tmp + 1 */ |
(...skipping 26 matching lines...) Expand all Loading... |
124 rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ]; | 124 rate0_Q5 = rates_Q5[ ind_tmp + NLSF_QUANT_MAX_AMPLITUDE ]; |
125 rate1_Q5 = rates_Q5[ ind_tmp + 1 + NLSF_QUANT_MAX_AMPLITUDE ]; | 125 rate1_Q5 = rates_Q5[ ind_tmp + 1 + NLSF_QUANT_MAX_AMPLITUDE ]; |
126 } | 126 } |
127 RD_tmp_Q25 = RD_Q25[ j ]; | 127 RD_tmp_Q25 = RD_Q25[ j ]; |
128 diff_Q10 = silk_SUB16( in_Q10, out0_Q10 ); | 128 diff_Q10 = silk_SUB16( in_Q10, out0_Q10 ); |
129 RD_Q25[ j ] = silk_SMLABB( silk_MLA( RD_tmp_Q25, silk_SMUL
BB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate0_Q5 ); | 129 RD_Q25[ j ] = silk_SMLABB( silk_MLA( RD_tmp_Q25, silk_SMUL
BB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate0_Q5 ); |
130 diff_Q10 = silk_SUB16( in_Q10, out1_Q10 ); | 130 diff_Q10 = silk_SUB16( in_Q10, out1_Q10 ); |
131 RD_Q25[ j + nStates ] = silk_SMLABB( silk_MLA( RD_tmp_Q25, silk_SMUL
BB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate1_Q5 ); | 131 RD_Q25[ j + nStates ] = silk_SMLABB( silk_MLA( RD_tmp_Q25, silk_SMUL
BB( diff_Q10, diff_Q10 ), w_Q5[ i ] ), mu_Q20, rate1_Q5 ); |
132 } | 132 } |
133 | 133 |
134 if( nStates <= ( NLSF_QUANT_DEL_DEC_STATES >> 1 ) ) { | 134 if( nStates <= NLSF_QUANT_DEL_DEC_STATES/2 ) { |
135 /* double number of states and copy */ | 135 /* double number of states and copy */ |
136 for( j = 0; j < nStates; j++ ) { | 136 for( j = 0; j < nStates; j++ ) { |
137 ind[ j + nStates ][ i ] = ind[ j ][ i ] + 1; | 137 ind[ j + nStates ][ i ] = ind[ j ][ i ] + 1; |
138 } | 138 } |
139 nStates = silk_LSHIFT( nStates, 1 ); | 139 nStates = silk_LSHIFT( nStates, 1 ); |
140 for( j = nStates; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { | 140 for( j = nStates; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { |
141 ind[ j ][ i ] = ind[ j - nStates ][ i ]; | 141 ind[ j ][ i ] = ind[ j - nStates ][ i ]; |
142 } | 142 } |
143 } else if( i > 0 ) { | 143 } else { |
144 /* sort lower and upper half of RD_Q25, pairwise */ | 144 /* sort lower and upper half of RD_Q25, pairwise */ |
145 for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { | 145 for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { |
146 if( RD_Q25[ j ] > RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] ) { | 146 if( RD_Q25[ j ] > RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] ) { |
147 RD_max_Q25[ j ] = RD_Q25[ j ]; | 147 RD_max_Q25[ j ] = RD_Q25[ j ]; |
148 RD_min_Q25[ j ] = RD_Q25[ j + NLSF_Q
UANT_DEL_DEC_STATES ]; | 148 RD_min_Q25[ j ] = RD_Q25[ j + NLSF_Q
UANT_DEL_DEC_STATES ]; |
149 RD_Q25[ j ] = RD_min_Q25[ j ]; | 149 RD_Q25[ j ] = RD_min_Q25[ j ]; |
150 RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] = RD_max_Q25[ j ]; | 150 RD_Q25[ j + NLSF_QUANT_DEL_DEC_STATES ] = RD_max_Q25[ j ]; |
151 /* swap prev_out values */ | 151 /* swap prev_out values */ |
152 out0_Q10 = prev_out_Q10[ j ]; | 152 out0_Q10 = prev_out_Q10[ j ]; |
153 prev_out_Q10[ j ] = prev_out_Q10[ j + NLSF_QUANT_DEL_DEC_STA
TES ]; | 153 prev_out_Q10[ j ] = prev_out_Q10[ j + NLSF_QUANT_DEL_DEC_STA
TES ]; |
(...skipping 30 matching lines...) Expand all Loading... |
184 RD_Q25[ ind_max_min ] = RD_Q25[ ind_min_max + NLSF_Q
UANT_DEL_DEC_STATES ]; | 184 RD_Q25[ ind_max_min ] = RD_Q25[ ind_min_max + NLSF_Q
UANT_DEL_DEC_STATES ]; |
185 prev_out_Q10[ ind_max_min ] = prev_out_Q10[ ind_min_max + NLSF_Q
UANT_DEL_DEC_STATES ]; | 185 prev_out_Q10[ ind_max_min ] = prev_out_Q10[ ind_min_max + NLSF_Q
UANT_DEL_DEC_STATES ]; |
186 RD_min_Q25[ ind_max_min ] = 0; | 186 RD_min_Q25[ ind_max_min ] = 0; |
187 RD_max_Q25[ ind_min_max ] = silk_int32_MAX; | 187 RD_max_Q25[ ind_min_max ] = silk_int32_MAX; |
188 silk_memcpy( ind[ ind_max_min ], ind[ ind_min_max ], MAX_LPC_ORD
ER * sizeof( opus_int8 ) ); | 188 silk_memcpy( ind[ ind_max_min ], ind[ ind_min_max ], MAX_LPC_ORD
ER * sizeof( opus_int8 ) ); |
189 } | 189 } |
190 /* increment index if it comes from the upper half */ | 190 /* increment index if it comes from the upper half */ |
191 for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { | 191 for( j = 0; j < NLSF_QUANT_DEL_DEC_STATES; j++ ) { |
192 ind[ j ][ i ] += silk_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_
STATES_LOG2 ); | 192 ind[ j ][ i ] += silk_RSHIFT( ind_sort[ j ], NLSF_QUANT_DEL_DEC_
STATES_LOG2 ); |
193 } | 193 } |
194 } else { /* i == 0 */ | |
195 break; | |
196 } | 194 } |
197 } | 195 } |
198 | 196 |
199 /* last sample: find winner, copy indices and return RD value */ | 197 /* last sample: find winner, copy indices and return RD value */ |
200 ind_tmp = 0; | 198 ind_tmp = 0; |
201 min_Q25 = silk_int32_MAX; | 199 min_Q25 = silk_int32_MAX; |
202 for( j = 0; j < 2 * NLSF_QUANT_DEL_DEC_STATES; j++ ) { | 200 for( j = 0; j < 2 * NLSF_QUANT_DEL_DEC_STATES; j++ ) { |
203 if( min_Q25 > RD_Q25[ j ] ) { | 201 if( min_Q25 > RD_Q25[ j ] ) { |
204 min_Q25 = RD_Q25[ j ]; | 202 min_Q25 = RD_Q25[ j ]; |
205 ind_tmp = j; | 203 ind_tmp = j; |
206 } | 204 } |
207 } | 205 } |
208 for( j = 0; j < order; j++ ) { | 206 for( j = 0; j < order; j++ ) { |
209 indices[ j ] = ind[ ind_tmp & ( NLSF_QUANT_DEL_DEC_STATES - 1 ) ][ j ]; | 207 indices[ j ] = ind[ ind_tmp & ( NLSF_QUANT_DEL_DEC_STATES - 1 ) ][ j ]; |
210 silk_assert( indices[ j ] >= -NLSF_QUANT_MAX_AMPLITUDE_EXT ); | 208 silk_assert( indices[ j ] >= -NLSF_QUANT_MAX_AMPLITUDE_EXT ); |
211 silk_assert( indices[ j ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); | 209 silk_assert( indices[ j ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); |
212 } | 210 } |
213 indices[ 0 ] += silk_RSHIFT( ind_tmp, NLSF_QUANT_DEL_DEC_STATES_LOG2 ); | 211 indices[ 0 ] += silk_RSHIFT( ind_tmp, NLSF_QUANT_DEL_DEC_STATES_LOG2 ); |
214 silk_assert( indices[ 0 ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); | 212 silk_assert( indices[ 0 ] <= NLSF_QUANT_MAX_AMPLITUDE_EXT ); |
215 silk_assert( min_Q25 >= 0 ); | 213 silk_assert( min_Q25 >= 0 ); |
216 return min_Q25; | 214 return min_Q25; |
217 } | 215 } |
OLD | NEW |