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 ***********************************************************************************/
Core_MixSoft_1St_D32C31_WRA(Mix_1St_Cll_FLOAT_t * pInstance,const LVM_FLOAT * src,LVM_FLOAT * dst,LVM_INT16 n)28 void Core_MixSoft_1St_D32C31_WRA(   Mix_1St_Cll_FLOAT_t       *pInstance,
29                                     const LVM_FLOAT     *src,
30                                     LVM_FLOAT     *dst,
31                                     LVM_INT16     n)
32 {
33     LVM_FLOAT Temp1,Temp2;
34     LVM_INT16 OutLoop;
35     LVM_INT16 InLoop;
36     LVM_FLOAT TargetTimesOneMinAlpha;
37     LVM_FLOAT CurrentTimesAlpha;
38 
39     LVM_INT16 ii;
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; /* float * float in float */
45     if (pInstance->Target >= pInstance->Current)
46     {
47         TargetTimesOneMinAlpha += (LVM_FLOAT)(2.0f / 2147483647.0f); /* Ceil*/
48     }
49 
50     if (OutLoop != 0)
51     {
52         CurrentTimesAlpha = (pInstance->Current * pInstance->Alpha);
53         pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha;
54 
55         for (ii = OutLoop; ii != 0; ii--)
56         {
57             Temp1 = *src;
58             src++;
59 
60             Temp2 = Temp1 * (pInstance->Current);
61             *dst = Temp2;
62             dst++;
63         }
64     }
65 
66     for (ii = InLoop; ii != 0; ii--)
67     {
68         CurrentTimesAlpha = pInstance->Current * pInstance->Alpha;
69         pInstance->Current = TargetTimesOneMinAlpha + CurrentTimesAlpha;
70 
71             Temp1 = *src;
72             src++;
73 
74             Temp2 = Temp1 * (pInstance->Current);
75             *dst = Temp2;
76             dst++;
77 
78             Temp1 = *src;
79             src++;
80 
81             Temp2 = Temp1 * (pInstance->Current);
82             *dst = Temp2;
83             dst++;
84 
85             Temp1 = *src;
86             src++;
87 
88             Temp2 = Temp1 * (pInstance->Current);
89             *dst = Temp2;
90             dst++;
91 
92             Temp1 = *src;
93             src++;
94             Temp2 = Temp1 * (pInstance->Current);
95             *dst = Temp2;
96             dst++;
97     }
98 }
99 /**********************************************************************************/
100