1 2 /* ----------------------------------------------------------------------------------------------------------- 3 Software License for The Fraunhofer FDK AAC Codec Library for Android 4 5 � Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur F�rderung der angewandten Forschung e.V. 6 All rights reserved. 7 8 1. INTRODUCTION 9 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements 10 the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. 11 This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 12 13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient general perceptual 14 audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by 15 independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part 16 of the MPEG specifications. 17 18 Patent licenses for necessary patent claims for the FDK AAC Codec (including those of Fraunhofer) 19 may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners 20 individually for the purpose of encoding or decoding bit streams in products that are compliant with 21 the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license 22 these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec 23 software may already be covered under those patent licenses when it is used for those licensed purposes only. 24 25 Commercially-licensed AAC software libraries, including floating-point versions with enhanced sound quality, 26 are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional 27 applications information and documentation. 28 29 2. COPYRIGHT LICENSE 30 31 Redistribution and use in source and binary forms, with or without modification, are permitted without 32 payment of copyright license fees provided that you satisfy the following conditions: 33 34 You must retain the complete text of this software license in redistributions of the FDK AAC Codec or 35 your modifications thereto in source code form. 36 37 You must retain the complete text of this software license in the documentation and/or other materials 38 provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. 39 You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 40 modifications thereto to recipients of copies in binary form. 41 42 The name of Fraunhofer may not be used to endorse or promote products derived from this library without 43 prior written permission. 44 45 You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec 46 software or your modifications thereto. 47 48 Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software 49 and 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 53 3. NO PATENT LICENSE 54 55 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, 56 ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with 57 respect to this software. 58 59 You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized 60 by appropriate patent licenses. 61 62 4. DISCLAIMER 63 64 This 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 66 of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 67 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, 68 including but not limited to procurement of substitute goods or services; loss of use, data, or profits, 69 or business interruption, however caused and on any theory of liability, whether in contract, strict 70 liability, or tort (including negligence), arising in any way out of the use of this software, even if 71 advised of the possibility of such damage. 72 73 5. CONTACT INFORMATION 74 75 Fraunhofer Institute for Integrated Circuits IIS 76 Attention: Audio and Multimedia Departments - FDK AAC LL 77 Am Wolfsmantel 33 78 91058 Erlangen, Germany 79 80 www.iis.fraunhofer.de/amm 81 amm-info@iis.fraunhofer.de 82 ----------------------------------------------------------------------------------------------------------- */ 83 84 /***************************** MPEG-4 AAC Decoder ************************** 85 86 Author(s): Josef Hoepfl 87 Description: 88 89 ******************************************************************************/ 90 91 #ifndef AACDECODER_H 92 #define AACDECODER_H 93 94 #include "common_fix.h" 95 96 #include "FDK_bitstream.h" 97 98 #include "channel.h" 99 100 #include "tpdec_lib.h" 101 #include "FDK_audio.h" 102 103 #include "block.h" 104 105 #include "genericStds.h" 106 107 108 #include "sbrdecoder.h" 109 110 111 #include "aacdec_drc.h" 112 113 #include "pcmutils_lib.h" 114 115 116 /* Capabilities flags */ 117 #define CAPF_AAC_LC 0x00000001 118 #define CAPF_AAC_LD 0x00000002 119 #define CAPF_AAC_SCAL 0x00000004 120 #define CAPF_AAC_ER 0x00000008 121 #define CAPF_AAC_480 0x00000010 122 #define CAPF_AAC_512 0x00000020 123 #define CAPF_AAC_960 0x00000040 124 #define CAPF_AAC_1024 0x00000080 125 #define CAPF_AAC_HCR 0x00000100 126 #define CAPF_AAC_VCB11 0x00000200 127 #define CAPF_AAC_RVLC 0x00000400 128 #define CAPF_AAC_MPEG4 0x00000800 /* PNS */ 129 #define CAPF_AAC_DRC 0x00001000 130 #define CAPF_AAC_CONCEAL 0x00002000 131 #define CAPF_AAC_DRM_BSFORMAT 0x00004000 132 #define CAPF_AAC_BSAC 0x00008000 133 134 typedef struct AAC_DECODER_INSTANCE *HANDLE_AACDECODER; 135 136 137 enum 138 { 139 L = 0, 140 R = 1 141 }; 142 143 typedef struct { 144 unsigned char *buffer; 145 int bufferSize; 146 int offset[8]; 147 int nrElements; 148 } CAncData; 149 150 typedef enum { 151 NOT_DEFINED = -1, 152 MODE_HQ = 0, 153 MODE_LP = 1 154 } QMF_MODE; 155 156 typedef struct { 157 int bsDelay; 158 } SBR_PARAMS; 159 160 161 /* AAC decoder (opaque toward userland) struct declaration */ 162 struct AAC_DECODER_INSTANCE { 163 INT aacChannels; /*!< Amount of AAC decoder channels allocated. */ 164 INT ascChannels; /*!< Amount of AAC decoder channels signalled in ASC. */ 165 INT blockNumber; /*!< frame counter */ 166 167 INT nrOfLayers; 168 169 INT outputInterleaved; /*!< PCM output format (interleaved/none interleaved). */ 170 171 HANDLE_TRANSPORTDEC hInput; /*!< Transport layer handle. */ 172 173 SamplingRateInfo samplingRateInfo; /*!< Sampling Rate information table */ 174 175 UCHAR frameOK; /*!< Will be unset if a consistency check, e.g. CRC etc. fails */ 176 177 UINT flags; /*!< Flags for internal decoder use. DO NOT USE self::streaminfo::flags ! */ 178 179 MP4_ELEMENT_ID elements[7]; /*!< Table where the element Id's are listed */ 180 UCHAR elTags[7]; /*!< Table where the elements id Tags are listed */ 181 UCHAR chMapping[(6)]; /*!< Table of MPEG canonical order to bitstream channel order mapping. */ 182 183 AUDIO_CHANNEL_TYPE channelType[(6)]; /*!< Audio channel type of each output audio channel (from 0 upto numChannels). */ 184 UCHAR channelIndices[(6)]; /*!< Audio channel index for each output audio channel (from 0 upto numChannels). */ 185 /* See ISO/IEC 13818-7:2005(E), 8.5.3.2 Explicit channel mapping using a program_config_element() */ 186 187 188 const UCHAR (*channelOutputMapping)[8]; /*!< Table for MPEG canonical order to output channel order mapping. */ 189 190 191 CProgramConfig pce; 192 CStreamInfo streamInfo; /*!< pointer to StreamInfo data (read from the bitstream) */ 193 CAacDecoderChannelInfo *pAacDecoderChannelInfo[(6)]; /*!< Temporal channel memory */ 194 CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[(6)]; /*!< Persistent channel memory */ 195 196 CAacDecoderCommonData aacCommonData; /*!< Temporal shared data for all channels hooked into pAacDecoderChannelInfo */ 197 198 CConcealParams concealCommonData; 199 INT concealChannels; 200 201 202 HANDLE_SBRDECODER hSbrDecoder; /*!< SBR decoder handle. */ 203 UCHAR sbrEnabled; /*!< flag to store if SBR has been detected */ 204 UCHAR sbrEnabledPrev; /*!< flag to store if SBR has been detected from previous frame */ 205 UCHAR psPossible; /*!< flag to store if PS is possible */ 206 SBR_PARAMS sbrParams; /*!< struct to store all sbr parameters */ 207 208 QMF_MODE qmfModeCurr; /*!< The current QMF mode */ 209 QMF_MODE qmfModeUser; /*!< The QMF mode requested by the library user */ 210 211 HANDLE_AAC_DRC hDrcInfo; /*!< handle to DRC data structure */ 212 213 214 CAncData ancData; /*!< structure to handle ancillary data */ 215 216 HANDLE_PCM_DOWNMIX hPcmUtils; /*!< privat data for the PCM utils. */ 217 218 }; 219 220 221 #define AAC_DEBUG_EXTHLP "\ 222 --- AAC-Core ---\n\ 223 0x00010000 Header data\n\ 224 0x00020000 CRC data\n\ 225 0x00040000 Channel info\n\ 226 0x00080000 Section data\n\ 227 0x00100000 Scalefactor data\n\ 228 0x00200000 Pulse data\n\ 229 0x00400000 Tns data\n\ 230 0x00800000 Quantized spectrum\n\ 231 0x01000000 Requantized spectrum\n\ 232 0x02000000 Time output\n\ 233 0x04000000 Fatal errors\n\ 234 0x08000000 Buffer fullness\n\ 235 0x10000000 Average bitrate\n\ 236 0x20000000 Synchronization\n\ 237 0x40000000 Concealment\n\ 238 0x7FFF0000 all AAC-Core-Info\n\ 239 " 240 241 /** 242 * \brief Synchronise QMF mode for all modules using QMF data. 243 * \param self decoder handle 244 */ 245 void CAacDecoder_SyncQmfMode(HANDLE_AACDECODER self); 246 247 /** 248 * \brief Signal a bit stream interruption to the decoder 249 * \param self decoder handle 250 */ 251 void CAacDecoder_SignalInterruption(HANDLE_AACDECODER self); 252 253 /*! 254 \brief Initialize ancillary buffer 255 256 \ancData Pointer to ancillary data structure 257 \buffer Pointer to (external) anc data buffer 258 \size Size of the buffer pointed on by buffer 259 260 \return Error code 261 */ 262 AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData, unsigned char *buffer, int size); 263 264 /*! 265 \brief Get one ancillary data element 266 267 \ancData Pointer to ancillary data structure 268 \index Index of the anc data element to get 269 \ptr Pointer to a buffer receiving a pointer to the requested anc data element 270 \size Pointer to a buffer receiving the length of the requested anc data element 271 272 \return Error code 273 */ 274 AAC_DECODER_ERROR CAacDecoder_AncDataGet(CAncData *ancData, int index, unsigned char **ptr, int *size); 275 276 277 /* initialization of aac decoder */ 278 LINKSPEC_H HANDLE_AACDECODER CAacDecoder_Open(TRANSPORT_TYPE bsFormat); 279 280 /* Initialization of stream-info elements */ 281 LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, 282 const CSAudioSpecificConfig *asc); 283 284 /*! 285 \brief Decodes one aac frame 286 287 The function decodes one aac frame. The decoding of coupling channel 288 elements are not supported. The transport layer might signal, that the 289 data of the current frame is invalid, e.g. as a result of a packet 290 loss in streaming mode. 291 The bitstream position of transportDec_GetBitstream(self->hInput) must 292 be exactly the end of the access unit, including all byte alignment bits. 293 For this purpose, the variable auStartAnchor is used. 294 295 \return error status 296 */ 297 LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_DecodeFrame( 298 HANDLE_AACDECODER self, 299 const UINT flags, 300 INT_PCM *pTimeData, 301 const INT timeDataSize, 302 const INT interleaved 303 ); 304 305 /* Destroy aac decoder */ 306 LINKSPEC_H void CAacDecoder_Close ( HANDLE_AACDECODER self ); 307 308 /* get streaminfo handle from decoder */ 309 LINKSPEC_H CStreamInfo* CAacDecoder_GetStreamInfo ( HANDLE_AACDECODER self ); 310 311 312 #endif /* #ifndef AACDECODER_H */ 313