webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
prefilter_FIX_mipsr1.h
Go to the documentation of this file.
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 #ifndef __PREFILTER_FIX_MIPSR1_H__
28 #define __PREFILTER_FIX_MIPSR1_H__
29 
30 #ifdef HAVE_CONFIG_H
31 #include "config.h"
32 #endif
33 
34 #include "main_FIX.h"
35 #include "stack_alloc.h"
36 #include "tuning_parameters.h"
37 
38 #define OVERRIDE_silk_warped_LPC_analysis_filter_FIX
40  opus_int32 state[], /* I/O State [order + 1] */
41  opus_int32 res_Q2[], /* O Residual signal [length] */
42  const opus_int16 coef_Q13[], /* I Coefficients [order] */
43  const opus_int16 input[], /* I Input signal [length] */
44  const opus_int16 lambda_Q16, /* I Warping factor */
45  const opus_int length, /* I Length of input signal */
46  const opus_int order, /* I Filter order (even) */
47  int arch
48 )
49 {
50  opus_int n, i;
51  opus_int32 acc_Q11, acc_Q22, tmp1, tmp2, tmp3, tmp4;
52  opus_int32 state_cur, state_next;
53 
54  (void)arch;
55 
56  /* Order must be even */
57  /* Length must be even */
58 
59  silk_assert( ( order & 1 ) == 0 );
60  silk_assert( ( length & 1 ) == 0 );
61 
62  for( n = 0; n < length; n+=2 ) {
63  /* Output of lowpass section */
64  tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 );
65  state_cur = silk_LSHIFT( input[ n ], 14 );
66  /* Output of allpass section */
67  tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 );
68  state_next = tmp2;
69  acc_Q11 = silk_RSHIFT( order, 1 );
70  acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] );
71 
72 
73  /* Output of lowpass section */
74  tmp4 = silk_SMLAWB( state_cur, state_next, lambda_Q16 );
75  state[ 0 ] = silk_LSHIFT( input[ n+1 ], 14 );
76  /* Output of allpass section */
77  tmp3 = silk_SMLAWB( state_next, tmp1 - tmp4, lambda_Q16 );
78  state[ 1 ] = tmp4;
79  acc_Q22 = silk_RSHIFT( order, 1 );
80  acc_Q22 = silk_SMLAWB( acc_Q22, tmp4, coef_Q13[ 0 ] );
81 
82  /* Loop over allpass sections */
83  for( i = 2; i < order; i += 2 ) {
84  /* Output of allpass section */
85  tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 );
86  state_cur = tmp1;
87  acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] );
88  /* Output of allpass section */
89  tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 );
90  state_next = tmp2;
91  acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] );
92 
93 
94  /* Output of allpass section */
95  tmp4 = silk_SMLAWB( state_cur, state_next - tmp3, lambda_Q16 );
96  state[ i ] = tmp3;
97  acc_Q22 = silk_SMLAWB( acc_Q22, tmp3, coef_Q13[ i - 1 ] );
98  /* Output of allpass section */
99  tmp3 = silk_SMLAWB( state_next, tmp1 - tmp4, lambda_Q16 );
100  state[ i + 1 ] = tmp4;
101  acc_Q22 = silk_SMLAWB( acc_Q22, tmp4, coef_Q13[ i ] );
102  }
103  acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] );
104  res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( acc_Q11, 9 );
105 
106  state[ order ] = tmp3;
107  acc_Q22 = silk_SMLAWB( acc_Q22, tmp3, coef_Q13[ order - 1 ] );
108  res_Q2[ n+1 ] = silk_LSHIFT( (opus_int32)input[ n+1 ], 2 ) - silk_RSHIFT_ROUND( acc_Q22, 9 );
109  }
110 }
111 
112 
113 
114 /* Prefilter for finding Quantizer input signal */
115 #define OVERRIDE_silk_prefilt_FIX
116 static inline void silk_prefilt_FIX(
117  silk_prefilter_state_FIX *P, /* I/O state */
118  opus_int32 st_res_Q12[], /* I short term residual signal */
119  opus_int32 xw_Q3[], /* O prefiltered signal */
120  opus_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */
121  opus_int Tilt_Q14, /* I Tilt shaping coeficient */
122  opus_int32 LF_shp_Q14, /* I Low-frequancy shaping coeficients */
123  opus_int lag, /* I Lag for harmonic shaping */
124  opus_int length /* I Length of signals */
125 )
126 {
127  opus_int i, idx, LTP_shp_buf_idx;
128  opus_int32 n_LTP_Q12, n_Tilt_Q10, n_LF_Q10;
129  opus_int32 sLF_MA_shp_Q12, sLF_AR_shp_Q12;
130  opus_int16 *LTP_shp_buf;
131 
132  /* To speed up use temp variables instead of using the struct */
133  LTP_shp_buf = P->sLTP_shp;
134  LTP_shp_buf_idx = P->sLTP_shp_buf_idx;
135  sLF_AR_shp_Q12 = P->sLF_AR_shp_Q12;
136  sLF_MA_shp_Q12 = P->sLF_MA_shp_Q12;
137 
138  if( lag > 0 ) {
139  for( i = 0; i < length; i++ ) {
140  /* unrolled loop */
142  idx = lag + LTP_shp_buf_idx;
143  n_LTP_Q12 = silk_SMULBB( LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 - 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 );
144  n_LTP_Q12 = silk_SMLABT( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 ) & LTP_MASK ], HarmShapeFIRPacked_Q12 );
145  n_LTP_Q12 = silk_SMLABB( n_LTP_Q12, LTP_shp_buf[ ( idx - HARM_SHAPE_FIR_TAPS / 2 + 1) & LTP_MASK ], HarmShapeFIRPacked_Q12 );
146 
147  n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 );
148  n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 );
149 
150  sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) );
151  sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) );
152 
153  LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK;
154  LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) );
155 
156  xw_Q3[i] = silk_RSHIFT_ROUND( silk_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 9 );
157  }
158  }
159  else
160  {
161  for( i = 0; i < length; i++ ) {
162 
163  n_LTP_Q12 = 0;
164 
165  n_Tilt_Q10 = silk_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 );
166  n_LF_Q10 = silk_SMLAWB( silk_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 );
167 
168  sLF_AR_shp_Q12 = silk_SUB32( st_res_Q12[ i ], silk_LSHIFT( n_Tilt_Q10, 2 ) );
169  sLF_MA_shp_Q12 = silk_SUB32( sLF_AR_shp_Q12, silk_LSHIFT( n_LF_Q10, 2 ) );
170 
171  LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK;
172  LTP_shp_buf[ LTP_shp_buf_idx ] = (opus_int16)silk_SAT16( silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) );
173 
174  xw_Q3[i] = silk_RSHIFT_ROUND( sLF_MA_shp_Q12, 9 );
175  }
176  }
177 
178  /* Copy temp variable back to state */
179  P->sLF_AR_shp_Q12 = sLF_AR_shp_Q12;
180  P->sLF_MA_shp_Q12 = sLF_MA_shp_Q12;
181  P->sLTP_shp_buf_idx = LTP_shp_buf_idx;
182 }
183 
184 #endif /* __PREFILTER_FIX_MIPSR1_H__ */
Definition: structs_FIX.h:53
void silk_warped_LPC_analysis_filter_FIX(opus_int32 state[], opus_int32 res_Q2[], const opus_int16 coef_Q13[], const opus_int16 input[], const opus_int16 lambda_Q16, const opus_int length, const opus_int order, int arch)
Definition: prefilter_FIX_mipsr1.h:39
#define silk_SMULWT(a, b)
Definition: macros_armv4.h:65
#define silk_SMLABB(a, b, c)
Definition: macros_armv5e.h:123
short opus_int16
Definition: opus_types.h:144
#define opus_int
Definition: opus_types.h:151
#define P
Definition: dtoa.cpp:99
opus_int sLTP_shp_buf_idx
Definition: structs_FIX.h:56
#define silk_SMLAWB(a, b, c)
Definition: macros_armv4.h:49
opus_int32 sLF_AR_shp_Q12
Definition: structs_FIX.h:57
#define silk_RSHIFT_ROUND(a, shift)
Definition: SigProc_FIX.h:507
#define silk_SMULWB(a, b)
Definition: macros_armv4.h:45
opus_int32 sLF_MA_shp_Q12
Definition: structs_FIX.h:58
#define silk_LSHIFT(a, shift)
Definition: SigProc_FIX.h:481
void
Definition: AVFoundationCFSoftLinking.h:81
EGLStreamKHR EGLint n
Definition: eglext.h:984
#define LTP_MASK
Definition: define.h:158
int opus_int32
Definition: opus_types.h:146
#define silk_RSHIFT(a, shift)
Definition: SigProc_FIX.h:487
opus_int16 sLTP_shp[LTP_BUF_LENGTH]
Definition: structs_FIX.h:54
#define HARM_SHAPE_FIR_TAPS
Definition: define.h:152
string arch
Definition: runtests.py:65
#define silk_assert(COND)
Definition: typedef.h:74
#define silk_SMULBB(a, b)
Definition: macros_armv5e.h:107
#define silk_SAT16(a)
Definition: SigProc_FIX.h:449
Temporary memory allocation on stack.
for i
Definition: complexityMeasures.m:24
#define silk_SUB32(a, b)
Definition: SigProc_FIX.h:444
#define silk_SMLABT(a, b, c)
Definition: macros_armv5e.h:154
string input
Definition: tokenizer_unittest.cc:198
string state
Definition: buildtests.py:34
GLuint GLsizei GLsizei * length
Definition: gl2.h:435