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: low_pass_filt_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 high pass 7kHz FIR filter
50 ------------------------------------------------------------------------------
54 ------------------------------------------------------------------------------
57 ------------------------------------------------------------------------------
60 ------------------------------------------------------------------------------
64 /*----------------------------------------------------------------------------
66 ----------------------------------------------------------------------------*/
68 #include "pv_amr_wb_type_defs.h"
69 #include "pvamrwbdecoder_basic_op.h"
70 #include "pvamrwbdecoder_cnst.h"
71 #include "pvamrwbdecoder_acelp.h"
73 /*----------------------------------------------------------------------------
75 ; Define module specific macros here
76 ----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------
81 ; Include all pre-processor statements here. Include conditional
82 ; compile variables also.
83 ----------------------------------------------------------------------------*/
86 /*----------------------------------------------------------------------------
87 ; LOCAL FUNCTION DEFINITIONS
88 ; Function Prototype declaration
89 ----------------------------------------------------------------------------*/
91 /*----------------------------------------------------------------------------
92 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
93 ; Variable declaration - defined here and used outside this module
94 ----------------------------------------------------------------------------*/
95 const int16 fir_7k[L_FIR+1] =
97 -21, 47, -89, 146, -203,
98 229, -177, 0, 335, -839,
99 1485, -2211, 2931, -3542, 3953,
100 28682, 3953, -3542, 2931, -2211,
101 1485, -839, 335, 0, -177,
102 229, -203, 146, -89, 47,
106 /*----------------------------------------------------------------------------
107 ; EXTERNAL FUNCTION REFERENCES
108 ; Declare functions defined elsewhere and referenced in this module
109 ----------------------------------------------------------------------------*/
111 /*----------------------------------------------------------------------------
112 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
113 ; Declare variables used in this module but defined elsewhere
114 ----------------------------------------------------------------------------*/
116 /*----------------------------------------------------------------------------
118 ----------------------------------------------------------------------------*/
121 void low_pass_filt_7k_init(int16 mem[]) /* mem[30] */
123 pv_memset((void *)mem, 0, (L_FIR)*sizeof(*mem));
129 /*----------------------------------------------------------------------------
131 ----------------------------------------------------------------------------*/
134 void low_pass_filt_7k(
135 int16 signal[], /* input: signal */
136 int16 lg, /* input: length of input */
137 int16 mem[], /* in/out: memory (size=30) */
147 pv_memcpy((void *)x, (void *)mem, (L_FIR)*sizeof(*x));
149 for (i = 0; i < lg >> 2; i++)
151 x[(i<<2) + L_FIR ] = signal[(i<<2)];
152 x[(i<<2) + L_FIR + 1] = signal[(i<<2)+1];
153 x[(i<<2) + L_FIR + 2] = signal[(i<<2)+2];
154 x[(i<<2) + L_FIR + 3] = signal[(i<<2)+3];
156 L_tmp1 = fxp_mac_16by16(x[(i<<2)] + signal[(i<<2)], fir_7k[0], 0x00004000);
157 L_tmp2 = fxp_mac_16by16(x[(i<<2)+1] + signal[(i<<2)+1], fir_7k[0], 0x00004000);
158 L_tmp3 = fxp_mac_16by16(x[(i<<2)+2] + signal[(i<<2)+2], fir_7k[0], 0x00004000);
159 L_tmp4 = fxp_mac_16by16(x[(i<<2)+3] + signal[(i<<2)+3], fir_7k[0], 0x00004000);
161 for (j = 1; j < L_FIR - 1; j += 4)
165 int16 tmp1 = x[(i<<2)+j ];
166 int16 tmp2 = x[(i<<2)+j+1];
167 int16 tmp3 = x[(i<<2)+j+2];
169 L_tmp1 = fxp_mac_16by16(tmp1, fir_7k[j ], L_tmp1);
170 L_tmp2 = fxp_mac_16by16(tmp2, fir_7k[j ], L_tmp2);
171 L_tmp1 = fxp_mac_16by16(tmp2, fir_7k[j+1], L_tmp1);
172 L_tmp2 = fxp_mac_16by16(tmp3, fir_7k[j+1], L_tmp2);
173 L_tmp3 = fxp_mac_16by16(tmp3, fir_7k[j ], L_tmp3);
174 L_tmp1 = fxp_mac_16by16(tmp3, fir_7k[j+2], L_tmp1);
176 tmp1 = x[(i<<2)+j+3];
177 tmp2 = x[(i<<2)+j+4];
179 L_tmp2 = fxp_mac_16by16(tmp1, fir_7k[j+2], L_tmp2);
180 L_tmp4 = fxp_mac_16by16(tmp1, fir_7k[j ], L_tmp4);
181 L_tmp3 = fxp_mac_16by16(tmp1, fir_7k[j+1], L_tmp3);
182 L_tmp1 = fxp_mac_16by16(tmp1, fir_7k[j+3], L_tmp1);
183 L_tmp2 = fxp_mac_16by16(tmp2, fir_7k[j+3], L_tmp2);
184 L_tmp4 = fxp_mac_16by16(tmp2, fir_7k[j+1], L_tmp4);
185 L_tmp3 = fxp_mac_16by16(tmp2, fir_7k[j+2], L_tmp3);
187 tmp1 = x[(i<<2)+j+5];
188 tmp2 = x[(i<<2)+j+6];
190 L_tmp4 = fxp_mac_16by16(tmp1, fir_7k[j+2], L_tmp4);
191 L_tmp3 = fxp_mac_16by16(tmp1, fir_7k[j+3], L_tmp3);
192 L_tmp4 = fxp_mac_16by16(tmp2, fir_7k[j+3], L_tmp4);
196 L_tmp1 = fxp_mac_16by16(x[(i<<2)+j ], fir_7k[j ], L_tmp1);
197 L_tmp2 = fxp_mac_16by16(x[(i<<2)+j+1], fir_7k[j ], L_tmp2);
198 L_tmp3 = fxp_mac_16by16(x[(i<<2)+j+2], fir_7k[j ], L_tmp3);
199 L_tmp4 = fxp_mac_16by16(x[(i<<2)+j+3], fir_7k[j ], L_tmp4);
201 signal[(i<<2)] = (int16)(L_tmp1 >> 15);
202 signal[(i<<2)+1] = (int16)(L_tmp2 >> 15);
203 signal[(i<<2)+2] = (int16)(L_tmp3 >> 15);
204 signal[(i<<2)+3] = (int16)(L_tmp4 >> 15);
208 pv_memcpy((void *)mem, (void *)(x + lg), (L_FIR)*sizeof(*mem));