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