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 /************************  Fraunhofer IIS SBR decoder library ******************
     85 
     86    Author(s):
     87    Description: SBR decoder front-end prototypes and definitions.
     88 
     89 ******************************************************************************/
     90 
     91 #ifndef __SBRDECODER_H
     92 #define __SBRDECODER_H
     93 
     94 #include "common_fix.h"
     95 
     96 #include "FDK_bitstream.h"
     97 #include "FDK_audio.h"
     98 
     99 
    100 #define SBR_DEBUG_EXTHLP "\
    101 --- SBR ---\n\
    102     0x00000010 Ancillary data and SBR-Header\n\
    103     0x00000020 SBR-Side info\n\
    104     0x00000040 Decoded SBR-bitstream data, e.g. envelope data\n\
    105     0x00000080 SBR-Bitstream statistics\n\
    106     0x00000100 Miscellaneous SBR-messages\n\
    107     0x00000200 SBR-Energies and gains in the adjustor\n\
    108     0x00000400 Fatal SBR errors\n\
    109     0x00000800 Transposer coefficients for inverse filtering\n\
    110 "
    111 
    112 /* Capability flags */
    113 #define CAPF_SBR_LP          0x00000001   /*!< Flag indicating library's capability of Low Power mode.            */
    114 #define CAPF_SBR_HQ          0x00000002   /*!< Flag indicating library's capability of High Quality mode.         */
    115 #define CAPF_SBR_DRM_BS      0x00000004   /*!< Flag indicating library's capability to decode DRM SBR data.       */
    116 #define CAPF_SBR_CONCEALMENT 0x00000008   /*!< Flag indicating library's capability to conceal erroneous frames.  */
    117 #define CAPF_SBR_DRC         0x00000010   /*!< Flag indicating library's capability for Dynamic Range Control.    */
    118 #define CAPF_SBR_PS_MPEG     0x00000020   /*!< Flag indicating library's capability to do MPEG Parametric Stereo. */
    119 #define CAPF_SBR_PS_DRM      0x00000040   /*!< Flag indicating library's capability to do DRM Parametric Stereo.  */
    120 
    121 typedef enum
    122 {
    123   SBRDEC_OK = 0,                       /*!< All fine.                                                       */
    124   /* SBRDEC_CONCEAL,                                                                                        */
    125   /* SBRDEC_NOSYNCH,                                                                                        */
    126   /* SBRDEC_ILLEGAL_PROGRAM,                                                                                */
    127   /* SBRDEC_ILLEGAL_TAG,                                                                                    */
    128   /* SBRDEC_ILLEGAL_CHN_CONFIG,                                                                             */
    129   /* SBRDEC_ILLEGAL_SECTION,                                                                                */
    130   /* SBRDEC_ILLEGAL_SCFACTORS,                                                                              */
    131   /* SBRDEC_ILLEGAL_PULSE_DATA,                                                                             */
    132   /* SBRDEC_MAIN_PROFILE_NOT_IMPLEMENTED,                                                                   */
    133   /* SBRDEC_GC_NOT_IMPLEMENTED,                                                                             */
    134   /* SBRDEC_ILLEGAL_PLUS_ELE_ID,                                                                            */
    135   SBRDEC_CREATE_ERROR,                 /*!<                                                                 */
    136   SBRDEC_NOT_INITIALIZED,              /*!<                                                                 */
    137   SBRDEC_MEM_ALLOC_FAILED,             /*!< Memory allocation failed. Probably not enough memory available. */
    138   SBRDEC_PARSE_ERROR,                  /*!<                                                                 */
    139   SBRDEC_UNSUPPORTED_CONFIG,           /*!<                                                                 */
    140   SBRDEC_SET_PARAM_FAIL                /*!<                                                                 */
    141 } SBR_ERROR;
    142 
    143 typedef enum
    144 {
    145   SBR_SYSTEM_BITSTREAM_DELAY,          /*!< System: Switch to enable an additional SBR bitstream delay of one frame. */
    146   SBR_QMF_MODE,                        /*!< Set QMF mode, either complex or low power. */
    147   SBR_LD_QMF_TIME_ALIGN,               /*!< Set QMF type, either LD-MPS or CLDFB. Relevant for ELD streams only. */
    148   SBR_BS_INTERRUPTION                  /*!< Signal bit stream interruption. Value is ignored. */
    149 } SBRDEC_PARAM;
    150 
    151 typedef struct SBR_DECODER_INSTANCE *HANDLE_SBRDECODER;
    152 
    153 
    154 #ifdef __cplusplus
    155 extern "C"
    156 {
    157 #endif
    158 
    159 
    160 /**
    161  * \brief        Allocates and initializes one SBR decoder instance.
    162  * \param pSelf  Pointer to where a SBR decoder handle is copied into.
    163  * \return       Error code.
    164  */
    165 SBR_ERROR sbrDecoder_Open ( HANDLE_SBRDECODER *pSelf );
    166 
    167 /**
    168  * \brief  Initialize a SBR decoder runtime instance. Must be called before decoding starts.
    169  *
    170  * \param self             Handle to a SBR decoder instance.
    171  * \param sampleRateIn     Input samplerate of the SBR decoder instance.
    172  * \param sampleRateOut    Output samplerate of the SBR decoder instance.
    173  * \param samplesPerFrame  Number of samples per frames.
    174  * \param coreCodec        Audio Object Type (AOT) of the core codec.
    175  * \param elementID        Table with MPEG-4 element Ids in canonical order.
    176  * \param forceReset       Flag that enforces a complete decoder reset.
    177  *
    178  * \return  Error code.
    179  */
    180 SBR_ERROR sbrDecoder_InitElement (
    181         HANDLE_SBRDECODER       self,
    182         const int               sampleRateIn,
    183         const int               sampleRateOut,
    184         const int               samplesPerFrame,
    185         const AUDIO_OBJECT_TYPE coreCodec,
    186         const MP4_ELEMENT_ID    elementID,
    187         const int               elementIndex
    188         );
    189 
    190 /**
    191  * \brief pass out of band SBR header to SBR decoder
    192  *
    193  * \param self         Handle to a SBR decoder instance.
    194  * \param hBs          bit stream handle data source.
    195  * \param elementID    SBR element ID.
    196  * \param elementIndex SBR element index.
    197  *
    198  * \return  Error code.
    199  */
    200 INT sbrDecoder_Header (
    201         HANDLE_SBRDECODER       self,
    202         HANDLE_FDK_BITSTREAM    hBs,
    203         const INT sampleRateIn,
    204         const INT sampleRateOut,
    205         const INT samplesPerFrame,
    206         const AUDIO_OBJECT_TYPE coreCodec,
    207         const MP4_ELEMENT_ID    elementID,
    208         const INT               elementIndex
    209         );
    210 
    211 /**
    212  * \brief        Set a parameter of the SBR decoder runtime instance.
    213  * \param self   SBR decoder handle.
    214  * \param param  Parameter which will be set if successfull.
    215  * \param value  New parameter value.
    216  * \return       Error code.
    217  */
    218 SBR_ERROR sbrDecoder_SetParam ( HANDLE_SBRDECODER   self,
    219                                 const SBRDEC_PARAM  param,
    220                                 const INT           value );
    221 
    222 /**
    223  * \brief  Feed DRC channel data into a SBR decoder runtime instance.
    224  *
    225  * \param self                    SBR decoder handle.
    226  * \param ch                      Channel number to which the DRC data is associated to.
    227  * \param numBands                Number of DRC bands.
    228  * \param pNextFact_mag           Pointer to a table with the DRC factor magnitudes.
    229  * \param nextFact_exp            Exponent for all DRC factors.
    230  * \param drcInterpolationScheme  DRC interpolation scheme.
    231  * \param winSequence             Window sequence from core coder (eight short or one long window).
    232  * \param pBandTop                Pointer to a table with the top borders for all DRC bands.
    233  *
    234  * \return  Error code.
    235  */
    236 SBR_ERROR sbrDecoder_drcFeedChannel ( HANDLE_SBRDECODER  self,
    237                                       INT                ch,
    238                                       UINT               numBands,
    239                                       FIXP_DBL          *pNextFact_mag,
    240                                       INT                nextFact_exp,
    241                                       SHORT              drcInterpolationScheme,
    242                                       UCHAR              winSequence,
    243                                       USHORT            *pBandTop );
    244 
    245 /**
    246  * \brief  Disable SBR DRC for a certain channel.
    247  *
    248  * \param hSbrDecoder  SBR decoder handle.
    249  * \param ch           Number of the channel that has to be disabled.
    250  *
    251  * \return  None.
    252  */
    253 void sbrDecoder_drcDisable ( HANDLE_SBRDECODER  self,
    254                              INT                ch );
    255 
    256 
    257 /**
    258  * \brief  Parse one SBR element data extension data block. The bit stream position will
    259  *         be placed at the end of the SBR payload block. The remaining bits will be returned
    260  *         into *count if a payload length is given (byPayLen > 0). If no SBR payload length is
    261  *         given (bsPayLen < 0) then the bit stream position on return will be random after this
    262  *         function call in case of errors, and any further decoding will be completely pointless.
    263  *
    264  * \param self           SBR decoder handle.
    265  * \param hBs            Bit stream handle as data source.
    266  * \param count          Pointer to an integer where the amount of parsed SBR payload bits is stored into.
    267  * \param bsPayLen       If > 0 this value is the SBR payload length. If < 0, the SBR payload length is unknown.
    268  * \param flags          CRC flag (0: EXT_SBR_DATA; 1: EXT_SBR_DATA_CRC)
    269  * \param prev_element   Previous MPEG-4 element ID.
    270  * \param element_index  Index of the current element.
    271  *
    272  * \return  Error code.
    273  */
    274 SBR_ERROR sbrDecoder_Parse (
    275         HANDLE_SBRDECODER  self,
    276         HANDLE_FDK_BITSTREAM hBs,
    277         int *count,
    278         int  bsPayLen,
    279         int  crcFlag,
    280         MP4_ELEMENT_ID prev_element,
    281         int element_index,
    282         int fGlobalIndependencyFlag
    283         );
    284 
    285 /**
    286  * \brief  This function decodes the given SBR bitstreams and applies SBR to the given time data.
    287  *
    288  * SBR-processing works InPlace. I.e. the calling function has to provide
    289  * a time domain buffer timeData which can hold the completely decoded
    290  * result.
    291  *
    292  * Left and right channel are read and stored according to the
    293  * interleaving flag, frame length and number of channels.
    294  *
    295  * \param self            Handle of an open SBR decoder instance.
    296  * \param hSbrBs          SBR Bitstream handle.
    297  * \param timeData        Pointer to input and finally upsampled output data.
    298  * \param numChannels     Pointer to a buffer holding the number of channels in time data buffer.
    299  * \param sampleRate      Output samplerate.
    300  * \param channelMapping  Channel mapping indices.
    301  * \param interleaved     Flag indicating if time data is stored interleaved (1: Interleaved time data, 0: non-interleaved timedata).
    302  * \param coreDecodedOk   Flag indicating if the core decoder did not find any error (0: core decoder found errors, 1: no errors).
    303  * \param psDecoded       Pointer to a buffer holding a flag. Input: PS is possible, Output: PS has been rendered.
    304  *
    305  * \return  Error code.
    306  */
    307 SBR_ERROR sbrDecoder_Apply ( HANDLE_SBRDECODER    self,
    308                              INT_PCM             *timeData,
    309                              int                 *numChannels,
    310                              int                 *sampleRate,
    311                              const UCHAR          channelMapping[(6)],
    312                              const int            interleaved,
    313                              const int            coreDecodedOk,
    314                              UCHAR               *psDecoded );
    315 
    316 
    317 /**
    318  * \brief       Close SBR decoder instance and free memory.
    319  * \param self  SBR decoder handle.
    320  * \return      Error Code.
    321  */
    322 SBR_ERROR sbrDecoder_Close ( HANDLE_SBRDECODER *self );
    323 
    324 
    325 /**
    326  * \brief       Get SBR decoder library information.
    327  * \param info  Pointer to a LIB_INFO struct, where library information is written to.
    328  * \return      0 on success, -1 if invalid handle or if no free element is available to write information to.
    329  */
    330 INT sbrDecoder_GetLibInfo( LIB_INFO *info );
    331 
    332 
    333 #ifdef __cplusplus
    334 }
    335 #endif
    336 
    337 #endif
    338