1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
22 ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
23 Available from http://www.3gpp.org
25 (C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
30 ------------------------------------------------------------------------------
34 Filename: band_pass_6k_7k.cpp
36 ------------------------------------------------------------------------------
37 INPUT AND OUTPUT DEFINITIONS
39 int16 signal[], input signal / output is divided by 16
40 int16 lg, lenght of signal
41 int16 mem[] in/out: memory (size=30)
42 int16 x[] scratch mem ( size= 60)
44 ------------------------------------------------------------------------------
47 15th order band pass 6kHz to 7kHz FIR filter.
49 frequency: 4kHz 5kHz 5.5kHz 6kHz 6.5kHz 7kHz 7.5kHz 8kHz
50 dB loss: -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB
53 ------------------------------------------------------------------------------
57 ------------------------------------------------------------------------------
60 ------------------------------------------------------------------------------
63 ------------------------------------------------------------------------------
67 /*----------------------------------------------------------------------------
69 ----------------------------------------------------------------------------*/
72 #include "pv_amr_wb_type_defs.h"
73 #include "pvamrwbdecoder_basic_op.h"
74 #include "pvamrwbdecoder_acelp.h"
75 #include "pvamrwbdecoder_cnst.h"
77 /*----------------------------------------------------------------------------
79 ; Define module specific macros here
80 ----------------------------------------------------------------------------*/
83 /*----------------------------------------------------------------------------
85 ; Include all pre-processor statements here. Include conditional
86 ; compile variables also.
87 ----------------------------------------------------------------------------*/
91 /*----------------------------------------------------------------------------
92 ; LOCAL FUNCTION DEFINITIONS
93 ; Function Prototype declaration
94 ----------------------------------------------------------------------------*/
96 /*----------------------------------------------------------------------------
97 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
98 ; Variable declaration - defined here and used outside this module
99 ----------------------------------------------------------------------------*/
101 /* filter coefficients (gain=4.0) */
103 const int16 fir_6k_7k[L_FIR] =
106 -369, 1122, -1421, 0,
107 3798, -8880, 12349, -10984,
110 -18001, 7766, 3548, -10984,
111 12349, -8880, 3798, 0,
112 -1421, 1122, -369, -27,
116 /*----------------------------------------------------------------------------
117 ; EXTERNAL FUNCTION REFERENCES
118 ; Declare functions defined elsewhere and referenced in this module
119 ----------------------------------------------------------------------------*/
121 /*----------------------------------------------------------------------------
122 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
123 ; Declare variables used in this module but defined elsewhere
124 ----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------
128 ----------------------------------------------------------------------------*/
130 void band_pass_6k_7k_init(int16 mem[]) /* mem[30] */
132 pv_memset((void *)mem, 0, L_FIR*sizeof(*mem));
136 /*----------------------------------------------------------------------------
138 ----------------------------------------------------------------------------*/
141 void band_pass_6k_7k(
142 int16 signal[], /* input: signal */
143 int16 lg, /* input: length of input */
144 int16 mem[], /* in/out: memory (size=30) */
154 int16 *pt_sign = signal;
156 pv_memcpy((void *)x, (void *)mem, L_FIR*sizeof(*x));
159 for (i = 0; i < lg >> 2; i++)
162 x[(i<<2) + L_FIR ] = *(pt_sign) >> 2; /* gain of filter = 4 */
163 x[(i<<2) + L_FIR + 1] = *(pt_sign + 1) >> 2; /* gain of filter = 4 */
164 x[(i<<2) + L_FIR + 2] = *(pt_sign + 2) >> 2; /* gain of filter = 4 */
165 x[(i<<2) + L_FIR + 3] = *(pt_sign + 3) >> 2; /* gain of filter = 4 */
172 L_tmp1 -= ((int32)x[(i<<2)+L_FIR ] << 5);
173 L_tmp2 -= ((int32)x[(i<<2)+L_FIR+1] << 5);
174 L_tmp3 -= ((int32)x[(i<<2)+L_FIR+2] << 5);
175 L_tmp4 -= ((int32)x[(i<<2)+L_FIR+3] << 5);
177 L_tmp1 -= ((int32)x[(i<<2)] << 5);
178 L_tmp2 -= ((int32)x[(i<<2)+1] << 5);
179 L_tmp3 -= ((int32)x[(i<<2)+2] << 5);
180 L_tmp4 -= ((int32)x[(i<<2)+3] << 5);
183 for (j = 1; j < L_FIR - 1; j += 4)
185 int16 tmp1 = x[(i<<2)+j ];
186 int16 tmp2 = x[(i<<2)+j+1];
187 int16 tmp3 = x[(i<<2)+j+2];
189 L_tmp1 = fxp_mac_16by16(tmp1, fir_6k_7k[j ], L_tmp1);
190 L_tmp2 = fxp_mac_16by16(tmp2, fir_6k_7k[j ], L_tmp2);
191 L_tmp1 = fxp_mac_16by16(tmp2, fir_6k_7k[j+1], L_tmp1);
192 L_tmp2 = fxp_mac_16by16(tmp3, fir_6k_7k[j+1], L_tmp2);
193 L_tmp3 = fxp_mac_16by16(tmp3, fir_6k_7k[j ], L_tmp3);
194 L_tmp1 = fxp_mac_16by16(tmp3, fir_6k_7k[j+2], L_tmp1);
196 tmp1 = x[(i<<2)+j+3];
197 tmp2 = x[(i<<2)+j+4];
199 L_tmp2 = fxp_mac_16by16(tmp1, fir_6k_7k[j+2], L_tmp2);
200 L_tmp4 = fxp_mac_16by16(tmp1, fir_6k_7k[j ], L_tmp4);
201 L_tmp3 = fxp_mac_16by16(tmp1, fir_6k_7k[j+1], L_tmp3);
202 L_tmp1 = fxp_mac_16by16(tmp1, fir_6k_7k[j+3], L_tmp1);
203 L_tmp2 = fxp_mac_16by16(tmp2, fir_6k_7k[j+3], L_tmp2);
204 L_tmp4 = fxp_mac_16by16(tmp2, fir_6k_7k[j+1], L_tmp4);
205 L_tmp3 = fxp_mac_16by16(tmp2, fir_6k_7k[j+2], L_tmp3);
207 tmp1 = x[(i<<2)+j+5];
208 tmp2 = x[(i<<2)+j+6];
210 L_tmp4 = fxp_mac_16by16(tmp1, fir_6k_7k[j+2], L_tmp4);
211 L_tmp3 = fxp_mac_16by16(tmp1, fir_6k_7k[j+3], L_tmp3);
212 L_tmp4 = fxp_mac_16by16(tmp2, fir_6k_7k[j+3], L_tmp4);
216 L_tmp1 = fxp_mac_16by16(x[(i<<2)+j ], fir_6k_7k[L_FIR-1 ], L_tmp1);
217 L_tmp2 = fxp_mac_16by16(x[(i<<2)+j+1], fir_6k_7k[L_FIR-1 ], L_tmp2);
218 L_tmp3 = fxp_mac_16by16(x[(i<<2)+j+2], fir_6k_7k[L_FIR-1 ], L_tmp3);
219 L_tmp4 = fxp_mac_16by16(x[(i<<2)+j+3], fir_6k_7k[L_FIR-1 ], L_tmp4);
222 *(pt_sign++) = (int16)(L_tmp1 >> 15);
223 *(pt_sign++) = (int16)(L_tmp2 >> 15);
224 *(pt_sign++) = (int16)(L_tmp3 >> 15);
225 *(pt_sign++) = (int16)(L_tmp4 >> 15);
229 pv_memcpy((void *)mem, (void *)(x + lg), L_FIR*sizeof(*mem));