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 #include "Mixer_private.h"
22 #include "LVM_Macros.h"
23 #include "ScalarArithmetic.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, const LVM_FLOAT* src, LVM_FLOAT* dst,
30 LVM_INT16 n) {
31 LVM_FLOAT Temp1, Temp2, Temp3;
32 LVM_INT16 OutLoop;
33 LVM_INT16 InLoop;
34 LVM_FLOAT TargetTimesOneMinAlpha;
35 LVM_FLOAT CurrentTimesAlpha;
36 LVM_INT16 ii, jj;
37
38 InLoop = (LVM_INT16)(n >> 2); /* Process per 4 samples */
39 OutLoop = (LVM_INT16)(n - (InLoop << 2));
40
41 TargetTimesOneMinAlpha = ((1.0f - pInstance->Alpha) * pInstance->Target);
42 if (pInstance->Target >= pInstance->Current) {
43 TargetTimesOneMinAlpha += (LVM_FLOAT)(2.0f / 2147483647.0f); /* Ceil*/
44 }
45
46 if (OutLoop) {
47 CurrentTimesAlpha = pInstance->Current * pInstance->Alpha;
48 pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha;
49
50 for (ii = OutLoop; ii != 0; ii--) {
51 Temp1 = *src++;
52 Temp2 = *dst;
53
54 Temp3 = Temp1 * (pInstance->Current);
55 *dst++ = LVM_Clamp(Temp2 + Temp3);
56 }
57 }
58
59 for (ii = InLoop; ii != 0; ii--) {
60 CurrentTimesAlpha = pInstance->Current * pInstance->Alpha;
61 pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha;
62
63 for (jj = 4; jj != 0; jj--) {
64 Temp1 = *src++;
65 Temp2 = *dst;
66
67 Temp3 = Temp1 * (pInstance->Current);
68 *dst++ = LVM_Clamp(Temp2 + Temp3);
69 }
70 }
71 }
72 /**********************************************************************************/
73