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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 #ifdef HAVE_CONFIG_H | 34 #ifdef HAVE_CONFIG_H |
35 #include "config.h" | 35 #include "config.h" |
36 #endif | 36 #endif |
37 | 37 |
38 #include "SigProc_FIX.h" | 38 #include "SigProc_FIX.h" |
39 #include "tables.h" | 39 #include "tables.h" |
40 | 40 |
41 /* Number of binary divisions, when not in low complexity mode */ | 41 /* Number of binary divisions, when not in low complexity mode */ |
42 #define BIN_DIV_STEPS_A2NLSF_FIX 3 /* must be no higher than 16 - log2( LSF
_COS_TAB_SZ_FIX ) */ | 42 #define BIN_DIV_STEPS_A2NLSF_FIX 3 /* must be no higher than 16 - log2( LSF
_COS_TAB_SZ_FIX ) */ |
43 #define MAX_ITERATIONS_A2NLSF_FIX 30 | 43 #define MAX_ITERATIONS_A2NLSF_FIX 16 |
44 | 44 |
45 /* Helper function for A2NLSF(..) */ | 45 /* Helper function for A2NLSF(..) */ |
46 /* Transforms polynomials from cos(n*f) to cos(f)^n */ | 46 /* Transforms polynomials from cos(n*f) to cos(f)^n */ |
47 static OPUS_INLINE void silk_A2NLSF_trans_poly( | 47 static OPUS_INLINE void silk_A2NLSF_trans_poly( |
48 opus_int32 *p, /* I/O Polynomial
*/ | 48 opus_int32 *p, /* I/O Polynomial
*/ |
49 const opus_int dd /* I Polynomial order (= fi
lter order / 2 ) */ | 49 const opus_int dd /* I Polynomial order (= fi
lter order / 2 ) */ |
50 ) | 50 ) |
51 { | 51 { |
52 opus_int k, n; | 52 opus_int k, n; |
53 | 53 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 /* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter co
efficients */ | 125 /* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter co
efficients */ |
126 /* If not all roots are found, the a_Q16 coefficients are bandwidth expanded unt
il convergence. */ | 126 /* If not all roots are found, the a_Q16 coefficients are bandwidth expanded unt
il convergence. */ |
127 void silk_A2NLSF( | 127 void silk_A2NLSF( |
128 opus_int16 *NLSF, /* O Normalized Line Spec
tral Frequencies in Q15 (0..2^15-1) [d] */ | 128 opus_int16 *NLSF, /* O Normalized Line Spec
tral Frequencies in Q15 (0..2^15-1) [d] */ |
129 opus_int32 *a_Q16, /* I/O Monic whitening filt
er coefficients in Q16 [d] */ | 129 opus_int32 *a_Q16, /* I/O Monic whitening filt
er coefficients in Q16 [d] */ |
130 const opus_int d /* I Filter order (must b
e even) */ | 130 const opus_int d /* I Filter order (must b
e even) */ |
131 ) | 131 ) |
132 { | 132 { |
133 opus_int i, k, m, dd, root_ix, ffrac; | 133 opus_int i, k, m, dd, root_ix, ffrac; |
134 opus_int32 xlo, xhi, xmid; | 134 opus_int32 xlo, xhi, xmid; |
135 opus_int32 ylo, yhi, ymid, thr; | 135 opus_int32 ylo, yhi, ymid, thr; |
136 opus_int32 nom, den; | 136 opus_int32 nom, den; |
137 opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ]; | 137 opus_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ]; |
138 opus_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ]; | 138 opus_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ]; |
139 opus_int32 *PQ[ 2 ]; | 139 opus_int32 *PQ[ 2 ]; |
140 opus_int32 *p; | 140 opus_int32 *p; |
141 | 141 |
142 /* Store pointers to array */ | 142 /* Store pointers to array */ |
143 PQ[ 0 ] = P; | 143 PQ[ 0 ] = P; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 xlo = xhi; | 232 xlo = xhi; |
233 ylo = yhi; | 233 ylo = yhi; |
234 thr = 0; | 234 thr = 0; |
235 | 235 |
236 if( k > LSF_COS_TAB_SZ_FIX ) { | 236 if( k > LSF_COS_TAB_SZ_FIX ) { |
237 i++; | 237 i++; |
238 if( i > MAX_ITERATIONS_A2NLSF_FIX ) { | 238 if( i > MAX_ITERATIONS_A2NLSF_FIX ) { |
239 /* Set NLSFs to white spectrum and exit */ | 239 /* Set NLSFs to white spectrum and exit */ |
240 NLSF[ 0 ] = (opus_int16)silk_DIV32_16( 1 << 15, d + 1 ); | 240 NLSF[ 0 ] = (opus_int16)silk_DIV32_16( 1 << 15, d + 1 ); |
241 for( k = 1; k < d; k++ ) { | 241 for( k = 1; k < d; k++ ) { |
242 NLSF[ k ] = (opus_int16)silk_SMULBB( k + 1, NLSF[ 0 ] ); | 242 NLSF[ k ] = (opus_int16)silk_ADD16( NLSF[ k-1 ], NLSF[ 0
] ); |
243 } | 243 } |
244 return; | 244 return; |
245 } | 245 } |
246 | 246 |
247 /* Error: Apply progressively more bandwidth expansion and run a
gain */ | 247 /* Error: Apply progressively more bandwidth expansion and run a
gain */ |
248 silk_bwexpander_32( a_Q16, d, 65536 - silk_SMULBB( 10 + i, i ) )
; /* 10_Q16 = 0.00015*/ | 248 silk_bwexpander_32( a_Q16, d, 65536 - silk_LSHIFT( 1, i ) ); |
249 | 249 |
250 silk_A2NLSF_init( a_Q16, P, Q, dd ); | 250 silk_A2NLSF_init( a_Q16, P, Q, dd ); |
251 p = P; /* Pointer to polynomial */ | 251 p = P; /* Pointer to polynomial */ |
252 xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/ | 252 xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; /* Q12*/ |
253 ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); | 253 ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); |
254 if( ylo < 0 ) { | 254 if( ylo < 0 ) { |
255 /* Set the first NLSF to zero and move on to the next */ | 255 /* Set the first NLSF to zero and move on to the next */ |
256 NLSF[ 0 ] = 0; | 256 NLSF[ 0 ] = 0; |
257 p = Q; /* Pointer to polynomial */ | 257 p = Q; /* Pointer to polynomial */ |
258 ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); | 258 ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); |
259 root_ix = 1; /* Index of current root */ | 259 root_ix = 1; /* Index of current root */ |
260 } else { | 260 } else { |
261 root_ix = 0; /* Index of current root */ | 261 root_ix = 0; /* Index of current root */ |
262 } | 262 } |
263 k = 1; /* Reset loop counter */ | 263 k = 1; /* Reset loop counter */ |
264 } | 264 } |
265 } | 265 } |
266 } | 266 } |
267 } | 267 } |
OLD | NEW |