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
Core_MixInSoft_D32C31_SAT(Mix_1St_Cll_FLOAT_t * pInstance,const LVM_FLOAT * src,LVM_FLOAT * dst,LVM_INT16 n)29 void Core_MixInSoft_D32C31_SAT( Mix_1St_Cll_FLOAT_t *pInstance,
30 const LVM_FLOAT *src,
31 LVM_FLOAT *dst,
32 LVM_INT16 n)
33 {
34 LVM_FLOAT Temp1,Temp2,Temp3;
35 LVM_INT16 OutLoop;
36 LVM_INT16 InLoop;
37 LVM_FLOAT TargetTimesOneMinAlpha;
38 LVM_FLOAT CurrentTimesAlpha;
39 LVM_INT16 ii,jj;
40
41 InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
42 OutLoop = (LVM_INT16)(n - (InLoop << 2));
43
44 TargetTimesOneMinAlpha = ((1.0f -pInstance->Alpha) * pInstance->Target);
45 if (pInstance->Target >= pInstance->Current){
46 TargetTimesOneMinAlpha +=(LVM_FLOAT)(2.0f / 2147483647.0f); /* Ceil*/
47 }
48
49 if (OutLoop){
50
51 CurrentTimesAlpha = pInstance->Current * pInstance->Alpha;
52 pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha;
53
54 for (ii = OutLoop; ii != 0; ii--){
55 Temp1 = *src++;
56 Temp2 = *dst;
57
58 Temp3 = Temp1 * (pInstance->Current);
59 Temp1 = Temp2 + Temp3;
60
61 if (Temp1 > 1.0f)
62 Temp1 = 1.0f;
63 else if (Temp1 < -1.0f)
64 Temp1 = -1.0f;
65
66 *dst++ = Temp1;
67 }
68 }
69
70 for (ii = InLoop; ii != 0; ii--){
71
72 CurrentTimesAlpha = pInstance->Current * pInstance->Alpha;
73 pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha;
74
75 for (jj = 4; jj!=0 ; jj--){
76 Temp1 = *src++;
77 Temp2 = *dst;
78
79 Temp3 = Temp1 * (pInstance->Current);
80 Temp1 = Temp2 + Temp3;
81
82 if (Temp1 > 1.0f)
83 Temp1 = 1.0f;
84 else if (Temp1 < -1.0f)
85 Temp1 = -1.0f;
86 *dst++ = Temp1;
87 }
88 }
89 }
90 /**********************************************************************************/
91