LVC_MixSoft_2St_D16C31_SAT.c revision d7d013446a64c6de9f0f2dfe098a721b140e0b48
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 "LVC_Mixer_Private.h"
23#include "VectorArithmetic.h"
24
25/**********************************************************************************
26   FUNCTION LVC_MixSoft_2St_D16C31_SAT.c
27***********************************************************************************/
28#ifdef BUILD_FLOAT
29void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_FLOAT_st *ptrInstance,
30                                 const   LVM_FLOAT       *src1,
31                                 LVM_FLOAT       *src2,
32                                 LVM_FLOAT       *dst,
33                                 LVM_INT16       n)
34{
35    Mix_Private_FLOAT_st  *pInstance1 = \
36                             (Mix_Private_FLOAT_st *)(ptrInstance->MixerStream[0].PrivateParams);
37    Mix_Private_FLOAT_st  *pInstance2 = \
38                             (Mix_Private_FLOAT_st *)(ptrInstance->MixerStream[1].PrivateParams);
39
40    if(n <= 0)    return;
41
42    /******************************************************************************
43       SOFT MIXING
44    *******************************************************************************/
45    if ((pInstance1->Current == pInstance1->Target) && (pInstance1->Current == 0)){
46        LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[1]),
47                                    src2, dst, n);
48    }
49    else if ((pInstance2->Current == pInstance2->Target) && (pInstance2->Current == 0)){
50        LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[0]),
51                                    src1, dst, n);
52    }
53    else if ((pInstance1->Current != pInstance1->Target) || \
54                                    (pInstance2->Current != pInstance2->Target))
55    {
56        LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[0]),
57                                   src1, dst, n);
58        LVC_MixInSoft_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[1]),
59                                  src2, dst, n);
60    }
61    else{
62        /******************************************************************************
63           HARD MIXING
64        *******************************************************************************/
65        LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0],
66                                         &ptrInstance->MixerStream[1],
67                                         src1, src2, dst, n);
68    }
69}
70#else
71void LVC_MixSoft_2St_D16C31_SAT( LVMixer3_2St_st *ptrInstance,
72                                    const   LVM_INT16       *src1,
73                                            LVM_INT16       *src2,
74                                            LVM_INT16       *dst,
75                                            LVM_INT16       n)
76{
77    Mix_Private_st  *pInstance1=(Mix_Private_st *)(ptrInstance->MixerStream[0].PrivateParams);
78    Mix_Private_st  *pInstance2=(Mix_Private_st *)(ptrInstance->MixerStream[1].PrivateParams);
79
80    if(n<=0)    return;
81
82    /******************************************************************************
83       SOFT MIXING
84    *******************************************************************************/
85    if ((pInstance1->Current == pInstance1->Target)&&(pInstance1->Current == 0)){
86        LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n);
87    }
88    else if ((pInstance2->Current == pInstance2->Target)&&(pInstance2->Current == 0)){
89        LVC_MixSoft_1St_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n);
90    }
91    else if ((pInstance1->Current != pInstance1->Target) || (pInstance2->Current != pInstance2->Target))
92    {
93        LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_st *)(&ptrInstance->MixerStream[0]), src1, dst, n);
94        LVC_MixInSoft_D16C31_SAT( (LVMixer3_1St_st *)(&ptrInstance->MixerStream[1]), src2, dst, n);
95    }
96    else{
97        /******************************************************************************
98           HARD MIXING
99        *******************************************************************************/
100        if(pInstance2->Shift!=0)
101            Shift_Sat_v16xv16 ((LVM_INT16)pInstance2->Shift,src2,src2,n);
102        if(pInstance1->Shift!=0)
103        {
104            Shift_Sat_v16xv16 ((LVM_INT16)pInstance1->Shift,src1,dst,n);
105            LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], dst, src2, dst, n);
106        }
107        else
108            LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0], &ptrInstance->MixerStream[1], src1, src2, dst, n);
109    }
110}
111#endif /*BUILD_FLOAT*/
112/**********************************************************************************/
113