2 * Copyright (C) 2004-2010 NXP Software
3 * Copyright (C) 2010 The Android Open Source Project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 /**********************************************************************************
20 ***********************************************************************************/
22 #include "LVC_Mixer_Private.h"
23 #include "VectorArithmetic.h"
24 #include "ScalarArithmetic.h"
26 /**********************************************************************************
28 ***********************************************************************************/
33 /**********************************************************************************
34 FUNCTION MIXINSOFT_D16C31_SAT
35 ***********************************************************************************/
37 void LVC_MixInSoft_D16C31_SAT( LVMixer3_1St_st *ptrInstance,
42 char HardMixing = TRUE;
44 Mix_Private_st *pInstance=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams);
48 /******************************************************************************
50 *******************************************************************************/
51 if (pInstance->Current != pInstance->Target)
53 if(pInstance->Delta == 0x7FFFFFFF){
54 pInstance->Current = pInstance->Target;
55 TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
56 LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
57 }else if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){
58 pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
59 TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
60 LVC_Mixer_SetTarget(&(ptrInstance->MixerStream[0]),TargetGain);
62 /* Soft mixing has to be applied */
64 if(pInstance->Shift!=0){
65 Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n);
66 LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n);
69 LVC_Core_MixInSoft_D16C31_SAT( &(ptrInstance->MixerStream[0]), src, dst, n);
73 /******************************************************************************
75 *******************************************************************************/
78 if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
79 if ((pInstance->Target>>16) == 0x7FFF){
80 if(pInstance->Shift!=0)
81 Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n);
82 Add2_Sat_16x16( src, dst, n );
85 if(pInstance->Shift!=0)
86 Shift_Sat_v16xv16 ((LVM_INT16)pInstance->Shift,src,src,n);
87 Mac3s_Sat_16x16(src,(LVM_INT16)(pInstance->Target>>16),dst,n);
88 pInstance->Current = pInstance->Target; /* In case the LVCore function would have changed the Current value */
94 /******************************************************************************
96 *******************************************************************************/
98 if (ptrInstance->MixerStream[0].CallbackSet){
99 if (Abs_32(pInstance->Current-pInstance->Target) < pInstance->Delta){
100 pInstance->Current = pInstance->Target; /* Difference is not significant anymore. Make them equal. */
101 TargetGain=pInstance->Target>>(16-pInstance->Shift); // TargetGain in Q16.15 format
102 LVC_Mixer_SetTarget(ptrInstance->MixerStream,TargetGain);
103 ptrInstance->MixerStream[0].CallbackSet = FALSE;
104 if (ptrInstance->MixerStream[0].pCallBack != 0){
105 (*ptrInstance->MixerStream[0].pCallBack) ( ptrInstance->MixerStream[0].pCallbackHandle, ptrInstance->MixerStream[0].pGeneralPurpose,ptrInstance->MixerStream[0].CallbackParam );
112 /**********************************************************************************/