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
MixInSoft_D32C31_SAT(Mix_1St_Cll_t * pInstance,const LVM_INT32 * src,LVM_INT32 * dst,LVM_INT16 n)36 void MixInSoft_D32C31_SAT( Mix_1St_Cll_t *pInstance,
37 const LVM_INT32 *src,
38 LVM_INT32 *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)&&
53 (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
54 pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
55 }else{
56 /* Soft mixing has to be applied */
57 HardMixing = FALSE;
58 Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
59 }
60 }
61
62 /******************************************************************************
63 HARD MIXING
64 *******************************************************************************/
65
66 if (HardMixing){
67 if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
68 if ((pInstance->Target>>16) == 0x7FFF)
69 Add2_Sat_32x32( src, dst, n );
70 else{
71 Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
72 pInstance->Current = pInstance->Target; /* In case the core function would have changed the Current value */
73 }
74 }
75 }
76
77 /******************************************************************************
78 CALL BACK
79 *******************************************************************************/
80 /* Call back before the hard mixing, because in this case, hard mixing makes
81 use of the core soft mix function which can change the Current value! */
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