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 18 #include "BIQUAD.h" 19 #include "DC_2I_D16_TRC_WRA_01_Private.h" 20 #include "LVM_Macros.h" 21 22 void DC_2I_D16_TRC_WRA_01( Biquad_Instance_t *pInstance, 23 LVM_INT16 *pDataIn, 24 LVM_INT16 *pDataOut, 25 LVM_INT16 NrSamples) 26 { 27 LVM_INT32 LeftDC,RightDC; 28 LVM_INT32 Diff; 29 LVM_INT32 j; 30 PFilter_State pBiquadState = (PFilter_State) pInstance; 31 32 LeftDC = pBiquadState->LeftDC; 33 RightDC = pBiquadState->RightDC; 34 for(j=NrSamples-1;j>=0;j--) 35 { 36 /* Subtract DC an saturate */ 37 Diff=*(pDataIn++)-(LeftDC>>16); 38 if (Diff > 32767) { 39 Diff = 32767; } 40 else if (Diff < -32768) { 41 Diff = -32768; } 42 *(pDataOut++)=(LVM_INT16)Diff; 43 if (Diff < 0) { 44 LeftDC -= DC_D16_STEP; } 45 else { 46 LeftDC += DC_D16_STEP; } 47 48 49 /* Subtract DC an saturate */ 50 Diff=*(pDataIn++)-(RightDC>>16); 51 if (Diff > 32767) { 52 Diff = 32767; } 53 else if (Diff < -32768) { 54 Diff = -32768; } 55 *(pDataOut++)=(LVM_INT16)Diff; 56 if (Diff < 0) { 57 RightDC -= DC_D16_STEP; } 58 else { 59 RightDC += DC_D16_STEP; } 60 61 } 62 pBiquadState->LeftDC = LeftDC; 63 pBiquadState->RightDC = RightDC; 64 65 66 } 67 68