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