MixInSoft_D32C31_SAT.c revision 2c8e5cab3faa6d360e222b7a6c40a80083d021ac
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/*                                                                      */
20/*     Project::                                                        */
21/*     $Author: beq07716 $*/
22/*     $Revision: 1000 $*/
23/*     $Date: 2010-06-28 13:08:20 +0200 (Mon, 28 Jun 2010) $*/
24/*                                                                      */
25/************************************************************************/
26
27/**********************************************************************************
28   INCLUDE FILES
29***********************************************************************************/
30
31#include "Mixer_private.h"
32#include "VectorArithmetic.h"
33
34/**********************************************************************************
35   DEFINITIONS
36***********************************************************************************/
37
38#define TRUE          1
39#define FALSE         0
40
41/**********************************************************************************
42   FUNCTION MIXINSOFT_D32C31_SAT
43***********************************************************************************/
44
45void MixInSoft_D32C31_SAT( Mix_1St_Cll_t        *pInstance,
46                           const LVM_INT32      *src,
47                                 LVM_INT32      *dst,
48                                 LVM_INT16      n)
49{
50    char HardMixing = TRUE;
51
52    if(n<=0)    return;
53
54    /******************************************************************************
55       SOFT MIXING
56    *******************************************************************************/
57    if (pInstance->Current != pInstance->Target)
58    {
59        if(pInstance->Alpha == 0){
60            pInstance->Current = pInstance->Target;
61        }else if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
62                 (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
63            pInstance->Current = pInstance->Target; /* Difference is not significant anymore.  Make them equal. */
64        }else{
65            /* Soft mixing has to be applied */
66            HardMixing = FALSE;
67            Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
68        }
69    }
70
71    /******************************************************************************
72       HARD MIXING
73    *******************************************************************************/
74
75    if (HardMixing){
76        if (pInstance->Target != 0){ /* Nothing to do in case Target = 0 */
77            if ((pInstance->Target>>16) == 0x7FFF)
78                Add2_Sat_32x32( src, dst, n );
79            else{
80                Core_MixInSoft_D32C31_SAT( pInstance, src, dst, n);
81                pInstance->Current = pInstance->Target; /* In case the core function would have changed the Current value */
82            }
83        }
84    }
85
86    /******************************************************************************
87       CALL BACK
88    *******************************************************************************/
89    /* Call back before the hard mixing, because in this case, hard mixing makes
90       use of the core soft mix function which can change the Current value!      */
91
92    if (pInstance->CallbackSet){
93        if ((pInstance->Current-pInstance->Target <POINT_ZERO_ONE_DB)&&
94            (pInstance->Current-pInstance->Target > -POINT_ZERO_ONE_DB)){
95            pInstance->Current = pInstance->Target; /* Difference is not significant anymore.  Make them equal. */
96            pInstance->CallbackSet = FALSE;
97            if (pInstance->pCallBack != 0){
98                (*pInstance->pCallBack) ( pInstance->pCallbackHandle, pInstance->pGeneralPurpose,pInstance->CallbackParam );
99            }
100        }
101    }
102}
103
104/**********************************************************************************/
105