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 MIXSOFT_1ST_D32C31_WRA
34 ***********************************************************************************/
MixSoft_1St_D32C31_WRA(Mix_1St_Cll_FLOAT_t * pInstance,const LVM_FLOAT * src,LVM_FLOAT * dst,LVM_INT16 n)35 void MixSoft_1St_D32C31_WRA(    Mix_1St_Cll_FLOAT_t       *pInstance,
36                                 const LVM_FLOAT     *src,
37                                       LVM_FLOAT     *dst,
38                                       LVM_INT16     n)
39 {
40     char HardMixing = TRUE;
41 
42     if(n <= 0)    return;
43 
44     /******************************************************************************
45        SOFT MIXING
46     *******************************************************************************/
47     if (pInstance->Current != pInstance->Target)
48     {
49         if(pInstance->Alpha == 0){
50             pInstance->Current = pInstance->Target;
51         }else if ((pInstance->Current - pInstance->Target < POINT_ZERO_ONE_DB_FLOAT) &&
52                  (pInstance->Current - pInstance->Target > -POINT_ZERO_ONE_DB_FLOAT)){
53             pInstance->Current = pInstance->Target; /* Difference is not significant anymore. \
54                                                        Make them equal. */
55         }else{
56             /* Soft mixing has to be applied */
57             HardMixing = FALSE;
58             Core_MixSoft_1St_D32C31_WRA(pInstance, src, dst, n);
59         }
60     }
61 
62     /******************************************************************************
63        HARD MIXING
64     *******************************************************************************/
65 
66     if (HardMixing){
67         if (pInstance->Target == 0)
68             LoadConst_Float(0, dst, n);
69         else if ((pInstance->Target) == 1.0f){
70             if (src != dst)
71                 Copy_Float((LVM_FLOAT*)src, (LVM_FLOAT*)dst, (LVM_INT16)(n));
72         }
73         else
74             Mult3s_Float(src, pInstance->Current, dst, n);
75     }
76 
77     /******************************************************************************
78        CALL BACK
79     *******************************************************************************/
80 
81     if (pInstance->CallbackSet){
82         if ((pInstance->Current - pInstance->Target < POINT_ZERO_ONE_DB_FLOAT) &&
83             (pInstance->Current - pInstance->Target > -POINT_ZERO_ONE_DB_FLOAT)){
84             pInstance->Current = pInstance->Target; /* Difference is not significant anymore. \
85                                                        Make them equal. */
86             pInstance->CallbackSet = FALSE;
87             if (pInstance->pCallBack != 0){
88                 (*pInstance->pCallBack) ( pInstance->pCallbackHandle,
89                                           pInstance->pGeneralPurpose,
90                                           pInstance->CallbackParam );
91             }
92         }
93     }
94 }
95 /**********************************************************************************/
96