1 /* 2 ** Copyright 2003-2010, VisualOn, Inc. 3 ** 4 ** Licensed under the Apache License, Version 2.0 (the "License"); 5 ** you may not use this file except in compliance with the License. 6 ** You may obtain a copy of the License at 7 ** 8 ** http://www.apache.org/licenses/LICENSE-2.0 9 ** 10 ** Unless required by applicable law or agreed to in writing, software 11 ** distributed under the License is distributed on an "AS IS" BASIS, 12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 ** See the License for the specific language governing permissions and 14 ** limitations under the License. 15 */ 16 17 /*********************************************************************** 18 * File: hp6k.c * 19 * * 20 * Description:15th order band pass 6kHz to 7kHz FIR filter * 21 * frequency: 4kHz 5kHz 5.5kHz 6kHz 6.5kHz 7kHz 7.5kHz 8kHz * 22 * dB loss: -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB * 23 * * 24 ************************************************************************/ 25 26 #include "typedef.h" 27 #include "basic_op.h" 28 #include "acelp.h" 29 #include "cnst.h" 30 31 #define L_FIR 31 32 33 /* filter coefficients (gain=4.0) */ 34 35 Word16 fir_6k_7k[L_FIR] = 36 { 37 -32, 47, 32, -27, -369, 38 1122, -1421, 0, 3798, -8880, 39 12349, -10984, 3548, 7766, -18001, 40 22118, -18001, 7766, 3548, -10984, 41 12349, -8880, 3798, 0, -1421, 42 1122, -369, -27, 32, 47, 43 -32 44 }; 45 46 47 void Init_Filt_6k_7k(Word16 mem[]) /* mem[30] */ 48 { 49 Set_zero(mem, L_FIR - 1); 50 return; 51 } 52 53 void Filt_6k_7k( 54 Word16 signal[], /* input: signal */ 55 Word16 lg, /* input: length of input */ 56 Word16 mem[] /* in/out: memory (size=30) */ 57 ) 58 { 59 Word16 x[L_SUBFR16k + (L_FIR - 1)]; 60 Word32 i, L_tmp; 61 62 Copy(mem, x, L_FIR - 1); 63 for (i = lg - 1; i >= 0; i--) 64 { 65 x[i + L_FIR - 1] = signal[i] >> 2; /* gain of filter = 4 */ 66 } 67 for (i = 0; i < lg; i++) 68 { 69 L_tmp = (x[i] + x[i+ 30]) * fir_6k_7k[0]; 70 L_tmp += (x[i+1] + x[i + 29]) * fir_6k_7k[1]; 71 L_tmp += (x[i+2] + x[i + 28]) * fir_6k_7k[2]; 72 L_tmp += (x[i+3] + x[i + 27]) * fir_6k_7k[3]; 73 L_tmp += (x[i+4] + x[i + 26]) * fir_6k_7k[4]; 74 L_tmp += (x[i+5] + x[i + 25]) * fir_6k_7k[5]; 75 L_tmp += (x[i+6] + x[i + 24]) * fir_6k_7k[6]; 76 L_tmp += (x[i+7] + x[i + 23]) * fir_6k_7k[7]; 77 L_tmp += (x[i+8] + x[i + 22]) * fir_6k_7k[8]; 78 L_tmp += (x[i+9] + x[i + 21]) * fir_6k_7k[9]; 79 L_tmp += (x[i+10] + x[i + 20]) * fir_6k_7k[10]; 80 L_tmp += (x[i+11] + x[i + 19]) * fir_6k_7k[11]; 81 L_tmp += (x[i+12] + x[i + 18]) * fir_6k_7k[12]; 82 L_tmp += (x[i+13] + x[i + 17]) * fir_6k_7k[13]; 83 L_tmp += (x[i+14] + x[i + 16]) * fir_6k_7k[14]; 84 L_tmp += (x[i+15]) * fir_6k_7k[15]; 85 signal[i] = (L_tmp + 0x4000) >> 15; 86 } 87 88 Copy(x + lg, mem, L_FIR - 1); 89 90 } 91 92 93 94