1 2/* ----------------------------------------------------------------------------------------------------------- 3Software License for The Fraunhofer FDK AAC Codec Library for Android 4 5� Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F�rderung der angewandten Forschung e.V. 6 All rights reserved. 7 8 1. INTRODUCTION 9The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements 10the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. 11This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 12 13AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual 14audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by 15independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part 16of the MPEG specifications. 17 18Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer) 19may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners 20individually for the purpose of encoding or decoding bit streams in products that are compliant with 21the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license 22these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec 23software may already be covered under those patent licenses when it is used for those licensed purposes only. 24 25Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality, 26are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional 27applications information and documentation. 28 292. COPYRIGHT LICENSE 30 31Redistribution and use in source and binary forms, with or without modification, are permitted without 32payment of copyright license fees provided that you satisfy the following conditions: 33 34You must retain the complete text of this software license in redistributions of the FDK AAC Codec or 35your modifications thereto in source code form. 36 37You must retain the complete text of this software license in the documentation and/or other materials 38provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. 39You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 40modifications thereto to recipients of copies in binary form. 41 42The name of Fraunhofer may not be used to endorse or promote products derived from this library without 43prior written permission. 44 45You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec 46software or your modifications thereto. 47 48Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software 49and the date of any change. For modified versions of the FDK AAC Codec, the term 50"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term 51"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android." 52 533. NO PATENT LICENSE 54 55NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, 56ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with 57respect to this software. 58 59You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized 60by appropriate patent licenses. 61 624. DISCLAIMER 63 64This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors 65"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties 66of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 67CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, 68including but not limited to procurement of substitute goods or services; loss of use, data, or profits, 69or business interruption, however caused and on any theory of liability, whether in contract, strict 70liability, or tort (including negligence), arising in any way out of the use of this software, even if 71advised of the possibility of such damage. 72 735. CONTACT INFORMATION 74 75Fraunhofer Institute for Integrated Circuits IIS 76Attention: Audio and Multimedia Departments - FDK AAC LL 77Am Wolfsmantel 33 7891058 Erlangen, Germany 79 80www.iis.fraunhofer.de/amm 81amm-info@iis.fraunhofer.de 82----------------------------------------------------------------------------------------------------------- */ 83 84/***************************** MPEG-4 AAC Decoder ************************** 85 86 Author(s): Manuel Jander 87 Description: MPEG Transport data tables 88 89******************************************************************************/ 90 91#ifndef __TP_DATA_H__ 92#define __TP_DATA_H__ 93 94#include "machine_type.h" 95#include "FDK_audio.h" 96#include "FDK_bitstream.h" 97 98/* 99 * Configuration 100 */ 101#define TP_GA_ENABLE 102/* #define TP_CELP_ENABLE */ 103/* #define TP_HVXC_ENABLE */ 104/* #define TP_SLS_ENABLE */ 105#define TP_ELD_ENABLE 106/* #define TP_USAC_ENABLE */ 107/* #define TP_RSVD50_ENABLE */ 108 109#if defined(TP_GA_ENABLE) || defined(TP_SLS_ENABLE) 110#define TP_PCE_ENABLE /**< Enable full PCE support */ 111#endif 112 113/** 114 * ProgramConfig struct. 115 */ 116/* ISO/IEC 14496-3 4.4.1.1 Table 4.2 Program config element */ 117#define PC_FSB_CHANNELS_MAX 16 /* Front/Side/Back channels */ 118#define PC_LFE_CHANNELS_MAX 4 119#define PC_ASSOCDATA_MAX 8 120#define PC_CCEL_MAX 16 /* CC elements */ 121#define PC_COMMENTLENGTH 256 122 123typedef struct 124{ 125#ifdef TP_PCE_ENABLE 126 /* PCE bitstream elements: */ 127 UCHAR ElementInstanceTag; 128 UCHAR Profile; 129 UCHAR SamplingFrequencyIndex; 130 UCHAR NumFrontChannelElements; 131 UCHAR NumSideChannelElements; 132 UCHAR NumBackChannelElements; 133 UCHAR NumLfeChannelElements; 134 UCHAR NumAssocDataElements; 135 UCHAR NumValidCcElements; 136 137 UCHAR MonoMixdownPresent; 138 UCHAR MonoMixdownElementNumber; 139 140 UCHAR StereoMixdownPresent; 141 UCHAR StereoMixdownElementNumber; 142 143 UCHAR MatrixMixdownIndexPresent; 144 UCHAR MatrixMixdownIndex; 145 UCHAR PseudoSurroundEnable; 146 147 UCHAR FrontElementIsCpe[PC_FSB_CHANNELS_MAX]; 148 UCHAR FrontElementTagSelect[PC_FSB_CHANNELS_MAX]; 149 UCHAR FrontElementHeightInfo[PC_FSB_CHANNELS_MAX]; 150 151 UCHAR SideElementIsCpe[PC_FSB_CHANNELS_MAX]; 152 UCHAR SideElementTagSelect[PC_FSB_CHANNELS_MAX]; 153 UCHAR SideElementHeightInfo[PC_FSB_CHANNELS_MAX]; 154 155 UCHAR BackElementIsCpe[PC_FSB_CHANNELS_MAX]; 156 UCHAR BackElementTagSelect[PC_FSB_CHANNELS_MAX]; 157 UCHAR BackElementHeightInfo[PC_FSB_CHANNELS_MAX]; 158 159 UCHAR LfeElementTagSelect[PC_LFE_CHANNELS_MAX]; 160 161 UCHAR AssocDataElementTagSelect[PC_ASSOCDATA_MAX]; 162 163 UCHAR CcElementIsIndSw[PC_CCEL_MAX]; 164 UCHAR ValidCcElementTagSelect[PC_CCEL_MAX]; 165 166 UCHAR CommentFieldBytes; 167 UCHAR Comment[PC_COMMENTLENGTH]; 168#endif /* TP_PCE_ENABLE */ 169 170 /* Helper variables for administration: */ 171 UCHAR isValid; /*!< Flag showing if PCE has been read successfully. */ 172 UCHAR NumChannels; /*!< Amount of audio channels summing all channel elements including LFEs */ 173 UCHAR NumEffectiveChannels; /*!< Amount of audio channels summing only SCEs and CPEs */ 174 UCHAR elCounter; 175 176} CProgramConfig; 177 178typedef enum { 179 ASCEXT_UNKOWN = -1, 180 ASCEXT_SBR = 0x2b7, 181 ASCEXT_PS = 0x548, 182 ASCEXT_MPS = 0x76a, 183 ASCEXT_SAOC = 0x7cb, 184 ASCEXT_LDMPS = 0x7cc 185 186} TP_ASC_EXTENSION_ID; 187 188#ifdef TP_GA_ENABLE 189/** 190 * GaSpecificConfig struct 191 */ 192typedef struct { 193 UINT m_frameLengthFlag ; 194 UINT m_dependsOnCoreCoder ; 195 UINT m_coreCoderDelay ; 196 197 UINT m_extensionFlag ; 198 UINT m_extensionFlag3 ; 199 200 UINT m_layer; 201 UINT m_numOfSubFrame; 202 UINT m_layerLength; 203 204} CSGaSpecificConfig; 205#endif /* TP_GA_ENABLE */ 206 207 208 209 210#ifdef TP_ELD_ENABLE 211 212typedef enum { 213 ELDEXT_TERM = 0x0, /* Termination tag */ 214 ELDEXT_SAOC = 0x1, /* SAOC config */ 215 ELDEXT_LDSAC = 0x2 /* LD MPEG Surround config */ 216 /* reserved */ 217} ASC_ELD_EXT_TYPE; 218 219typedef struct { 220 UCHAR m_frameLengthFlag; 221 222 UCHAR m_sbrPresentFlag; 223 UCHAR m_useLdQmfTimeAlign; /* Use LD-MPS QMF in SBR to achive time alignment */ 224 UCHAR m_sbrSamplingRate; 225 UCHAR m_sbrCrcFlag; 226 227} CSEldSpecificConfig; 228#endif /* TP_ELD_ENABLE */ 229 230 231 232 233/** 234 * Audio configuration struct, suitable for encoder and decoder configuration. 235 */ 236typedef struct { 237 238 /* XYZ Specific Data */ 239 union { 240#ifdef TP_GA_ENABLE 241 CSGaSpecificConfig m_gaSpecificConfig; /**< General audio specific configuration. */ 242#endif /* TP_GA_ENABLE */ 243#ifdef TP_ELD_ENABLE 244 CSEldSpecificConfig m_eldSpecificConfig; /**< ELD specific configuration. */ 245#endif /* TP_ELD_ENABLE */ 246 } m_sc; 247 248 /* Common ASC parameters */ 249#ifdef TP_PCE_ENABLE 250 CProgramConfig m_progrConfigElement; /**< Program configuration. */ 251#endif /* TP_PCE_ENABLE */ 252 253 AUDIO_OBJECT_TYPE m_aot; /**< Audio Object Type. */ 254 UINT m_samplingFrequency; /**< Samplerate. */ 255 UINT m_samplesPerFrame; /**< Amount of samples per frame. */ 256 UINT m_directMapping; /**< Document this please !! */ 257 258 AUDIO_OBJECT_TYPE m_extensionAudioObjectType; /**< Audio object type */ 259 UINT m_extensionSamplingFrequency; /**< Samplerate */ 260 261 SCHAR m_channelConfiguration; /**< Channel configuration index */ 262 263 SCHAR m_epConfig; /**< Error protection index */ 264 SCHAR m_vcb11Flag; /**< aacSectionDataResilienceFlag */ 265 SCHAR m_rvlcFlag; /**< aacScalefactorDataResilienceFlag */ 266 SCHAR m_hcrFlag; /**< aacSpectralDataResilienceFlag */ 267 268 SCHAR m_sbrPresentFlag; /**< Flag indicating the presence of SBR data in the bitstream */ 269 SCHAR m_psPresentFlag; /**< Flag indicating the presence of parametric stereo data in the bitstream */ 270 UCHAR m_samplingFrequencyIndex; /**< Samplerate index */ 271 UCHAR m_extensionSamplingFrequencyIndex; /**< Samplerate index */ 272 SCHAR m_extensionChannelConfiguration; /**< Channel configuration index */ 273 274} CSAudioSpecificConfig; 275 276typedef INT (*cbUpdateConfig_t)(void*, const CSAudioSpecificConfig*); 277typedef INT (*cbSsc_t)( 278 void*, HANDLE_FDK_BITSTREAM, 279 const AUDIO_OBJECT_TYPE coreCodec, 280 const INT samplingFrequency, 281 const INT muxMode, 282 const INT configBytes 283 ); 284typedef INT (*cbSbr_t)( 285 void * self, 286 HANDLE_FDK_BITSTREAM hBs, 287 const INT sampleRateIn, 288 const INT sampleRateOut, 289 const INT samplesPerFrame, 290 const AUDIO_OBJECT_TYPE coreCodec, 291 const MP4_ELEMENT_ID elementID, 292 const INT elementIndex 293 ); 294 295typedef struct { 296 cbUpdateConfig_t cbUpdateConfig; /*!< Function pointer for Config change notify callback. */ 297 void *cbUpdateConfigData; /*!< User data pointer for Config change notify callback. */ 298 cbSsc_t cbSsc; /*!< Function pointer for SSC parser callback. */ 299 void *cbSscData; /*!< User data pointer for SSC parser callback. */ 300 cbSbr_t cbSbr; /*!< Function pointer for SBR header parser callback. */ 301 void *cbSbrData; /*!< User data pointer for SBR header parser callback. */ 302} CSTpCallBacks; 303 304static const UINT SamplingRateTable[] = 305{ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 306 0 307}; 308 309static inline 310int getSamplingRateIndex( UINT samplingRate ) 311{ 312 UINT sf_index, tableSize=sizeof(SamplingRateTable)/sizeof(UINT); 313 314 for (sf_index=0; sf_index<tableSize; sf_index++) { 315 if( SamplingRateTable[sf_index] == samplingRate ) break; 316 } 317 318 if (sf_index>tableSize-1) { 319 return tableSize-1; 320 } 321 322 return sf_index; 323} 324 325/* 326 * Get Channel count from channel configuration 327 */ 328static inline int getNumberOfTotalChannels(int channelConfig) 329{ 330 switch (channelConfig) { 331 case 1: case 2: case 3: 332 case 4: case 5: case 6: 333 return channelConfig; 334 case 7: case 12: case 14: 335 return 8; 336 case 11: 337 return 7; 338 default: 339 return 0; 340 } 341} 342 343static inline 344int getNumberOfEffectiveChannels(const int channelConfig) 345{ /* index: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 */ 346 const int n[] = {0,1,2,3,4,5,5,7,0,0, 0, 6, 7, 0, 7, 0}; 347 return n[channelConfig]; 348} 349 350#endif /* __TP_DATA_H__ */ 351