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 ***********************************************************************************/
MixInSoft_D32C31_SAT(Mix_1St_Cll_FLOAT_t * pInstance,const LVM_FLOAT * src,LVM_FLOAT * dst,LVM_INT16 n)35 void MixInSoft_D32C31_SAT(Mix_1St_Cll_FLOAT_t* pInstance, const LVM_FLOAT* src, LVM_FLOAT* dst,
36 LVM_INT16 n) {
37 char HardMixing = TRUE;
38
39 if (n <= 0) return;
40
41 /******************************************************************************
42 SOFT MIXING
43 *******************************************************************************/
44 if (pInstance->Current != pInstance->Target) {
45 if (pInstance->Alpha == 0) {
46 pInstance->Current = pInstance->Target;
47 } else if ((pInstance->Current - pInstance->Target < POINT_ZERO_ONE_DB_FLOAT) &&
48 (pInstance->Current - pInstance->Target > -POINT_ZERO_ONE_DB_FLOAT)) {
49 pInstance->Current = pInstance->Target; /* Difference is not significant anymore. \
50 Make them equal. */
51 } else {
52 /* Soft mixing has to be applied */
53 HardMixing = FALSE;
54 Core_MixInSoft_D32C31_SAT(pInstance, src, dst, n);
55 }
56 }
57
58 /******************************************************************************
59 HARD MIXING
60 *******************************************************************************/
61
62 if (HardMixing) {
63 if (pInstance->Target != 0) { /* Nothing to do in case Target = 0 */
64 if ((pInstance->Target) == 1.0f)
65 Add2_Sat_Float(src, dst, n);
66 else {
67 Core_MixInSoft_D32C31_SAT(pInstance, src, dst, n);
68 pInstance->Current = pInstance->Target; /* In case the core function would \
69 have changed the Current value */
70 }
71 }
72 }
73
74 /******************************************************************************
75 CALL BACK
76 *******************************************************************************/
77 /* Call back before the hard mixing, because in this case, hard mixing makes
78 use of the core soft mix function which can change the Current value! */
79
80 if (pInstance->CallbackSet) {
81 if ((pInstance->Current - pInstance->Target < POINT_ZERO_ONE_DB_FLOAT) &&
82 (pInstance->Current - pInstance->Target > -POINT_ZERO_ONE_DB_FLOAT)) {
83 pInstance->Current = pInstance->Target; /* Difference is not significant anymore. \
84 Make them equal. */
85 pInstance->CallbackSet = FALSE;
86 if (pInstance->pCallBack != 0) {
87 (*pInstance->pCallBack)(pInstance->pCallbackHandle, pInstance->pGeneralPurpose,
88 pInstance->CallbackParam);
89 }
90 }
91 }
92 }
93 /**********************************************************************************/
94