1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
******************************************************************************
* @file M4ENCODER_AudioCommon.h
* @brief VES audio encoders shell interface.
* @note This file defines the types internally used by the VES to abstract audio encoders
******************************************************************************
*/
#ifndef __M4ENCODER_AUDIOCOMMON_H__
#define __M4ENCODER_AUDIOCOMMON_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include "M4OSA_OptionID.h" /* for M4OSA_OPTION_ID_CREATE() */
#include "M4OSA_CoreID.h"
#define M4ENCODER_AUDIO_NB_CHANNELS_MAX 2
/* WARNING: this value must be equal to the number of samples grabbed */
//#define M4ENCODER_AUDIO_PCM_SAMPLE_NUMBER 960 /* imposed by the AAC encoder. */
#define M4ENCODER_AUDIO_PCM_SAMPLE_NUMBER 1024 /* imposed by the AAC encoder. */
/**
******************************************************************************
* enumeration M4ENCODER_Audio_OptionID
* @brief This enum defines the core AAC shell encoder options
******************************************************************************
*/
typedef enum
{
/* Maximum generated AU size */
M4ENCODER_Audio_maxAUsize = M4OSA_OPTION_ID_CREATE(M4_READ,M4ENCODER_AUDIO, 0x01)
} M4ENCODER_Audio_OptionID;
/**
******************************************************************************
* enum M4ENCODER_SamplingFrequency
* @brief Thie enum defines the audio sampling frequency.
******************************************************************************
*/
typedef enum
{
M4ENCODER_k8000Hz = 8000,
M4ENCODER_k11025Hz = 11025,
M4ENCODER_k12000Hz = 12000,
M4ENCODER_k16000Hz = 16000,
M4ENCODER_k22050Hz = 22050,
M4ENCODER_k24000Hz = 24000,
M4ENCODER_k32000Hz = 32000,
M4ENCODER_k44100Hz = 44100,
M4ENCODER_k48000Hz = 48000
} M4ENCODER_SamplingFrequency;
/**
******************************************************************************
* enum M4ENCODER_AudioFormat
* @brief This enum defines the audio compression formats.
******************************************************************************
*/
typedef enum
{
M4ENCODER_kAMRNB = 0,
M4ENCODER_kAAC,
M4ENCODER_kAudioNULL, /**< No compression */
M4ENCODER_kMP3,
M4ENCODER_kAudio_NB /* number of encoders, keep it as last enum entry */
} M4ENCODER_AudioFormat;
/**
******************************************************************************
* enum M4ENCODER_ChannelNumber
* @brief Thie enum defines the number of audio channels.
******************************************************************************
*/
typedef enum
{
M4ENCODER_kMono = 0,
M4ENCODER_kStereo,
M4ENCODER_kStereoNoInterleave
} M4ENCODER_ChannelNumber;
/**
******************************************************************************
* enum M4ENCODER_AudioBitrate
* @brief Thie enum defines the avalaible bitrates.
******************************************************************************
*/
typedef enum
{
M4ENCODER_kAudio_4_75_KBPS = 4750,
M4ENCODER_kAudio_5_15_KBPS = 5150,
M4ENCODER_kAudio_5_9_KBPS = 5900,
M4ENCODER_kAudio_6_7_KBPS = 6700,
M4ENCODER_kAudio_7_4_KBPS = 7400,
M4ENCODER_kAudio_7_95_KBPS = 7950,
M4ENCODER_kAudio_8_KBPS = 8000,
M4ENCODER_kAudio_10_2_KBPS = 10200,
M4ENCODER_kAudio_12_2_KBPS = 12200,
M4ENCODER_kAudio_16_KBPS = 16000,
M4ENCODER_kAudio_24_KBPS = 24000,
M4ENCODER_kAudio_32_KBPS = 32000,
M4ENCODER_kAudio_40_KBPS = 40000,
M4ENCODER_kAudio_48_KBPS = 48000,
M4ENCODER_kAudio_56_KBPS = 56000,
M4ENCODER_kAudio_64_KBPS = 64000,
M4ENCODER_kAudio_80_KBPS = 80000,
M4ENCODER_kAudio_96_KBPS = 96000,
M4ENCODER_kAudio_112_KBPS = 112000,
M4ENCODER_kAudio_128_KBPS = 128000,
M4ENCODER_kAudio_144_KBPS = 144000,
M4ENCODER_kAudio_160_KBPS = 160000,
M4ENCODER_kAudio_192_KBPS = 192000,
M4ENCODER_kAudio_224_KBPS = 224000,
M4ENCODER_kAudio_256_KBPS = 256000,
M4ENCODER_kAudio_320_KBPS = 320000
} M4ENCODER_AudioBitrate;
/**
******************************************************************************
* enum M4ENCODER_AacRegulation
* @brief The current mode of the bitrate regulation.
******************************************************************************
*/
typedef enum
{
M4ENCODER_kAacRegulNone = 0, /**< no bitrate regulation */
M4ENCODER_kAacBitReservoir /**< better quality, but more CPU consumed */
} M4ENCODER_AacRegulation;
/**
******************************************************************************
* enum M4ENCODER_AmrSID
* @brief This enum defines the SID of the AMR encoder.
******************************************************************************
*/
typedef enum
{
M4ENCODER_kAmrNoSID = 0 /**< no SID */
} M4ENCODER_AmrSID;
/**
******************************************************************************
* struct M4ENCODER_AacParams
* @brief This structure defines all the settings specific to the AAC encoder.
******************************************************************************
*/
typedef struct
{
M4ENCODER_AacRegulation Regulation;
M4OSA_Bool bHighSpeed;
M4OSA_Bool bTNS;
M4OSA_Bool bPNS;
M4OSA_Bool bIS;
M4OSA_Bool bMS;
} M4ENCODER_AacParams;
/**
******************************************************************************
* struct M4ENCODER_AudioParams
* @brief This structure defines all the settings avalaible when encoding audio.
******************************************************************************
*/
typedef struct s_M4ENCODER_AudioParams
{
M4ENCODER_SamplingFrequency Frequency; /**< the sampling frequency */
M4ENCODER_ChannelNumber ChannelNum; /**< the numbe of channels (mono, stereo, ..) */
M4ENCODER_AudioBitrate Bitrate; /**< bitrate, see enum */
M4ENCODER_AudioFormat Format; /**< audio compression format, AMR, AAC ... */
union {
M4ENCODER_AacParams AacParam;
M4ENCODER_AmrSID AmrSID;
} SpecifParam; /**< the audio encoder specific parameters */
} M4ENCODER_AudioParams;
/**
******************************************************************************
* struct M4ENCODER_AudioDecSpecificInfo
* @brief This structure describes the decoder specific info buffer.
******************************************************************************
*/
typedef struct
{
M4OSA_MemAddr8 pInfo; /**< the buffer adress */
M4OSA_UInt32 infoSize; /**< the buffer size in bytes */
} M4ENCODER_AudioDecSpecificInfo;
/**
******************************************************************************
* struct M4ENCODER_AudioBuffer
* @brief This structure defines the data buffer.
******************************************************************************
*/
typedef struct
{
/**< the table of buffers (unused buffers are set to NULL) */
M4OSA_MemAddr8 pTableBuffer[M4ENCODER_AUDIO_NB_CHANNELS_MAX];
/**< the table of the size of corresponding buffer at same index */
M4OSA_UInt32 pTableBufferSize[M4ENCODER_AUDIO_NB_CHANNELS_MAX];
} M4ENCODER_AudioBuffer;
typedef M4OSA_ERR (M4AE_init) (M4OSA_Context* hContext, M4OSA_Void* pUserData);
typedef M4OSA_ERR (M4AE_cleanUp) (M4OSA_Context pContext);
typedef M4OSA_ERR (M4AE_open) (M4OSA_Context pContext, M4ENCODER_AudioParams *params,
M4ENCODER_AudioDecSpecificInfo *decSpecInfo,
M4OSA_Context grabberContext);
typedef M4OSA_ERR (M4AE_close) (M4OSA_Context pContext);
typedef M4OSA_ERR (M4AE_step) (M4OSA_Context pContext, M4ENCODER_AudioBuffer *inBuffer,
M4ENCODER_AudioBuffer *outBuffer);
typedef M4OSA_ERR (M4AE_getOption) (M4OSA_Context pContext, M4OSA_OptionID option,
M4OSA_DataOption *valuePtr);
/**
******************************************************************************
* struct M4ENCODER_AudioGlobalInterface
* @brief Defines all the functions required for an audio encoder shell.
******************************************************************************
*/
typedef struct _M4ENCODER_AudioGlobalInterface
{
M4AE_init* pFctInit;
M4AE_cleanUp* pFctCleanUp;
M4AE_open* pFctOpen;
M4AE_close* pFctClose;
M4AE_step* pFctStep;
M4AE_getOption* pFctGetOption;
} M4ENCODER_AudioGlobalInterface;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*__M4ENCODER_AUDIOCOMMON_H__*/
|