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 /********************************************************************************** 19 INCLUDE FILES 20 ***********************************************************************************/ 21 22 #include "Mixer_private.h" 23 #include "LVM_Macros.h" 24 25 /********************************************************************************** 26 FUNCTION CORE_MIXSOFT_1ST_D32C31_WRA 27 ***********************************************************************************/ 28 29 void Core_MixSoft_1St_D32C31_WRA( Mix_1St_Cll_t *pInstance, 30 const LVM_INT32 *src, 31 LVM_INT32 *dst, 32 LVM_INT16 n) 33 { 34 LVM_INT32 Temp1,Temp2; 35 LVM_INT16 OutLoop; 36 LVM_INT16 InLoop; 37 LVM_INT32 TargetTimesOneMinAlpha; 38 LVM_INT32 CurrentTimesAlpha; 39 LVM_INT16 CurrentShort; 40 LVM_INT16 ii; 41 42 InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */ 43 OutLoop = (LVM_INT16)(n - (InLoop << 2)); 44 45 MUL32x32INTO32((0x7FFFFFFF-pInstance->Alpha),pInstance->Target,TargetTimesOneMinAlpha,31) /* Q31 * Q31 in Q31 */ 46 if (pInstance->Target >= pInstance->Current) 47 { 48 TargetTimesOneMinAlpha +=2; /* Ceil*/ 49 } 50 51 if (OutLoop!=0) 52 { 53 MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */ 54 pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/ 55 CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ 56 57 for (ii = OutLoop; ii != 0; ii--) 58 { 59 Temp1=*src; 60 src++; 61 62 MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) 63 *dst = Temp2; 64 dst++; 65 } 66 } 67 68 for (ii = InLoop; ii != 0; ii--) 69 { 70 MUL32x32INTO32(pInstance->Current,pInstance->Alpha,CurrentTimesAlpha,31) /* Q31 * Q31 in Q31 */ 71 pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha; /* Q31 + Q31 into Q31*/ 72 CurrentShort = (LVM_INT16)(pInstance->Current>>16); /* From Q31 to Q15*/ 73 Temp1=*src; 74 src++; 75 76 MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) 77 *dst = Temp2; 78 dst++; 79 80 Temp1=*src; 81 src++; 82 83 MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) 84 *dst = Temp2; 85 dst++; 86 87 Temp1=*src; 88 src++; 89 90 MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) 91 *dst = Temp2; 92 dst++; 93 94 Temp1=*src; 95 src++; 96 MUL32x16INTO32(Temp1,CurrentShort,Temp2,15) 97 *dst = Temp2; 98 dst++; 99 } 100 } 101 102 103 /**********************************************************************************/ 104