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