Home | History | Annotate | Download | only in include
      1 /* -----------------------------------------------------------------------------
      2 Software License for The Fraunhofer FDK AAC Codec Library for Android
      3 
      4  Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Frderung der angewandten
      5 Forschung e.V. All rights reserved.
      6 
      7  1.    INTRODUCTION
      8 The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
      9 that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
     10 scheme for digital audio. This FDK AAC Codec software is intended to be used on
     11 a wide variety of Android devices.
     12 
     13 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
     14 general perceptual audio codecs. AAC-ELD is considered the best-performing
     15 full-bandwidth communications codec by independent studies and is widely
     16 deployed. AAC has been standardized by ISO and IEC as part of the MPEG
     17 specifications.
     18 
     19 Patent licenses for necessary patent claims for the FDK AAC Codec (including
     20 those of Fraunhofer) may be obtained through Via Licensing
     21 (www.vialicensing.com) or through the respective patent owners individually for
     22 the purpose of encoding or decoding bit streams in products that are compliant
     23 with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
     24 Android devices already license these patent claims through Via Licensing or
     25 directly from the patent owners, and therefore FDK AAC Codec software may
     26 already be covered under those patent licenses when it is used for those
     27 licensed purposes only.
     28 
     29 Commercially-licensed AAC software libraries, including floating-point versions
     30 with enhanced sound quality, are also available from Fraunhofer. Users are
     31 encouraged to check the Fraunhofer website for additional applications
     32 information and documentation.
     33 
     34 2.    COPYRIGHT LICENSE
     35 
     36 Redistribution and use in source and binary forms, with or without modification,
     37 are permitted without payment of copyright license fees provided that you
     38 satisfy the following conditions:
     39 
     40 You must retain the complete text of this software license in redistributions of
     41 the FDK AAC Codec or your modifications thereto in source code form.
     42 
     43 You must retain the complete text of this software license in the documentation
     44 and/or other materials provided with redistributions of the FDK AAC Codec or
     45 your modifications thereto in binary form. You must make available free of
     46 charge copies of the complete source code of the FDK AAC Codec and your
     47 modifications thereto to recipients of copies in binary form.
     48 
     49 The name of Fraunhofer may not be used to endorse or promote products derived
     50 from this library without prior written permission.
     51 
     52 You may not charge copyright license fees for anyone to use, copy or distribute
     53 the FDK AAC Codec software or your modifications thereto.
     54 
     55 Your modified versions of the FDK AAC Codec must carry prominent notices stating
     56 that you changed the software and the date of any change. For modified versions
     57 of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
     58 must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
     59 AAC Codec Library for Android."
     60 
     61 3.    NO PATENT LICENSE
     62 
     63 NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
     64 limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
     65 Fraunhofer provides no warranty of patent non-infringement with respect to this
     66 software.
     67 
     68 You may use this FDK AAC Codec software or modifications thereto only for
     69 purposes that are authorized by appropriate patent licenses.
     70 
     71 4.    DISCLAIMER
     72 
     73 This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
     74 holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
     75 including but not limited to the implied warranties of merchantability and
     76 fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
     77 CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
     78 or consequential damages, including but not limited to procurement of substitute
     79 goods or services; loss of use, data, or profits, or business interruption,
     80 however caused and on any theory of liability, whether in contract, strict
     81 liability, or tort (including negligence), arising in any way out of the use of
     82 this software, even if advised of the possibility of such damage.
     83 
     84 5.    CONTACT INFORMATION
     85 
     86 Fraunhofer Institute for Integrated Circuits IIS
     87 Attention: Audio and Multimedia Departments - FDK AAC LL
     88 Am Wolfsmantel 33
     89 91058 Erlangen, Germany
     90 
     91 www.iis.fraunhofer.de/amm
     92 amm-info (at) iis.fraunhofer.de
     93 ----------------------------------------------------------------------------- */
     94 
     95 /******************* MPEG transport format decoder library *********************
     96 
     97    Author(s):   Manuel Jander
     98 
     99    Description: MPEG Transport decoder
    100 
    101 *******************************************************************************/
    102 
    103 #ifndef TPDEC_LIB_H
    104 #define TPDEC_LIB_H
    105 
    106 #include "tp_data.h"
    107 
    108 #include "FDK_bitstream.h"
    109 
    110 typedef enum {
    111   TRANSPORTDEC_OK = 0, /*!< All fine. */
    112 
    113   /* Synchronization errors. Wait for new input data and try again. */
    114   tpdec_sync_error_start = 0x100,
    115   TRANSPORTDEC_NOT_ENOUGH_BITS, /*!< Out of bits. Provide more bits and try
    116                                    again.              */
    117   TRANSPORTDEC_SYNC_ERROR, /*!< No sync was found or sync got lost. Keep trying.
    118                             */
    119   tpdec_sync_error_end,
    120 
    121   /* Decode errors. Mostly caused due to bit errors. */
    122   tpdec_decode_error_start = 0x400,
    123   TRANSPORTDEC_PARSE_ERROR, /*!< Bitstream data showed inconsistencies (wrong
    124                                syntax).      */
    125   TRANSPORTDEC_UNSUPPORTED_FORMAT, /*!< Unsupported format or feature found in
    126                                       the bitstream data. */
    127   TRANSPORTDEC_CRC_ERROR, /*!< CRC error encountered in bitstream data. */
    128   tpdec_decode_error_end,
    129 
    130   /* Fatal errors. Stop immediately on one of these errors! */
    131   tpdec_fatal_error_start = 0x200,
    132   TRANSPORTDEC_UNKOWN_ERROR,      /*!< An unknown error occured.      */
    133   TRANSPORTDEC_INVALID_PARAMETER, /*!< An invalid parameter was passed to a
    134                                      function.             */
    135   TRANSPORTDEC_NEED_TO_RESTART,   /*!< The decoder needs to be restarted, since
    136                                      the requiered   configuration change cannot
    137                                      be   performed.                  */
    138   TRANSPORTDEC_TOO_MANY_BITS,     /*!< In case of packet based formats: Supplied
    139                                      number of bits     exceed the size of the
    140                                      internal     bit buffer.                */
    141   tpdec_fatal_error_end
    142 
    143 } TRANSPORTDEC_ERROR;
    144 
    145 /** Macro to identify decode errors. */
    146 #define TPDEC_IS_DECODE_ERROR(err)                                            \
    147   (((err >= tpdec_decode_error_start) && (err <= tpdec_decode_error_end)) ? 1 \
    148                                                                           : 0)
    149 /** Macro to identify fatal errors. */
    150 #define TPDEC_IS_FATAL_ERROR(err) \
    151   (((err >= tpdec_fatal_error_start) && (err <= tpdec_fatal_error_end)) ? 1 : 0)
    152 
    153 /**
    154  * \brief Parameter identifiers for transportDec_SetParam()
    155  */
    156 typedef enum {
    157   TPDEC_PARAM_MINIMIZE_DELAY = 1, /** Delay minimization strategy. 0: none, 1:
    158                                      discard as many frames as possible. */
    159   TPDEC_PARAM_EARLY_CONFIG,       /** Enable early config discovery. */
    160   TPDEC_PARAM_IGNORE_BUFFERFULLNESS, /** Ignore buffer fullness. */
    161   TPDEC_PARAM_SET_BITRATE,  /** Set average bit rate for bit stream interruption
    162                                frame misses estimation. */
    163   TPDEC_PARAM_RESET,        /** Reset transport decoder instance status. */
    164   TPDEC_PARAM_BURST_PERIOD, /** Set data reception burst period in mili seconds.
    165                              */
    166   TPDEC_PARAM_TARGETLAYOUT, /** Set CICP target layout */
    167   TPDEC_PARAM_FORCE_CONFIG_CHANGE, /** Force config change for next received
    168                                       config */
    169   TPDEC_PARAM_USE_ELEM_SKIPPING
    170 } TPDEC_PARAM;
    171 
    172 /*!
    173   \brief               Reset Program Config Element.
    174   \param pPce          Program Config Element structure.
    175   \return              void
    176 */
    177 void CProgramConfig_Reset(CProgramConfig *pPce);
    178 
    179 /*!
    180   \brief               Initialize Program Config Element.
    181   \param pPce          Program Config Element structure.
    182   \return              void
    183 */
    184 void CProgramConfig_Init(CProgramConfig *pPce);
    185 
    186 /*!
    187   \brief               Inquire state of present Program Config Element
    188   structure. \param pPce          Program Config Element structure. \return
    189   1 if the PCE structure is filled correct, 0 if no valid PCE present.
    190 */
    191 int CProgramConfig_IsValid(const CProgramConfig *pPce);
    192 
    193 /*!
    194   \brief               Read Program Config Element.
    195   \param pPce          Program Config Element structure.
    196   \param bs            Bitstream buffer to read from.
    197   \param alignAnchor   Align bitstream to alignAnchor bits after all read
    198   operations. \return              void
    199 */
    200 void CProgramConfig_Read(CProgramConfig *pPce, HANDLE_FDK_BITSTREAM bs,
    201                          UINT alignAnchor);
    202 
    203 /*!
    204   \brief               Compare two Program Config Elements.
    205   \param pPce1         Pointer to first Program Config Element structure.
    206   \param pPce2         Pointer to second Program Config Element structure.
    207   \return              -1 if PCEs are completely different,
    208                         0 if PCEs are completely equal,
    209                         1 if PCEs are different but have the same channel
    210   config, 2 if PCEs have different channel config but same number of channels.
    211 */
    212 int CProgramConfig_Compare(const CProgramConfig *const pPce1,
    213                            const CProgramConfig *const pPce2);
    214 
    215 /*!
    216   \brief               Get a Program Config Element that matches the predefined
    217   MPEG-4 channel configurations 1-14. \param pPce          Program Config
    218   Element structure. \param channelConfig MPEG-4 channel configuration. \return
    219   void
    220 */
    221 void CProgramConfig_GetDefault(CProgramConfig *pPce, const UINT channelConfig);
    222 
    223 /**
    224  * \brief Lookup and verify a given element. The decoder calls this
    225  *        method with every new element ID found in the bitstream.
    226  *
    227  * \param pPce        A valid Program config structure.
    228  * \param chConfig    MPEG-4 channel configuration.
    229  * \param tag         Tag of the current element to be looked up.
    230  * \param channelIdx  The current channel count of the decoder parser.
    231  * \param chMapping   Array to store the canonical channel mapping indexes.
    232  * \param chType      Array to store the audio channel type.
    233  * \param chIndex     Array to store the individual audio channel type index.
    234  * \param chDescrLen  Length of the output channel description array.
    235  * \param elMapping   Pointer where the canonical element index is stored.
    236  * \param elType      The element id of the current element to be looked up.
    237  *
    238  * \return            Non-zero if the element belongs to the current program,
    239  * zero if it does not.
    240  */
    241 int CProgramConfig_LookupElement(CProgramConfig *pPce, UINT chConfig,
    242                                  const UINT tag, const UINT channelIdx,
    243                                  UCHAR chMapping[], AUDIO_CHANNEL_TYPE chType[],
    244                                  UCHAR chIndex[], const UINT chDescrLen,
    245                                  UCHAR *elMapping, MP4_ELEMENT_ID elList[],
    246                                  MP4_ELEMENT_ID elType);
    247 
    248 /**
    249  * \brief             Get table of channel indices in the order of their
    250  * appearance in by the program config field.
    251  * \param pPce        A valid program config structure.
    252  * \param pceChMap    Array to store the channel mapping indices like they
    253  * appear in the PCE.
    254  * \param pceChMapLen Lenght of the channel mapping index array (pceChMap).
    255  *
    256  * \return            Non-zero if any error occured otherwise zero.
    257  */
    258 int CProgramConfig_GetPceChMap(const CProgramConfig *pPce, UCHAR pceChMap[],
    259                                const UINT pceChMapLen);
    260 
    261 /**
    262  * \brief             Get table of elements in canonical order from a
    263  *                    give program config field.
    264  * \param pPce        A valid program config structure.
    265  * \param table       An array where the element IDs are stored.
    266  * \param elListSize  The length of the table array.
    267  * \param pChMapIdx   Pointer to a field receiving the corresponding
    268  *                    implicit channel configuration index of the given
    269  *                    PCE. If none can be found it receives the value 0.
    270  * \return            Total element count including all SCE, CPE and LFE.
    271  */
    272 int CProgramConfig_GetElementTable(const CProgramConfig *pPce,
    273                                    MP4_ELEMENT_ID table[], const INT elListSize,
    274                                    UCHAR *pChMapIdx);
    275 
    276 /**
    277  * \brief          Get channel description (type and index) for implicit
    278                    configurations (chConfig > 0) in MPEG canonical order.
    279  * \param chConfig MPEG-4 channel configuration.
    280  * \param chType   Array to store the audio channel type.
    281  * \param chIndex  Array to store the individual audio channel type index.
    282  * \return         void
    283  */
    284 void CProgramConfig_GetChannelDescription(const UINT chConfig,
    285                                           const CProgramConfig *pPce,
    286                                           AUDIO_CHANNEL_TYPE chType[],
    287                                           UCHAR chIndex[]);
    288 
    289 /**
    290  * \brief       Initialize a given AudioSpecificConfig structure.
    291  * \param pAsc  A pointer to an allocated CSAudioSpecificConfig struct.
    292  * \return      void
    293  */
    294 void AudioSpecificConfig_Init(CSAudioSpecificConfig *pAsc);
    295 
    296 /**
    297  * \brief   Parse a AudioSpecificConfig from a given bitstream handle.
    298  *
    299  * \param pAsc                         A pointer to an allocated
    300  * CSAudioSpecificConfig struct.
    301  * \param hBs                          Bitstream handle.
    302  * \param fExplicitBackwardCompatible  Do explicit backward compatibility
    303  * parsing if set (flag).
    304  * \param cb pointer to structure holding callback information
    305  * \param configMode Config modes: memory allocation mode or config change
    306  * detection mode.
    307  * \param configChanged Indicates a config change.
    308  * \param m_aot in case of unequal AOT_NULL_OBJECT only the specific config is
    309  * parsed.
    310  *
    311  * \return  Total element count including all SCE, CPE and LFE.
    312  */
    313 TRANSPORTDEC_ERROR AudioSpecificConfig_Parse(
    314     CSAudioSpecificConfig *pAsc, HANDLE_FDK_BITSTREAM hBs,
    315     int fExplicitBackwardCompatible, CSTpCallBacks *cb, UCHAR configMode,
    316     UCHAR configChanged, AUDIO_OBJECT_TYPE m_aot);
    317 
    318 /* CELP stuff */
    319 enum { MPE = 0, RPE = 1, fs8KHz = 0, fs16KHz = 1 };
    320 
    321 /* Defintion of flags that can be passed to transportDecOpen() */
    322 #define TP_FLAG_MPEG4 1
    323 
    324 /* Capability flags */
    325 #define CAPF_TPDEC_ADIF \
    326   0x00001000 /**< Flag indicating support for ADIF transport format.        */
    327 #define CAPF_TPDEC_ADTS \
    328   0x00002000 /**< Flag indicating support for ADTS transport format.        */
    329 #define CAPF_TPDEC_LOAS \
    330   0x00004000 /**< Flag indicating support for LOAS transport format.        */
    331 #define CAPF_TPDEC_LATM \
    332   0x00008000 /**< Flag indicating support for LATM transport format.        */
    333 #define CAPF_TPDEC_RAWPACKETS \
    334   0x00010000 /**< Flag indicating support for raw packets transport format. */
    335 
    336 typedef struct TRANSPORTDEC *HANDLE_TRANSPORTDEC;
    337 
    338 /**
    339  * \brief Configure Transport Decoder via a binary coded AudioSpecificConfig or
    340  * StreamMuxConfig. The previously requested configuration callback will be
    341  * called as well. The buffer conf must containt a SMC in case of
    342  * LOAS/LATM transport format, and an ASC elseways.
    343  *
    344  * \param hTp     Handle of a transport decoder.
    345  * \param conf    UCHAR buffer of the binary coded config (ASC or SMC).
    346  * \param length  The length in bytes of the conf buffer.
    347  *
    348  * \return        Error code.
    349  */
    350 TRANSPORTDEC_ERROR transportDec_OutOfBandConfig(const HANDLE_TRANSPORTDEC hTp,
    351                                                 UCHAR *conf, const UINT length,
    352                                                 const UINT layer);
    353 
    354 /**
    355  * \brief Configure Transport Decoder via a binary coded USAC/RSV603DA Config.
    356  *        The buffer newConfig contains a binary coded USAC/RSV603DA config of
    357  * length newConfigLength bytes. If the new config and the previous config are
    358  * different configChanged is set to 1 otherwise it is set to 0.
    359  *
    360  * \param hTp              Handle of a transport decoder.
    361  * \param newConfig        buffer of the binary coded config.
    362  * \param newConfigLength  Length of new config in bytes.
    363  * \param buildUpStatus    Indicates build up status: off|on|idle.
    364  * \param configChanged    Indicates if config changed.
    365  * \param layer            Instance layer.
    366  *
    367  * \return        Error code.
    368  */
    369 TRANSPORTDEC_ERROR transportDec_InBandConfig(
    370     const HANDLE_TRANSPORTDEC hTp, UCHAR *newConfig, const UINT newConfigLength,
    371     const UCHAR buildUpStatus, UCHAR *configChanged, const UINT layer,
    372     UCHAR *implicitExplicitCfgDiff);
    373 
    374 /**
    375  * \brief Open Transport medium for reading.
    376  *
    377  * \param transportDecFmt Format of the transport decoder medium to be accessed.
    378  * \param flags           Transport decoder flags. Currently only TP_FLAG_MPEG4,
    379  * which signals a MPEG4 capable decoder (relevant for ADTS only).
    380  *
    381  * \return   A pointer to a valid and allocated HANDLE_TRANSPORTDEC or a null
    382  * pointer on failure.
    383  */
    384 HANDLE_TRANSPORTDEC transportDec_Open(TRANSPORT_TYPE transportDecFmt,
    385                                       const UINT flags, const UINT nrOfLayer);
    386 
    387 /**
    388  * \brief                Register configuration change callback.
    389  * \param hTp            Handle of transport decoder.
    390  * \param cbUpdateConfig Pointer to a callback function to handle audio config
    391  * changes.
    392  * \param user_data      void pointer for user data passed to the callback as
    393  * first parameter.
    394  * \return               0 on success.
    395  */
    396 int transportDec_RegisterAscCallback(HANDLE_TRANSPORTDEC hTp,
    397                                      const cbUpdateConfig_t cbUpdateConfig,
    398                                      void *user_data);
    399 
    400 /**
    401  * \brief                Register free memory callback.
    402  * \param hTp            Handle of transport decoder.
    403  * \param cbFreeMem      Pointer to a callback function to free config dependent
    404  * memory.
    405  * \param user_data      void pointer for user data passed to the callback as
    406  * first parameter.
    407  * \return               0 on success.
    408  */
    409 int transportDec_RegisterFreeMemCallback(HANDLE_TRANSPORTDEC hTp,
    410                                          const cbFreeMem_t cbFreeMem,
    411                                          void *user_data);
    412 
    413 /**
    414  * \brief                 Register config change control callback.
    415  * \param hTp             Handle of transport decoder.
    416  * \param cbCtrlCFGChange Pointer to a callback function for config change
    417  * control.
    418  * \param user_data       void pointer for user data passed to the callback as
    419  * first parameter.
    420  * \return                0 on success.
    421  */
    422 int transportDec_RegisterCtrlCFGChangeCallback(
    423     HANDLE_TRANSPORTDEC hTp, const cbCtrlCFGChange_t cbCtrlCFGChange,
    424     void *user_data);
    425 
    426 /**
    427  * \brief                Register SSC parser callback.
    428  * \param hTp            Handle of transport decoder.
    429  * \param cbUpdateConfig Pointer to a callback function to handle SSC parsing.
    430  * \param user_data      void pointer for user data passed to the callback as
    431  * first parameter.
    432  * \return               0 on success.
    433  */
    434 int transportDec_RegisterSscCallback(HANDLE_TRANSPORTDEC hTp,
    435                                      const cbSsc_t cbSscParse, void *user_data);
    436 
    437 /**
    438  * \brief                Register SBR header parser callback.
    439  * \param hTp            Handle of transport decoder.
    440  * \param cbUpdateConfig Pointer to a callback function to handle SBR header
    441  * parsing.
    442  * \param user_data      void pointer for user data passed to the callback as
    443  * first parameter.
    444  * \return               0 on success.
    445  */
    446 int transportDec_RegisterSbrCallback(HANDLE_TRANSPORTDEC hTpDec,
    447                                      const cbSbr_t cbSbr, void *user_data);
    448 
    449 /**
    450  * \brief                Register USAC SC parser callback.
    451  * \param hTp            Handle of transport decoder.
    452  * \param cbUpdateConfig Pointer to a callback function to handle USAC SC
    453  * parsing.
    454  * \param user_data      void pointer for user data passed to the callback as
    455  * first parameter.
    456  * \return               0 on success.
    457  */
    458 int transportDec_RegisterUsacCallback(HANDLE_TRANSPORTDEC hTpDec,
    459                                       const cbUsac_t cbUsac, void *user_data);
    460 
    461 /**
    462  * \brief                Register uniDrcConfig and loudnessInfoSet parser
    463  * callback.
    464  * \param hTp            Handle of transport decoder.
    465  * \param cbUpdateConfig Pointer to a callback function to handle uniDrcConfig
    466  * and loudnessInfoSet parsing.
    467  * \param user_data      void pointer for user data passed to the callback as
    468  * first parameter.
    469  * \return               0 on success.
    470  */
    471 int transportDec_RegisterUniDrcConfigCallback(HANDLE_TRANSPORTDEC hTpDec,
    472                                               const cbUniDrc_t cbUniDrc,
    473                                               void *user_data,
    474                                               UINT *pLoudnessInfoSetPosition);
    475 
    476 /**
    477  * \brief Fill internal input buffer with bitstream data from the external input
    478  * buffer. The function only copies such data as long as the decoder-internal
    479  * input buffer is not full. So it grabs whatever it can from pBuffer and
    480  * returns information (bytesValid) so that at a subsequent call of
    481  * %transportDec_FillData(), the right position in pBuffer can be determined to
    482  *  grab the next data.
    483  *
    484  * \param hTp         Handle of transportDec.
    485  * \param pBuffer     Pointer to external input buffer.
    486  * \param bufferSize  Size of external input buffer. This argument is required
    487  * because decoder-internally we need the information to calculate the offset to
    488  * pBuffer, where the next available data is, which is then
    489  * fed into the decoder-internal buffer (as much as
    490  * possible). Our example framework implementation fills the
    491  * buffer at pBuffer again, once it contains no available valid bytes anymore
    492  * (meaning bytesValid equal 0).
    493  * \param bytesValid  Number of bitstream bytes in the external bitstream buffer
    494  * that have not yet been copied into the decoder's internal bitstream buffer by
    495  * calling this function. The value is updated according to
    496  * the amount of newly copied bytes.
    497  * \param layer       The layer the bitstream belongs to.
    498  * \return            Error code.
    499  */
    500 TRANSPORTDEC_ERROR transportDec_FillData(const HANDLE_TRANSPORTDEC hTp,
    501                                          UCHAR *pBuffer, const UINT bufferSize,
    502                                          UINT *pBytesValid, const INT layer);
    503 
    504 /**
    505  * \brief      Get transportDec bitstream handle.
    506  * \param hTp  Pointer to a transport decoder handle.
    507  * \return     HANDLE_FDK_BITSTREAM bitstream handle.
    508  */
    509 HANDLE_FDK_BITSTREAM transportDec_GetBitstream(const HANDLE_TRANSPORTDEC hTp,
    510                                                const UINT layer);
    511 
    512 /**
    513  * \brief      Get transport format.
    514  * \param hTp  Pointer to a transport decoder handle.
    515  * \return     The transport format.
    516  */
    517 TRANSPORT_TYPE transportDec_GetFormat(const HANDLE_TRANSPORTDEC hTp);
    518 
    519 /**
    520  * \brief Get the current buffer fullness value.
    521  *
    522  * \param hTp     Handle of a transport decoder.
    523  *
    524  * \return        Buffer fullness
    525  */
    526 INT transportDec_GetBufferFullness(const HANDLE_TRANSPORTDEC hTp);
    527 
    528 /**
    529  * \brief       Close and deallocate transportDec.
    530  * \param phTp  Pointer to a previously allocated transport decoder handle.
    531  * \return      void
    532  */
    533 void transportDec_Close(HANDLE_TRANSPORTDEC *phTp);
    534 
    535 /**
    536  * \brief         Read one access unit from the transportDec medium.
    537  * \param hTp     Handle of transportDec.
    538  * \param length  On return, this value is overwritten with the actual access
    539  * unit length in bits. Set to -1 if length is unknown.
    540  * \return        Error code.
    541  */
    542 TRANSPORTDEC_ERROR transportDec_ReadAccessUnit(const HANDLE_TRANSPORTDEC hTp,
    543                                                const UINT layer);
    544 
    545 /**
    546  * \brief          Get AudioSpecificConfig.
    547  * \param hTp      Handle of transportDec.
    548  * \param layer    Transport layer.
    549  * \param asc      Pointer to AudioSpecificConfig.
    550  * \return         Error code.
    551  */
    552 TRANSPORTDEC_ERROR transportDec_GetAsc(const HANDLE_TRANSPORTDEC hTp,
    553                                        const UINT layer,
    554                                        CSAudioSpecificConfig *asc);
    555 
    556 /**
    557  * \brief Get the remaining amount of bits of the current access unit. The
    558  * result can be below zero, meaning that too many bits have been read.
    559  * \param hTp     Handle of transportDec.
    560  * \return amount of remaining bits.
    561  */
    562 INT transportDec_GetAuBitsRemaining(const HANDLE_TRANSPORTDEC hTp,
    563                                     const UINT layer);
    564 
    565 /**
    566  * \brief Get the total amount of bits of the current access unit.
    567  * \param hTp     Handle of transportDec.
    568  * \return amount of total bits.
    569  */
    570 INT transportDec_GetAuBitsTotal(const HANDLE_TRANSPORTDEC hTp,
    571                                 const UINT layer);
    572 
    573 /**
    574  * \brief      This function is required to be called when the decoder has
    575  * finished parsing one Access Unit for bitstream housekeeping.
    576  * \param hTp  Transport Handle.
    577  * \return     Error code.
    578  */
    579 TRANSPORTDEC_ERROR transportDec_EndAccessUnit(const HANDLE_TRANSPORTDEC hTp);
    580 
    581 /**
    582  * \brief      Obtain the amount of missing access units if applicable in case
    583  * of a bit stream synchronization error. Each time
    584  * transportDec_ReadAccessUnit() returns TRANSPORTDEC_SYNC_ERROR
    585  * this function can be called to retrieve an estimate of the amount
    586  * of missing access units. This works only in case of constant
    587  * average bit rate (has to be known) and if the parameter
    588  * TPDEC_PARAM_SET_BITRATE has been set accordingly.
    589  * \param hTp  Transport Handle.
    590  * \param pNAccessUnits pointer to a memory location where the estimated lost
    591  * frame count will be stored into.
    592  * \return     Error code.
    593  */
    594 TRANSPORTDEC_ERROR transportDec_GetMissingAccessUnitCount(
    595     INT *pNAccessUnits, HANDLE_TRANSPORTDEC hTp);
    596 
    597 /**
    598  * \brief        Set a given setting.
    599  * \param hTp    Transport Handle.
    600  * \param param  Identifier of the parameter to be changed.
    601  * \param value  Value for the parameter to be changed.
    602  * \return       Error code.
    603  */
    604 TRANSPORTDEC_ERROR transportDec_SetParam(const HANDLE_TRANSPORTDEC hTp,
    605                                          const TPDEC_PARAM param,
    606                                          const INT value);
    607 
    608 /**
    609  * \brief        Get number of subframes (for LATM or ADTS)
    610  * \param hTp    Transport Handle.
    611  * \return       Number of ADTS/LATM subframes (return 1 for all other transport
    612  * types).
    613  */
    614 UINT transportDec_GetNrOfSubFrames(HANDLE_TRANSPORTDEC hTp);
    615 
    616 /**
    617  * \brief       Get info structure of transport decoder library.
    618  * \param info  A pointer to an allocated LIB_INFO struct.
    619  * \return      Error code.
    620  */
    621 TRANSPORTDEC_ERROR transportDec_GetLibInfo(LIB_INFO *info);
    622 
    623 /* ADTS CRC support */
    624 
    625 /**
    626  * \brief        Set current bitstream position as start of a new data region.
    627  * \param hTp    Transport handle.
    628  * \param mBits  Size in bits of the data region. Set to 0 if it should not be
    629  * of a fixed size.
    630  * \return       Data region ID, which should be used when calling
    631  * transportDec_CrcEndReg().
    632  */
    633 int transportDec_CrcStartReg(const HANDLE_TRANSPORTDEC hTp, const INT mBits);
    634 
    635 /**
    636  * \brief        Set end of data region.
    637  * \param hTp    Transport handle.
    638  * \param reg    Data region ID, opbtained from transportDec_CrcStartReg().
    639  * \return       void
    640  */
    641 void transportDec_CrcEndReg(const HANDLE_TRANSPORTDEC hTp, const INT reg);
    642 
    643 /**
    644  * \brief      Calculate ADTS crc and check if it is correct. The ADTS checksum
    645  * is held internally.
    646  * \param hTp  Transport handle.
    647  * \return     Return TRANSPORTDEC_OK if the CRC is ok, or error if CRC is not
    648  * correct.
    649  */
    650 TRANSPORTDEC_ERROR transportDec_CrcCheck(const HANDLE_TRANSPORTDEC hTp);
    651 
    652 /**
    653  * \brief Only check whether a given config seems to be valid without modifying
    654  * internal states.
    655  *
    656  * \param conf    UCHAR buffer of the binary coded config (SDC type 9).
    657  * \param length  The length in bytes of the conf buffer.
    658  *
    659  * \return        Error code.
    660  */
    661 TRANSPORTDEC_ERROR transportDec_DrmRawSdcAudioConfig_Check(UCHAR *conf,
    662                                                            const UINT length);
    663 
    664 #endif /* #ifndef TPDEC_LIB_H */
    665