1 /*
2 * Copyright (C) 2004-2010 NXP Software
3 * Copyright (C) 2010 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 #include "BIQUAD.h"
18 #include "DC_2I_D16_TRC_WRA_01_Private.h"
19 #include "LVM_Macros.h"
20 #include "ScalarArithmetic.h"
21 /*
22 * FUNCTION: DC_Mc_D16_TRC_WRA_01
23 *
24 * DESCRIPTION:
25 * DC removal from all channels of a multichannel input
26 *
27 * PARAMETERS:
28 * pInstance Instance pointer
29 * pDataIn Input/Source
30 * pDataOut Output/Destination
31 * NrFrames Number of frames
32 * NrChannels Number of channels
33 *
34 * RETURNS:
35 * void
36 *
37 */
DC_Mc_D16_TRC_WRA_01(Biquad_FLOAT_Instance_t * pInstance,LVM_FLOAT * pDataIn,LVM_FLOAT * pDataOut,LVM_INT16 NrFrames,LVM_INT16 NrChannels)38 void DC_Mc_D16_TRC_WRA_01(Biquad_FLOAT_Instance_t* pInstance, LVM_FLOAT* pDataIn,
39 LVM_FLOAT* pDataOut, LVM_INT16 NrFrames, LVM_INT16 NrChannels) {
40 LVM_FLOAT* ChDC;
41 LVM_FLOAT Diff;
42 LVM_INT32 j;
43 LVM_INT32 i;
44 PFilter_FLOAT_State_Mc pBiquadState = (PFilter_FLOAT_State_Mc)pInstance;
45
46 ChDC = &pBiquadState->ChDC[0];
47 for (j = NrFrames - 1; j >= 0; j--) {
48 /* Subtract DC and saturate */
49 for (i = NrChannels - 1; i >= 0; i--) {
50 Diff = *(pDataIn++) - (ChDC[i]);
51 *(pDataOut++) = LVM_Clamp(Diff);
52 if (Diff < 0) {
53 ChDC[i] -= DC_FLOAT_STEP;
54 } else {
55 ChDC[i] += DC_FLOAT_STEP;
56 }
57 }
58 }
59 }
60