1
0
mirror of https://github.com/mstorsjo/fdk-aac.git synced 2025-06-05 22:39:13 +02:00

Upgrade to FDKv2

Bug: 71430241
Test: CTS DecoderTest and DecoderTestAacDrc

original-Change-Id: Iaa20f749b8a04d553b20247cfe1a8930ebbabe30

Apply clang-format also on header files.

original-Change-Id: I14de1ef16bbc79ec0283e745f98356a10efeb2e4

Fixes for MPEG-D DRC

original-Change-Id: If1de2d74bbbac84b3f67de3b88b83f6a23b8a15c

Catch unsupported tw_mdct at an early stage

original-Change-Id: Ied9dd00d754162a0e3ca1ae3e6b854315d818afe

Fixing PVC transition frames

original-Change-Id: Ib75725abe39252806c32d71176308f2c03547a4e

Move qmf bands sanity check

original-Change-Id: Iab540c3013c174d9490d2ae100a4576f51d8dbc4

Initialize scaling variable

original-Change-Id: I3c4087101b70e998c71c1689b122b0d7762e0f9e

Add 16 qmf band configuration to getSlotNrgHQ()

original-Change-Id: I49a5d30f703a1b126ff163df9656db2540df21f1

Always apply byte alignment at the end of the AudioMuxElement

original-Change-Id: I42d560287506d65d4c3de8bfe3eb9a4ebeb4efc7

Setup SBR element only if no parse error exists

original-Change-Id: I1915b73704bc80ab882b9173d6bec59cbd073676

Additional array index check in HCR

original-Change-Id: I18cc6e501ea683b5009f1bbee26de8ddd04d8267

Fix fade-in index selection in concealment module

original-Change-Id: Ibf802ed6ed8c05e9257e1f3b6d0ac1162e9b81c1

Enable explicit backward compatible parser for AAC_LD

original-Change-Id: I27e9c678dcb5d40ed760a6d1e06609563d02482d

Skip spatial specific config in explicit backward compatible ASC

original-Change-Id: Iff7cc365561319e886090cedf30533f562ea4d6e

Update flags description in decoder API

original-Change-Id: I9a5b4f8da76bb652f5580cbd3ba9760425c43830

Add QMF domain reset function

original-Change-Id: I4f89a8a2c0277d18103380134e4ed86996e9d8d6

DRC upgrade v2.1.0

original-Change-Id: I5731c0540139dab220094cd978ef42099fc45b74

Fix integer overflow in sqrtFixp_lookup()

original-Change-Id: I429a6f0d19aa2cc957e0f181066f0ca73968c914

Fix integer overflow in invSqrtNorm2()

original-Change-Id: I84de5cbf9fb3adeb611db203fe492fabf4eb6155

Fix integer overflow in GenerateRandomVector()

original-Change-Id: I3118a641008bd9484d479e5b0b1ee2b5d7d44d74

Fix integer overflow in adjustTimeSlot_EldGrid()

original-Change-Id: I29d503c247c5c8282349b79df940416a512fb9d5

Fix integer overflow in FDKsbrEnc_codeEnvelope()

original-Change-Id: I6b34b61ebb9d525b0c651ed08de2befc1f801449

Follow-up on: Fix integer overflow in adjustTimeSlot_EldGrid()

original-Change-Id: I6f8f578cc7089e5eb7c7b93e580b72ca35ad689a

Fix integer overflow in get_pk_v2()

original-Change-Id: I63375bed40d45867f6eeaa72b20b1f33e815938c

Fix integer overflow in Syn_filt_zero()

original-Change-Id: Ie0c02fdfbe03988f9d3b20d10cd9fe4c002d1279

Fix integer overflow in CFac_CalcFacSignal()

original-Change-Id: Id2d767c40066c591b51768e978eb8af3b803f0c5

Fix integer overflow in FDKaacEnc_FDKaacEnc_calcPeNoAH()

original-Change-Id: Idcbd0f4a51ae2550ed106aa6f3d678d1f9724841

Fix integer overflow in sbrDecoder_calculateGainVec()

original-Change-Id: I7081bcbe29c5cede9821b38d93de07c7add2d507

Fix integer overflow in CLpc_SynthesisLattice()

original-Change-Id: I4a95ddc18de150102352d4a1845f06094764c881

Fix integer overflow in Pred_Lt4()

original-Change-Id: I4dbd012b2de7d07c3e70a47b92e3bfae8dbc750a

Fix integer overflow in FDKsbrEnc_InitSbrFastTransientDetector()

original-Change-Id: I788cbec1a4a00f44c2f3a72ad7a4afa219807d04

Fix unsigned integer overflow in FDKaacEnc_WriteBitstream()

original-Change-Id: I68fc75166e7d2cd5cd45b18dbe3d8c2a92f1822a

Fix unsigned integer overflow in FDK_MetadataEnc_Init()

original-Change-Id: Ie8d025f9bcdb2442c704bd196e61065c03c10af4

Fix overflow in pseudo random number generators

original-Change-Id: I3e2551ee01356297ca14e3788436ede80bd5513c

Fix unsigned integer overflow in sbrDecoder_Parse()

original-Change-Id: I3f231b2f437e9c37db4d5b964164686710eee971

Fix unsigned integer overflow in longsub()

original-Change-Id: I73c2bc50415cac26f1f5a29e125bbe75f9180a6e

Fix unsigned integer overflow in CAacDecoder_DecodeFrame()

original-Change-Id: Ifce2db4b1454b46fa5f887e9d383f1cc43b291e4

Fix overflow at CLpdChannelStream_Read()

original-Change-Id: Idb9d822ce3a4272e4794b643644f5434e2d4bf3f

Fix unsigned integer overflow in Hcr_State_BODY_SIGN_ESC__ESC_WORD()

original-Change-Id: I1ccf77c0015684b85534c5eb97162740a870b71c

Fix unsigned integer overflow in UsacConfig_Parse()

original-Change-Id: Ie6d27f84b6ae7eef092ecbff4447941c77864d9f

Fix unsigned integer overflow in aacDecoder_drcParse()

original-Change-Id: I713f28e883eea3d70b6fa56a7b8f8c22bcf66ca0

Fix unsigned integer overflow in aacDecoder_drcReadCompression()

original-Change-Id: Ia34dfeb88c4705c558bce34314f584965cafcf7a

Fix unsigned integer overflow in CDataStreamElement_Read()

original-Change-Id: Iae896cc1d11f0a893d21be6aa90bd3e60a2c25f0

Fix unsigned integer overflow in transportDec_AdjustEndOfAccessUnit()

original-Change-Id: I64cf29a153ee784bb4a16fdc088baabebc0007dc

Fix unsigned integer overflow in transportDec_GetAuBitsRemaining()

original-Change-Id: I975b3420faa9c16a041874ba0db82e92035962e4

Fix unsigned integer overflow in extractExtendedData()

original-Change-Id: I2a59eb09e2053cfb58dfb75fcecfad6b85a80a8f

Fix signed integer overflow in CAacDecoder_ExtPayloadParse()

original-Change-Id: I4ad5ca4e3b83b5d964f1c2f8c5e7b17c477c7929

Fix unsigned integer overflow in CAacDecoder_DecodeFrame()

original-Change-Id: I29a39df77d45c52a0c9c5c83c1ba81f8d0f25090

Follow-up on: Fix integer overflow in CLpc_SynthesisLattice()

original-Change-Id: I8fb194ffc073a3432a380845be71036a272d388f

Fix signed integer overflow in _interpolateDrcGain()

original-Change-Id: I879ec9ab14005069a7c47faf80e8bc6e03d22e60

Fix unsigned integer overflow in FDKreadBits()

original-Change-Id: I1f47a6a8037ff70375aa8844947d5681bb4287ad

Fix unsigned integer overflow in FDKbyteAlign()

original-Change-Id: Id5f3a11a0c9e50fc6f76ed6c572dbd4e9f2af766

Fix unsigned integer overflow in FDK_get32()

original-Change-Id: I9d33b8e97e3d38cbb80629cb859266ca0acdce96

Fix unsigned integer overflow in FDK_pushBack()

original-Change-Id: Ic87f899bc8c6acf7a377a8ca7f3ba74c3a1e1c19

Fix unsigned integer overflow in FDK_pushForward()

original-Change-Id: I3b754382f6776a34be1602e66694ede8e0b8effc

Fix unsigned integer overflow in ReadPsData()

original-Change-Id: I25361664ba8139e32bbbef2ca8c106a606ce9c37

Fix signed integer overflow in E_UTIL_residu()

original-Change-Id: I8c3abd1f437ee869caa8fb5903ce7d3d641b6aad

REVERT: Follow-up on: Integer overflow in CLpc_SynthesisLattice().

original-Change-Id: I3d340099acb0414795c8dfbe6362bc0a8f045f9b

Follow-up on: Fix integer overflow in CLpc_SynthesisLattice()

original-Change-Id: I4aedb8b3a187064e9f4d985175aa55bb99cc7590

Follow-up on: Fix unsigned integer overflow in aacDecoder_drcParse()

original-Change-Id: I2aa2e13916213bf52a67e8b0518e7bf7e57fb37d

Fix integer overflow in acelp

original-Change-Id: Ie6390c136d84055f8b728aefbe4ebef6e029dc77

Fix unsigned integer overflow in aacDecoder_UpdateBitStreamCounters()

original-Change-Id: I391ffd97ddb0b2c184cba76139bfb356a3b4d2e2

Adjust concealment default settings

original-Change-Id: I6a95db935a327c47df348030bcceafcb29f54b21

Saturate estimatedStartPos

original-Change-Id: I27be2085e0ae83ec9501409f65e003f6bcba1ab6

Negative shift exponent in _interpolateDrcGain()

original-Change-Id: I18edb26b26d002aafd5e633d4914960f7a359c29

Negative shift exponent in calculateICC()

original-Change-Id: I3dcd2ae98d2eb70ee0d59750863cbb2a6f4f8aba

Too large shift exponent in FDK_put()

original-Change-Id: Ib7d9aaa434d2d8de4a13b720ca0464b31ca9b671

Too large shift exponent in CalcInvLdData()

original-Change-Id: I43e6e78d4cd12daeb1dcd5d82d1798bdc2550262

Member access within null pointer of type SBR_CHANNEL

original-Change-Id: Idc5e4ea8997810376d2f36bbdf628923b135b097

Member access within null pointer of type CpePersistentData

original-Change-Id: Ib6c91cb0d37882768e5baf63324e429589de0d9d

Member access within null pointer FDKaacEnc_psyMain()

original-Change-Id: I7729b7f4479970531d9dc823abff63ca52e01997

Member access within null pointer FDKaacEnc_GetPnsParam()

original-Change-Id: I9aa3b9f3456ae2e0f7483dbd5b3dde95fc62da39

Member access within null pointer FDKsbrEnc_EnvEncodeFrame()

original-Change-Id: I67936f90ea714e90b3e81bc0dd1472cc713eb23a

Add HCR sanity check

