• 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 "VectorArithmetic.h"
24 
25 /**********************************************************************************
26    DEFINITIONS
27 ***********************************************************************************/
28 
29 #define TRUE          1
30 #define FALSE         0
31 
32 /**********************************************************************************
33    FUNCTION MIXINSOFT_D32C31_SAT
34 ***********************************************************************************/
35 #ifdef BUILD_FLOAT
MixInSoft_D32C31_SAT(Mix_1St_Cll_FLOAT_t * pInstance,const LVM_FLOAT * src,LVM_FLOAT * dst,LVM_INT16 n)36 void MixInSoft_D32C31_SAT( Mix_1St_Cll_FLOAT_t        *pInstance,
37                            const LVM_FLOAT      *src,
38                            LVM_FLOAT      *dst,
39                            LVM_INT16      n)
40 {
41     char HardMixing = TRUE;
42 
43     if(n <= 0)    return;
44 
45     /******************************************************************************
46        SOFT MIXING
47     *******************************************************************************/
48     if (pInstance->Current != pInstance->Target)
49     {
50         if(pInstance->Alpha == 0){
51             pInstance->Current = pInstance->Target;
52         }else if ((pInstance->Current-pInstance->Target < POINT_ZERO_ONE_DB_FLOAT) &&
53                  (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB_FLOAT)){
54             pInstance->Current = pInstance->Target; /* Difference is not significant anymore. \
55                                                        Make them equal. */
56         }else{
57             /* Soft mixing has to be applied */
58             HardMixing = FALSE;
59             Core_MixInSoft_D32C31_SAT(pInstance, src, dst, n);
60         }
61     }
62 
63     /******************************************************************************
64        HARD MIXING
65     *******************************************************************************/
66 
67     if (HardMixing){
68         if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
69             if ((pInstance->Target) == 1.0f)
70                 Add2_Sat_Float(src, dst, n);
71             else{
72                 Core_MixInSoft_D32C31_SAT(pInstance, src, dst, n);
73                 pInstance->Current = pInstance->Target; /* In case the core function would \
74                                                            have changed the Current value */
75             }
76         }
77     }
78 
79     /******************************************************************************
80        CALL BACK
81     *******************************************************************************/
82     /* Call back before the hard mixing, because in this case, hard mixing makes
83        use of the core soft mix function which can change the Current value!      */
84 
85     if (pInstance->CallbackSet){
86         if ((pInstance->Current - pInstance->Target < POINT_ZERO_ONE_DB_FLOAT) &&
87             (pInstance->Current - pInstance->Target > -POINT_ZERO_ONE_DB_FLOAT)){
88             pInstance->Current = pInstance->Target; /* Difference is not significant anymore. \
89                                                        Make them equal. */
90             pInstance->CallbackSet = FALSE;
91             if (pInstance->pCallBack != 0){
92                 (*pInstance->pCallBack) ( pInstance->pCallbackHandle,
93                                           pInstance->pGeneralPurpose,
94                                           pInstance->CallbackParam );
95             }
96         }
97     }
98 }
99 #else
MixInSoft_D32C31_SAT(Mix_1St_Cll_t * pInstance,const LVM_INT32 * src,LVM_INT32 * dst,LVM_INT16 n)100 void MixInSoft_D32C31_SAT( Mix_1St_Cll_t        *pInstance,
101                            const LVM_INT32      *src,
102                                  LVM_INT32      *dst,
103                                  LVM_INT16      n)
104 {
105     char HardMixing = TRUE;
106 
107     if(n<=0)    return;
108 
109     /******************************************************************************
110        SOFT MIXING
111     *******************************************************************************/
112     if (pInstance->Current != pInstance->Target)
113     {
114         if(pInstance->Alpha == 0){
115             pInstance->Current = pInstance->Target;
116         }else if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
117                  (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
118             pInstance->Current = pInstance->Target; /* Difference is not significant anymore.  Make them equal. */
119         }else{
120             /* Soft mixing has to be applied */
121             HardMixing = FALSE;
122             Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
123         }
124     }
125 
126     /******************************************************************************
127        HARD MIXING
128     *******************************************************************************/
129 
130     if (HardMixing){
131         if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
132             if ((pInstance->Target>>16) == 0x7FFF)
133                 Add2_Sat_32x32( src, dst, n );
134             else{
135                 Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
136                 pInstance->Current = pInstance->Target; /* In case the core function would have changed the Current value */
137             }
138         }
139     }
140 
141     /******************************************************************************
142        CALL BACK
143     *******************************************************************************/
144     /* Call back before the hard mixing, because in this case, hard mixing makes
145        use of the core soft mix function which can change the Current value!      */
146 
147     if (pInstance->CallbackSet){
148         if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
149             (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
150             pInstance->Current = pInstance->Target; /* Difference is not significant anymore.  Make them equal. */
151             pInstance->CallbackSet = FALSE;
152             if (pInstance->pCallBack != 0){
153                 (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam );
154             }
155         }
156     }
157 }
158 #endif
159 /**********************************************************************************/
160