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. |
11 - Neither the name of Internet Society, IETF or IETF Trust, nor the | 11 - Neither the name of Internet Society, IETF or IETF Trust, nor the |
12 names of specific contributors, may be used to endorse or promote | 12 names of specific contributors, may be used to endorse or promote |
13 products derived from this software without specific prior written | 13 products derived from this software without specific prior written |
14 permission. | 14 permission. |
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” | 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 POSSIBILITY OF SUCH DAMAGE. | 25 POSSIBILITY OF SUCH DAMAGE. |
26 ***********************************************************************/ | 26 ***********************************************************************/ |
27 | 27 |
28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
29 #include "config.h" | 29 #include "config.h" |
30 #endif | 30 #endif |
31 | 31 |
32 #include "main_FIX.h" | 32 #include "main_FIX.h" |
| 33 #include "stack_alloc.h" |
33 #include "tuning_parameters.h" | 34 #include "tuning_parameters.h" |
34 | 35 |
35 /* Prefilter for finding Quantizer input signal */ | 36 /* Prefilter for finding Quantizer input signal */ |
36 static inline void silk_prefilt_FIX( | 37 static inline void silk_prefilt_FIX( |
37 silk_prefilter_state_FIX *P, /* I/O state
*/ | 38 silk_prefilter_state_FIX *P, /* I/O state
*/ |
38 opus_int32 st_res_Q12[], /* I short term r
esidual signal */ | 39 opus_int32 st_res_Q12[], /* I short term r
esidual signal */ |
39 opus_int32 xw_Q3[], /* O prefiltered
signal */ | 40 opus_int32 xw_Q3[], /* O prefiltered
signal */ |
40 opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic sha
ping coeficients */ | 41 opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic sha
ping coeficients */ |
41 opus_int Tilt_Q14, /* I Tilt shaping
coeficient */ | 42 opus_int Tilt_Q14, /* I Tilt shaping
coeficient */ |
42 opus_int32 LF_shp_Q14, /* I Low-frequanc
y shaping coeficients */ | 43 opus_int32 LF_shp_Q14, /* I Low-frequanc
y shaping coeficients */ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ) | 95 ) |
95 { | 96 { |
96 silk_prefilter_state_FIX *P = &psEnc->sPrefilt; | 97 silk_prefilter_state_FIX *P = &psEnc->sPrefilt; |
97 opus_int j, k, lag; | 98 opus_int j, k, lag; |
98 opus_int32 tmp_32; | 99 opus_int32 tmp_32; |
99 const opus_int16 *AR1_shp_Q13; | 100 const opus_int16 *AR1_shp_Q13; |
100 const opus_int16 *px; | 101 const opus_int16 *px; |
101 opus_int32 *pxw_Q3; | 102 opus_int32 *pxw_Q3; |
102 opus_int HarmShapeGain_Q12, Tilt_Q14; | 103 opus_int HarmShapeGain_Q12, Tilt_Q14; |
103 opus_int32 HarmShapeFIRPacked_Q12, LF_shp_Q14; | 104 opus_int32 HarmShapeFIRPacked_Q12, LF_shp_Q14; |
104 opus_int32 x_filt_Q12[ MAX_SUB_FRAME_LENGTH ]; | 105 VARDECL( opus_int32, x_filt_Q12 ); |
105 opus_int32 st_res_Q2[ MAX_SUB_FRAME_LENGTH + MAX_LPC_ORDER ]; | 106 VARDECL( opus_int32, st_res_Q2 ); |
106 opus_int16 B_Q10[ 2 ]; | 107 opus_int16 B_Q10[ 2 ]; |
| 108 SAVE_STACK; |
107 | 109 |
108 /* Set up pointers */ | 110 /* Set up pointers */ |
109 px = x; | 111 px = x; |
110 pxw_Q3 = xw_Q3; | 112 pxw_Q3 = xw_Q3; |
111 lag = P->lagPrev; | 113 lag = P->lagPrev; |
| 114 ALLOC( x_filt_Q12, psEnc->sCmn.subfr_length, opus_int32 ); |
| 115 ALLOC( st_res_Q2, psEnc->sCmn.subfr_length, opus_int32 ); |
112 for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { | 116 for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { |
113 /* Update Variables that change per sub frame */ | 117 /* Update Variables that change per sub frame */ |
114 if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { | 118 if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { |
115 lag = psEncCtrl->pitchL[ k ]; | 119 lag = psEncCtrl->pitchL[ k ]; |
116 } | 120 } |
117 | 121 |
118 /* Noise shape parameters */ | 122 /* Noise shape parameters */ |
119 HarmShapeGain_Q12 = silk_SMULWB( (opus_int32)psEncCtrl->HarmShapeGain_Q1
4[ k ], 16384 - psEncCtrl->HarmBoost_Q14[ k ] ); | 123 HarmShapeGain_Q12 = silk_SMULWB( (opus_int32)psEncCtrl->HarmShapeGain_Q1
4[ k ], 16384 - psEncCtrl->HarmBoost_Q14[ k ] ); |
120 silk_assert( HarmShapeGain_Q12 >= 0 ); | 124 silk_assert( HarmShapeGain_Q12 >= 0 ); |
121 HarmShapeFIRPacked_Q12 = silk_RSHIFT( HarmShap
eGain_Q12, 2 ); | 125 HarmShapeFIRPacked_Q12 = silk_RSHIFT( HarmShap
eGain_Q12, 2 ); |
(...skipping 19 matching lines...) Expand all Loading... |
141 } | 145 } |
142 P->sHarmHP_Q2 = st_res_Q2[ psEnc->sCmn.subfr_length - 1 ]; | 146 P->sHarmHP_Q2 = st_res_Q2[ psEnc->sCmn.subfr_length - 1 ]; |
143 | 147 |
144 silk_prefilt_FIX( P, x_filt_Q12, pxw_Q3, HarmShapeFIRPacked_Q12, Tilt_Q1
4, LF_shp_Q14, lag, psEnc->sCmn.subfr_length ); | 148 silk_prefilt_FIX( P, x_filt_Q12, pxw_Q3, HarmShapeFIRPacked_Q12, Tilt_Q1
4, LF_shp_Q14, lag, psEnc->sCmn.subfr_length ); |
145 | 149 |
146 px += psEnc->sCmn.subfr_length; | 150 px += psEnc->sCmn.subfr_length; |
147 pxw_Q3 += psEnc->sCmn.subfr_length; | 151 pxw_Q3 += psEnc->sCmn.subfr_length; |
148 } | 152 } |
149 | 153 |
150 P->lagPrev = psEncCtrl->pitchL[ psEnc->sCmn.nb_subfr - 1 ]; | 154 P->lagPrev = psEncCtrl->pitchL[ psEnc->sCmn.nb_subfr - 1 ]; |
| 155 RESTORE_STACK; |
151 } | 156 } |
152 | 157 |
153 /* Prefilter for finding Quantizer input signal */ | 158 /* Prefilter for finding Quantizer input signal */ |
154 static inline void silk_prefilt_FIX( | 159 static inline void silk_prefilt_FIX( |
155 silk_prefilter_state_FIX *P, /* I/O state
*/ | 160 silk_prefilter_state_FIX *P, /* I/O state
*/ |
156 opus_int32 st_res_Q12[], /* I short term r
esidual signal */ | 161 opus_int32 st_res_Q12[], /* I short term r
esidual signal */ |
157 opus_int32 xw_Q3[], /* O prefiltered
signal */ | 162 opus_int32 xw_Q3[], /* O prefiltered
signal */ |
158 opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic sha
ping coeficients */ | 163 opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic sha
ping coeficients */ |
159 opus_int Tilt_Q14, /* I Tilt shaping
coeficient */ | 164 opus_int Tilt_Q14, /* I Tilt shaping
coeficient */ |
160 opus_int32 LF_shp_Q14, /* I Low-frequanc
y shaping coeficients */ | 165 opus_int32 LF_shp_Q14, /* I Low-frequanc
y shaping coeficients */ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROU
ND( sLF_MA_shp_Q12, 12 ) ); | 200 LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROU
ND( sLF_MA_shp_Q12, 12 ) ); |
196 | 201 |
197 xw_Q3[i] = silk_RSHIFT_ROUND( silk_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 9
); | 202 xw_Q3[i] = silk_RSHIFT_ROUND( silk_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 9
); |
198 } | 203 } |
199 | 204 |
200 /* Copy temp variable back to state */ | 205 /* Copy temp variable back to state */ |
201 P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12; | 206 P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12; |
202 P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12; | 207 P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12; |
203 P->sLTP_shp_buf_idx = LTP_shp_buf_idx; | 208 P->sLTP_shp_buf_idx = LTP_shp_buf_idx; |
204 } | 209 } |
OLD | NEW |