original-Change-Id: I6c1d9732ebcf6af12f50b7641400752f74be39f7

Fix memory issue for HBE edge case with 8:3 SBR

original-Change-Id: I11ea58a61e69fbe8bf75034b640baee3011e63e9

Additional SBR parametrization sanity check for ELD

original-Change-Id: Ie26026fbfe174c2c7b3691f6218b5ce63e322140

Add MPEG-D DRC channel layout check

original-Change-Id: Iea70a74f171b227cce636a9eac4ba662777a2f72

Additional out-of-bounds checks in MPEG-D DRC

original-Change-Id: Ife4a8c3452c6fde8a0a09e941154a39a769777d4

Change-Id: Ic63cb2f628720f54fe9b572b0cb528e2599c624e
This commit is contained in:
Fraunhofer IIS FDK
2018-02-26 20:17:00 +01:00
committed by Jean-Michel Trivi
parent 6288a1e34c
commit 6cfabd3536
450 changed files with 164126 additions and 83284 deletions

View File

@@ -1,140 +0,0 @@
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 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-4 AAC Decoder **************************
Author(s): Manuel Jander
Description: Bitstream data provider for MP4 decoders
******************************************************************************/
#include "machine_type.h"
#include "FDK_audio.h"
/*!< If MPFWRITE_MP4FF_ENABLE is set, include support for MPEG ISO fileformat.
If not set, no .mp4, .m4a and .3gp files can be used for input. */
/* #define MPFWRITE_MP4FF_ENABLE */
typedef struct STRUCT_FILEWRITE *HANDLE_FILEWRITE;
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief Open an MPEG audio file.
* \param mpegFileWrite_Filename String of the filename to be opened.
* \param fileFmt Transport format to use.
* \param conf
* \param confSize
* \return MPEG file write handle.
*/
HANDLE_FILEWRITE mpegFileWrite_Open( char *mpegFileWrite_Filename,
FILE_FORMAT fileFmt,
TRANSPORT_TYPE transportType,
UCHAR *conf,
UINT confSize
);
/**
* \brief Write to an MPEG audio file.
* \param inBuffer Buffer to write.
* \param bufferSize Size of buffer to write in bytes.
* \return 0 on sucess, -1 on unsupported file format or write error.
*/
int mpegFileWrite_Write( HANDLE_FILEWRITE hFileWrite,
UCHAR *inBuffer,
int bufferSize
);
/**
* \brief Deallocate memory and close file.
* \param hFileWrite MPEG file write handle.
* \return 0 on sucess.
*/
int mpegFileWrite_Close( HANDLE_FILEWRITE *hFileWrite );
#ifdef __cplusplus
}
#endif

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder **************************
/******************* MPEG transport format encoder library *********************
Author(s): Manuel Jander
Author(s): Manuel Jander
Description: MPEG Transport data tables
******************************************************************************/
*******************************************************************************/
#ifndef __TP_DATA_H__
#define __TP_DATA_H__
#ifndef TP_DATA_H
#define TP_DATA_H
#include "machine_type.h"
#include "FDK_audio.h"
@@ -98,17 +110,35 @@ amm-info@iis.fraunhofer.de
/*
* Configuration
*/
#define TP_GA_ENABLE
/* #define TP_CELP_ENABLE */
/* #define TP_HVXC_ENABLE */
/* #define TP_SLS_ENABLE */
#define TP_ELD_ENABLE
/* #define TP_USAC_ENABLE */
/* #define TP_RSVD50_ENABLE */
#if defined(TP_GA_ENABLE) || defined(TP_SLS_ENABLE)
#define TP_PCE_ENABLE /**< Enable full PCE support */
#endif
#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.
@@ -116,13 +146,12 @@ amm-info@iis.fraunhofer.de
/* 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_ASSOCDATA_MAX 8
#define PC_CCEL_MAX 16 /* CC elements */
#define PC_COMMENTLENGTH 256
#define PC_NUM_HEIGHT_LAYER 3
typedef struct
{
#ifdef TP_PCE_ENABLE
typedef struct {
/* PCE bitstream elements: */
UCHAR ElementInstanceTag;
UCHAR Profile;
@@ -165,54 +194,50 @@ typedef struct
UCHAR CommentFieldBytes;
UCHAR Comment[PC_COMMENTLENGTH];
#endif /* TP_PCE_ENABLE */
/* 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 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
ASCEXT_SBR = 0x2b7,
ASCEXT_PS = 0x548,
ASCEXT_MPS = 0x76a,
ASCEXT_SAOC = 0x7cb,
ASCEXT_LDMPS = 0x7cc
} TP_ASC_EXTENSION_ID;
#ifdef TP_GA_ENABLE
/**
* GaSpecificConfig struct
*/
typedef struct {
UINT m_frameLengthFlag ;
UINT m_dependsOnCoreCoder ;
UINT m_coreCoderDelay ;
UINT m_frameLengthFlag;
UINT m_dependsOnCoreCoder;
UINT m_coreCoderDelay;
UINT m_extensionFlag ;
UINT m_extensionFlag3 ;
UINT m_extensionFlag;
UINT m_extensionFlag3;
UINT m_layer;
UINT m_numOfSubFrame;
UINT m_layerLength;
} CSGaSpecificConfig;
#endif /* TP_GA_ENABLE */
#ifdef TP_ELD_ENABLE
typedef enum {
ELDEXT_TERM = 0x0, /* Termination tag */
ELDEXT_SAOC = 0x1, /* SAOC config */
ELDEXT_LDSAC = 0x2 /* LD MPEG Surround config */
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;
@@ -220,103 +245,186 @@ typedef struct {
UCHAR m_frameLengthFlag;
UCHAR m_sbrPresentFlag;
UCHAR m_useLdQmfTimeAlign; /* Use LD-MPS QMF in SBR to achive time alignment */
UCHAR
m_useLdQmfTimeAlign; /* Use LD-MPS QMF in SBR to achive time alignment */
UCHAR m_sbrSamplingRate;
UCHAR m_sbrCrcFlag;
UINT m_downscaledSamplingFrequency;
} CSEldSpecificConfig;
#endif /* TP_ELD_ENABLE */
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 {
#ifdef TP_GA_ENABLE
CSGaSpecificConfig m_gaSpecificConfig; /**< General audio specific configuration. */
#endif /* TP_GA_ENABLE */
#ifdef TP_ELD_ENABLE
CSEldSpecificConfig m_eldSpecificConfig; /**< ELD specific configuration. */
#endif /* TP_ELD_ENABLE */
CSGaSpecificConfig
m_gaSpecificConfig; /**< General audio specific configuration. */
CSEldSpecificConfig m_eldSpecificConfig; /**< ELD specific configuration. */
CSUsacConfig m_usacConfig; /**< USAC specific configuration */
} m_sc;
/* Common ASC parameters */
#ifdef TP_PCE_ENABLE
CProgramConfig m_progrConfigElement; /**< Program configuration. */
#endif /* TP_PCE_ENABLE */
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_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 */
AUDIO_OBJECT_TYPE m_extensionAudioObjectType; /**< Audio object type */
UINT m_extensionSamplingFrequency; /**< Samplerate */
SCHAR m_channelConfiguration; /**< Channel configuration index */
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_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 */
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 INT (*cbUpdateConfig_t)(void*, const CSAudioSpecificConfig*);
typedef INT (*cbSsc_t)(
void*, HANDLE_FDK_BITSTREAM,
const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingFrequency,
const INT muxMode,
const INT configBytes
);
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
);
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 struct {
cbUpdateConfig_t cbUpdateConfig; /*!< Function pointer for Config change notify callback. */
void *cbUpdateConfigData; /*!< User data pointer for Config change notify 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. */
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 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,
0
};
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 sf_index, tableSize=sizeof(SamplingRateTable)/sizeof(UINT);
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;
for (sf_index = 0; sf_index < tableSize; sf_index++) {
if (SamplingRateTable[sf_index] == samplingRate) break;
}
if (sf_index>tableSize-1) {
return tableSize-1;
if (sf_index > tableSize) {
return tableSize - 1;
}
return sf_index;
@@ -325,26 +433,33 @@ int getSamplingRateIndex( UINT samplingRate )
/*
* Get Channel count from channel configuration
*/
static inline int getNumberOfTotalChannels(int channelConfig)
{
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;
default:
return 0;
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, 0, 7, 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__ */
#endif /* TP_DATA_H */

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************** MPEG-4 Transport Encoder ************************
/******************* MPEG transport format encoder library *********************
Author(s): Manuel Jander
Author(s): Manuel Jander
Description: MPEG Transport encode
******************************************************************************/
*******************************************************************************/
#ifndef __TPENC_LIB_H__
#define __TPENC_LIB_H__
#ifndef TPENC_LIB_H
#define TPENC_LIB_H
#include "tp_data.h"
#include "FDK_bitstream.h"
@@ -97,61 +109,78 @@ amm-info@iis.fraunhofer.de
#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_PARSE_ERROR, /*!< Bitstream data contained inconsistencies (wrong syntax). */
TRANSPORTENC_UNSUPPORTED_FORMAT, /*!< Unsupported transport format. */
TRANSPORTENC_NOT_ENOUGH_BITS, /*!< Out of bits. Provide more bits and try again. */
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_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_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.
* \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.
* \return CHANNEL_MODE value that matches the given amount of audio
* channels.
*/
CHANNEL_MODE transportEnc_GetChannelMode( int noChannels );
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.
* \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
);
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.
* \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
);
int transportEnc_RegisterSscCallback(HANDLE_TRANSPORTENC hTpEnc,
const cbSsc_t cbSsc, void *user_data);
/**
* \brief Write ASC from given parameters.
@@ -160,24 +189,20 @@ int transportEnc_RegisterSscCallback (
* \param cb callback information structure.
* \return 0 on success.
*/
int transportEnc_writeASC (
HANDLE_FDK_BITSTREAM asc,
CODER_CONFIG *config,
CSTpCallBacks *cb
);
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 */
#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 );
TRANSPORTENC_ERROR transportEnc_Open(HANDLE_TRANSPORTENC *phTpEnc);
/**
* \brief Init transport encoder.
@@ -189,21 +214,26 @@ TRANSPORTENC_ERROR transportEnc_Open( HANDLE_TRANSPORTENC *phTpEnc );
* \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
);
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 );
HANDLE_FDK_BITSTREAM transportEnc_GetBitstream(HANDLE_TRANSPORTENC hTp);
/**
* \brief Get amount of bits required by the transport headers.
@@ -211,57 +241,66 @@ HANDLE_FDK_BITSTREAM transportEnc_GetBitstream( HANDLE_TRANSPORTENC hTp );
* \param auBits Amount of payload bits required for the current subframe.
* \return Error code.
*/
INT transportEnc_GetStaticBits( HANDLE_TRANSPORTENC hTp, int auBits );
INT transportEnc_GetStaticBits(HANDLE_TRANSPORTENC hTp, int auBits);
/**
* \brief Close transport encoder. This function assures that all allocated memory is freed.
* \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 );
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).
* \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 );
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.
* \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.
* \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.
* 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);
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).
* \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);
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().
* \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);
@@ -274,23 +313,27 @@ int transportEnc_CrcStartReg(HANDLE_TRANSPORTENC hTpEnc, int mBits);
void transportEnc_CrcEndReg(HANDLE_TRANSPORTENC hTpEnc, int reg);
/**
* \brief Get AudioSpecificConfig or StreamMuxConfig from transport encoder handle and write it to dataBuffer.
* \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 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).
* \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 );
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.
* \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 );
TRANSPORTENC_ERROR transportEnc_GetLibInfo(LIB_INFO *info);
#endif /* #ifndef __TPENC_LIB_H__ */
#endif /* #ifndef TPENC_LIB_H */

View File

@@ -0,0 +1,118 @@
/* -----------------------------------------------------------------------------
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):
Description:
*******************************************************************************/
#if !defined(TP_VERSION_H)
#define TP_VERSION_H
/* library info */
#define TP_LIB_VL0 3
#define TP_LIB_VL1 0
#define TP_LIB_VL2 0
#define TP_LIB_TITLE "MPEG Transport"
#ifdef __ANDROID__
#define TP_LIB_BUILD_DATE ""
#define TP_LIB_BUILD_TIME ""
#else
#define TP_LIB_BUILD_DATE __DATE__
#define TP_LIB_BUILD_TIME __TIME__
#endif
#endif /* !defined(TP_VERSION_H) */

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,104 +90,97 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/******************* MPEG transport format encoder library *********************
contents/description: ADIF Transport Headers writing
Author(s):
******************************************************************************/
Description: ADIF Transport Headers writing
*******************************************************************************/
#include "tpenc_adif.h"
#include "tpenc_lib.h"
#include "tpenc_asc.h"
int adifWrite_EncodeHeader(ADIF_INFO *adif,
HANDLE_FDK_BITSTREAM hBs,
INT adif_buffer_fullness)
{
int adifWrite_EncodeHeader(ADIF_INFO *adif, HANDLE_FDK_BITSTREAM hBs,
INT adif_buffer_fullness) {
/* ADIF/PCE/ADTS definitions */
const char adifId[5]="ADIF";
const int copyRightIdPresent=0;
const int originalCopy=0;
const int home=0;
const char adifId[5] = "ADIF";
const int copyRightIdPresent = 0;
const int originalCopy = 0;
const int home = 0;
int err = 0;
int i;
INT sampleRate = adif->samplingRate;
INT totalBitRate = adif->bitRate;
if (adif->headerWritten)
return 0;
if (adif->headerWritten) return 0;
/* Align inside PCE with respect to the first bit of the header */
UINT alignAnchor = FDKgetValidBits(hBs);
/* Signal variable bitrate if buffer fullnes exceeds 20 bit */
adif->bVariableRate = ( adif_buffer_fullness >= (INT)(0x1<<20) ) ? 1 : 0;
adif->bVariableRate = (adif_buffer_fullness >= (INT)(0x1 << 20)) ? 1 : 0;
FDKwriteBits(hBs, adifId[0],8);
FDKwriteBits(hBs, adifId[1],8);
FDKwriteBits(hBs, adifId[2],8);
FDKwriteBits(hBs, adifId[3],8);
FDKwriteBits(hBs, adifId[0], 8);
FDKwriteBits(hBs, adifId[1], 8);
FDKwriteBits(hBs, adifId[2], 8);
FDKwriteBits(hBs, adifId[3], 8);
FDKwriteBits(hBs, copyRightIdPresent ? 1 : 0, 1);
FDKwriteBits(hBs, copyRightIdPresent ? 1:0,1);
if(copyRightIdPresent) {
for(i=0;i<72;i++) {
FDKwriteBits(hBs,0,1);
if (copyRightIdPresent) {
for (i = 0; i < 72; i++) {
FDKwriteBits(hBs, 0, 1);
}
}
FDKwriteBits(hBs, originalCopy ? 1:0,1);
FDKwriteBits(hBs, home ? 1:0,1);
FDKwriteBits(hBs, adif->bVariableRate?1:0, 1);
FDKwriteBits(hBs, totalBitRate,23);
FDKwriteBits(hBs, originalCopy ? 1 : 0, 1);
FDKwriteBits(hBs, home ? 1 : 0, 1);
FDKwriteBits(hBs, adif->bVariableRate ? 1 : 0, 1);
FDKwriteBits(hBs, totalBitRate, 23);
/* we write only one PCE at the moment */
FDKwriteBits(hBs, 0, 4);
if(!adif->bVariableRate) {
if (!adif->bVariableRate) {
FDKwriteBits(hBs, adif_buffer_fullness, 20);
}
/* Write PCE */
transportEnc_writePCE(hBs, adif->cm, sampleRate, adif->instanceTag, adif->profile, 0, 0, alignAnchor);
transportEnc_writePCE(hBs, adif->cm, adif->samplingRate, adif->instanceTag,
adif->profile, adif->matrixMixdownA,
(adif->pseudoSurroundEnable) ? 1 : 0, alignAnchor);
return 0;
return err;
}
int adifWrite_GetHeaderBits(ADIF_INFO *adif)
{
int adifWrite_GetHeaderBits(ADIF_INFO *adif) {
/* ADIF definitions */
const int copyRightIdPresent=0;
const int copyRightIdPresent = 0;
if (adif->headerWritten)
return 0;
if (adif->headerWritten) return 0;
int bits = 0;
bits += 8*4; /* ADIF ID */
bits += 8 * 4; /* ADIF ID */
bits += 1; /* Copyright present */
if (copyRightIdPresent)
bits += 72; /* Copyright ID */
if (copyRightIdPresent) bits += 72; /* Copyright ID */
bits += 26;
bits += 4; /* Number of PCE's */
if(!adif->bVariableRate) {
if (!adif->bVariableRate) {
bits += 20;
}
/* write PCE */
bits = transportEnc_GetPCEBits(adif->cm, 0, bits);
bits = transportEnc_GetPCEBits(adif->cm, adif->matrixMixdownA, bits);
return bits;
}

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/******************* MPEG transport format encoder library *********************
Initial author: Alex Goeschel
contents/description: Transport Headers support
Author(s): Alex Goeschel
******************************************************************************/
Description: Transport Headers support
*******************************************************************************/
#ifndef TPENC_ADIF_H
#define TPENC_ADIF_H
@@ -104,6 +116,9 @@ typedef struct {
int bVariableRate;
int instanceTag;
int headerWritten;
int matrixMixdownA;
int pseudoSurroundEnable;
} ADIF_INFO;
/**
@@ -115,21 +130,17 @@ typedef struct {
*
* \return 0 on success
*/
int adifWrite_EncodeHeader(
ADIF_INFO *adif,
HANDLE_FDK_BITSTREAM hBitStream,
INT adif_buffer_fullness
);
int adifWrite_EncodeHeader(ADIF_INFO *adif, HANDLE_FDK_BITSTREAM hBitStream,
INT adif_buffer_fullness);
/**
* \brief Get bit demand of a ADIF header
*
* \param adif pointer to ADIF_INFO structure
*
* \return amount of bits required to write the ADIF header according to the data
* contained in the adif parameter
* \return amount of bits required to write the ADIF header according to the
* data contained in the adif parameter
*/
int adifWrite_GetHeaderBits( ADIF_INFO *adif );
int adifWrite_GetHeaderBits(ADIF_INFO *adif);
#endif /* TPENC_ADIF_H */

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,48 +90,43 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/******************* MPEG transport format encoder library *********************
Initial author: Alex Groeschel
contents/description: ADTS Transport Headers support
Author(s): Alex Groeschel
******************************************************************************/
Description: ADTS Transport Headers support
*******************************************************************************/
#include "tpenc_adts.h"
#include "tpenc_lib.h"
#include "tpenc_asc.h"
int adtsWrite_CrcStartReg(
HANDLE_ADTS pAdts, /*!< pointer to adts stucture */
HANDLE_FDK_BITSTREAM hBs, /*!< handle to current bit buffer structure */
int mBits /*!< number of bits in crc region */
)
{
HANDLE_ADTS pAdts, /*!< pointer to adts stucture */
HANDLE_FDK_BITSTREAM hBs, /*!< handle to current bit buffer structure */
int mBits /*!< number of bits in crc region */
) {
if (pAdts->protection_absent) {
return 0;
}
return ( FDKcrcStartReg(&pAdts->crcInfo, hBs, mBits) );
return (FDKcrcStartReg(&pAdts->crcInfo, hBs, mBits));
}
void adtsWrite_CrcEndReg(
HANDLE_ADTS pAdts, /*!< pointer to adts crc info stucture */
HANDLE_FDK_BITSTREAM hBs, /*!< handle to current bit buffer structure */
int reg /*!< crc region */
)
{
if (pAdts->protection_absent == 0)
{
HANDLE_ADTS pAdts, /*!< pointer to adts crc info stucture */
HANDLE_FDK_BITSTREAM hBs, /*!< handle to current bit buffer structure */
int reg /*!< crc region */
) {
if (pAdts->protection_absent == 0) {
FDKcrcEndReg(&pAdts->crcInfo, hBs, reg);
}
}
int adtsWrite_GetHeaderBits( HANDLE_ADTS hAdts )
{
int adtsWrite_GetHeaderBits(HANDLE_ADTS hAdts) {
int bits = 0;
if (hAdts->currentBlock == 0) {
@@ -129,14 +135,15 @@ int adtsWrite_GetHeaderBits( HANDLE_ADTS hAdts )
if (!hAdts->protection_absent) {
/* Add header/ single raw data block CRC bits */
bits += 16;
if (hAdts->num_raw_blocks>0) {
if (hAdts->num_raw_blocks > 0) {
/* Add bits of raw data block position markers */
bits += (hAdts->num_raw_blocks)*16;
bits += (hAdts->num_raw_blocks) * 16;
}
}
}
if (!hAdts->protection_absent && hAdts->num_raw_blocks>0) {
/* Add raw data block CRC bits. Not really part of the header, put they cause bit overhead to be accounted. */
if (!hAdts->protection_absent && hAdts->num_raw_blocks > 0) {
/* Add raw data block CRC bits. Not really part of the header, put they
* cause bit overhead to be accounted. */
bits += 16;
}
@@ -145,13 +152,10 @@ int adtsWrite_GetHeaderBits( HANDLE_ADTS hAdts )
return bits;
}
INT adtsWrite_Init(HANDLE_ADTS hAdts, CODER_CONFIG *config)
{
INT adtsWrite_Init(HANDLE_ADTS hAdts, CODER_CONFIG *config) {
/* Sanity checks */
if ( config->nSubFrames < 1
|| config->nSubFrames > 4
|| (int)config->aot > 4
|| (int)config->aot < 1 ) {
if (config->nSubFrames < 1 || config->nSubFrames > 4 ||
(int)config->aot > 4 || (int)config->aot < 1) {
return -1;
}
@@ -161,41 +165,38 @@ INT adtsWrite_Init(HANDLE_ADTS hAdts, CODER_CONFIG *config)
} else {
hAdts->mpeg_id = 1; /* MPEG 2 */
}
hAdts->layer=0;
hAdts->protection_absent = ! (config->flags & CC_PROTECTION);
hAdts->layer = 0;
hAdts->protection_absent = !(config->flags & CC_PROTECTION);
hAdts->profile = ((int)config->aot) - 1;
hAdts->sample_freq_index = getSamplingRateIndex(config->samplingRate);
hAdts->sample_freq_index = getSamplingRateIndex(config->samplingRate, 4);
hAdts->sample_freq = config->samplingRate;
hAdts->private_bit=0;
hAdts->private_bit = 0;
hAdts->channel_mode = config->channelMode;
hAdts->original=0;
hAdts->home=0;
hAdts->original = 0;
hAdts->home = 0;
/* variable header */
hAdts->copyright_id=0;
hAdts->copyright_start=0;
hAdts->copyright_id = 0;
hAdts->copyright_start = 0;
hAdts->num_raw_blocks=config->nSubFrames-1; /* 0 means 1 raw data block */
hAdts->num_raw_blocks = config->nSubFrames - 1; /* 0 means 1 raw data block */
hAdts->channel_config_zero = config->channelConfigZero;
FDKcrcInit(&hAdts->crcInfo, 0x8005, 0xFFFF, 16);
hAdts->currentBlock = 0;
return 0;
}
int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts,
HANDLE_FDK_BITSTREAM hBitStream,
int buffer_fullness,
int frame_length)
{
int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts, HANDLE_FDK_BITSTREAM hBitStream,
int buffer_fullness, int frame_length) {
INT crcIndex = 0;
hAdts->headerBits = adtsWrite_GetHeaderBits(hAdts);
FDK_ASSERT(((frame_length+hAdts->headerBits)/8)<0x2000); /*13 bit*/
FDK_ASSERT(buffer_fullness<0x800); /* 11 bit */
FDK_ASSERT(((frame_length + hAdts->headerBits) / 8) < 0x2000); /*13 bit*/
FDK_ASSERT(buffer_fullness < 0x800); /* 11 bit */
if (!hAdts->protection_absent) {
FDKcrcReset(&hAdts->crcInfo);
@@ -208,8 +209,7 @@ int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts,
hAdts->subFrameStartBit = FDKgetValidBits(hBitStream);
/* Skip new header if this is raw data block 1..n */
if (hAdts->currentBlock == 0)
{
if (hAdts->currentBlock == 0) {
FDKresetBitbuffer(hBitStream, BS_WRITER);
if (hAdts->num_raw_blocks == 0) {
@@ -224,24 +224,27 @@ int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts,
FDKwriteBits(hBitStream, hAdts->profile, 2);
FDKwriteBits(hBitStream, hAdts->sample_freq_index, 4);
FDKwriteBits(hBitStream, hAdts->private_bit, 1);
FDKwriteBits(hBitStream, getChannelConfig(hAdts->channel_mode), 3);
FDKwriteBits(
hBitStream,
getChannelConfig(hAdts->channel_mode, hAdts->channel_config_zero), 3);
FDKwriteBits(hBitStream, hAdts->original, 1);
FDKwriteBits(hBitStream, hAdts->home, 1);
/* variable header */
FDKwriteBits(hBitStream, hAdts->copyright_id, 1);
FDKwriteBits(hBitStream, hAdts->copyright_start, 1);
FDKwriteBits(hBitStream, (frame_length + hAdts->headerBits)>>3, 13);
FDKwriteBits(hBitStream, (frame_length + hAdts->headerBits) >> 3, 13);
FDKwriteBits(hBitStream, buffer_fullness, 11);
FDKwriteBits(hBitStream, hAdts->num_raw_blocks, 2);
if (!hAdts->protection_absent) {
int i;
/* End header CRC portion for single raw data block and write dummy zero values for unknown fields. */
/* End header CRC portion for single raw data block and write dummy zero
* values for unknown fields. */
if (hAdts->num_raw_blocks == 0) {
adtsWrite_CrcEndReg(hAdts, hBitStream, crcIndex);
} else {
for (i=0; i<hAdts->num_raw_blocks; i++) {
for (i = 0; i < hAdts->num_raw_blocks; i++) {
FDKwriteBits(hBitStream, 0, 16);
}
}
@@ -252,14 +255,13 @@ int adtsWrite_EncodeHeader(HANDLE_ADTS hAdts,
return 0;
}
void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts,
HANDLE_FDK_BITSTREAM hBs,
int *pBits)
{
void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts, HANDLE_FDK_BITSTREAM hBs,
int *pBits) {
if (!hAdts->protection_absent) {
FDK_BITSTREAM bsWriter;
FDKinitBitStream(&bsWriter, hBs->hBitBuf.Buffer, hBs->hBitBuf.bufSize, 0, BS_WRITER);
FDKinitBitStream(&bsWriter, hBs->hBitBuf.Buffer, hBs->hBitBuf.bufSize, 0,
BS_WRITER);
FDKpushFor(&bsWriter, 56);
if (hAdts->num_raw_blocks == 0) {
@@ -272,32 +274,35 @@ void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts,
/* Write distance to current data block */
if (hAdts->currentBlock < hAdts->num_raw_blocks) {
FDKpushFor(&bsWriter, hAdts->currentBlock*16);
distance = FDKgetValidBits(hBs) - (56 + (hAdts->num_raw_blocks)*16 + 16);
FDKwriteBits(&bsWriter, distance>>3, 16);
FDKpushFor(&bsWriter, hAdts->currentBlock * 16);
distance =
FDKgetValidBits(hBs) - (56 + (hAdts->num_raw_blocks) * 16 + 16);
FDKwriteBits(&bsWriter, distance >> 3, 16);
}
}
FDKsyncCache(&bsWriter);
}
/* Write total frame lenth for multiple raw data blocks and header CRC */
if (hAdts->num_raw_blocks > 0 && hAdts->currentBlock == hAdts->num_raw_blocks) {
if (hAdts->num_raw_blocks > 0 &&
hAdts->currentBlock == hAdts->num_raw_blocks) {
FDK_BITSTREAM bsWriter;
int crcIndex = 0;
FDKinitBitStream(&bsWriter, hBs->hBitBuf.Buffer, hBs->hBitBuf.bufSize, 0, BS_WRITER);
FDKinitBitStream(&bsWriter, hBs->hBitBuf.Buffer, hBs->hBitBuf.bufSize, 0,
BS_WRITER);
if (!hAdts->protection_absent) {
FDKcrcReset(&hAdts->crcInfo);
crcIndex = FDKcrcStartReg(&hAdts->crcInfo, &bsWriter, 0);
}
/* Write total frame length */
FDKpushFor(&bsWriter, 56-28+2);
FDKwriteBits(&bsWriter, FDKgetValidBits(hBs)>>3, 13);
FDKpushFor(&bsWriter, 56 - 28 + 2);
FDKwriteBits(&bsWriter, FDKgetValidBits(hBs) >> 3, 13);
/* Write header CRC */
if (!hAdts->protection_absent) {
FDKpushFor(&bsWriter, 11+2 + (hAdts->num_raw_blocks)*16);
FDKpushFor(&bsWriter, 11 + 2 + (hAdts->num_raw_blocks) * 16);
FDKcrcEndReg(&hAdts->crcInfo, &bsWriter, crcIndex);
FDKwriteBits(&bsWriter, FDKcrcGetCRC(&hAdts->crcInfo), 16);
}
@@ -312,4 +317,3 @@ void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts,
}
hAdts->currentBlock++;
}

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,20 +90,19 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder **************************
/******************* MPEG transport format encoder library *********************
Initial author: Alex Groeschel
contents/description: ADTS Transport writer
Author(s): Alex Groeschel
******************************************************************************/
Description: ADTS Transport writer
*******************************************************************************/
#ifndef TPENC_ADTS_H
#define TPENC_ADTS_H
#include "tp_data.h"
#include "FDK_crc.h"
@@ -114,9 +124,11 @@ typedef struct {
USHORT frame_length;
UCHAR num_raw_blocks;
UCHAR BufferFullnesStartFlag;
int headerBits; /*!< Header bit demand for the current raw data block */
int currentBlock; /*!< Index of current raw data block */
int subFrameStartBit; /*!< Bit position where the current raw data block begins */
UCHAR channel_config_zero;
int headerBits; /*!< Header bit demand for the current raw data block */
int currentBlock; /*!< Index of current raw data block */
int subFrameStartBit; /*!< Bit position where the current raw data block
begins */
FDK_CRCINFO crcInfo;
} STRUCT_ADTS;
@@ -131,10 +143,7 @@ typedef STRUCT_ADTS *HANDLE_ADTS;
*
* \return 0 in case of success.
*/
INT adtsWrite_Init(
HANDLE_ADTS hAdts,
CODER_CONFIG *config
);
INT adtsWrite_Init(HANDLE_ADTS hAdts, CODER_CONFIG *config);
/**
* \brief Get the total bit overhead caused by ADTS
@@ -143,7 +152,7 @@ INT adtsWrite_Init(
*
* \return Amount of additional bits required for the current raw data block
*/
int adtsWrite_GetHeaderBits( HANDLE_ADTS hAdts );
int adtsWrite_GetHeaderBits(HANDLE_ADTS hAdts);
/**
* \brief Write an ADTS header into the given bitstream. May not write a header
@@ -156,47 +165,36 @@ int adtsWrite_GetHeaderBits( HANDLE_ADTS hAdts );
*
* \return 0 in case of success.
*/
INT adtsWrite_EncodeHeader(
HANDLE_ADTS hAdts,
HANDLE_FDK_BITSTREAM hBitStream,
int bufferFullness,
int frame_length
);
INT adtsWrite_EncodeHeader(HANDLE_ADTS hAdts, HANDLE_FDK_BITSTREAM hBitStream,
int bufferFullness, int frame_length);
/**
* \brief Finish a ADTS raw data block
*
* \param hAdts ADTS data handle
* \param hBs bitstream handle into which the ADTS may be written into
* \param pBits a pointer to a integer holding the current bitstream buffer bit count,
* which is corrected to the current raw data block boundary.
* \param pBits a pointer to a integer holding the current bitstream buffer bit
* count, which is corrected to the current raw data block boundary.
*
*/
void adtsWrite_EndRawDataBlock(
HANDLE_ADTS hAdts,
HANDLE_FDK_BITSTREAM hBs,
int *bits
);
void adtsWrite_EndRawDataBlock(HANDLE_ADTS hAdts, HANDLE_FDK_BITSTREAM hBs,
int *bits);
/**
* \brief Start CRC region with a maximum number of bits
* If mBits is positive zero padding will be used for CRC calculation, if there
* are less than mBits bits available.
* If mBits is negative no zero padding is done.
* If mBits is zero the memory for the buffer is allocated dynamically, the
* number of bits is not limited.
* If mBits is positive zero padding will be used for CRC calculation, if
* there are less than mBits bits available. If mBits is negative no zero
* padding is done. If mBits is zero the memory for the buffer is
* allocated dynamically, the number of bits is not limited.
*
* \param pAdts ADTS data handle
* \param hBs bitstream handle of which the CRC region ends
* \param mBits limit of number of bits to be considered for the requested CRC region
* \param mBits limit of number of bits to be considered for the requested CRC
* region
*
* \return ID for the created region, -1 in case of an error
*/
int adtsWrite_CrcStartReg(
HANDLE_ADTS pAdts,
HANDLE_FDK_BITSTREAM hBs,
int mBits
);
int adtsWrite_CrcStartReg(HANDLE_ADTS pAdts, HANDLE_FDK_BITSTREAM hBs,
int mBits);
/**
* \brief Ends CRC region identified by reg
@@ -205,14 +203,6 @@ int adtsWrite_CrcStartReg(
* \param hBs bitstream handle of which the CRC region ends
* \param reg a CRC region ID returned previously by adtsWrite_CrcStartReg()
*/
void adtsWrite_CrcEndReg(
HANDLE_ADTS pAdts,
HANDLE_FDK_BITSTREAM hBs,
int reg
);
void adtsWrite_CrcEndReg(HANDLE_ADTS pAdts, HANDLE_FDK_BITSTREAM hBs, int reg);
#endif /* TPENC_ADTS_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder **************************
/******************* MPEG transport format encoder library *********************
Author(s): Manuel Jander
Author(s): Manuel Jander
Description: Audio Specific Config writer
******************************************************************************/
*******************************************************************************/
#ifndef TPENC_ASC_H
#define TPENC_ASC_H
@@ -95,10 +107,12 @@ amm-info@iis.fraunhofer.de
* \brief Get channel config from channel mode.
*
* \param channel_mode channel mode
* \param channel_config_zero no standard channel configuration
*
* \return chanel config
*/
int getChannelConfig( CHANNEL_MODE channel_mode );
int getChannelConfig(const CHANNEL_MODE channel_mode,
const UCHAR channel_config_zero);
/**
* \brief Write a Program Config Element.
@@ -113,16 +127,10 @@ int getChannelConfig( CHANNEL_MODE channel_mode );
* \param reference bitstream position for alignment
* \return zero on success, non-zero on failure.
*/
int transportEnc_writePCE(
HANDLE_FDK_BITSTREAM hBs,
CHANNEL_MODE channelMode,
INT sampleRate,
int instanceTagPCE,
int profile,
int matrixMixdownA,
int pseudoSurroundEnable,
UINT alignAnchor
);
int transportEnc_writePCE(HANDLE_FDK_BITSTREAM hBs, CHANNEL_MODE channelMode,
INT sampleRate, int instanceTagPCE, int profile,
int matrixMixdownA, int pseudoSurroundEnable,
UINT alignAnchor);
/**
* \brief Get the bit count required by a Program Config Element
@@ -130,13 +138,10 @@ int transportEnc_writePCE(
* \param channelMode the channel mode to be used
* \param matrix mixdown gain
* \param bit offset at which the PCE would start
* \return the amount of bits required for the PCE including the given bit offset.
* \return the amount of bits required for the PCE including the given bit
* offset.
*/
int transportEnc_GetPCEBits(
CHANNEL_MODE channelMode,
int matrixMixdownA,
int bits
);
int transportEnc_GetPCEBits(CHANNEL_MODE channelMode, int matrixMixdownA,
int bits);
#endif /* TPENC_ASC_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,35 +90,35 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder **************************
/******************* MPEG transport format encoder library *********************
Author(s):
Description:
******************************************************************************/
*******************************************************************************/
#ifndef TPENC_LATM_H
#define TPENC_LATM_H
#include "tpenc_lib.h"
#include "FDK_bitstream.h"
#define DEFAULT_LATM_NR_OF_SUBFRAMES 1
#define DEFAULT_LATM_SMC_REPEAT 8
#define DEFAULT_LATM_SMC_REPEAT 8
#define MAX_AAC_LAYERS 9
#define MAX_AAC_LAYERS 9
#define LATM_MAX_PROGRAMS 1
#define LATM_MAX_STREAM_ID 16
#define LATM_MAX_PROGRAMS 1
#define LATM_MAX_STREAM_ID 16
#define LATM_MAX_LAYERS 1 /*MAX_AAC_LAYERS*/
#define LATM_MAX_LAYERS 1 /*MAX_AAC_LAYERS*/
#define MAX_NR_OF_SUBFRAMES 2 /* set this carefully to avoid buffer overflows */
#define MAX_NR_OF_SUBFRAMES \
2 /* set this carefully to avoid buffer overflows \
*/
typedef enum { LATMVAR_SIMPLE_SEQUENCE } LATM_VAR_MODE;
@@ -118,67 +129,80 @@ typedef struct {
signed int streamID;
} LATM_LAYER_INFO;
typedef struct {
LATM_LAYER_INFO m_linfo[LATM_MAX_PROGRAMS][LATM_MAX_LAYERS];
CODER_CONFIG *config[LATM_MAX_PROGRAMS][LATM_MAX_LAYERS];
LATM_LAYER_INFO m_linfo[LATM_MAX_PROGRAMS][LATM_MAX_LAYERS];
CODER_CONFIG *config[LATM_MAX_PROGRAMS][LATM_MAX_LAYERS];
LATM_VAR_MODE varMode;
TRANSPORT_TYPE tt;
LATM_VAR_MODE varMode;
TRANSPORT_TYPE tt;
int audioMuxLengthBytes;
int audioMuxLengthBytes;
int audioMuxLengthBytesPos;
int taraBufferFullness; /* state of the bit reservoir */
int varStreamCnt;
unsigned int otherDataLenBytes;
int audioMuxLengthBytesPos;
int taraBufferFullness; /* state of the bit reservoir */
int varStreamCnt;
UCHAR latmFrameCounter; /* Current frame number. Counts modulo muxConfigPeriod */
UCHAR muxConfigPeriod; /* Distance in frames between MuxConfig */
UCHAR
latmFrameCounter; /* Current frame number. Counts modulo muxConfigPeriod
*/
UCHAR muxConfigPeriod; /* Distance in frames between MuxConfig */
UCHAR audioMuxVersion; /* AMV1 supports transmission of taraBufferFullness and ASC lengths */
UCHAR audioMuxVersionA; /* for future extensions */
UCHAR
audioMuxVersion; /* AMV1 supports transmission of taraBufferFullness and
ASC lengths */
UCHAR audioMuxVersionA; /* for future extensions */
UCHAR noProgram;
UCHAR noLayer[LATM_MAX_PROGRAMS];
UCHAR fractDelayPresent;
UCHAR noProgram;
UCHAR noLayer[LATM_MAX_PROGRAMS];
UCHAR fractDelayPresent;
UCHAR allStreamsSameTimeFraming;
UCHAR subFrameCnt; /* Current Subframe frame */
UCHAR noSubframes; /* Number of subframes */
UINT latmSubframeStart; /* Position of current subframe start */
UCHAR noSubframes_next;
UCHAR allStreamsSameTimeFraming;
UCHAR subFrameCnt; /* Current Subframe frame */
UCHAR noSubframes; /* Number of subframes */
UINT latmSubframeStart; /* Position of current subframe start */
UCHAR noSubframes_next;
UCHAR fillBits; /* AudioMuxElement fill bits */
UCHAR streamMuxConfigBits;
UCHAR otherDataLenBits; /* AudioMuxElement other data bits */
UCHAR fillBits; /* AudioMuxElement fill bits */
UINT streamMuxConfigBits;
} LATM_STREAM;
typedef LATM_STREAM *HANDLE_LATM_STREAM;
/**
* \brief Initialize LATM_STREAM Handle. Creates automatically one program with one layer with
* the given layerConfig. The layerConfig must be persisten because references to this pointer
* are made at any time again.
* Use transportEnc_Latm_AddLayer() to add more programs/layers.
* \brief Initialize LATM_STREAM Handle. Creates automatically one program with
* one layer with the given layerConfig. The layerConfig must be persisten
* because references to this pointer are made at any time again. Use
* transportEnc_Latm_AddLayer() to add more programs/layers.
*
* \param hLatmStreamInfo HANDLE_LATM_STREAM handle
* \param hBs Bitstream handle
* \param layerConfig a valid CODER_CONFIG struct containing the current audio configuration parameters
* \param layerConfig a valid CODER_CONFIG struct containing the current audio
* configuration parameters
* \param audioMuxVersion the LATM audioMuxVersion to be used
* \param tt the specific TRANSPORT_TYPE to be used, either TT_MP4_LOAS, TT_MP4_LATM_MCP1 or TT_MP4_LATM_MCP0 LOAS
* \param tt the specific TRANSPORT_TYPE to be used, either TT_MP4_LOAS,
* TT_MP4_LATM_MCP1 or TT_MP4_LATM_MCP0 LOAS
* \param cb callback information structure.
*
* \return an TRANSPORTENC_ERROR error code
*/
TRANSPORTENC_ERROR transportEnc_Latm_Init(
HANDLE_LATM_STREAM hLatmStreamInfo,
HANDLE_FDK_BITSTREAM hBs,
CODER_CONFIG *layerConfig,
UINT audioMuxVersion,
TRANSPORT_TYPE tt,
CSTpCallBacks *cb
);
TRANSPORTENC_ERROR transportEnc_Latm_Init(HANDLE_LATM_STREAM hLatmStreamInfo,
HANDLE_FDK_BITSTREAM hBs,
CODER_CONFIG *layerConfig,
UINT audioMuxVersion,
TRANSPORT_TYPE tt, CSTpCallBacks *cb);
/**
* \brief Write addional other data bits in AudioMuxElement
*
* \param hAss HANDLE_LATM_STREAM handle
* \param otherDataBits number of other data bits to be written
*
* \return an TRANSPORTENC_ERROR error code
*/
TRANSPORTENC_ERROR transportEnc_LatmAddOtherDataBits(HANDLE_LATM_STREAM hAss,
const int otherDataBits);
/**
* \brief Get bit demand of next LATM/LOAS header
@@ -188,10 +212,8 @@ TRANSPORTENC_ERROR transportEnc_Latm_Init(
*
* \return the number of bits required by the LATM/LOAS headers
*/
unsigned int transportEnc_LatmCountTotalBitDemandHeader (
HANDLE_LATM_STREAM hAss,
unsigned int streamDataLength
);
unsigned int transportEnc_LatmCountTotalBitDemandHeader(
HANDLE_LATM_STREAM hAss, unsigned int streamDataLength);
/**
* \brief Write LATM/LOAS header into given bitstream handle
@@ -205,42 +227,35 @@ unsigned int transportEnc_LatmCountTotalBitDemandHeader (
* \return an TRANSPORTENC_ERROR error code
*/
TRANSPORTENC_ERROR
transportEnc_LatmWrite (
HANDLE_LATM_STREAM hAss,
HANDLE_FDK_BITSTREAM hBitstream,
int auBits,
int bufferFullness,
CSTpCallBacks *cb
);
transportEnc_LatmWrite(HANDLE_LATM_STREAM hAss, HANDLE_FDK_BITSTREAM hBitstream,
int auBits, int bufferFullness, CSTpCallBacks *cb);
/**
* \brief Adjust bit count relative to current subframe
*
* \param hAss HANDLE_LATM_STREAM handle
* \param pBits pointer to an int, where the current frame bit count is contained,
* and where the subframe relative bit count will be returned into
* \param pBits pointer to an int, where the current frame bit count is
* contained, and where the subframe relative bit count will be returned into
*
* \return void
*/
void transportEnc_LatmAdjustSubframeBits(HANDLE_LATM_STREAM hAss,
int *pBits);
void transportEnc_LatmAdjustSubframeBits(HANDLE_LATM_STREAM hAss, int *pBits);
/**
* \brief Request an LATM frame, which may, or may not be available
*
* \param hAss HANDLE_LATM_STREAM handle
* \param hBs Bitstream handle
* \param pBytes pointer to an int, where the current frame byte count stored into.
* A return value of zero means that currently no LATM/LOAS frame can be returned.
* The latter is expected in case of multiple subframes being used.
* \param pBytes pointer to an int, where the current frame byte count stored
* into. A return value of zero means that currently no LATM/LOAS frame can be
* returned. The latter is expected in case of multiple subframes being
* used.
*
* \return void
* \return an TRANSPORTENC_ERROR error code
*/
void transportEnc_LatmGetFrame(
HANDLE_LATM_STREAM hAss,
HANDLE_FDK_BITSTREAM hBs,
int *pBytes
);
TRANSPORTENC_ERROR transportEnc_LatmGetFrame(HANDLE_LATM_STREAM hAss,
HANDLE_FDK_BITSTREAM hBs,
int *pBytes);
/**
* \brief Write a StreamMuxConfig into the given bitstream handle
@@ -253,12 +268,7 @@ void transportEnc_LatmGetFrame(
* \return void
*/
TRANSPORTENC_ERROR
CreateStreamMuxConfig(
HANDLE_LATM_STREAM hAss,
HANDLE_FDK_BITSTREAM hBs,
int bufferFullness,
CSTpCallBacks *cb
);
CreateStreamMuxConfig(HANDLE_LATM_STREAM hAss, HANDLE_FDK_BITSTREAM hBs,
int bufferFullness, CSTpCallBacks *cb);
#endif /* TPENC_LATM_H */

View File

@@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V.
All rights reserved.
© 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.
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.
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.
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.
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:
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 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
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.
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.
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."
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.
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.
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.
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
@@ -79,24 +90,24 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */
----------------------------------------------------------------------------- */
/************************** MPEG-4 Transport Encoder ************************
/******************* MPEG transport format encoder library *********************
Author(s): Manuel Jander
Author(s): Manuel Jander
Description: MPEG Transport encode
******************************************************************************/
*******************************************************************************/
#include "tpenc_lib.h"
/* library info */
#include "version"
#include "tp_version.h"
#define MODULE_NAME "transportEnc"
#include "tpenc_asc.h"
#include "conv_string.h"
#include "tpenc_adts.h"
@@ -104,25 +115,23 @@ amm-info@iis.fraunhofer.de
#include "tpenc_latm.h"
typedef struct {
int curSubFrame;
int nSubFrames;
int prevBits;
} RAWPACKETS_INFO;
struct TRANSPORTENC
{
struct TRANSPORTENC {
CODER_CONFIG config;
TRANSPORT_TYPE transportFmt; /*!< MPEG4 transport type. */
TRANSPORT_TYPE transportFmt; /*!< MPEG4 transport type. */
FDK_BITSTREAM bitStream;
UCHAR *bsBuffer;
INT bsBufferSize;
INT pceFrameCounter; /*!< Indicates frame period when PCE must be written in raw_data_block.
-1 means not to write a PCE in raw_dat_block. */
INT pceFrameCounter; /*!< Indicates frame period when PCE must be written in
raw_data_block. -1 means not to write a PCE in
raw_dat_block. */
union {
STRUCT_ADTS adts;
@@ -132,8 +141,6 @@ struct TRANSPORTENC
RAWPACKETS_INFO raw;
} writer;
CSTpCallBacks callbacks;
@@ -141,24 +148,22 @@ struct TRANSPORTENC
typedef struct _TRANSPORTENC_STRUCT TRANSPORTENC_STRUCT;
/*
* MEMORY Declaration
*/
C_ALLOC_MEM(Ram_TransportEncoder, TRANSPORTENC, 1)
C_ALLOC_MEM(Ram_TransportEncoder, struct TRANSPORTENC, 1)
TRANSPORTENC_ERROR transportEnc_Open( HANDLE_TRANSPORTENC *phTpEnc )
{
TRANSPORTENC_ERROR transportEnc_Open(HANDLE_TRANSPORTENC *phTpEnc) {
HANDLE_TRANSPORTENC hTpEnc;
if ( phTpEnc == NULL ){
if (phTpEnc == NULL) {
return TRANSPORTENC_INVALID_PARAMETER;
}
hTpEnc = GetRam_TransportEncoder(0);
if ( hTpEnc == NULL ) {
if (hTpEnc == NULL) {
return TRANSPORTENC_NO_MEM;
}
@@ -169,29 +174,31 @@ TRANSPORTENC_ERROR transportEnc_Open( HANDLE_TRANSPORTENC *phTpEnc )
/**
* \brief Get frame period of PCE in raw_data_block.
*
* - Write PCE only if necessary. PCE can be part of the ASC if chConfig==0 whererfore
* no additonal PCE will be written in raw_data_block.
* - Write PCE only if necessary. PCE can be part of the ASC if chConfig==0
* whererfore no additonal PCE will be written in raw_data_block.
* - A matrixMixdown coefficient can only be written if chConfig is 5.0 or 5.1.
* - The PCE repetition rate in raw_data_block can be controlled via headerPeriod parameter.
* - The PCE repetition rate in raw_data_block can be controlled via
* headerPeriod parameter.
*
* \param channelConfig Channel Configuration derived from Channel Mode
* \param channelMode Encoder Channel Mode.
* \param channelConfigZero No standard channel configuration.
* \param transportFmt Format of the transport to be written.
* \param headerPeriod Chosen PCE frame repetition rate.
* \param matrixMixdownA Indicates if a valid Matrix Mixdown coefficient is available.
* \param matrixMixdownA Indicates if a valid Matrix Mixdown coefficient
* is available.
*
* \return PCE frame repetition rate. -1 means no PCE present in raw_data_block.
* \return PCE frame repetition rate. -1 means no PCE present in
* raw_data_block.
*/
static INT getPceRepetitionRate(
const int channelConfig,
const TRANSPORT_TYPE transportFmt,
const int headerPeriod,
const int matrixMixdownA
)
{
static INT getPceRepetitionRate(const CHANNEL_MODE channelMode,
const int channelConfigZero,
const TRANSPORT_TYPE transportFmt,
const int headerPeriod,
const int matrixMixdownA) {
INT pceFrameCounter = -1; /* variable to be returned */
if (headerPeriod>0) {
switch ( channelConfig ) {
if (headerPeriod > 0) {
switch (getChannelConfig(channelMode, channelConfigZero)) {
case 0:
switch (transportFmt) {
case TT_MP4_ADTS:
@@ -199,53 +206,52 @@ static INT getPceRepetitionRate(
case TT_MP4_RAW:
pceFrameCounter = headerPeriod;
break;
case TT_MP4_ADIF: /* ADIF header comprises PCE */
case TT_MP4_LOAS: /* PCE in ASC if chChonfig==0 */
case TT_MP4_LATM_MCP1: /* PCE in ASC if chChonfig==0 */
case TT_DRM: /* PCE not allowed in DRM */
case TT_MP4_ADIF: /* ADIF header comprises PCE */
if ((channelMode == MODE_1_2_2) || (channelMode == MODE_1_2_2_1)) {
pceFrameCounter = headerPeriod; /* repeating pce only meaningful
for potential matrix mixdown */
break;
}
case TT_MP4_LOAS: /* PCE in ASC if chChonfig==0 */
case TT_MP4_LATM_MCP1: /* PCE in ASC if chChonfig==0 */
default:
pceFrameCounter = -1; /* no PCE in raw_data_block */
pceFrameCounter = -1; /* no PCE in raw_data_block */
}
break;
case 5: /* MODE_1_2_2 */
case 6: /* MODE_1_2_2_1 */
/* matrixMixdownCoefficient can only be written if 5.0 and 5.1 config present. */
if (matrixMixdownA!=0) {
/* matrixMixdownCoefficient can only be written if 5.0 and 5.1 config
* present. */
if (matrixMixdownA != 0) {
switch (transportFmt) {
case TT_MP4_ADIF: /* ADIF header comprises PCE */
case TT_MP4_ADIF: /* ADIF header comprises PCE */
case TT_MP4_ADTS:
case TT_MP4_LOAS: /* no PCE in ASC because chConfig!=0 */
case TT_MP4_LATM_MCP1: /* no PCE in ASC because chConfig!=0 */
case TT_MP4_LOAS: /* no PCE in ASC because chConfig!=0 */
case TT_MP4_LATM_MCP1: /* no PCE in ASC because chConfig!=0 */
case TT_MP4_LATM_MCP0:
case TT_MP4_RAW:
pceFrameCounter = headerPeriod;
break;
case TT_DRM: /* PCE not allowed in DRM */
default:
pceFrameCounter = -1; /* no PCE in raw_data_block */
} /* switch transportFmt */
} /* if matrixMixdownA!=0 */
pceFrameCounter = -1; /* no PCE in raw_data_block */
} /* switch transportFmt */
} /* if matrixMixdownA!=0 */
break;
default:
pceFrameCounter = -1; /* no PCE in raw_data_block */
} /* switch getChannelConfig() */
} /* if headerPeriod>0 */
pceFrameCounter = -1; /* no PCE in raw_data_block */
} /* switch getChannelConfig() */
} /* if headerPeriod>0 */
else {
pceFrameCounter = -1; /* no PCE in raw_data_block */
pceFrameCounter = -1; /* no PCE in raw_data_block */
}
return pceFrameCounter;
}
TRANSPORTENC_ERROR transportEnc_Init(
HANDLE_TRANSPORTENC hTpEnc,
UCHAR *bsBuffer,
INT bsBufferSize,
TRANSPORT_TYPE transportFmt,
CODER_CONFIG *cconfig,
UINT flags
)
{
TRANSPORTENC_ERROR transportEnc_Init(HANDLE_TRANSPORTENC hTpEnc,
UCHAR *bsBuffer, INT bsBufferSize,
TRANSPORT_TYPE transportFmt,
CODER_CONFIG *cconfig, UINT flags) {
/* Copy configuration structure */
FDKmemcpy(&hTpEnc->config, cconfig, sizeof(CODER_CONFIG));
@@ -255,86 +261,95 @@ TRANSPORTENC_ERROR transportEnc_Init(
hTpEnc->bsBuffer = bsBuffer;
hTpEnc->bsBufferSize = bsBufferSize;
FDKinitBitStream(&hTpEnc->bitStream, hTpEnc->bsBuffer, hTpEnc->bsBufferSize, 0, BS_WRITER);
FDKinitBitStream(&hTpEnc->bitStream, hTpEnc->bsBuffer, hTpEnc->bsBufferSize,
0, BS_WRITER);
switch (transportFmt) {
case TT_MP4_ADIF:
/* Sanity checks */
if ((hTpEnc->config.aot != AOT_AAC_LC) ||
(hTpEnc->config.samplesPerFrame != 1024)) {
return TRANSPORTENC_INVALID_PARAMETER;
}
hTpEnc->writer.adif.headerWritten = 0;
hTpEnc->writer.adif.samplingRate = hTpEnc->config.samplingRate;
hTpEnc->writer.adif.bitRate = hTpEnc->config.bitRate;
hTpEnc->writer.adif.profile = ((int)hTpEnc->config.aot) - 1;
hTpEnc->writer.adif.cm = hTpEnc->config.channelMode;
hTpEnc->writer.adif.bVariableRate = 0;
hTpEnc->writer.adif.instanceTag = 0;
hTpEnc->writer.adif.matrixMixdownA = hTpEnc->config.matrixMixdownA;
hTpEnc->writer.adif.pseudoSurroundEnable =
(hTpEnc->config.flags & CC_PSEUDO_SURROUND) ? 1 : 0;
break;
case TT_MP4_ADIF:
/* Sanity checks */
if ( (hTpEnc->config.aot != AOT_AAC_LC)
||(hTpEnc->config.samplesPerFrame != 1024))
{
return TRANSPORTENC_INVALID_PARAMETER;
}
hTpEnc->writer.adif.headerWritten = 0;
hTpEnc->writer.adif.samplingRate = hTpEnc->config.samplingRate;
hTpEnc->writer.adif.bitRate = hTpEnc->config.bitRate;
hTpEnc->writer.adif.profile = ((int)hTpEnc->config.aot) - 1;
hTpEnc->writer.adif.cm = hTpEnc->config.channelMode;
hTpEnc->writer.adif.bVariableRate = 0;
hTpEnc->writer.adif.instanceTag = 0;
break;
case TT_MP4_ADTS:
/* Sanity checks */
if ((hTpEnc->config.aot != AOT_AAC_LC) ||
(hTpEnc->config.samplesPerFrame != 1024)) {
return TRANSPORTENC_INVALID_PARAMETER;
}
if (adtsWrite_Init(&hTpEnc->writer.adts, &hTpEnc->config) != 0) {
return TRANSPORTENC_INVALID_PARAMETER;
}
break;
case TT_MP4_ADTS:
/* Sanity checks */
if ( ( hTpEnc->config.aot != AOT_AAC_LC)
||(hTpEnc->config.samplesPerFrame != 1024) )
{
return TRANSPORTENC_INVALID_PARAMETER;
}
if ( adtsWrite_Init(&hTpEnc->writer.adts, &hTpEnc->config) != 0) {
return TRANSPORTENC_INVALID_PARAMETER;
}
break;
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1:
{
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1: {
TRANSPORTENC_ERROR error;
error = transportEnc_Latm_Init(
&hTpEnc->writer.latm,
&hTpEnc->bitStream,
&hTpEnc->config,
flags & TP_FLAG_LATM_AMV,
transportFmt,
&hTpEnc->callbacks
);
error = transportEnc_Latm_Init(&hTpEnc->writer.latm, &hTpEnc->bitStream,
&hTpEnc->config, flags & TP_FLAG_LATM_AMV,
transportFmt, &hTpEnc->callbacks);
if (error != TRANSPORTENC_OK) {
return error;
}
}
break;
} break;
case TT_MP4_RAW:
hTpEnc->writer.raw.curSubFrame = 0;
hTpEnc->writer.raw.nSubFrames = hTpEnc->config.nSubFrames;
break;
case TT_MP4_RAW:
hTpEnc->writer.raw.curSubFrame = 0;
hTpEnc->writer.raw.nSubFrames = hTpEnc->config.nSubFrames;
break;
default:
return TRANSPORTENC_INVALID_PARAMETER;
default:
return TRANSPORTENC_INVALID_PARAMETER;
}
/* pceFrameCounter indicates if PCE must be written in raw_data_block. */
hTpEnc->pceFrameCounter = getPceRepetitionRate(
getChannelConfig(hTpEnc->config.channelMode),
transportFmt,
hTpEnc->config.headerPeriod,
hTpEnc->config.matrixMixdownA);
hTpEnc->config.channelMode, hTpEnc->config.channelConfigZero,
transportFmt, hTpEnc->config.headerPeriod, hTpEnc->config.matrixMixdownA);
return TRANSPORTENC_OK;
}
HANDLE_FDK_BITSTREAM transportEnc_GetBitstream( HANDLE_TRANSPORTENC hTp )
{
TRANSPORTENC_ERROR transportEnc_AddOtherDataBits(HANDLE_TRANSPORTENC hTpEnc,
const int nBits) {
TRANSPORTENC_ERROR tpErr = TRANSPORTENC_OK;
switch (hTpEnc->transportFmt) {
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1:
case TT_MP4_LOAS:
tpErr = transportEnc_LatmAddOtherDataBits(&hTpEnc->writer.latm, nBits);
break;
case TT_MP4_ADTS:
case TT_MP4_ADIF:
case TT_MP4_RAW:
default:
tpErr = TRANSPORTENC_UNKOWN_ERROR;
}
return tpErr;
}
HANDLE_FDK_BITSTREAM transportEnc_GetBitstream(HANDLE_TRANSPORTENC hTp) {
return &hTp->bitStream;
}
int transportEnc_RegisterSbrCallback( HANDLE_TRANSPORTENC hTpEnc, const cbSbr_t cbSbr, void* user_data)
{
int transportEnc_RegisterSbrCallback(HANDLE_TRANSPORTENC hTpEnc,
const cbSbr_t cbSbr, void *user_data) {
if (hTpEnc == NULL) {
return -1;
}
@@ -342,15 +357,29 @@ int transportEnc_RegisterSbrCallback( HANDLE_TRANSPORTENC hTpEnc, const cbSbr_t
hTpEnc->callbacks.cbSbrData = user_data;
return 0;
}
int transportEnc_RegisterUsacCallback(HANDLE_TRANSPORTENC hTpEnc,
const cbUsac_t cbUsac, void *user_data) {
if (hTpEnc == NULL) {
return -1;
}
hTpEnc->callbacks.cbUsac = cbUsac;
hTpEnc->callbacks.cbUsacData = user_data;
return 0;
}
int transportEnc_RegisterSscCallback(HANDLE_TRANSPORTENC hTpEnc,
const cbSsc_t cbSsc, void *user_data) {
if (hTpEnc == NULL) {
return -1;
}
hTpEnc->callbacks.cbSsc = cbSsc;
hTpEnc->callbacks.cbSscData = user_data;
return 0;
}
TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(
HANDLE_TRANSPORTENC hTp,
INT frameUsedBits,
int bufferFullness,
int ncc
)
{
TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(HANDLE_TRANSPORTENC hTp,
INT frameUsedBits,
int bufferFullness, int ncc) {
TRANSPORTENC_ERROR err = TRANSPORTENC_OK;
if (!hTp) {
@@ -359,48 +388,41 @@ TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(
HANDLE_FDK_BITSTREAM hBs = &hTp->bitStream;
/* In case of writing PCE in raw_data_block frameUsedBits must be adapted. */
if (hTp->pceFrameCounter>=hTp->config.headerPeriod) {
frameUsedBits += transportEnc_GetPCEBits(hTp->config.channelMode, hTp->config.matrixMixdownA, 3); /* Consider 3 bits ID signalling in alignment */
if (hTp->pceFrameCounter >= hTp->config.headerPeriod) {
frameUsedBits += transportEnc_GetPCEBits(
hTp->config.channelMode, hTp->config.matrixMixdownA,
3); /* Consider 3 bits ID signalling in alignment */
}
switch (hTp->transportFmt) {
case TT_MP4_ADIF:
FDKinitBitStream(&hTp->bitStream, hTp->bsBuffer, hTp->bsBufferSize, 0, BS_WRITER);
adifWrite_EncodeHeader(
&hTp->writer.adif,
hBs,
bufferFullness
);
FDKinitBitStream(&hTp->bitStream, hTp->bsBuffer, hTp->bsBufferSize, 0,
BS_WRITER);
if (0 != adifWrite_EncodeHeader(&hTp->writer.adif, hBs, bufferFullness)) {
err = TRANSPORTENC_INVALID_CONFIG;
}
break;
case TT_MP4_ADTS:
bufferFullness /= ncc; /* Number of Considered Channels */
bufferFullness /= ncc; /* Number of Considered Channels */
bufferFullness /= 32;
bufferFullness = FDKmin(0x7FF, bufferFullness); /* Signal variable rate */
adtsWrite_EncodeHeader(
&hTp->writer.adts,
&hTp->bitStream,
bufferFullness,
frameUsedBits
);
adtsWrite_EncodeHeader(&hTp->writer.adts, &hTp->bitStream, bufferFullness,
frameUsedBits);
break;
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1:
bufferFullness /= ncc; /* Number of Considered Channels */
bufferFullness /= ncc; /* Number of Considered Channels */
bufferFullness /= 32;
bufferFullness = FDKmin(0xFF, bufferFullness); /* Signal variable rate */
transportEnc_LatmWrite(
&hTp->writer.latm,
hBs,
frameUsedBits,
bufferFullness,
&hTp->callbacks
);
break;
transportEnc_LatmWrite(&hTp->writer.latm, hBs, frameUsedBits,
bufferFullness, &hTp->callbacks);
break;
case TT_MP4_RAW:
if (hTp->writer.raw.curSubFrame >= hTp->writer.raw.nSubFrames) {
hTp->writer.raw.curSubFrame = 0;
FDKinitBitStream(&hTp->bitStream, hTp->bsBuffer, hTp->bsBufferSize, 0, BS_WRITER);
FDKinitBitStream(&hTp->bitStream, hTp->bsBuffer, hTp->bsBufferSize, 0,
BS_WRITER);
}
hTp->writer.raw.prevBits = FDKgetValidBits(hBs);
break;
@@ -410,7 +432,7 @@ TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(
}
/* Write PCE in raw_data_block if required */
if (hTp->pceFrameCounter>=hTp->config.headerPeriod) {
if (hTp->pceFrameCounter >= hTp->config.headerPeriod) {
INT crcIndex = 0;
/* Align inside PCE with repsect to the first bit of the raw_data_block() */
UINT alignAnchor = FDKgetValidBits(&hTp->bitStream);
@@ -418,29 +440,34 @@ TRANSPORTENC_ERROR transportEnc_WriteAccessUnit(
/* Write PCE element ID bits */
FDKwriteBits(&hTp->bitStream, ID_PCE, 3);
if ( (hTp->transportFmt==TT_MP4_ADTS) && !hTp->writer.adts.protection_absent) {
if ((hTp->transportFmt == TT_MP4_ADTS) &&
!hTp->writer.adts.protection_absent) {
crcIndex = adtsWrite_CrcStartReg(&hTp->writer.adts, &hTp->bitStream, 0);
}
/* Write PCE as first raw_data_block element */
transportEnc_writePCE(&hTp->bitStream, hTp->config.channelMode, hTp->config.samplingRate, 0, 1, hTp->config.matrixMixdownA, (hTp->config.flags&CC_PSEUDO_SURROUND)?1:0, alignAnchor);
transportEnc_writePCE(
&hTp->bitStream, hTp->config.channelMode, hTp->config.samplingRate, 0,
1, hTp->config.matrixMixdownA,
(hTp->config.flags & CC_PSEUDO_SURROUND) ? 1 : 0, alignAnchor);
if ( (hTp->transportFmt==TT_MP4_ADTS) && !hTp->writer.adts.protection_absent) {
if ((hTp->transportFmt == TT_MP4_ADTS) &&
!hTp->writer.adts.protection_absent) {
adtsWrite_CrcEndReg(&hTp->writer.adts, &hTp->bitStream, crcIndex);
}
hTp->pceFrameCounter = 0; /* reset pce frame counter */
}
if (hTp->pceFrameCounter!=-1) {
hTp->pceFrameCounter++; /* Update pceFrameCounter only if PCE writing is active. */
if (hTp->pceFrameCounter != -1) {
hTp->pceFrameCounter++; /* Update pceFrameCounter only if PCE writing is
active. */
}
return err;
}
TRANSPORTENC_ERROR transportEnc_EndAccessUnit(HANDLE_TRANSPORTENC hTp, int *bits)
{
TRANSPORTENC_ERROR transportEnc_EndAccessUnit(HANDLE_TRANSPORTENC hTp,
int *bits) {
switch (hTp->transportFmt) {
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1:
@@ -465,8 +492,9 @@ TRANSPORTENC_ERROR transportEnc_EndAccessUnit(HANDLE_TRANSPORTENC hTp, int *bits
return TRANSPORTENC_OK;
}
TRANSPORTENC_ERROR transportEnc_GetFrame(HANDLE_TRANSPORTENC hTpEnc, int *nbytes)
{
TRANSPORTENC_ERROR transportEnc_GetFrame(HANDLE_TRANSPORTENC hTpEnc,
int *nbytes) {
TRANSPORTENC_ERROR tpErr = TRANSPORTENC_OK;
HANDLE_FDK_BITSTREAM hBs = &hTpEnc->bitStream;
switch (hTpEnc->transportFmt) {
@@ -474,11 +502,12 @@ TRANSPORTENC_ERROR transportEnc_GetFrame(HANDLE_TRANSPORTENC hTpEnc, int *nbytes
case TT_MP4_LATM_MCP1:
case TT_MP4_LOAS:
*nbytes = hTpEnc->bsBufferSize;
transportEnc_LatmGetFrame(&hTpEnc->writer.latm, hBs, nbytes);
tpErr = transportEnc_LatmGetFrame(&hTpEnc->writer.latm, hBs, nbytes);
break;
case TT_MP4_ADTS:
if (hTpEnc->writer.adts.currentBlock >= hTpEnc->writer.adts.num_raw_blocks+1) {
*nbytes = (FDKgetValidBits(hBs) + 7)>>3;
if (hTpEnc->writer.adts.currentBlock >=
hTpEnc->writer.adts.num_raw_blocks + 1) {
*nbytes = (FDKgetValidBits(hBs) + 7) >> 3;
hTpEnc->writer.adts.currentBlock = 0;
} else {
*nbytes = 0;
@@ -486,28 +515,31 @@ TRANSPORTENC_ERROR transportEnc_GetFrame(HANDLE_TRANSPORTENC hTpEnc, int *nbytes
break;
case TT_MP4_ADIF:
FDK_ASSERT((INT)FDKgetValidBits(hBs) >= 0);
*nbytes = (FDKgetValidBits(hBs) + 7)>>3;
*nbytes = (FDKgetValidBits(hBs) + 7) >> 3;
break;
case TT_MP4_RAW:
FDKsyncCache(hBs);
hTpEnc->writer.raw.curSubFrame++;
*nbytes = ((FDKgetValidBits(hBs)-hTpEnc->writer.raw.prevBits) + 7)>>3;
*nbytes = ((FDKgetValidBits(hBs) - hTpEnc->writer.raw.prevBits) + 7) >> 3;
break;
default:
break;
}
return TRANSPORTENC_OK;
return tpErr;
}
INT transportEnc_GetStaticBits( HANDLE_TRANSPORTENC hTp, int auBits )
{
INT transportEnc_GetStaticBits(HANDLE_TRANSPORTENC hTp, int auBits) {
INT nbits = 0, nPceBits = 0;
/* Write PCE within raw_data_block in transport lib. */
if (hTp->pceFrameCounter>=hTp->config.headerPeriod) {
nPceBits = transportEnc_GetPCEBits(hTp->config.channelMode, hTp->config.matrixMixdownA, 3); /* Consider 3 bits ID signalling in alignment */
auBits += nPceBits; /* Adapt required raw_data_block bit consumtpion for AU length information e.g. in LATM/LOAS configuration. */
if (hTp->pceFrameCounter >= hTp->config.headerPeriod) {
nPceBits = transportEnc_GetPCEBits(
hTp->config.channelMode, hTp->config.matrixMixdownA,
3); /* Consider 3 bits ID signalling in alignment */
auBits += nPceBits; /* Adapt required raw_data_block bit consumtpion for AU
length information e.g. in LATM/LOAS configuration.
*/
}
switch (hTp->transportFmt) {
@@ -521,73 +553,70 @@ INT transportEnc_GetStaticBits( HANDLE_TRANSPORTENC hTp, int auBits )
case TT_MP4_LOAS:
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1:
nbits = transportEnc_LatmCountTotalBitDemandHeader( &hTp->writer.latm, auBits );
nbits =
transportEnc_LatmCountTotalBitDemandHeader(&hTp->writer.latm, auBits);
break;
default:
nbits = 0;
break;
}
/* PCE is written in the transport library therefore the bit consumption is part of the transport static bits. */
/* PCE is written in the transport library therefore the bit consumption is
* part of the transport static bits. */
nbits += nPceBits;
return nbits;
}
void transportEnc_Close(HANDLE_TRANSPORTENC *phTp)
{
if (phTp != NULL)
{
void transportEnc_Close(HANDLE_TRANSPORTENC *phTp) {
if (phTp != NULL) {
if (*phTp != NULL) {
FreeRam_TransportEncoder(phTp);
}
}
}
int transportEnc_CrcStartReg(HANDLE_TRANSPORTENC hTpEnc, int mBits)
{
int transportEnc_CrcStartReg(HANDLE_TRANSPORTENC hTpEnc, int mBits) {
int crcReg = 0;
switch (hTpEnc->transportFmt) {
case TT_MP4_ADTS:
crcReg = adtsWrite_CrcStartReg(&hTpEnc->writer.adts, &hTpEnc->bitStream, mBits);
break;
default:
break;
case TT_MP4_ADTS:
crcReg = adtsWrite_CrcStartReg(&hTpEnc->writer.adts, &hTpEnc->bitStream,
mBits);
break;
default:
break;
}
return crcReg;
}
void transportEnc_CrcEndReg(HANDLE_TRANSPORTENC hTpEnc, int reg)
{
void transportEnc_CrcEndReg(HANDLE_TRANSPORTENC hTpEnc, int reg) {
switch (hTpEnc->transportFmt) {
case TT_MP4_ADTS:
adtsWrite_CrcEndReg(&hTpEnc->writer.adts, &hTpEnc->bitStream, reg);
break;
default:
break;
case TT_MP4_ADTS:
adtsWrite_CrcEndReg(&hTpEnc->writer.adts, &hTpEnc->bitStream, reg);
break;
default:
break;
}
}
TRANSPORTENC_ERROR transportEnc_GetConf(HANDLE_TRANSPORTENC hTpEnc,
CODER_CONFIG *cc,
FDK_BITSTREAM *dataBuffer,
UINT *confType)
{
TRANSPORTENC_ERROR transportEnc_GetConf(HANDLE_TRANSPORTENC hTpEnc,
CODER_CONFIG *cc,
FDK_BITSTREAM *dataBuffer,
UINT *confType) {
TRANSPORTENC_ERROR tpErr = TRANSPORTENC_OK;
HANDLE_LATM_STREAM hLatmConfig = &hTpEnc->writer.latm;
*confType = 0; /* set confType variable to default */
/* write StreamMuxConfig or AudioSpecificConfig depending on format used */
switch (hTpEnc->transportFmt)
{
switch (hTpEnc->transportFmt) {
case TT_MP4_LATM_MCP0:
case TT_MP4_LATM_MCP1:
case TT_MP4_LOAS:
tpErr = CreateStreamMuxConfig(hLatmConfig, dataBuffer, 0, &hTpEnc->callbacks);
tpErr =
CreateStreamMuxConfig(hLatmConfig, dataBuffer, 0, &hTpEnc->callbacks);
*confType = 1; /* config is SMC */
break;
default:
@@ -597,11 +626,9 @@ TRANSPORTENC_ERROR transportEnc_GetConf(HANDLE_TRANSPORTENC hTpEnc,
}
return tpErr;
}
TRANSPORTENC_ERROR transportEnc_GetLibInfo( LIB_INFO *info )
{
TRANSPORTENC_ERROR transportEnc_GetLibInfo(LIB_INFO *info) {
int i;
if (info == NULL) {
@@ -629,14 +656,8 @@ TRANSPORTENC_ERROR transportEnc_GetLibInfo( LIB_INFO *info )
info->title = TP_LIB_TITLE;
/* Set flags */
info->flags = 0
| CAPF_ADIF
| CAPF_ADTS
| CAPF_LATM
| CAPF_LOAS
| CAPF_RAWPACKETS
;
info->flags =
0 | CAPF_ADIF | CAPF_ADTS | CAPF_LATM | CAPF_LOAS | CAPF_RAWPACKETS;
return TRANSPORTENC_OK;
}

View File

@@ -1,13 +0,0 @@
/* library info */
#define TP_LIB_VL0 2
#define TP_LIB_VL1 3
#define TP_LIB_VL2 6
#define TP_LIB_TITLE "MPEG Transport"
#ifdef __ANDROID__
#define TP_LIB_BUILD_DATE ""
#define TP_LIB_BUILD_TIME ""
#else
#define TP_LIB_BUILD_DATE __DATE__
#define TP_LIB_BUILD_TIME __TIME__
#endif