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 ***********************************************************************************/
LVC_MixSoft_2St_D16C31_SAT(LVMixer3_2St_FLOAT_st * ptrInstance,const LVM_FLOAT * src1,const LVM_FLOAT * src2,LVM_FLOAT * dst,LVM_INT16 n)28 void LVC_MixSoft_2St_D16C31_SAT(LVMixer3_2St_FLOAT_st *ptrInstance,
29                                 const LVM_FLOAT       *src1,
30                                 const LVM_FLOAT       *src2,
31                                       LVM_FLOAT       *dst,
32                                       LVM_INT16       n)
33 {
34     Mix_Private_FLOAT_st  *pInstance1 = \
35                              (Mix_Private_FLOAT_st *)(ptrInstance->MixerStream[0].PrivateParams);
36     Mix_Private_FLOAT_st  *pInstance2 = \
37                              (Mix_Private_FLOAT_st *)(ptrInstance->MixerStream[1].PrivateParams);
38 
39     if(n <= 0)    return;
40 
41     /******************************************************************************
42        SOFT MIXING
43     *******************************************************************************/
44     if ((pInstance1->Current == pInstance1->Target) && (pInstance1->Current == 0)){
45         LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[1]),
46                                     src2, dst, n);
47     }
48     else if ((pInstance2->Current == pInstance2->Target) && (pInstance2->Current == 0)){
49         LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[0]),
50                                     src1, dst, n);
51     }
52     else if ((pInstance1->Current != pInstance1->Target) || \
53                                     (pInstance2->Current != pInstance2->Target))
54     {
55         LVC_MixSoft_1St_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[0]),
56                                    src1, dst, n);
57         LVC_MixInSoft_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[1]),
58                                   src2, dst, n);
59     }
60     else{
61         /******************************************************************************
62            HARD MIXING
63         *******************************************************************************/
64         LVC_Core_MixHard_2St_D16C31_SAT( &ptrInstance->MixerStream[0],
65                                          &ptrInstance->MixerStream[1],
66                                          src1, src2, dst, n);
67     }
68 }
69 
70 #ifdef SUPPORT_MC
71 /*
72  * FUNCTION:       LVC_MixSoft_2Mc_D16C31_SAT
73  *
74  * DESCRIPTION:
75  *  2 stream Mixer function with support for processing multichannel input
76  *
77  * PARAMETERS:
78  *  ptrInstance    Instance pointer
79  *  src1           First multichannel source
80  *  src2           Second multichannel source
81  *  dst            Destination
82  *  NrFrames       Number of frames
83  *  NrChannels     Number of channels
84  *
85  * RETURNS:
86  *  void
87  *
88  */
LVC_MixSoft_2Mc_D16C31_SAT(LVMixer3_2St_FLOAT_st * ptrInstance,const LVM_FLOAT * src1,const LVM_FLOAT * src2,LVM_FLOAT * dst,LVM_INT16 NrFrames,LVM_INT16 NrChannels)89 void LVC_MixSoft_2Mc_D16C31_SAT(LVMixer3_2St_FLOAT_st *ptrInstance,
90                                 const LVM_FLOAT       *src1,
91                                 const LVM_FLOAT       *src2,
92                                       LVM_FLOAT       *dst,
93                                       LVM_INT16       NrFrames,
94                                       LVM_INT16       NrChannels)
95 {
96     Mix_Private_FLOAT_st  *pInstance1 = \
97                              (Mix_Private_FLOAT_st *)(ptrInstance->MixerStream[0].PrivateParams);
98     Mix_Private_FLOAT_st  *pInstance2 = \
99                              (Mix_Private_FLOAT_st *)(ptrInstance->MixerStream[1].PrivateParams);
100 
101     if (NrFrames <= 0)    return;
102 
103     /******************************************************************************
104        SOFT MIXING
105     *******************************************************************************/
106     if ((pInstance1->Current == pInstance1->Target) && (pInstance1->Current == 0)) {
107         LVC_MixSoft_Mc_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[1]),
108                                     src2, dst, NrFrames, NrChannels);
109     }
110     else if ((pInstance2->Current == pInstance2->Target) && (pInstance2->Current == 0)) {
111         LVC_MixSoft_Mc_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[0]),
112                                     src1, dst, NrFrames, NrChannels);
113     }
114     else if ((pInstance1->Current != pInstance1->Target) || \
115                                     (pInstance2->Current != pInstance2->Target))
116     {
117         LVC_MixSoft_Mc_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[0]),
118                                    src1, dst, NrFrames, NrChannels);
119         LVC_MixInSoft_Mc_D16C31_SAT((LVMixer3_1St_FLOAT_st *)(&ptrInstance->MixerStream[1]),
120                                    src2, dst, NrFrames, NrChannels);
121     }
122     else{
123         /******************************************************************************
124            HARD MIXING
125         *******************************************************************************/
126         LVC_Core_MixHard_2St_D16C31_SAT(&ptrInstance->MixerStream[0],
127                                         &ptrInstance->MixerStream[1],
128                                         src1, src2, dst, NrFrames * NrChannels);
129     }
130 }
131 #endif
132 
133 /**********************************************************************************/
134