Home | History | Annotate | Download | only in include
      1 
      2 /* -----------------------------------------------------------------------------------------------------------
      3 Software License for The Fraunhofer FDK AAC Codec Library for Android
      4 
      5  Copyright  1995 - 2013 Fraunhofer-Gesellschaft zur Frderung 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 (at) 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 
    123 typedef 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 
    178 typedef 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  */
    192 typedef 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 
    212 typedef 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 
    219 typedef 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  */
    236 typedef 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 
    276 typedef INT (*cbUpdateConfig_t)(void*, const CSAudioSpecificConfig*);
    277 typedef 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         );
    284 typedef 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 
    295 typedef 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 
    304 static const UINT SamplingRateTable[] =
    305 { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0,
    306   0
    307 };
    308 
    309 static inline
    310 int 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  */
    328 static 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 
    343 static inline
    344 int 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