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