diff options
Diffstat (limited to 'fdk-aac/libMpegTPEnc/include')
-rw-r--r-- | fdk-aac/libMpegTPEnc/include/tp_data.h | 466 | ||||
-rw-r--r-- | fdk-aac/libMpegTPEnc/include/tpenc_lib.h | 339 |
2 files changed, 805 insertions, 0 deletions
diff --git a/fdk-aac/libMpegTPEnc/include/tp_data.h b/fdk-aac/libMpegTPEnc/include/tp_data.h new file mode 100644 index 0000000..00de356 --- /dev/null +++ b/fdk-aac/libMpegTPEnc/include/tp_data.h @@ -0,0 +1,466 @@ +/* ----------------------------------------------------------------------------- +Software License for The Fraunhofer FDK AAC Codec Library for Android + +© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +Forschung e.V. All rights reserved. + + 1. INTRODUCTION +The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software +that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding +scheme for digital audio. This FDK AAC Codec software is intended to be used on +a wide variety of Android devices. + +AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient +general perceptual audio codecs. AAC-ELD is considered the best-performing +full-bandwidth communications codec by independent studies and is widely +deployed. AAC has been standardized by ISO and IEC as part of the MPEG +specifications. + +Patent licenses for necessary patent claims for the FDK AAC Codec (including +those of Fraunhofer) may be obtained through Via Licensing +(www.vialicensing.com) or through the respective patent owners individually for +the purpose of encoding or decoding bit streams in products that are compliant +with the ISO/IEC MPEG audio standards. Please note that most manufacturers of +Android devices already license these patent claims through Via Licensing or +directly from the patent owners, and therefore FDK AAC Codec software may +already be covered under those patent licenses when it is used for those +licensed purposes only. + +Commercially-licensed AAC software libraries, including floating-point versions +with enhanced sound quality, are also available from Fraunhofer. Users are +encouraged to check the Fraunhofer website for additional applications +information and documentation. + +2. COPYRIGHT LICENSE + +Redistribution and use in source and binary forms, with or without modification, +are permitted without payment of copyright license fees provided that you +satisfy the following conditions: + +You must retain the complete text of this software license in redistributions of +the FDK AAC Codec or your modifications thereto in source code form. + +You must retain the complete text of this software license in the documentation +and/or other materials provided with redistributions of the FDK AAC Codec or +your modifications thereto in binary form. You must make available free of +charge copies of the complete source code of the FDK AAC Codec and your +modifications thereto to recipients of copies in binary form. + +The name of Fraunhofer may not be used to endorse or promote products derived +from this library without prior written permission. + +You may not charge copyright license fees for anyone to use, copy or distribute +the FDK AAC Codec software or your modifications thereto. + +Your modified versions of the FDK AAC Codec must carry prominent notices stating +that you changed the software and the date of any change. For modified versions +of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android" +must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK +AAC Codec Library for Android." + +3. NO PATENT LICENSE + +NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without +limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE. +Fraunhofer provides no warranty of patent non-infringement with respect to this +software. + +You may use this FDK AAC Codec software or modifications thereto only for +purposes that are authorized by appropriate patent licenses. + +4. DISCLAIMER + +This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright +holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, +including but not limited to the implied warranties of merchantability and +fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, +or consequential damages, including but not limited to procurement of substitute +goods or services; loss of use, data, or profits, or business interruption, +however caused and on any theory of liability, whether in contract, strict +liability, or tort (including negligence), arising in any way out of the use of +this software, even if advised of the possibility of such damage. + +5. CONTACT INFORMATION + +Fraunhofer Institute for Integrated Circuits IIS +Attention: Audio and Multimedia Departments - FDK AAC LL +Am Wolfsmantel 33 +91058 Erlangen, Germany + +www.iis.fraunhofer.de/amm +amm-info@iis.fraunhofer.de +----------------------------------------------------------------------------- */ + +/******************* MPEG transport format encoder library ********************* + + Author(s): Manuel Jander + + Description: MPEG Transport data tables + +*******************************************************************************/ + +#ifndef TP_DATA_H +#define TP_DATA_H + +#include "machine_type.h" +#include "FDK_audio.h" +#include "FDK_bitstream.h" + +/* + * Configuration + */ + +#define TP_USAC_MAX_SPEAKERS (24) + +#define TP_USAC_MAX_EXT_ELEMENTS ((24)) + +#define TP_USAC_MAX_ELEMENTS ((24) + TP_USAC_MAX_EXT_ELEMENTS) + +#define TP_USAC_MAX_CONFIG_LEN \ + 512 /* next power of two of maximum of escapedValue(hBs, 4, 4, 8) in \ + AudioPreRoll() (285) */ + +#define TPDEC_USAC_NUM_CONFIG_CHANGE_FRAMES \ + (1) /* Number of frames for config change in USAC */ + +enum { + TPDEC_FLUSH_OFF = 0, + TPDEC_RSV60_CFG_CHANGE_ATSC_FLUSH_ON = 1, + TPDEC_RSV60_DASH_IPF_ATSC_FLUSH_ON = 2, + TPDEC_USAC_DASH_IPF_FLUSH_ON = 3 +}; + +enum { + TPDEC_BUILD_UP_OFF = 0, + TPDEC_RSV60_BUILD_UP_ON = 1, + TPDEC_RSV60_BUILD_UP_ON_IN_BAND = 2, + TPDEC_USAC_BUILD_UP_ON = 3, + TPDEC_RSV60_BUILD_UP_IDLE = 4, + TPDEC_RSV60_BUILD_UP_IDLE_IN_BAND = 5 +}; + +/** + * ProgramConfig struct. + */ +/* ISO/IEC 14496-3 4.4.1.1 Table 4.2 Program config element */ +#define PC_FSB_CHANNELS_MAX 16 /* Front/Side/Back channels */ +#define PC_LFE_CHANNELS_MAX 4 +#define PC_ASSOCDATA_MAX 8 +#define PC_CCEL_MAX 16 /* CC elements */ +#define PC_COMMENTLENGTH 256 +#define PC_NUM_HEIGHT_LAYER 3 + +typedef struct { + /* PCE bitstream elements: */ + UCHAR ElementInstanceTag; + UCHAR Profile; + UCHAR SamplingFrequencyIndex; + UCHAR NumFrontChannelElements; + UCHAR NumSideChannelElements; + UCHAR NumBackChannelElements; + UCHAR NumLfeChannelElements; + UCHAR NumAssocDataElements; + UCHAR NumValidCcElements; + + UCHAR MonoMixdownPresent; + UCHAR MonoMixdownElementNumber; + + UCHAR StereoMixdownPresent; + UCHAR StereoMixdownElementNumber; + + UCHAR MatrixMixdownIndexPresent; + UCHAR MatrixMixdownIndex; + UCHAR PseudoSurroundEnable; + + UCHAR FrontElementIsCpe[PC_FSB_CHANNELS_MAX]; + UCHAR FrontElementTagSelect[PC_FSB_CHANNELS_MAX]; + UCHAR FrontElementHeightInfo[PC_FSB_CHANNELS_MAX]; + + UCHAR SideElementIsCpe[PC_FSB_CHANNELS_MAX]; + UCHAR SideElementTagSelect[PC_FSB_CHANNELS_MAX]; + UCHAR SideElementHeightInfo[PC_FSB_CHANNELS_MAX]; + + UCHAR BackElementIsCpe[PC_FSB_CHANNELS_MAX]; + UCHAR BackElementTagSelect[PC_FSB_CHANNELS_MAX]; + UCHAR BackElementHeightInfo[PC_FSB_CHANNELS_MAX]; + + UCHAR LfeElementTagSelect[PC_LFE_CHANNELS_MAX]; + + UCHAR AssocDataElementTagSelect[PC_ASSOCDATA_MAX]; + + UCHAR CcElementIsIndSw[PC_CCEL_MAX]; + UCHAR ValidCcElementTagSelect[PC_CCEL_MAX]; + + UCHAR CommentFieldBytes; + UCHAR Comment[PC_COMMENTLENGTH]; + + /* Helper variables for administration: */ + UCHAR isValid; /*!< Flag showing if PCE has been read successfully. */ + UCHAR + NumChannels; /*!< Amount of audio channels summing all channel elements + including LFEs */ + UCHAR NumEffectiveChannels; /*!< Amount of audio channels summing only SCEs + and CPEs */ + UCHAR elCounter; + +} CProgramConfig; + +typedef enum { + ASCEXT_UNKOWN = -1, + ASCEXT_SBR = 0x2b7, + ASCEXT_PS = 0x548, + ASCEXT_MPS = 0x76a, + ASCEXT_SAOC = 0x7cb, + ASCEXT_LDMPS = 0x7cc + +} TP_ASC_EXTENSION_ID; + +/** + * GaSpecificConfig struct + */ +typedef struct { + UINT m_frameLengthFlag; + UINT m_dependsOnCoreCoder; + UINT m_coreCoderDelay; + + UINT m_extensionFlag; + UINT m_extensionFlag3; + + UINT m_layer; + UINT m_numOfSubFrame; + UINT m_layerLength; + +} CSGaSpecificConfig; + +typedef enum { + ELDEXT_TERM = 0x0, /* Termination tag */ + ELDEXT_SAOC = 0x1, /* SAOC config */ + ELDEXT_LDSAC = 0x2, /* LD MPEG Surround config */ + ELDEXT_DOWNSCALEINFO = 0x3 /* ELD sample rate adaptation */ + /* reserved */ +} ASC_ELD_EXT_TYPE; + +typedef struct { + UCHAR m_frameLengthFlag; + + UCHAR m_sbrPresentFlag; + UCHAR + m_useLdQmfTimeAlign; /* Use LD-MPS QMF in SBR to achive time alignment */ + UCHAR m_sbrSamplingRate; + UCHAR m_sbrCrcFlag; + UINT m_downscaledSamplingFrequency; + +} CSEldSpecificConfig; + +typedef struct { + USAC_EXT_ELEMENT_TYPE usacExtElementType; + USHORT usacExtElementConfigLength; + USHORT usacExtElementDefaultLength; + UCHAR usacExtElementPayloadFrag; + UCHAR usacExtElementHasAudioPreRoll; +} CSUsacExtElementConfig; + +typedef struct { + MP4_ELEMENT_ID usacElementType; + UCHAR m_noiseFilling; + UCHAR m_harmonicSBR; + UCHAR m_interTes; + UCHAR m_pvc; + UCHAR m_stereoConfigIndex; + CSUsacExtElementConfig extElement; +} CSUsacElementConfig; + +typedef struct { + UCHAR m_frameLengthFlag; + UCHAR m_coreSbrFrameLengthIndex; + UCHAR m_sbrRatioIndex; + UCHAR m_nUsacChannels; /* number of audio channels signaled in + UsacDecoderConfig() / rsv603daDecoderConfig() via + numElements and usacElementType */ + UCHAR m_channelConfigurationIndex; + UINT m_usacNumElements; + CSUsacElementConfig element[TP_USAC_MAX_ELEMENTS]; + + UCHAR numAudioChannels; + UCHAR m_usacConfigExtensionPresent; + UCHAR elementLengthPresent; + UCHAR UsacConfig[TP_USAC_MAX_CONFIG_LEN]; + USHORT UsacConfigBits; +} CSUsacConfig; + +/** + * Audio configuration struct, suitable for encoder and decoder configuration. + */ +typedef struct { + /* XYZ Specific Data */ + union { + CSGaSpecificConfig + m_gaSpecificConfig; /**< General audio specific configuration. */ + CSEldSpecificConfig m_eldSpecificConfig; /**< ELD specific configuration. */ + CSUsacConfig m_usacConfig; /**< USAC specific configuration */ + } m_sc; + + /* Common ASC parameters */ + CProgramConfig m_progrConfigElement; /**< Program configuration. */ + + AUDIO_OBJECT_TYPE m_aot; /**< Audio Object Type. */ + UINT m_samplingFrequency; /**< Samplerate. */ + UINT m_samplesPerFrame; /**< Amount of samples per frame. */ + UINT m_directMapping; /**< Document this please !! */ + + AUDIO_OBJECT_TYPE m_extensionAudioObjectType; /**< Audio object type */ + UINT m_extensionSamplingFrequency; /**< Samplerate */ + + SCHAR m_channelConfiguration; /**< Channel configuration index */ + + SCHAR m_epConfig; /**< Error protection index */ + SCHAR m_vcb11Flag; /**< aacSectionDataResilienceFlag */ + SCHAR m_rvlcFlag; /**< aacScalefactorDataResilienceFlag */ + SCHAR m_hcrFlag; /**< aacSpectralDataResilienceFlag */ + + SCHAR m_sbrPresentFlag; /**< Flag indicating the presence of SBR data in the + bitstream */ + SCHAR + m_psPresentFlag; /**< Flag indicating the presence of parametric stereo + data in the bitstream */ + UCHAR m_samplingFrequencyIndex; /**< Samplerate index */ + UCHAR m_extensionSamplingFrequencyIndex; /**< Samplerate index */ + SCHAR m_extensionChannelConfiguration; /**< Channel configuration index */ + + UCHAR + configMode; /**< The flag indicates if the callback shall work in memory + allocation mode or in config change detection mode */ + UCHAR AacConfigChanged; /**< The flag will be set if at least one aac config + parameter has changed that requires a memory + reconfiguration, otherwise it will be cleared */ + UCHAR SbrConfigChanged; /**< The flag will be set if at least one sbr config + parameter has changed that requires a memory + reconfiguration, otherwise it will be cleared */ + UCHAR SacConfigChanged; /**< The flag will be set if at least one sac config + parameter has changed that requires a memory + reconfiguration, otherwise it will be cleared */ + + UCHAR + config[TP_USAC_MAX_CONFIG_LEN]; /**< Configuration stored as bitstream */ + UINT configBits; /**< Configuration length in bits */ + +} CSAudioSpecificConfig; + +typedef struct { + SCHAR flushCnt; /**< Flush frame counter */ + UCHAR flushStatus; /**< Flag indicates flush mode: on|off */ + SCHAR buildUpCnt; /**< Build up frame counter */ + UCHAR buildUpStatus; /**< Flag indicates build up mode: on|off */ + UCHAR cfgChanged; /**< Flag indicates that the config changed and the decoder + needs to be initialized again via callback. Make sure + that memory is freed before initialization. */ + UCHAR contentChanged; /**< Flag indicates that the content changed i.e. a + right truncation occured before */ + UCHAR forceCfgChange; /**< Flag indicates if config change has to be forced + even if new config is the same */ +} CCtrlCFGChange; + +typedef INT (*cbUpdateConfig_t)(void *, const CSAudioSpecificConfig *, + const UCHAR configMode, UCHAR *configChanged); +typedef INT (*cbFreeMem_t)(void *, const CSAudioSpecificConfig *); +typedef INT (*cbCtrlCFGChange_t)(void *, const CCtrlCFGChange *); +typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM, + const AUDIO_OBJECT_TYPE coreCodec, + const INT samplingRate, const INT frameSize, + const INT stereoConfigIndex, + const INT coreSbrFrameLengthIndex, const INT configBytes, + const UCHAR configMode, UCHAR *configChanged); + +typedef INT (*cbSbr_t)(void *self, HANDLE_FDK_BITSTREAM hBs, + const INT sampleRateIn, const INT sampleRateOut, + const INT samplesPerFrame, + const AUDIO_OBJECT_TYPE coreCodec, + const MP4_ELEMENT_ID elementID, const INT elementIndex, + const UCHAR harmonicSbr, const UCHAR stereoConfigIndex, + const UCHAR configMode, UCHAR *configChanged, + const INT downscaleFactor); + +typedef INT (*cbUsac_t)(void *self, HANDLE_FDK_BITSTREAM hBs); + +typedef INT (*cbUniDrc_t)(void *self, HANDLE_FDK_BITSTREAM hBs, + const INT fullPayloadLength, const INT payloadType, + const INT subStreamIndex, const INT payloadStart, + const AUDIO_OBJECT_TYPE); + +typedef struct { + cbUpdateConfig_t cbUpdateConfig; /*!< Function pointer for Config change + notify callback. */ + void *cbUpdateConfigData; /*!< User data pointer for Config change notify + callback. */ + cbFreeMem_t cbFreeMem; /*!< Function pointer for free memory callback. */ + void *cbFreeMemData; /*!< User data pointer for free memory callback. */ + cbCtrlCFGChange_t cbCtrlCFGChange; /*!< Function pointer for config change + control callback. */ + void *cbCtrlCFGChangeData; /*!< User data pointer for config change control + callback. */ + cbSsc_t cbSsc; /*!< Function pointer for SSC parser callback. */ + void *cbSscData; /*!< User data pointer for SSC parser callback. */ + cbSbr_t cbSbr; /*!< Function pointer for SBR header parser callback. */ + void *cbSbrData; /*!< User data pointer for SBR header parser callback. */ + cbUsac_t cbUsac; + void *cbUsacData; + cbUniDrc_t cbUniDrc; /*!< Function pointer for uniDrcConfig and + loudnessInfoSet parser callback. */ + void *cbUniDrcData; /*!< User data pointer for uniDrcConfig and + loudnessInfoSet parser callback. */ +} CSTpCallBacks; + +static const UINT SamplingRateTable[] = { + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, + 8000, 7350, 0, 0, 57600, 51200, 40000, 38400, 34150, 28800, 25600, + 20000, 19200, 17075, 14400, 12800, 9600, 0, 0, 0, 0}; + +static inline int getSamplingRateIndex(UINT samplingRate, UINT nBits) { + UINT sf_index; + UINT tableSize = (1 << nBits) - 1; + + for (sf_index = 0; sf_index < tableSize; sf_index++) { + if (SamplingRateTable[sf_index] == samplingRate) break; + } + + if (sf_index > tableSize) { + return tableSize - 1; + } + + return sf_index; +} + +/* + * Get Channel count from channel configuration + */ +static inline int getNumberOfTotalChannels(int channelConfig) { + switch (channelConfig) { + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + return channelConfig; + case 7: + case 12: + case 14: + return 8; + case 11: + return 7; + case 13: + return 24; + default: + return 0; + } +} + +static inline int getNumberOfEffectiveChannels( + const int + channelConfig) { /* index: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 */ + const int n[] = {0, 1, 2, 3, 4, 5, 5, 7, 0, 0, 0, 6, 7, 22, 7, 0}; + return n[channelConfig]; +} + +#endif /* TP_DATA_H */ diff --git a/fdk-aac/libMpegTPEnc/include/tpenc_lib.h b/fdk-aac/libMpegTPEnc/include/tpenc_lib.h new file mode 100644 index 0000000..4eb89a7 --- /dev/null +++ b/fdk-aac/libMpegTPEnc/include/tpenc_lib.h @@ -0,0 +1,339 @@ +/* ----------------------------------------------------------------------------- +Software License for The Fraunhofer FDK AAC Codec Library for Android + +© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +Forschung e.V. All rights reserved. + + 1. INTRODUCTION +The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software +that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding +scheme for digital audio. This FDK AAC Codec software is intended to be used on +a wide variety of Android devices. + +AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient +general perceptual audio codecs. AAC-ELD is considered the best-performing +full-bandwidth communications codec by independent studies and is widely +deployed. AAC has been standardized by ISO and IEC as part of the MPEG +specifications. + +Patent licenses for necessary patent claims for the FDK AAC Codec (including +those of Fraunhofer) may be obtained through Via Licensing +(www.vialicensing.com) or through the respective patent owners individually for +the purpose of encoding or decoding bit streams in products that are compliant +with the ISO/IEC MPEG audio standards. Please note that most manufacturers of +Android devices already license these patent claims through Via Licensing or +directly from the patent owners, and therefore FDK AAC Codec software may +already be covered under those patent licenses when it is used for those +licensed purposes only. + +Commercially-licensed AAC software libraries, including floating-point versions +with enhanced sound quality, are also available from Fraunhofer. Users are +encouraged to check the Fraunhofer website for additional applications +information and documentation. + +2. COPYRIGHT LICENSE + +Redistribution and use in source and binary forms, with or without modification, +are permitted without payment of copyright license fees provided that you +satisfy the following conditions: + +You must retain the complete text of this software license in redistributions of +the FDK AAC Codec or your modifications thereto in source code form. + +You must retain the complete text of this software license in the documentation +and/or other materials provided with redistributions of the FDK AAC Codec or +your modifications thereto in binary form. You must make available free of +charge copies of the complete source code of the FDK AAC Codec and your +modifications thereto to recipients of copies in binary form. + +The name of Fraunhofer may not be used to endorse or promote products derived +from this library without prior written permission. + +You may not charge copyright license fees for anyone to use, copy or distribute +the FDK AAC Codec software or your modifications thereto. + +Your modified versions of the FDK AAC Codec must carry prominent notices stating +that you changed the software and the date of any change. For modified versions +of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android" +must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK +AAC Codec Library for Android." + +3. NO PATENT LICENSE + +NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without +limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE. +Fraunhofer provides no warranty of patent non-infringement with respect to this +software. + +You may use this FDK AAC Codec software or modifications thereto only for +purposes that are authorized by appropriate patent licenses. + +4. DISCLAIMER + +This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright +holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, +including but not limited to the implied warranties of merchantability and +fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, +or consequential damages, including but not limited to procurement of substitute +goods or services; loss of use, data, or profits, or business interruption, +however caused and on any theory of liability, whether in contract, strict +liability, or tort (including negligence), arising in any way out of the use of +this software, even if advised of the possibility of such damage. + +5. CONTACT INFORMATION + +Fraunhofer Institute for Integrated Circuits IIS +Attention: Audio and Multimedia Departments - FDK AAC LL +Am Wolfsmantel 33 +91058 Erlangen, Germany + +www.iis.fraunhofer.de/amm +amm-info@iis.fraunhofer.de +----------------------------------------------------------------------------- */ + +/******************* MPEG transport format encoder library ********************* + + Author(s): Manuel Jander + + Description: MPEG Transport encode + +*******************************************************************************/ + +#ifndef TPENC_LIB_H +#define TPENC_LIB_H + +#include "tp_data.h" +#include "FDK_bitstream.h" + +#define TRANSPORTENC_INBUF_SIZE 8192 + +typedef enum { + TRANSPORTENC_OK = 0, /*!< All fine. */ + TRANSPORTENC_NO_MEM, /*!< Out of memory. */ + TRANSPORTENC_UNKOWN_ERROR = 1, /*!< Unknown error (embarrasing). */ + TRANSPORTENC_INVALID_PARAMETER, /*!< An invalid parameter was passed to a + function . */ + TRANSPORTENC_UNSUPPORTED_FORMAT, /*!< Unsupported transport format. */ + TRANSPORTENC_NOT_ENOUGH_BITS, /*!< Out of bits. Provide more bits and try + again. */ + + TRANSPORTENC_INVALID_CONFIG, /*!< Error in configuration. */ + TRANSPORTENC_LATM_INVALID_NR_OF_SUBFRAMES, /*!< LATM: number of subframes out + of range. */ + TRANSPORTENC_LOAS_NOT_AVAILABLE, /*!< LOAS format not supported. */ + TRANSPORTENC_INVALID_LATM_ALIGNMENT, /*!< AudioMuxElement length not aligned + to 1 byte. */ + + TRANSPORTENC_INVALID_TRANSMISSION_FRAME_LENGTH, /*!< Invalid transmission + frame length (< 0). */ + TRANSPORTENC_INVALID_CELP_FRAME_LENGTH, /*!< Invalid CELP frame length found + (>= 62). */ + TRANSPORTENC_INVALID_FRAME_BITS, /*!< Frame bits is not 40 and not 80. */ + TRANSPORTENC_INVALID_AOT, /*!< Unknown AOT found. */ + TRANSPORTENC_INVALID_AU_LENGTH /*!< Invalid Access Unit length (not + byte-aligned). */ + +} TRANSPORTENC_ERROR; + +typedef struct TRANSPORTENC *HANDLE_TRANSPORTENC; + +/** + * \brief Determine a reasonable channel configuration on the basis + * of channel_mode. + * \param noChannels Number of audio channels. + * \return CHANNEL_MODE value that matches the given amount of audio + * channels. + */ +CHANNEL_MODE transportEnc_GetChannelMode(int noChannels); + +/** + * \brief Register SBR heaqder writer callback. + * \param hTp Handle of transport decoder. + * \param cbUpdateConfig Pointer to a callback function to handle SBR header + * writing. + * \param user_data void pointer for user data passed to the callback as + * first parameter. + * \return 0 on success. + */ +int transportEnc_RegisterSbrCallback(HANDLE_TRANSPORTENC hTpEnc, + const cbSbr_t cbSbr, void *user_data); + +/** + * \brief Register USAC SC writer callback. + * \param hTp Handle of transport decoder. + * \param cbUpdateConfig Pointer to a callback function to handle USAC + * SCwriting. + * \param user_data void pointer for user data passed to the callback as + * first parameter. + * \return 0 on success. + */ +int transportEnc_RegisterUsacCallback(HANDLE_TRANSPORTENC hTpEnc, + const cbUsac_t cbUsac, void *user_data); + +/** + * \brief Register SSC writer callback. + * \param hTp Handle of transport decoder. + * \param cbUpdateConfig Pointer to a callback function to handle SSC writing. + * \param user_data void pointer for user data passed to the callback as + * first parameter. + * \return 0 on success. + */ +int transportEnc_RegisterSscCallback(HANDLE_TRANSPORTENC hTpEnc, + const cbSsc_t cbSsc, void *user_data); + +/** + * \brief Write ASC from given parameters. + * \param asc A HANDLE_FDK_BITSTREAM where the ASC is written to. + * \param config Structure containing the codec configuration settings. + * \param cb callback information structure. + * \return 0 on success. + */ +int transportEnc_writeASC(HANDLE_FDK_BITSTREAM asc, CODER_CONFIG *config, + CSTpCallBacks *cb); + +/* Defintion of flags that can be passed to transportEnc_Open() */ +#define TP_FLAG_MPEG4 1 /** MPEG4 (instead of MPEG2) */ +#define TP_FLAG_LATM_AMV 2 /** LATM AudioMuxVersion */ +#define TP_FLAG_LATM_AMVA 4 /** LATM AudioMuxVersionA */ + +/** + * \brief Allocate transport encoder. + * \param phTpEnc Pointer to transport encoder handle. + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_Open(HANDLE_TRANSPORTENC *phTpEnc); + +/** + * \brief Init transport encoder. + * \param bsBuffer Pointer to transport encoder. + * \param bsBuffer Pointer to bitstream buffer. + * \param bsBufferSize Size in bytes of bsBuffer. + * \param transportFmt Format of the transport to be written. + * \param config Pointer to a valid CODER_CONFIG struct. + * \param flags Transport encoder flags. + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_Init(HANDLE_TRANSPORTENC hTpEnc, + UCHAR *bsBuffer, INT bsBufferSize, + TRANSPORT_TYPE transportFmt, + CODER_CONFIG *config, UINT flags); + +/** + * \brief Write additional bits in transport encoder. + * \param config Pointer to a valid CODER_CONFIG struct. + * \param nBits Number of additional bits. + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_AddOtherDataBits(HANDLE_TRANSPORTENC hTpEnc, + const int nBits); + +/** + * \brief Get transport encoder bitstream. + * \param hTp Pointer to a transport encoder handle. + * \return The handle to the requested FDK bitstream. + */ +HANDLE_FDK_BITSTREAM transportEnc_GetBitstream(HANDLE_TRANSPORTENC hTp); + +/** + * \brief Get amount of bits required by the transport headers. + * \param hTp Handle of transport encoder. + * \param auBits Amount of payload bits required for the current subframe. + * \return Error code. + */ +INT transportEnc_GetStaticBits(HANDLE_TRANSPORTENC hTp, int auBits); + +/** + * \brief Close transport encoder. This function assures that all + * allocated memory is freed. + * \param phTp Pointer to a previously allocated transport encoder handle. + */ +void transportEnc_Close(HANDLE_TRANSPORTENC *phTp); + +/** + * \brief Write one access unit. + * \param hTp Handle of transport encoder. + * \param total_bits Amount of total access unit bits. + * \param bufferFullness Value of current buffer fullness in bits. + * \param noConsideredChannels Number of bitrate wise considered channels (all + * minus LFE channels). + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(HANDLE_TRANSPORTENC hTp, + INT total_bits, + int bufferFullness, + int noConsideredChannels); + +/** + * \brief Inform the transportEnc layer that writing of access unit has + * finished. This function is required to be called when the encoder has + * finished writing one Access one Access Unit for bitstream + * housekeeping. + * \param hTp Transport handle. + * \param pBits Pointer to an int, where the current amount of frame bits is + * passed and where the current amount of subframe bits is returned. + * + * OR: This integer is modified by the amount of extra bit alignment that may + * occurr. + * + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_EndAccessUnit(HANDLE_TRANSPORTENC hTp, + int *pBits); + +/* + * \brief Get a payload frame. + * \param hTpEnc Transport encoder handle. + * \param nBytes Pointer to an int to hold the frame size in bytes. Returns + * zero if currently there is no complete frame for output (number of sub frames + * > 1). + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_GetFrame(HANDLE_TRANSPORTENC hTpEnc, + int *nbytes); + +/* ADTS CRC support */ + +/** + * \brief Set current bitstream position as start of a new data region. + * \param hTpEnc Transport encoder handle. + * \param mBits Size in bits of the data region. Set to 0 if it should not be + * of a fixed size. + * \return Data region ID, which should be used when calling + * transportEnc_CrcEndReg(). + */ +int transportEnc_CrcStartReg(HANDLE_TRANSPORTENC hTpEnc, int mBits); + +/** + * \brief Set end of data region. + * \param hTpEnc Transport encoder handle. + * \param reg Data region ID, opbtained from transportEnc_CrcStartReg(). + * \return void + */ +void transportEnc_CrcEndReg(HANDLE_TRANSPORTENC hTpEnc, int reg); + +/** + * \brief Get AudioSpecificConfig or StreamMuxConfig from transport + * encoder handle and write it to dataBuffer. + * \param hTpEnc Transport encoder handle. + * \param cc Pointer to the current and valid configuration contained + * in a CODER_CONFIG struct. + * \param dataBuffer Bitbuffer holding binary configuration. + * \param confType Pointer to an UINT where the configuration type is + * returned (0:ASC, 1:SMC). + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_GetConf(HANDLE_TRANSPORTENC hTpEnc, + CODER_CONFIG *cc, + FDK_BITSTREAM *dataBuffer, + UINT *confType); + +/** + * \brief Get information (version among other things) of the transport + * encoder library. + * \param info Pointer to an allocated LIB_INFO struct. + * \return Error code. + */ +TRANSPORTENC_ERROR transportEnc_GetLibInfo(LIB_INFO *info); + +#endif /* #ifndef TPENC_LIB_H */ |