2018-02-26 20:17:00 +01:00
|
|
|
/* -----------------------------------------------------------------------------
|
2012-07-11 19:15:24 +02:00
|
|
|
Software License for The Fraunhofer FDK AAC Codec Library for Android
|
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
|
|
|
|
Forschung e.V. All rights reserved.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
1. INTRODUCTION
|
2018-02-26 20:17:00 +01:00
|
|
|
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.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
2. COPYRIGHT LICENSE
|
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
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:
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
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.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
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
|
2012-07-11 19:15:24 +02:00
|
|
|
modifications thereto to recipients of copies in binary form.
|
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
The name of Fraunhofer may not be used to endorse or promote products derived
|
|
|
|
from this library without prior written permission.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
You may not charge copyright license fees for anyone to use, copy or distribute
|
|
|
|
the FDK AAC Codec software or your modifications thereto.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
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."
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
3. NO PATENT LICENSE
|
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
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.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
You may use this FDK AAC Codec software or modifications thereto only for
|
|
|
|
purposes that are authorized by appropriate patent licenses.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
4. DISCLAIMER
|
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
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.
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
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
|
2018-02-26 20:17:00 +01:00
|
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/******************* MPEG transport format encoder library *********************
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
Author(s): Manuel Jander
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
Description: MPEG Transport encode
|
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
*******************************************************************************/
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
#ifndef TPENC_LIB_H
|
|
|
|
#define TPENC_LIB_H
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
#include "tp_data.h"
|
|
|
|
#include "FDK_bitstream.h"
|
|
|
|
|
|
|
|
#define TRANSPORTENC_INBUF_SIZE 8192
|
|
|
|
|
|
|
|
typedef enum {
|
2018-02-26 20:17:00 +01:00
|
|
|
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). */
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
} TRANSPORTENC_ERROR;
|
|
|
|
|
|
|
|
typedef struct TRANSPORTENC *HANDLE_TRANSPORTENC;
|
|
|
|
|
|
|
|
/**
|
2018-02-26 20:17:00 +01:00
|
|
|
* \brief Determine a reasonable channel configuration on the basis
|
|
|
|
* of channel_mode.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \param noChannels Number of audio channels.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \return CHANNEL_MODE value that matches the given amount of audio
|
|
|
|
* channels.
|
2012-07-11 19:15:24 +02:00
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
CHANNEL_MODE transportEnc_GetChannelMode(int noChannels);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Register SBR heaqder writer callback.
|
|
|
|
* \param hTp Handle of transport decoder.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \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.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \return 0 on success.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
int transportEnc_RegisterUsacCallback(HANDLE_TRANSPORTENC hTpEnc,
|
|
|
|
const cbUsac_t cbUsac, void *user_data);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Register SSC writer callback.
|
|
|
|
* \param hTp Handle of transport decoder.
|
|
|
|
* \param cbUpdateConfig Pointer to a callback function to handle SSC writing.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \param user_data void pointer for user data passed to the callback as
|
|
|
|
* first parameter.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \return 0 on success.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
int transportEnc_RegisterSscCallback(HANDLE_TRANSPORTENC hTpEnc,
|
|
|
|
const cbSsc_t cbSsc, void *user_data);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \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.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
int transportEnc_writeASC(HANDLE_FDK_BITSTREAM asc, CODER_CONFIG *config,
|
|
|
|
CSTpCallBacks *cb);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/* Defintion of flags that can be passed to transportEnc_Open() */
|
2018-02-26 20:17:00 +01:00
|
|
|
#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 */
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Allocate transport encoder.
|
|
|
|
* \param phTpEnc Pointer to transport encoder handle.
|
|
|
|
* \return Error code.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
TRANSPORTENC_ERROR transportEnc_Open(HANDLE_TRANSPORTENC *phTpEnc);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \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.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
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);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get transport encoder bitstream.
|
|
|
|
* \param hTp Pointer to a transport encoder handle.
|
|
|
|
* \return The handle to the requested FDK bitstream.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
HANDLE_FDK_BITSTREAM transportEnc_GetBitstream(HANDLE_TRANSPORTENC hTp);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \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.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
INT transportEnc_GetStaticBits(HANDLE_TRANSPORTENC hTp, int auBits);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
2018-02-26 20:17:00 +01:00
|
|
|
* \brief Close transport encoder. This function assures that all
|
|
|
|
* allocated memory is freed.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \param phTp Pointer to a previously allocated transport encoder handle.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
void transportEnc_Close(HANDLE_TRANSPORTENC *phTp);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \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.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \param noConsideredChannels Number of bitrate wise considered channels (all
|
|
|
|
* minus LFE channels).
|
2012-07-11 19:15:24 +02:00
|
|
|
* \return Error code.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(HANDLE_TRANSPORTENC hTp,
|
|
|
|
INT total_bits,
|
|
|
|
int bufferFullness,
|
|
|
|
int noConsideredChannels);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
2018-02-26 20:17:00 +01:00
|
|
|
* \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.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \param hTp Transport handle.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \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.
|
2012-07-11 19:15:24 +02:00
|
|
|
*
|
2018-02-26 20:17:00 +01:00
|
|
|
* OR: This integer is modified by the amount of extra bit alignment that may
|
|
|
|
* occurr.
|
2012-07-11 19:15:24 +02:00
|
|
|
*
|
|
|
|
* \return Error code.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
TRANSPORTENC_ERROR transportEnc_EndAccessUnit(HANDLE_TRANSPORTENC hTp,
|
|
|
|
int *pBits);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* \brief Get a payload frame.
|
|
|
|
* \param hTpEnc Transport encoder handle.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \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).
|
2012-07-11 19:15:24 +02:00
|
|
|
* \return Error code.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
TRANSPORTENC_ERROR transportEnc_GetFrame(HANDLE_TRANSPORTENC hTpEnc,
|
|
|
|
int *nbytes);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/* ADTS CRC support */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Set current bitstream position as start of a new data region.
|
|
|
|
* \param hTpEnc Transport encoder handle.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \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().
|
2012-07-11 19:15:24 +02:00
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
2018-02-26 20:17:00 +01:00
|
|
|
* \brief Get AudioSpecificConfig or StreamMuxConfig from transport
|
|
|
|
* encoder handle and write it to dataBuffer.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \param hTpEnc Transport encoder handle.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \param cc Pointer to the current and valid configuration contained
|
|
|
|
* in a CODER_CONFIG struct.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \param dataBuffer Bitbuffer holding binary configuration.
|
2018-02-26 20:17:00 +01:00
|
|
|
* \param confType Pointer to an UINT where the configuration type is
|
|
|
|
* returned (0:ASC, 1:SMC).
|
2012-07-11 19:15:24 +02:00
|
|
|
* \return Error code.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
TRANSPORTENC_ERROR transportEnc_GetConf(HANDLE_TRANSPORTENC hTpEnc,
|
|
|
|
CODER_CONFIG *cc,
|
|
|
|
FDK_BITSTREAM *dataBuffer,
|
|
|
|
UINT *confType);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
|
|
|
/**
|
2018-02-26 20:17:00 +01:00
|
|
|
* \brief Get information (version among other things) of the transport
|
|
|
|
* encoder library.
|
2012-07-11 19:15:24 +02:00
|
|
|
* \param info Pointer to an allocated LIB_INFO struct.
|
|
|
|
* \return Error code.
|
|
|
|
*/
|
2018-02-26 20:17:00 +01:00
|
|
|
TRANSPORTENC_ERROR transportEnc_GetLibInfo(LIB_INFO *info);
|
2012-07-11 19:15:24 +02:00
|
|
|
|
2018-02-26 20:17:00 +01:00
|
|
|
#endif /* #ifndef TPENC_LIB_H */
|