Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: opus/silk/fixed/prefilter_FIX.c

Issue 11196031: Add copy of opus library in deps/third_party. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « opus/silk/fixed/pitch_analysis_core_FIX.c ('k') | opus/silk/fixed/process_gains_FIX.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /***********************************************************************
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6 - Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright
9 notice, this list of conditions and the following disclaimer in the
10 documentation and/or other materials provided with the distribution.
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
13 products derived from this software without specific prior written
14 permission.
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
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
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
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
25 POSSIBILITY OF SUCH DAMAGE.
26 ***********************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #include "main_FIX.h"
33 #include "tuning_parameters.h"
34
35 /* Prefilter for finding Quantizer input signal */
36 static inline void silk_prefilt_FIX(
37 silk_prefilter_state_FIX *P, /* I/O state */
38 opus_int32 st_res_Q12[], /* I short term r esidual signal */
39 opus_int32 xw_Q3[], /* O prefiltered signal */
40 opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic sha ping coeficients */
41 opus_int Tilt_Q14, /* I Tilt shaping coeficient */
42 opus_int32 LF_shp_Q14, /* I Low-frequanc y shaping coeficients */
43 opus_int lag, /* I Lag for harm onic shaping */
44 opus_int length /* I Length of si gnals */
45 );
46
47 void silk_warped_LPC_analysis_filter_FIX(
48 opus_int32 state[], /* I/O State [order + 1] */
49 opus_int32 res_Q2[], /* O Residual sig nal [length] */
50 const opus_int16 coef_Q13[], /* I Coefficients [order] */
51 const opus_int16 input[], /* I Input signal [length] */
52 const opus_int16 lambda_Q16, /* I Warping fact or */
53 const opus_int length, /* I Length of in put signal */
54 const opus_int order /* I Filter order (even) */
55 )
56 {
57 opus_int n, i;
58 opus_int32 acc_Q11, tmp1, tmp2;
59
60 /* Order must be even */
61 silk_assert( ( order & 1 ) == 0 );
62
63 for( n = 0; n < length; n++ ) {
64 /* Output of lowpass section */
65 tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 );
66 state[ 0 ] = silk_LSHIFT( input[ n ], 14 );
67 /* Output of allpass section */
68 tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 );
69 state[ 1 ] = tmp2;
70 acc_Q11 = silk_RSHIFT( order, 1 );
71 acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] );
72 /* Loop over allpass sections */
73 for( i = 2; i < order; i += 2 ) {
74 /* Output of allpass section */
75 tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 );
76 state[ i ] = tmp1;
77 acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] );
78 /* Output of allpass section */
79 tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q1 6 );
80 state[ i + 1 ] = tmp2;
81 acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] );
82 }
83 state[ order ] = tmp1;
84 acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] );
85 res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROU ND( acc_Q11, 9 );
86 }
87 }
88
89 void silk_prefilter_FIX(
90 silk_encoder_state_FIX *psEnc, /* I /O Encoder state */
91 const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
92 opus_int32 xw_Q3[], /* O Weighted signal */
93 const opus_int16 x[] /* I Speech signal */
94 )
95 {
96 silk_prefilter_state_FIX *P = &psEnc->sPrefilt;
97 opus_int j, k, lag;
98 opus_int32 tmp_32;
99 const opus_int16 *AR1_shp_Q13;
100 const opus_int16 *px;
101 opus_int32 *pxw_Q3;
102 opus_int HarmShapeGain_Q12, Tilt_Q14;
103 opus_int32 HarmShapeFIRPacked_Q12, LF_shp_Q14;
104 opus_int32 x_filt_Q12[ MAX_SUB_FRAME_LENGTH ];
105 opus_int32 st_res_Q2[ MAX_SUB_FRAME_LENGTH + MAX_LPC_ORDER ];
106 opus_int16 B_Q10[ 2 ];
107
108 /* Set up pointers */
109 px = x;
110 pxw_Q3 = xw_Q3;
111 lag = P->lagPrev;
112 for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
113 /* Update Variables that change per sub frame */
114 if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
115 lag = psEncCtrl->pitchL[ k ];
116 }
117
118 /* Noise shape parameters */
119 HarmShapeGain_Q12 = silk_SMULWB( (opus_int32)psEncCtrl->HarmShapeGain_Q1 4[ k ], 16384 - psEncCtrl->HarmBoost_Q14[ k ] );
120 silk_assert( HarmShapeGain_Q12 >= 0 );
121 HarmShapeFIRPacked_Q12 = silk_RSHIFT( HarmShap eGain_Q12, 2 );
122 HarmShapeFIRPacked_Q12 |= silk_LSHIFT( (opus_int32)silk_RSHIFT( HarmShap eGain_Q12, 1 ), 16 );
123 Tilt_Q14 = psEncCtrl->Tilt_Q14[ k ];
124 LF_shp_Q14 = psEncCtrl->LF_shp_Q14[ k ];
125 AR1_shp_Q13 = &psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER ];
126
127 /* Short term FIR filtering*/
128 silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res_Q2, AR1_shp_Q13, px,
129 psEnc->sCmn.warping_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.shapi ngLPCOrder );
130
131 /* Reduce (mainly) low frequencies during harmonic emphasis */
132 B_Q10[ 0 ] = silk_RSHIFT_ROUND( psEncCtrl->GainsPre_Q14[ k ], 4 );
133 tmp_32 = silk_SMLABB( SILK_FIX_CONST( INPUT_TILT, 26 ), psEncCtrl->HarmB oost_Q14[ k ], HarmShapeGain_Q12 ); /* Q26 */
134 tmp_32 = silk_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, SILK_FIX_CO NST( HIGH_RATE_INPUT_TILT, 12 ) ); /* Q26 */
135 tmp_32 = silk_SMULWB( tmp_32, -psEncCtrl->GainsPre_Q14[ k ] ); /* Q24 */
136 tmp_32 = silk_RSHIFT_ROUND( tmp_32, 14 ); /* Q10 */
137 B_Q10[ 1 ]= silk_SAT16( tmp_32 );
138 x_filt_Q12[ 0 ] = silk_MLA( silk_MUL( st_res_Q2[ 0 ], B_Q10[ 0 ] ), P->s HarmHP_Q2, B_Q10[ 1 ] );
139 for( j = 1; j < psEnc->sCmn.subfr_length; j++ ) {
140 x_filt_Q12[ j ] = silk_MLA( silk_MUL( st_res_Q2[ j ], B_Q10[ 0 ] ), st_res_Q2[ j - 1 ], B_Q10[ 1 ] );
141 }
142 P->sHarmHP_Q2 = st_res_Q2[ psEnc->sCmn.subfr_length - 1 ];
143
144 silk_prefilt_FIX( P, x_filt_Q12, pxw_Q3, HarmShapeFIRPacked_Q12, Tilt_Q1 4, LF_shp_Q14, lag, psEnc->sCmn.subfr_length );
145
146 px += psEnc->sCmn.subfr_length;
147 pxw_Q3 += psEnc->sCmn.subfr_length;
148 }
149
150 P->lagPrev = psEncCtrl->pitchL[ psEnc->sCmn.nb_subfr - 1 ];
151 }
152
153 /* Prefilter for finding Quantizer input signal */
154 static inline void silk_prefilt_FIX(
155 silk_prefilter_state_FIX *P, /* I/O state */
156 opus_int32 st_res_Q12[], /* I short term r esidual signal */
157 opus_int32 xw_Q3[], /* O prefiltered signal */
158 opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic sha ping coeficients */
159 opus_int Tilt_Q14, /* I Tilt shaping coeficient */
160 opus_int32 LF_shp_Q14, /* I Low-frequanc y shaping coeficients */
161 opus_int lag, /* I Lag for harm onic shaping */
162 opus_int length /* I Length of si gnals */
163 )
164 {
165 opus_int i, idx, LTP_shp_buf_idx;
166 opus_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10;
167 opus_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12;
168 opus_int16 *LTP_shp_buf;
169
170 /* To speed up use temp variables instead of using the struct */
171 LTP_shp_buf = P->sLTP_shp;
172 LTP_shp_buf_idx = P->sLTP_shp_buf_idx;
173 sLF_AR_shp_Q12 = P->sLF_AR_shp_Q12;
174 sLF_MA_shp_Q12 = P->sLF_MA_shp_Q12;
175
176 for( i = 0; i < length; i++ ) {
177 if( lag > 0 ) {
178 /* unrolled loop */
179 silk_assert( HARM_SHAPE_FIR_TAPS == 3 );
180 idx = lag + LTP_shp_buf_idx;
181 n_LTP_Q12 = silk_SMULBB( LTP_shp_buf[ ( idx - HARM_SHAPE_ FIR_TAPS / 2 - 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 );
182 n_LTP_Q12 = silk_SMLABT( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_ FIR_TAPS / 2 ) & LTP_MASK ], HarmShapeFIRPacked_Q12 );
183 n_LTP_Q12 = silk_SMLABB( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_ FIR_TAPS / 2 + 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 );
184 } else {
185 n_LTP_Q12 = 0;
186 }
187
188 n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 );
189 n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF _MA_shp_Q12, LF_shp_Q14 );
190
191 sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) );
192 sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) );
193
194 LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK;
195 LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROU ND( sLF_MA_shp_Q12, 12 ) );
196
197 xw_Q3[i] = silk_RSHIFT_ROUND( silk_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 9 );
198 }
199
200 /* Copy temp variable back to state */
201 P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12;
202 P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12;
203 P->sLTP_shp_buf_idx = LTP_shp_buf_idx;
204 }
OLDNEW
« no previous file with comments | « opus/silk/fixed/pitch_analysis_core_FIX.c ('k') | opus/silk/fixed/process_gains_FIX.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698