blob: 10157212149c2e457f00bfe9b15f5c8212b21579 [file] [log] [blame]
Dharmaray Kundargi643290d2011-01-16 16:02:42 -08001/*
2 * Copyright (C) 2011 NXP Software
3 * Copyright (C) 2011 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#include "M4OSA_Error.h"
19#include "M4OSA_Types.h"
20#include "M4OSA_Memory.h"
21#include "M4OSA_Export.h"
22#include "M4OSA_CoreID.h"
23
24namespace android{
25
26#define WINDOW_SIZE 10
27
28enum veAudioFormat {MONO_16_BIT, STEREO_16_BIT};
29
30
31typedef struct {
32 M4OSA_UInt16* m_dataAddress; // Android SRC needs a Int16 pointer
33 M4OSA_UInt32 m_bufferSize;
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080034} M4AM_Buffer16; // Structure contains Int16_t pointer
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080035
36// Following struct will be used by app to supply the PT and BT properties
37// along with ducking values
38typedef struct {
39 M4OSA_Int32 lvInSampleRate; // Sampling audio freq (8000,16000 or more )
40 M4OSA_Int32 lvOutSampleRate; //Sampling audio freq (8000,16000 or more )
41 veAudioFormat lvBTFormat;
42
43 M4OSA_Int32 lvInDucking_threshold;
44 M4OSA_Float lvInDucking_lowVolume;
45 M4OSA_Bool lvInDucking_enable;
46 M4OSA_Float lvPTVolLevel;
47 M4OSA_Float lvBTVolLevel;
48 M4OSA_Int32 lvBTChannelCount;
49 M4OSA_Int32 lvPTChannelCount;
50} veAudMixSettings;
51
52// This class is defined to get SF SRC access
53class VideoEditorBGAudioProcessing {
54public:
55 VideoEditorBGAudioProcessing();
James Dong3b9ba852011-05-03 23:31:23 -070056 void veSetAudioProcessingParams(const veAudMixSettings& mixParams);
57
58 M4OSA_Int32 veProcessAudioMixNDuck(
59 void* primaryTrackBuffer,
60 void* backgroundTrackBuffer,
61 void* mixedOutputBuffer);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080062
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080063 ~VideoEditorBGAudioProcessing();
64
65private:
66 M4OSA_Int32 mInSampleRate;
67 M4OSA_Int32 mOutSampleRate;
68 veAudioFormat mBTFormat;
69
70 M4OSA_Bool mIsSSRCneeded;
71 M4OSA_Int32 mBTChannelCount;
72 M4OSA_Int32 mPTChannelCount;
73 M4OSA_UInt8 mChannelConversion;
74
75 M4OSA_UInt32 mDucking_threshold;
76 M4OSA_Float mDucking_lowVolume;
77 M4OSA_Float mDuckingFactor ;
78 M4OSA_Bool mDucking_enable;
79 M4OSA_Int32 mAudioVolumeArray[WINDOW_SIZE];
80 M4OSA_Int32 mAudVolArrIndex;
81 M4OSA_Bool mDoDucking;
82 M4OSA_Float mPTVolLevel;
83 M4OSA_Float mBTVolLevel;
84
Rajneesh Chowdury1c97d9a2011-02-21 15:43:33 -080085 M4AM_Buffer16 mBTBuffer;
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080086
87 M4OSA_Int32 getDecibelSound(M4OSA_UInt32 value);
88 M4OSA_Bool isThresholdBreached(M4OSA_Int32* averageValue,
James Dong3b9ba852011-05-03 23:31:23 -070089 M4OSA_Int32 storeCount, M4OSA_Int32 thresholdValue);
Dharmaray Kundargi643290d2011-01-16 16:02:42 -080090
91 // This returns the size of buffer which needs to allocated
92 // before resampling is called
93 M4OSA_Int32 calculateOutResampleBufSize();
94};
95} // namespace android