1 /***********************************************************************
\r
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
\r
3 Redistribution and use in source and binary forms, with or without
\r
4 modification, (subject to the limitations in the disclaimer below)
\r
5 are permitted provided that the following conditions are met:
\r
6 - Redistributions of source code must retain the above copyright notice,
\r
7 this list of conditions and the following disclaimer.
\r
8 - Redistributions in binary form must reproduce the above copyright
\r
9 notice, this list of conditions and the following disclaimer in the
\r
10 documentation and/or other materials provided with the distribution.
\r
11 - Neither the name of Skype Limited, nor the names of specific
\r
12 contributors, may be used to endorse or promote products derived from
\r
13 this software without specific prior written permission.
\r
14 NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
\r
15 BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
\r
16 CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
\r
17 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
\r
18 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
\r
19 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
\r
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
22 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
\r
23 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
26 ***********************************************************************/
\r
29 #include "SKP_Silk_main_FLP.h"
\r
31 /*******************************************/
\r
32 /* LPC analysis filter */
\r
33 /* NB! State is kept internally and the */
\r
34 /* filter always starts with zero state */
\r
35 /* first Order output samples are not set */
\r
36 /*******************************************/
\r
38 /* 16th order LPC analysis filter, does not write first 16 samples */
\r
39 void SKP_Silk_LPC_analysis_filter16_FLP(
\r
40 SKP_float r_LPC[], /* O LPC residual signal */
\r
41 const SKP_float PredCoef[], /* I LPC coefficients */
\r
42 const SKP_float s[], /* I Input signal */
\r
43 const SKP_int length /* I Length of input signal */
\r
48 const SKP_float *s_ptr;
\r
50 for ( ix = 16; ix < length; ix++) {
\r
53 /* short-term prediction */
\r
54 LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] +
\r
55 s_ptr[ -1 ] * PredCoef[ 1 ] +
\r
56 s_ptr[ -2 ] * PredCoef[ 2 ] +
\r
57 s_ptr[ -3 ] * PredCoef[ 3 ] +
\r
58 s_ptr[ -4 ] * PredCoef[ 4 ] +
\r
59 s_ptr[ -5 ] * PredCoef[ 5 ] +
\r
60 s_ptr[ -6 ] * PredCoef[ 6 ] +
\r
61 s_ptr[ -7 ] * PredCoef[ 7 ] +
\r
62 s_ptr[ -8 ] * PredCoef[ 8 ] +
\r
63 s_ptr[ -9 ] * PredCoef[ 9 ] +
\r
64 s_ptr[ -10 ] * PredCoef[ 10 ] +
\r
65 s_ptr[ -11 ] * PredCoef[ 11 ] +
\r
66 s_ptr[ -12 ] * PredCoef[ 12 ] +
\r
67 s_ptr[ -13 ] * PredCoef[ 13 ] +
\r
68 s_ptr[ -14 ] * PredCoef[ 14 ] +
\r
69 s_ptr[ -15 ] * PredCoef[ 15 ];
\r
71 /* prediction error */
\r
72 r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;
\r
76 /* 14th order LPC analysis filter, does not write first 14 samples */
\r
77 void SKP_Silk_LPC_analysis_filter14_FLP(
\r
78 SKP_float r_LPC[], /* O LPC residual signal */
\r
79 const SKP_float PredCoef[], /* I LPC coefficients */
\r
80 const SKP_float s[], /* I Input signal */
\r
81 const SKP_int length /* I Length of input signal */
\r
86 const SKP_float *s_ptr;
\r
88 for ( ix = 14; ix < length; ix++) {
\r
91 /* short-term prediction */
\r
92 LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] +
\r
93 s_ptr[ -1 ] * PredCoef[ 1 ] +
\r
94 s_ptr[ -2 ] * PredCoef[ 2 ] +
\r
95 s_ptr[ -3 ] * PredCoef[ 3 ] +
\r
96 s_ptr[ -4 ] * PredCoef[ 4 ] +
\r
97 s_ptr[ -5 ] * PredCoef[ 5 ] +
\r
98 s_ptr[ -6 ] * PredCoef[ 6 ] +
\r
99 s_ptr[ -7 ] * PredCoef[ 7 ] +
\r
100 s_ptr[ -8 ] * PredCoef[ 8 ] +
\r
101 s_ptr[ -9 ] * PredCoef[ 9 ] +
\r
102 s_ptr[ -10 ] * PredCoef[ 10 ] +
\r
103 s_ptr[ -11 ] * PredCoef[ 11 ] +
\r
104 s_ptr[ -12 ] * PredCoef[ 12 ] +
\r
105 s_ptr[ -13 ] * PredCoef[ 13 ];
\r
107 /* prediction error */
\r
108 r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;
\r
112 /* 12th order LPC analysis filter, does not write first 12 samples */
\r
113 void SKP_Silk_LPC_analysis_filter12_FLP(
\r
114 SKP_float r_LPC[], /* O LPC residual signal */
\r
115 const SKP_float PredCoef[], /* I LPC coefficients */
\r
116 const SKP_float s[], /* I Input signal */
\r
117 const SKP_int length /* I Length of input signal */
\r
121 SKP_float LPC_pred;
\r
122 const SKP_float *s_ptr;
\r
124 for ( ix = 12; ix < length; ix++) {
\r
125 s_ptr = &s[ix - 1];
\r
127 /* short-term prediction */
\r
128 LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] +
\r
129 s_ptr[ -1 ] * PredCoef[ 1 ] +
\r
130 s_ptr[ -2 ] * PredCoef[ 2 ] +
\r
131 s_ptr[ -3 ] * PredCoef[ 3 ] +
\r
132 s_ptr[ -4 ] * PredCoef[ 4 ] +
\r
133 s_ptr[ -5 ] * PredCoef[ 5 ] +
\r
134 s_ptr[ -6 ] * PredCoef[ 6 ] +
\r
135 s_ptr[ -7 ] * PredCoef[ 7 ] +
\r
136 s_ptr[ -8 ] * PredCoef[ 8 ] +
\r
137 s_ptr[ -9 ] * PredCoef[ 9 ] +
\r
138 s_ptr[ -10 ] * PredCoef[ 10 ] +
\r
139 s_ptr[ -11 ] * PredCoef[ 11 ];
\r
141 /* prediction error */
\r
142 r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;
\r
146 /* 10th order LPC analysis filter, does not write first 10 samples */
\r
147 void SKP_Silk_LPC_analysis_filter10_FLP(
\r
148 SKP_float r_LPC[], /* O LPC residual signal */
\r
149 const SKP_float PredCoef[], /* I LPC coefficients */
\r
150 const SKP_float s[], /* I Input signal */
\r
151 const SKP_int length /* I Length of input signal */
\r
155 SKP_float LPC_pred;
\r
156 const SKP_float *s_ptr;
\r
158 for ( ix = 10; ix < length; ix++) {
\r
159 s_ptr = &s[ix - 1];
\r
161 /* short-term prediction */
\r
162 LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] +
\r
163 s_ptr[ -1 ] * PredCoef[ 1 ] +
\r
164 s_ptr[ -2 ] * PredCoef[ 2 ] +
\r
165 s_ptr[ -3 ] * PredCoef[ 3 ] +
\r
166 s_ptr[ -4 ] * PredCoef[ 4 ] +
\r
167 s_ptr[ -5 ] * PredCoef[ 5 ] +
\r
168 s_ptr[ -6 ] * PredCoef[ 6 ] +
\r
169 s_ptr[ -7 ] * PredCoef[ 7 ] +
\r
170 s_ptr[ -8 ] * PredCoef[ 8 ] +
\r
171 s_ptr[ -9 ] * PredCoef[ 9 ];
\r
173 /* prediction error */
\r
174 r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;
\r
178 /* 8th order LPC analysis filter, does not write first 8 samples */
\r
179 void SKP_Silk_LPC_analysis_filter8_FLP(
\r
180 SKP_float r_LPC[], /* O LPC residual signal */
\r
181 const SKP_float PredCoef[], /* I LPC coefficients */
\r
182 const SKP_float s[], /* I Input signal */
\r
183 const SKP_int length /* I Length of input signal */
\r
187 SKP_float LPC_pred;
\r
188 const SKP_float *s_ptr;
\r
190 for ( ix = 8; ix < length; ix++) {
\r
191 s_ptr = &s[ix - 1];
\r
193 /* short-term prediction */
\r
194 LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] +
\r
195 s_ptr[ -1 ] * PredCoef[ 1 ] +
\r
196 s_ptr[ -2 ] * PredCoef[ 2 ] +
\r
197 s_ptr[ -3 ] * PredCoef[ 3 ] +
\r
198 s_ptr[ -4 ] * PredCoef[ 4 ] +
\r
199 s_ptr[ -5 ] * PredCoef[ 5 ] +
\r
200 s_ptr[ -6 ] * PredCoef[ 6 ] +
\r
201 s_ptr[ -7 ] * PredCoef[ 7 ];
\r
203 /* prediction error */
\r
204 r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;
\r
208 /* 6th order LPC analysis filter, does not write first 6 samples */
\r
209 void SKP_Silk_LPC_analysis_filter6_FLP(
\r
210 SKP_float r_LPC[], /* O LPC residual signal */
\r
211 const SKP_float PredCoef[], /* I LPC coefficients */
\r
212 const SKP_float s[], /* I Input signal */
\r
213 const SKP_int length /* I Length of input signal */
\r
217 SKP_float LPC_pred;
\r
218 const SKP_float *s_ptr;
\r
220 for ( ix = 6; ix < length; ix++) {
\r
221 s_ptr = &s[ix - 1];
\r
223 /* short-term prediction */
\r
224 LPC_pred = s_ptr[ 0 ] * PredCoef[ 0 ] +
\r
225 s_ptr[ -1 ] * PredCoef[ 1 ] +
\r
226 s_ptr[ -2 ] * PredCoef[ 2 ] +
\r
227 s_ptr[ -3 ] * PredCoef[ 3 ] +
\r
228 s_ptr[ -4 ] * PredCoef[ 4 ] +
\r
229 s_ptr[ -5 ] * PredCoef[ 5 ];
\r
231 /* prediction error */
\r
232 r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;
\r
236 void SKP_Silk_LPC_analysis_filter_FLP(
\r
237 SKP_float r_LPC[], /* O LPC residual signal */
\r
238 const SKP_float PredCoef[], /* I LPC coefficients */
\r
239 const SKP_float s[], /* I Input signal */
\r
240 const SKP_int length, /* I Length of input signal */
\r
241 const SKP_int Order /* I LPC order */
\r
244 SKP_assert( Order <= length );
\r
248 SKP_Silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length );
\r
252 SKP_Silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length );
\r
256 SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length );
\r
260 SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length );
\r
264 SKP_Silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length );
\r
268 SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length );
\r
276 /* Set first LPC Order samples to zero instead of undefined */
\r
277 SKP_memset( r_LPC, 0, Order * sizeof( SKP_float ) );
\r