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