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

4
.clang-format Normal file
View File

@ -0,0 +1,4 @@
BasedOnStyle: Google
SortIncludes: false
# Do not reformat the Doxygen-style comments in the code
CommentPragmas : "^ * \\\\"

View File

@ -11,16 +11,22 @@ cc_library_static {
"libMpegTPEnc/src/*.cpp", "libMpegTPEnc/src/*.cpp",
"libSBRdec/src/*.cpp", "libSBRdec/src/*.cpp",
"libSBRenc/src/*.cpp", "libSBRenc/src/*.cpp",
"libArithCoding/src/*.cpp",
"libDRCdec/src/*.cpp",
"libSACdec/src/*.cpp",
"libSACenc/src/*.cpp",
], ],
cflags: [ cflags: [
"-Werror", "-Werror",
"-Wno-constant-conversion", "-Wno-unused-parameter",
"-Wno-sequence-point",
"-Wno-extra",
"-Wno-#warnings", "-Wno-#warnings",
"-Wno-constant-logical-operand", "-Wuninitialized",
"-Wno-self-assign", "-Wno-self-assign",
], ],
sanitize: {
misc_undefined:["unsigned-integer-overflow", "signed-integer-overflow"],
cfi: true,
},
export_include_dirs: [ export_include_dirs: [
"libAACdec/include", "libAACdec/include",
"libAACenc/include", "libAACenc/include",
@ -31,5 +37,9 @@ cc_library_static {
"libMpegTPEnc/include", "libMpegTPEnc/include",
"libSBRdec/include", "libSBRdec/include",
"libSBRenc/include", "libSBRenc/include",
"libArithCoding/include",
"libDRCdec/include",
"libSACdec/include",
"libSACenc/include",
], ],
} }

104
NOTICE
View File

@ -1,72 +1,84 @@
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
© Copyright 1995 - 2012 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

173
libAACdec/src/FDK_delay.cpp Normal file
View File

@ -0,0 +1,173 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description:
*******************************************************************************/
#include "FDK_delay.h"
#include "genericStds.h"
#define MAX_FRAME_LENGTH (1024)
INT FDK_Delay_Create(FDK_SignalDelay* data, const USHORT delay,
const UCHAR num_channels) {
FDK_ASSERT(data != NULL);
FDK_ASSERT(num_channels > 0);
if (delay > 0) {
data->delay_line =
(INT_PCM*)FDKcalloc(num_channels * delay, sizeof(INT_PCM));
if (data->delay_line == NULL) {
return -1;
}
} else {
data->delay_line = NULL;
}
data->num_channels = num_channels;
data->delay = delay;
return 0;
}
void FDK_Delay_Apply(FDK_SignalDelay* data, FIXP_PCM* time_buffer,
const UINT frame_length, const UCHAR channel) {
FDK_ASSERT(data != NULL);
if (data->delay > 0) {
C_ALLOC_SCRATCH_START(tmp, FIXP_PCM, MAX_FRAME_LENGTH)
FDK_ASSERT(frame_length <= MAX_FRAME_LENGTH);
FDK_ASSERT(channel < data->num_channels);
FDK_ASSERT(time_buffer != NULL);
if (frame_length >= data->delay) {
FDKmemcpy(tmp, &time_buffer[frame_length - data->delay],
data->delay * sizeof(FIXP_PCM));
FDKmemmove(&time_buffer[data->delay], &time_buffer[0],
(frame_length - data->delay) * sizeof(FIXP_PCM));
FDKmemcpy(&time_buffer[0], &data->delay_line[channel * data->delay],
data->delay * sizeof(FIXP_PCM));
FDKmemcpy(&data->delay_line[channel * data->delay], tmp,
data->delay * sizeof(FIXP_PCM));
} else {
FDKmemcpy(tmp, &time_buffer[0], frame_length * sizeof(FIXP_PCM));
FDKmemcpy(&time_buffer[0], &data->delay_line[channel * data->delay],
frame_length * sizeof(FIXP_PCM));
FDKmemcpy(&data->delay_line[channel * data->delay],
&data->delay_line[channel * data->delay + frame_length],
(data->delay - frame_length) * sizeof(FIXP_PCM));
FDKmemcpy(&data->delay_line[channel * data->delay +
(data->delay - frame_length)],
tmp, frame_length * sizeof(FIXP_PCM));
}
C_ALLOC_SCRATCH_END(tmp, FIXP_PCM, MAX_FRAME_LENGTH)
}
return;
}
void FDK_Delay_Destroy(FDK_SignalDelay* data) {
if (data->delay_line != NULL) {
FDKfree(data->delay_line);
}
data->delay_line = NULL;
data->delay = 0;
data->num_channels = 0;
return;
}

152
libAACdec/src/FDK_delay.h Normal file
View File

@ -0,0 +1,152 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description:
*******************************************************************************/
#ifndef FDK_DELAY_H
#define FDK_DELAY_H
#include "aac_rom.h"
/**
* Structure representing one delay element for multiple channels.
*/
typedef struct {
INT_PCM* delay_line; /*!< Pointer which stores allocated delay line. */
USHORT delay; /*!< Delay required in samples (per channel). */
UCHAR num_channels; /*!< Number of channels to delay. */
} FDK_SignalDelay;
/**
* \brief Create delay element for multiple channels with fixed delay value.
*
* \param data Pointer delay element structure.
* \param delay Required delay value in samples per channel.
* \param num_channels Required number of channels.
*
* \return -1 on out of memory, else 0
*/
INT FDK_Delay_Create(FDK_SignalDelay* data, const USHORT delay,
const UCHAR num_channels);
/**
* \brief Apply delay to one channel (non-interleaved storage assumed).
*
* \param data Pointer delay element structure.
* \param time_buffer Pointer to signal to delay.
* \param frame_length Frame length of input/output signal (needs to be >=
* delay).
* \param channel Index of current channel (0 <= channel < num_channels).
*
* \return void
*/
void FDK_Delay_Apply(FDK_SignalDelay* data, FIXP_PCM* time_buffer,
const UINT frame_length, const UCHAR channel);
/**
* \brief Destroy delay element.
*
* \param data Pointer delay element structure.
*
* \return void
*/
void FDK_Delay_Destroy(FDK_SignalDelay* data);
#endif /* #ifndef FDK_DELAY_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,13 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
******************************************************************************/ Description:
*******************************************************************************/
#include "aac_ram.h" #include "aac_ram.h"
#include "aac_rom.h" #include "aac_rom.h"
@ -93,10 +106,17 @@ amm-info@iis.fraunhofer.de
#define WORKBUFFER1_TAG 0 #define WORKBUFFER1_TAG 0
#define WORKBUFFER2_TAG 1 #define WORKBUFFER2_TAG 1
/*! The structure AAC_DECODER_INSTANCE is the top level structure holding all decoder configurations, #define WORKBUFFER3_TAG 4
handles and structs. #define WORKBUFFER4_TAG 5
#define WORKBUFFER5_TAG 6
#define WORKBUFFER6_TAG 7
/*! The structure AAC_DECODER_INSTANCE is the top level structure holding all
decoder configurations, handles and structs.
*/ */
C_ALLOC_MEM(AacDecoder, AAC_DECODER_INSTANCE, 1) C_ALLOC_MEM(AacDecoder, struct AAC_DECODER_INSTANCE, 1)
/*! /*!
\name StaticAacData \name StaticAacData
@ -105,21 +125,36 @@ C_ALLOC_MEM(AacDecoder, AAC_DECODER_INSTANCE, 1)
*/ */
/* @{ */ /* @{ */
/*! The structure CAacDecoderStaticChannelInfo contains the static sideinfo which is needed /*! The structure CAacDecoderStaticChannelInfo contains the static sideinfo
for the decoding of one aac channel. <br> which is needed for the decoding of one aac channel. <br> Dimension:
Dimension: #AacDecoderChannels */ #AacDecoderChannels */
C_ALLOC_MEM2(AacDecoderStaticChannelInfo, CAacDecoderStaticChannelInfo, 1, (8)) C_ALLOC_MEM2(AacDecoderStaticChannelInfo, CAacDecoderStaticChannelInfo, 1, (8))
/*! The structure CAacDecoderChannelInfo contains the dynamic sideinfo which is needed /*! The structure CAacDecoderChannelInfo contains the dynamic sideinfo which is
for the decoding of one aac channel. <br> needed for the decoding of one aac channel. <br> Dimension:
Dimension: #AacDecoderChannels */ #AacDecoderChannels */
C_AALLOC_MEM2(AacDecoderChannelInfo, CAacDecoderChannelInfo, 1, (8)) C_AALLOC_MEM2(AacDecoderChannelInfo, CAacDecoderChannelInfo, 1, (8))
/*! Overlap buffer */ /*! Overlap buffer */
C_ALLOC_MEM2(OverlapBuffer, FIXP_DBL, OverlapBufferSize, (8)) C_AALLOC_MEM2(OverlapBuffer, FIXP_DBL, OverlapBufferSize, (8))
C_ALLOC_MEM(DrcInfo, CDrcInfo, 1) C_ALLOC_MEM(DrcInfo, CDrcInfo, 1)
/*! The structure CpePersistentData holds the persistent data shared by both
channels of a CPE. <br> It needs to be allocated for each CPE. <br>
Dimension: 1 */
C_ALLOC_MEM(CpePersistentData, CpePersistentData, 1)
/*! The structure CCplxPredictionData holds data for complex stereo prediction.
<br> Dimension: 1
*/
C_ALLOC_MEM(CplxPredictionData, CCplxPredictionData, 1)
/*! The buffer holds time samples for the crossfade in case of an USAC DASH IPF
config change Dimension: (8)
*/
C_ALLOC_MEM2(TimeDataFlush, INT_PCM, TIME_DATA_FLUSH_SIZE, (8))
/* @} */ /* @} */
/*! /*!
@ -128,15 +163,23 @@ C_ALLOC_MEM(DrcInfo, CDrcInfo, 1)
Dynamic memory areas, might be reused in other algorithm sections, Dynamic memory areas, might be reused in other algorithm sections,
e.g. the sbr decoder e.g. the sbr decoder
*/ */
C_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL, ((8)*1024), SECT_DATA_L2, WORKBUFFER2_TAG)
/* Take into consideration to make use of the WorkBufferCore[3/4] for decoder
* configurations with more than 2 channels */
C_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL, ((8) * 1024), SECT_DATA_L2,
WORKBUFFER2_TAG)
C_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1, 1, SECT_DATA_L1, WORKBUFFER1_TAG) C_ALLOC_MEM_OVERLAY(WorkBufferCore3, FIXP_DBL, WB_SECTION_SIZE, SECT_DATA_L2,
WORKBUFFER3_TAG)
/* @{ */ C_AALLOC_MEM(WorkBufferCore4, FIXP_DBL, WB_SECTION_SIZE)
C_ALLOC_MEM_OVERLAY(WorkBufferCore6, SCHAR,
fMax((INT)(sizeof(FIXP_DBL) * WB_SECTION_SIZE),
/* @} */ (INT)sizeof(CAacDecoderCommonData)),
SECT_DATA_L2, WORKBUFFER6_TAG)
C_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1, 1, SECT_DATA_L1,
WORKBUFFER1_TAG)
/* double buffer size needed for de-/interleaving */
C_ALLOC_MEM_OVERLAY(WorkBufferCore5, PCM_DEC, (8) * (1024 * 4) * 2,
SECT_DATA_EXTERN, WORKBUFFER5_TAG)

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: Description:
******************************************************************************/ *******************************************************************************/
#ifndef AAC_RAM_H #ifndef AAC_RAM_H
#define AAC_RAM_H #define AAC_RAM_H
@ -97,6 +109,8 @@ amm-info@iis.fraunhofer.de
#include "channel.h" #include "channel.h"
#include "ac_arith_coder.h"
#include "aacdec_hcr_types.h" #include "aacdec_hcr_types.h"
#include "aacdec_hcr.h" #include "aacdec_hcr.h"
@ -113,8 +127,21 @@ H_ALLOC_MEM(AacDecoderStaticChannelInfo, CAacDecoderStaticChannelInfo)
H_ALLOC_MEM(AacDecoderChannelInfo, CAacDecoderChannelInfo) H_ALLOC_MEM(AacDecoderChannelInfo, CAacDecoderChannelInfo)
H_ALLOC_MEM(OverlapBuffer, FIXP_DBL) H_ALLOC_MEM(OverlapBuffer, FIXP_DBL)
H_ALLOC_MEM(CpePersistentData, CpePersistentData)
H_ALLOC_MEM(CplxPredictionData, CCplxPredictionData)
H_ALLOC_MEM(SpectralCoeffs, FIXP_DBL)
H_ALLOC_MEM(SpecScale, SHORT)
H_ALLOC_MEM(TimeDataFlush, INT_PCM)
H_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1) H_ALLOC_MEM_OVERLAY(WorkBufferCore1, CWorkBufferCore1)
H_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL) H_ALLOC_MEM_OVERLAY(WorkBufferCore2, FIXP_DBL)
H_ALLOC_MEM_OVERLAY(WorkBufferCore3, FIXP_DBL)
H_ALLOC_MEM(WorkBufferCore4, FIXP_DBL)
H_ALLOC_MEM_OVERLAY(WorkBufferCore5, PCM_DEC)
H_ALLOC_MEM_OVERLAY(WorkBufferCore6, SCHAR)
#endif /* #ifndef AAC_RAM_H */ #endif /* #ifndef AAC_RAM_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: Definition of constant tables Description: Definition of constant tables
******************************************************************************/ *******************************************************************************/
#ifndef AAC_ROM_H #ifndef AAC_ROM_H
#define AAC_ROM_H #define AAC_ROM_H
@ -96,7 +108,20 @@ amm-info@iis.fraunhofer.de
#include "aacdec_hcr_types.h" #include "aacdec_hcr_types.h"
#include "aacdec_hcrs.h" #include "aacdec_hcrs.h"
#define AAC_NF_NO_RANDOM_VAL 512 /*!< Size of random number array for noise floor */ #define PCM_DEC FIXP_DBL
#define MAXVAL_PCM_DEC MAXVAL_DBL
#define MINVAL_PCM_DEC MINVAL_DBL
#define FIXP_DBL2PCM_DEC(x) (x)
#define PCM_DEC2FIXP_DBL(x) (x)
#define PCM_DEC_BITS DFRACT_BITS
#define PCM_DEC2FX_PCM(x) FX_DBL2FX_PCM(x)
#define FX_PCM2PCM_DEC(x) FX_PCM2FX_DBL(x)
#define AACDEC_MAX_CH_CONF 14
#define AACDEC_CH_ELEMENTS_TAB_SIZE 7 /*!< Size of element tables */
#define AAC_NF_NO_RANDOM_VAL \
512 /*!< Size of random number array for noise floor */
#define INV_QUANT_TABLESIZE 256 #define INV_QUANT_TABLESIZE 256
@ -112,6 +137,11 @@ extern const SCHAR ExponentTable [4][14] ;
#define WTS2 (-2) #define WTS2 (-2)
extern const FIXP_WTB LowDelaySynthesis512[1536]; extern const FIXP_WTB LowDelaySynthesis512[1536];
extern const FIXP_WTB LowDelaySynthesis480[1440]; extern const FIXP_WTB LowDelaySynthesis480[1440];
extern const FIXP_WTB LowDelaySynthesis256[768];
extern const FIXP_WTB LowDelaySynthesis240[720];
extern const FIXP_WTB LowDelaySynthesis160[480];
extern const FIXP_WTB LowDelaySynthesis128[384];
extern const FIXP_WTB LowDelaySynthesis120[360];
typedef struct { typedef struct {
const SHORT *sfbOffsetLong; const SHORT *sfbOffsetLong;
@ -123,13 +153,9 @@ typedef struct {
extern const SFB_INFO sfbOffsetTables[5][16]; extern const SFB_INFO sfbOffsetTables[5][16];
/* Huffman tables */ /* Huffman tables */
enum { enum { HuffmanBits = 2, HuffmanEntries = (1 << HuffmanBits) };
HuffmanBits = 2,
HuffmanEntries = (1 << HuffmanBits)
};
typedef struct typedef struct {
{
const USHORT (*CodeBook)[HuffmanEntries]; const USHORT (*CodeBook)[HuffmanEntries];
UCHAR Dimension; UCHAR Dimension;
UCHAR numBits; UCHAR numBits;
@ -139,7 +165,6 @@ typedef struct
extern const CodeBookDescription AACcodeBookDescriptionTable[13]; extern const CodeBookDescription AACcodeBookDescriptionTable[13];
extern const CodeBookDescription AACcodeBookDescriptionSCL; extern const CodeBookDescription AACcodeBookDescriptionSCL;
extern const STATEFUNC aStateConstant2State[]; extern const STATEFUNC aStateConstant2State[];
extern const SCHAR aCodebook2StartInt[]; extern const SCHAR aCodebook2StartInt[];
@ -161,7 +186,6 @@ extern const USHORT aLargestAbsoluteValue[];
extern const UINT aHuffTreeRvlcEscape[]; extern const UINT aHuffTreeRvlcEscape[];
extern const UINT aHuffTreeRvlCodewds[]; extern const UINT aHuffTreeRvlCodewds[];
extern const UCHAR tns_max_bands_tbl[13][2]; extern const UCHAR tns_max_bands_tbl[13][2];
extern const UCHAR tns_max_bands_tbl_480[13]; extern const UCHAR tns_max_bands_tbl_480[13];
@ -172,7 +196,10 @@ extern const UCHAR tns_max_bands_tbl_512[13];
extern const FIXP_TCC FDKaacDec_tnsCoeff3[8]; extern const FIXP_TCC FDKaacDec_tnsCoeff3[8];
extern const FIXP_TCC FDKaacDec_tnsCoeff4[16]; extern const FIXP_TCC FDKaacDec_tnsCoeff4[16];
extern const USHORT randomSign[AAC_NF_NO_RANDOM_VAL/16]; extern const UCHAR FDKaacDec_tnsCoeff3_gain_ld[];
extern const UCHAR FDKaacDec_tnsCoeff4_gain_ld[];
extern const USHORT AacDec_randomSign[AAC_NF_NO_RANDOM_VAL / 16];
extern const FIXP_DBL pow2_div24minus1[47]; extern const FIXP_DBL pow2_div24minus1[47];
extern const int offsetTab[2][16]; extern const int offsetTab[2][16];
@ -183,6 +210,28 @@ extern const UCHAR channelMappingTablePassthrough[15][8];
extern const UCHAR channelMappingTableWAV[15][8]; extern const UCHAR channelMappingTableWAV[15][8];
/* Lookup tables for elements in ER bitstream */ /* Lookup tables for elements in ER bitstream */
extern const MP4_ELEMENT_ID elementsTab[15][7]; extern const MP4_ELEMENT_ID elementsTab[AACDEC_MAX_CH_CONF]
[AACDEC_CH_ELEMENTS_TAB_SIZE];
#define SF_FNA_COEFFS \
1 /* Compile-time prescaler for MDST-filter coefficients. */
/* SF_FNA_COEFFS > 0 should only be considered for FIXP_DBL-coefficients */
/* (i.e. if CPLX_PRED_FILTER_16BIT is not defined). */
/* With FIXP_DBL loss of precision is possible for SF_FNA_COEFFS > 11. */
#ifdef CPLX_PRED_FILTER_16BIT
#define FIXP_FILT FIXP_SGL
#define FILT(a) ((FL2FXCONST_SGL(a)) >> SF_FNA_COEFFS)
#else
#define FIXP_FILT FIXP_DBL
#define FILT(a) ((FL2FXCONST_DBL(a)) >> SF_FNA_COEFFS)
#endif
extern const FIXP_FILT mdst_filt_coef_curr[20][3]; /* MDST-filter coefficient
tables used for current
window */
extern const FIXP_FILT mdst_filt_coef_prev[6][4]; /* MDST-filter coefficient
tables used for previous
window */
#endif /* #ifndef AAC_ROM_H */ #endif /* #ifndef AAC_ROM_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,111 +90,103 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Christian Griebel Author(s): Christian Griebel
Description: Dynamic range control (DRC) decoder tool for AAC Description: Dynamic range control (DRC) decoder tool for AAC
******************************************************************************/ *******************************************************************************/
#ifndef AACDEC_DRC_H #ifndef AACDEC_DRC_H
#define AACDEC_DRC_H #define AACDEC_DRC_H
#include "tp_data.h" /* for program config element support */ #include "tp_data.h" /* for program config element support */
#include "aacdec_drc_types.h" #include "aacdec_drc_types.h"
#include "channel.h" #include "channel.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
#define AACDEC_DRC_DFLT_EXPIRY_FRAMES ( 50 ) /* Default DRC data expiry time in AAC frames */ #define AACDEC_DRC_DFLT_EXPIRY_FRAMES \
(0) /* Default DRC data expiry time in AAC frames */
/* #define AACDEC_DRC_IGNORE_FRAMES_WITH_MULTIPLE_CH_THREADS */ /* The name says
it all. */
/* #define AACDEC_DRC_DEBUG */
/** /**
* \brief DRC module setting parameters * \brief DRC module setting parameters
*/ */
typedef enum typedef enum {
{
DRC_CUT_SCALE = 0, DRC_CUT_SCALE = 0,
DRC_BOOST_SCALE, DRC_BOOST_SCALE,
TARGET_REF_LEVEL, TARGET_REF_LEVEL,
DRC_BS_DELAY, DRC_BS_DELAY,
DRC_DATA_EXPIRY_FRAME, DRC_DATA_EXPIRY_FRAME,
APPLY_NORMALIZATION, APPLY_NORMALIZATION,
APPLY_HEAVY_COMPRESSION APPLY_HEAVY_COMPRESSION,
DEFAULT_PRESENTATION_MODE,
ENCODER_TARGET_LEVEL,
MAX_OUTPUT_CHANNELS,
UNIDRC_PRECEDENCE
} AACDEC_DRC_PARAM; } AACDEC_DRC_PARAM;
/** /**
* \brief DRC module interface functions * \brief DRC module interface functions
*/ */
void aacDecoder_drcInit ( void aacDecoder_drcInit(HANDLE_AAC_DRC self);
HANDLE_AAC_DRC self );
void aacDecoder_drcInitChannelData ( void aacDecoder_drcInitChannelData(CDrcChannelData *pDrcChannel);
CDrcChannelData *pDrcChannel );
AAC_DECODER_ERROR aacDecoder_drcSetParam ( AAC_DECODER_ERROR aacDecoder_drcSetParam(HANDLE_AAC_DRC self,
HANDLE_AAC_DRC self, AACDEC_DRC_PARAM param, INT value);
AACDEC_DRC_PARAM param,
INT value );
int aacDecoder_drcMarkPayload ( int aacDecoder_drcMarkPayload(HANDLE_AAC_DRC self, HANDLE_FDK_BITSTREAM hBs,
HANDLE_AAC_DRC self,
HANDLE_FDK_BITSTREAM hBs,
AACDEC_DRC_PAYLOAD_TYPE type); AACDEC_DRC_PAYLOAD_TYPE type);
int aacDecoder_drcProlog( int aacDecoder_drcProlog(
HANDLE_AAC_DRC self, HANDLE_AAC_DRC self, HANDLE_FDK_BITSTREAM hBs,
HANDLE_FDK_BITSTREAM hBs,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[], CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
UCHAR pceInstanceTag, UCHAR pceInstanceTag, UCHAR channelMapping[], int validChannels);
UCHAR channelMapping[],
int numChannels );
/** /**
* \brief Apply DRC. If SBR is present, DRC data is handed over to the SBR decoder. * \brief Apply DRC. If SBR is present, DRC data is handed over to the SBR
* decoder.
* \param self AAC decoder instance * \param self AAC decoder instance
* \param pSbrDec pointer to SBR decoder instance * \param pSbrDec pointer to SBR decoder instance
* \param pAacDecoderChannelInfo AAC decoder channel instance to be processed * \param pAacDecoderChannelInfo AAC decoder channel instance to be processed
* \param pDrcDat DRC channel data * \param pDrcDat DRC channel data
* \param extGain Pointer to a FIXP_DBL where a externally applyable gain will be stored into (independently on whether it will be apply internally or not). * \param extGain Pointer to a FIXP_DBL where a externally applyable gain will
* At function call the buffer must hold the scale (0 >= scale < DFRACT_BITS) to be applied on the gain value. * be stored into (independently on whether it will be apply internally or not).
* At function call the buffer must hold the scale (0 >= scale <
* DFRACT_BITS) to be applied on the gain value.
* \param ch channel index * \param ch channel index
* \param aacFrameSize AAC frame size * \param aacFrameSize AAC frame size
* \param bSbrPresent flag indicating that SBR is present, in which case DRC is handed over to the SBR instance pSbrDec * \param bSbrPresent flag indicating that SBR is present, in which case DRC is
* handed over to the SBR instance pSbrDec
*/ */
void aacDecoder_drcApply ( void aacDecoder_drcApply(HANDLE_AAC_DRC self, void *pSbrDec,
HANDLE_AAC_DRC self,
void *pSbrDec,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CDrcChannelData *pDrcDat, CDrcChannelData *pDrcDat, FIXP_DBL *extGain, int ch,
FIXP_DBL *extGain, int aacFrameSize, int bSbrPresent);
int ch,
int aacFrameSize,
int bSbrPresent );
int aacDecoder_drcEpilog( int aacDecoder_drcEpilog(
HANDLE_AAC_DRC self, HANDLE_AAC_DRC self, HANDLE_FDK_BITSTREAM hBs,
HANDLE_FDK_BITSTREAM hBs,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[], CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
UCHAR pceInstanceTag, UCHAR pceInstanceTag, UCHAR channelMapping[], int validChannels);
UCHAR channelMapping[],
int validChannels );
/** /**
* \brief Get metadata information found in bitstream. * \brief Get metadata information found in bitstream.
* \param self DRC module instance handle. * \param self DRC module instance handle.
* \param pPresMode Pointer to field where the presentation mode will be written to. * \param pPresMode Pointer to field where the presentation mode will be written
* \param pProgRefLevel Pointer to field where the program reference level will be written to. * to.
* \param pProgRefLevel Pointer to field where the program reference level will
* be written to.
* \return Nothing. * \return Nothing.
*/ */
void aacDecoder_drcGetInfo ( void aacDecoder_drcGetInfo(HANDLE_AAC_DRC self, SCHAR *pPresMode,
HANDLE_AAC_DRC self,
SCHAR *pPresMode,
SCHAR *pProgRefLevel); SCHAR *pProgRefLevel);
#endif /* AACDEC_DRC_H */ #endif /* AACDEC_DRC_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,38 +90,49 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Christian Griebel Author(s): Christian Griebel
Description: Dynamic range control (DRC) global data types Description: Dynamic range control (DRC) global data types
******************************************************************************/ *******************************************************************************/
#ifndef AACDEC_DRC_TYPES_H #ifndef AACDEC_DRC_TYPES_H
#define AACDEC_DRC_TYPES_H #define AACDEC_DRC_TYPES_H
#include "common_fix.h" #include "common_fix.h"
#define MAX_DRC_THREADS ( 3 ) /* Heavy compression value is handled just like MPEG DRC data */ #define MAX_DRC_THREADS \
((8) + 1) /* Heavy compression value is handled just like MPEG DRC data */
#define MAX_DRC_BANDS (16) /* 2^LEN_DRC_BAND_INCR (LEN_DRC_BAND_INCR = 4) */ #define MAX_DRC_BANDS (16) /* 2^LEN_DRC_BAND_INCR (LEN_DRC_BAND_INCR = 4) */
/** /**
* \brief DRC module global data types * \brief DRC module global data types
*/ */
typedef enum typedef enum {
{
UNKNOWN_PAYLOAD = 0, UNKNOWN_PAYLOAD = 0,
MPEG_DRC_EXT_DATA = 1, MPEG_DRC_EXT_DATA = 1,
DVB_DRC_ANC_DATA = 2 DVB_DRC_ANC_DATA = 2
} AACDEC_DRC_PAYLOAD_TYPE; } AACDEC_DRC_PAYLOAD_TYPE;
typedef struct /**
{ * \brief Options for parameter handling / presentation mode
*/
typedef enum {
DISABLED_PARAMETER_HANDLING = -1, /*!< DRC parameter handling disabled, all
parameters are applied as requested. */
ENABLED_PARAMETER_HANDLING =
0, /*!< Apply changes to requested DRC parameters to prevent clipping */
DRC_PRESENTATION_MODE_1 = 1, /*!< DRC Presentation mode 1*/
DRC_PRESENTATION_MODE_2 = 2 /*!< DRC Presentation mode 2*/
} AACDEC_DRC_PARAMETER_HANDLING;
typedef struct {
UINT expiryCount; UINT expiryCount;
UINT numBands; UINT numBands;
USHORT bandTop[MAX_DRC_BANDS]; USHORT bandTop[MAX_DRC_BANDS];
@ -120,55 +142,79 @@ typedef struct
} CDrcChannelData; } CDrcChannelData;
typedef struct typedef struct {
{
UINT excludedChnsMask; UINT excludedChnsMask;
SCHAR progRefLevel; SCHAR progRefLevel;
SCHAR presMode; /* Presentation mode: 0 (not indicated), 1, 2, and 3 (reserved). */ SCHAR presMode; /* Presentation mode: 0 (not indicated), 1, 2, and 3
(reserved). */
SCHAR pceInstanceTag; SCHAR pceInstanceTag;
CDrcChannelData channelData; CDrcChannelData channelData;
} CDrcPayload; } CDrcPayload;
typedef struct typedef struct {
{ /* DRC parameters: Latest user requests */
FIXP_DBL cut; /* The attenuation scale factor currently used. */ FIXP_DBL usrCut;
FIXP_DBL usrCut; /* The latest attenuation scale factor set by user. */ FIXP_DBL usrBoost;
FIXP_DBL boost; /* The boost scale factor currently used. */ UCHAR usrApplyHeavyCompression;
FIXP_DBL usrBoost; /* The latest boost scale factor set by user. */
/* DRC parameters: Currently used, possibly changed by
* aacDecoder_drcParameterHandling */
FIXP_DBL cut; /* attenuation scale factor */
FIXP_DBL boost; /* boost scale factor */
SCHAR targetRefLevel; /* target reference level for loudness normalization */
UCHAR applyHeavyCompression; /* heavy compression (DVB) flag */
UINT expiryFrame; UINT expiryFrame;
SCHAR targetRefLevel;
UCHAR bsDelayEnable; UCHAR bsDelayEnable;
UCHAR applyDigitalNorm; UCHAR applyDigitalNorm;
UCHAR applyHeavyCompression;
AACDEC_DRC_PARAMETER_HANDLING defaultPresentationMode;
UCHAR encoderTargetLevel;
} CDrcParams; } CDrcParams;
typedef struct {
typedef struct CDrcParams
{ params; /* Module parameters that can be set by user (via SetParam API
CDrcParams params; /* Module parameters that can be set by user (via SetParam API function) */ function) */
UCHAR enable; /* Switch that controls dynamic range processing */ UCHAR enable; /* Switch that controls dynamic range processing */
UCHAR digitalNorm; /* Switch to en-/disable reference level normalization in digital domain */ UCHAR digitalNorm; /* Switch to en-/disable reference level normalization in
digital domain */
USHORT numPayloads; /* The number of DRC data payload elements found within frame */ UCHAR update; /* Flag indicating the change of a user or bitstream parameter
USHORT numThreads; /* The number of DRC data threads extracted from the found payload elements */ which affects aacDecoder_drcParameterHandling */
INT numOutChannels; /* Number of output channels */
INT prevAacNumChannels; /* Previous number of channels of aac bitstream, used
for update flag */
USHORT numPayloads; /* The number of DRC data payload elements found within
frame */
USHORT
numThreads; /* The number of DRC data threads extracted from the found
payload elements */
SCHAR progRefLevel; /* Program reference level for all channels */ SCHAR progRefLevel; /* Program reference level for all channels */
UCHAR progRefLevelPresent; /* Program reference level found in bitstream */ UCHAR progRefLevelPresent; /* Program reference level found in bitstream */
UINT prlExpiryCount; /* Counter that can be used to monitor the life time of the program reference level. */ UINT prlExpiryCount; /* Counter that can be used to monitor the life time of
the program reference level. */
SCHAR presMode; /* Presentation mode as defined in ETSI TS 101 154 */ SCHAR presMode; /* Presentation mode as defined in ETSI TS 101 154 */
UCHAR dvbAncDataAvailable; /* Flag that indicates whether DVB ancillary data is present or not */ UCHAR dvbAncDataAvailable; /* Flag that indicates whether DVB ancillary data
UINT dvbAncDataPosition; /* Used to store the DVB ancillary data payload position in the bitstream (only one per frame) */ is present or not */
UINT drcPayloadPosition[MAX_DRC_THREADS]; /* Used to store the DRC payload positions in the bitstream */ UINT dvbAncDataPosition; /* Used to store the DVB ancillary data payload
position in the bitstream (only one per frame) */
UINT drcPayloadPosition[MAX_DRC_THREADS]; /* Used to store the DRC payload
positions in the bitstream */
UCHAR
uniDrcPrecedence; /* Flag for signalling that uniDrc is active and takes
precedence over legacy DRC */
} CDrcInfo; } CDrcInfo;
typedef CDrcInfo *HANDLE_AAC_DRC; typedef CDrcInfo *HANDLE_AAC_DRC;
#endif /* AACDEC_DRC_TYPES_H */ #endif /* AACDEC_DRC_TYPES_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,48 +90,39 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder *************************** /**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions) Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Interface function declaration; common defines Description: HCR Decoder: Interface function declaration; common defines
and structures; defines for switching error-generator, and structures; defines for switching error-generator,
-detector, and -concealment -detector, and -concealment
*******************************************************************************/ *******************************************************************************/
#ifndef _AACDEC_HCR_H_ #ifndef AACDEC_HCR_H
#define _AACDEC_HCR_H_ #define AACDEC_HCR_H
#include "channelinfo.h" #include "channelinfo.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
void HcrInitRom (H_HCR_INFO hHcr); UINT HcrInit(H_HCR_INFO pHcr, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UINT HcrInit(H_HCR_INFO pHcr,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
HANDLE_FDK_BITSTREAM bs); HANDLE_FDK_BITSTREAM bs);
UINT HcrDecoder (H_HCR_INFO hHcr, UINT HcrDecoder(H_HCR_INFO hHcr, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
HANDLE_FDK_BITSTREAM bs); HANDLE_FDK_BITSTREAM bs);
void CarryBitToBranchValue( void CarryBitToBranchValue(UCHAR carryBit, UINT treeNode, UINT *branchValue,
UCHAR carryBit, UINT *branchNode);
UINT treeNode,
UINT *branchValue,
UINT *branchNode
);
void CHcr_Read(HANDLE_FDK_BITSTREAM bs, void CHcr_Read(HANDLE_FDK_BITSTREAM bs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo); CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const MP4_ELEMENT_ID globalHcrType);
void HcrMuteErroneousLines(H_HCR_INFO hHcr); void HcrMuteErroneousLines(H_HCR_INFO hHcr);
void setHcrType(H_HCR_INFO hHcr, MP4_ELEMENT_ID type); void setHcrType(H_HCR_INFO hHcr, MP4_ELEMENT_ID type);
INT getHcrType(H_HCR_INFO hHcr); INT getHcrType(H_HCR_INFO hHcr);
#endif /* AACDEC_HCR_H */
#endif /* _AACDEC_HCR_H_ */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,39 +90,38 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder *************************** /**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions) Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Bitstream reading Description: HCR Decoder: Bitstream reading
*******************************************************************************/ *******************************************************************************/
#include "aacdec_hcr_bit.h" #include "aacdec_hcr_bit.h"
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
description: This function toggles the read direction. description: This function toggles the read direction.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
input: current read direction input: current read direction
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: new read direction return: new read direction
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
UCHAR ToggleReadDirection(UCHAR readDirection) */
{ UCHAR ToggleReadDirection(UCHAR readDirection) {
if (readDirection == FROM_LEFT_TO_RIGHT) { if (readDirection == FROM_LEFT_TO_RIGHT) {
return FROM_RIGHT_TO_LEFT; return FROM_RIGHT_TO_LEFT;
} } else {
else {
return FROM_LEFT_TO_RIGHT; return FROM_LEFT_TO_RIGHT;
} }
} }
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
description: This function returns a bit from the bitstream according to read direction. description: This function returns a bit from the bitstream according to
It is called very often, therefore it makes sense to inline it (runtime). read direction. It is called very often, therefore it makes sense to inline it
(runtime).
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
input: - handle to FDK bitstream input: - handle to FDK bitstream
- reference value marking start of bitfield - reference value marking start of bitfield
@ -120,12 +130,10 @@ UCHAR ToggleReadDirection(UCHAR readDirection)
- readDirection - readDirection
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - bit from bitstream return: - bit from bitstream
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs, */
USHORT *pLeftStartOfSegment, UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pLeftStartOfSegment,
USHORT *pRightStartOfSegment, INT *pRightStartOfSegment, UCHAR readDirection) {
UCHAR readDirection)
{
UINT bit; UINT bit;
INT readBitOffset; INT readBitOffset;
@ -138,8 +146,7 @@ UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs,
bit = FDKreadBits(bs, 1); bit = FDKreadBits(bs, 1);
*pLeftStartOfSegment += 1; *pLeftStartOfSegment += 1;
} } else {
else {
readBitOffset = *pRightStartOfSegment - FDKgetBitCnt(bs); readBitOffset = *pRightStartOfSegment - FDKgetBitCnt(bs);
if (readBitOffset) { if (readBitOffset) {
FDKpushBiDirectional(bs, readBitOffset); FDKpushBiDirectional(bs, readBitOffset);
@ -152,14 +159,5 @@ UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs,
*pRightStartOfSegment -= 1; *pRightStartOfSegment -= 1;
} }
#if ERROR_GENERATOR_BIT_STREAM_HCR
static int a;
if ((++a % MODULO_DIVISOR_HCR) == 0) {
bit = (bit == 0) ? 1 : 0;
}
#endif
return (bit); return (bit);
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,28 +90,24 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder *************************** /**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions) Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Bitstream reading prototypes Description: HCR Decoder: Bitstream reading prototypes
*******************************************************************************/ *******************************************************************************/
#ifndef _AACDEC_HCR_BIT_H_ #ifndef AACDEC_HCR_BIT_H
#define _AACDEC_HCR_BIT_H_ #define AACDEC_HCR_BIT_H
#include "aacdec_hcr.h" #include "aacdec_hcr.h"
UCHAR ToggleReadDirection(UCHAR readDirection); UCHAR ToggleReadDirection(UCHAR readDirection);
UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs, UINT HcrGetABitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pLeftStartOfSegment,
USHORT *pLeftStartOfSegment, INT *pRightStartOfSegment, UCHAR readDirection);
USHORT *pRightStartOfSegment,
UCHAR readDirection);
#endif /* AACDEC_HCR_BIT_H */
#endif /* _AACDEC_HCR_BIT_H_ */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,20 +90,19 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder *************************** /**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions) Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Common defines and structures; defines for Description: HCR Decoder: Common defines and structures; defines for
switching error-generator, -detector, and -concealment; switching error-generator, -detector, and -concealment;
*******************************************************************************/ *******************************************************************************/
#ifndef _AACDEC_HCR_TYPES_H_ #ifndef AACDEC_HCR_TYPES_H
#define _AACDEC_HCR_TYPES_H_ #define AACDEC_HCR_TYPES_H
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
#include "overlapadd.h" #include "overlapadd.h"
@ -106,12 +116,13 @@ amm-info@iis.fraunhofer.de
/* ------------------------------------------------ */ /* ------------------------------------------------ */
/* ----------- basic HCR configuration ------------ */ /* ----------- basic HCR configuration ------------ */
#define MAX_SFB_HCR \
#define MAX_SFB_HCR (((1024/8) / LINES_PER_UNIT) * 8) /* (8 * 16) is not enough because sfbs are split in units for blocktype short */ (((1024 / 8) / LINES_PER_UNIT) * 8) /* (8 * 16) is not enough because sfbs \
are split in units for blocktype \
short */
#define NUMBER_OF_UNIT_GROUPS (LINES_PER_UNIT * 8) #define NUMBER_OF_UNIT_GROUPS (LINES_PER_UNIT * 8)
#define LINES_PER_UNIT_GROUP (1024 / NUMBER_OF_UNIT_GROUPS) /* 15 16 30 32 */ #define LINES_PER_UNIT_GROUP (1024 / NUMBER_OF_UNIT_GROUPS) /* 15 16 30 32 */
/* ------------------------------------------------ */ /* ------------------------------------------------ */
/* ------------------------------------------------ */ /* ------------------------------------------------ */
/* ------------------------------------------------ */ /* ------------------------------------------------ */
@ -128,7 +139,9 @@ amm-info@iis.fraunhofer.de
#define MAX_CB 32 /* last used CB is cb #31 when VCB11 is used */ #define MAX_CB 32 /* last used CB is cb #31 when VCB11 is used */
#define MAX_CB_CHECK 32 /* support for VCB11 available -- is more general, could therefore used in both cases */ #define MAX_CB_CHECK \
32 /* support for VCB11 available -- is more general, could therefore used \
in both cases */
#define NUMBER_OF_BIT_IN_WORD 32 #define NUMBER_OF_BIT_IN_WORD 32
@ -143,7 +156,8 @@ amm-info@iis.fraunhofer.de
#define LEN_OF_LONGEST_CW_TOP_LENGTH 49 #define LEN_OF_LONGEST_CW_TOP_LENGTH 49
/* qsc's of high level */ /* qsc's of high level */
#define Q_VALUE_INVALID 8192 /* mark a invalid line with this value (to be concealed later on) */ #define Q_VALUE_INVALID \
8192 /* mark a invalid line with this value (to be concealed later on) */
#define HCR_DIRAC 500 /* a line of high level */ #define HCR_DIRAC 500 /* a line of high level */
/* masks */ /* masks */
@ -154,10 +168,10 @@ amm-info@iis.fraunhofer.de
#define LEFT_OFFSET 12 #define LEFT_OFFSET 12
/* when set HCR is replaced by a dummy-module which just fills the outputbuffer with a dirac sequence */ /* when set HCR is replaced by a dummy-module which just fills the outputbuffer
/* use this if HCR is suspected to write in other modules -- if error is stell there, HCR is innocent */ * with a dirac sequence */
#define USE_HCR_DUMMY 0 /* use this if HCR is suspected to write in other modules -- if error is stell
* there, HCR is innocent */
/* ------------------------------ */ /* ------------------------------ */
/* - insert HCR errors - */ /* - insert HCR errors - */
@ -168,63 +182,96 @@ amm-info@iis.fraunhofer.de
#define ERROR_LOLC 0 /* offset: error if different from zero */ #define ERROR_LOLC 0 /* offset: error if different from zero */
/* segments are earlier empty as expected when decoding PCWs */ /* segments are earlier empty as expected when decoding PCWs */
#define ERROR_PCW_BODY 0 /* set a positive values to trigger the error (make segments earlyer appear to be empty) */ #define ERROR_PCW_BODY \
#define ERROR_PCW_BODY_SIGN 0 /* set a positive values to trigger the error (make segments earlyer appear to be empty) */ 0 /* set a positive values to trigger the error (make segments earlyer \
#define ERROR_PCW_BODY_SIGN_ESC 0 /* set a positive values to trigger the error (make segments earlyer appear to be empty) */ appear to be empty) */
#define ERROR_PCW_BODY_SIGN \
0 /* set a positive values to trigger the error (make segments earlyer \
appear to be empty) */
#define ERROR_PCW_BODY_SIGN_ESC \
0 /* set a positive values to trigger the error (make segments earlyer \
appear to be empty) */
/* pretend there are too many bits decoded (enlarge length of codeword) at PCWs -- use a positive value */ /* pretend there are too many bits decoded (enlarge length of codeword) at PCWs
#define ERROR_PCW_BODY_ONLY_TOO_LONG 0 /* set a positive values to trigger the error */ * -- use a positive value */
#define ERROR_PCW_BODY_SIGN_TOO_LONG 0 /* set a positive values to trigger the error */ #define ERROR_PCW_BODY_ONLY_TOO_LONG \
#define ERROR_PCW_BODY_SIGN_ESC_TOO_LONG 0 /* set a positive values to trigger the error */ 0 /* set a positive values to trigger the error */
#define ERROR_PCW_BODY_SIGN_TOO_LONG \
0 /* set a positive values to trigger the error */
#define ERROR_PCW_BODY_SIGN_ESC_TOO_LONG \
0 /* set a positive values to trigger the error */
/* modify HCR bitstream block */ /* modify HCR bitstream block */
#define ERROR_GENERATOR_BIT_STREAM_HCR 0 /* modify every <MODULO_DIVISOR_HCR>-bit when reading from bitstream */ /* !!! BEWARE!!! if RVLC is active, also RVLC data at ESC2 will be modified !!! */
#define MODULO_DIVISOR_HCR 30
#define MODULO_DIVISOR_HCR 30
/* ------------------------------ */ /* ------------------------------ */
/* - detect HCR errors - */ /* - detect HCR errors - */
/* ------------------------------ */ /* ------------------------------ */
/* check input data */ /* check input data */
#define CHECK_VALID_HCR_INPUT 1 /* it is highly recommended to check input data */
/* during decoding */ /* during decoding */
#define CHECK_SEGMENTATION_IMMEDIATELY 1 /* the 2 or 4 lines of a detected PCW-decoding-error is marked */
#define CHECK_SEGMENTATION_FINAL 1 /* all the segments are checked -- therefore -- if this check passes, its a kind of evidence that the /* all the segments are checked -- therefore -- if this check passes, its a kind
decoded PCWs and non-PCWs are fine */ of evidence that the decoded PCWs and non-PCWs are fine */
#define DETECT_TOO_LONG_CW_READS 1 /* if a codeword is decoded there exists a border for the number of bits, which are allowed to read for this /* if a codeword is decoded there exists a border for the number of bits, which
codeword. This border is the minimum of the length of the longest codeword (for the currently used are allowed to read for this codeword. This border is the minimum of the
codebook) and the separately transmitted 'lengthOfLongestCodeword' in this frame and channel. The number length of the longest codeword (for the currently used codebook) and the
of decoded bits is counted (for PCWs only -- there it makes really sense in my opinion). If this number separately transmitted 'lengthOfLongestCodeword' in this frame and channel.
exceeds the border (derived as minimum -- see above), a error is detected. */ The number of decoded bits is counted (for PCWs only -- there it makes really
sense in my opinion). If this number exceeds the border (derived as minimum
-- see above), a error is detected. */
/* -----------------------------------------------------------------------------------------------------
This error check could be set to zero because due to a test within
RVLC-Escape-huffman-Decoder a too long codeword could not be detected -- it
seems that for RVLC-Escape-Codeword the coderoom is used to 100%. Therefore I
assume that the coderoom is used to 100% also for the codebooks 1..11 used at
HCR Therefore this test is deactivated pending further notice
-----------------------------------------------------------------------------------------------------
*/
/* test if the number of remaining bits in a segment is _below_ zero. If there
are no errors the lowest allowed value for remainingBitsInSegment is zero.
This check also could be set to zero (save runtime) */
#define STATE_MACHINE_ERROR_CHECK 1 /* test if the number of remaining bits in a segment is _below_ zero. If there are no errors the lowest
allowed value for remainingBitsInSegment is zero. This check also could be set to zero (save runtime) */
/* other */ /* other */
#define VALID_LAV_ERROR_TRIGGER 1 /* when set to '1', avoid setting the LAV-Flag in errorLog due to a previous-line-marking (at PCW decoder). A little /* when set to '1', avoid setting the LAV-Flag in errorLog due to a
more runtime is needed then when writing values out into output-buffer. */ previous-line-marking (at PCW decoder). A little more runtime is needed then
when writing values out into output-buffer. */
#define HCR_LISTEN_TO_MUTED_LINES 0 /* listen to the "error-concealment" for testing */
/* ------------------------------ */ /* ------------------------------ */
/* - conceal HCR errors - */ /* - conceal HCR errors - */
/* ------------------------------ */ /* ------------------------------ */
#define HCR_ERROR_CONCEALMENT 1 /* if set to '1', HCR _mutes_ the erred quantized spectral coefficients */ #define HCR_ERROR_CONCEALMENT \
1 /* if set to '1', HCR _mutes_ the erred quantized spectral coefficients */
// ------------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------------
// errorLog: A word of 32 bits used for logging possible errors within HCR // errorLog: A word of 32 bits used for
// in case of distorted bitstreams. Table of all known errors: // logging possible errors within HCR
// in case of distorted
// bitstreams. Table of all
// known errors:
// ------------------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------------------
// bit fatal location meaning // bit fatal location meaning
// ----+-----+-----------+-------------------------------------- // ----+-----+-----------+--------------------------------------
#define SEGMENT_OVERRIDE_ERR_PCW_BODY 0x80000000 // 31 no PCW-Dec During PCW decoding it is checked after every PCW if there are too many bits decoded (immediate check). #define SEGMENT_OVERRIDE_ERR_PCW_BODY \
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN 0x40000000 // 30 no PCW-Dec During PCW decoding it is checked after every PCW if there are too many bits decoded (immediate check). 0x80000000 // 31 no PCW-Dec During PCW decoding it is checked after
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN_ESC 0x20000000 // 29 no PCW-Dec During PCW decoding it is checked after every PCW if there are too many bits decoded (immediate check). // every PCW if there are too many bits decoded (immediate
#define EXTENDED_SORTED_COUNTER_OVERFLOW 0x10000000 // 28 yes Init-Dec Error during extending sideinfo (neither a PCW nor a nonPCW was decoded so far) // check).
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN \
0x40000000 // 30 no PCW-Dec During PCW decoding it is checked after
// every PCW if there are too many bits decoded (immediate
// check).
#define SEGMENT_OVERRIDE_ERR_PCW_BODY_SIGN_ESC \
0x20000000 // 29 no PCW-Dec During PCW decoding it is checked after
// every PCW if there are too many bits decoded (immediate
// check).
#define EXTENDED_SORTED_COUNTER_OVERFLOW \
0x10000000 // 28 yes Init-Dec Error during extending sideinfo
// (neither a PCW nor a nonPCW was decoded so far)
// 0x08000000 // 27 reserved // 0x08000000 // 27 reserved
// 0x04000000 // 26 reserved // 0x04000000 // 26 reserved
// 0x02000000 // 25 reserved // 0x02000000 // 25 reserved
@ -235,39 +282,65 @@ amm-info@iis.fraunhofer.de
// 0x00100000 // 20 reserved // 0x00100000 // 20 reserved
/* special errors */ /* special errors */
#define TOO_MANY_PCW_BODY_BITS_DECODED 0x00080000 // 19 yes PCW-Dec During PCW-body-decoding too many bits have been read from bitstream -- advice: skip non-PCW decoding #define TOO_MANY_PCW_BODY_BITS_DECODED \
#define TOO_MANY_PCW_BODY_SIGN_BITS_DECODED 0x00040000 // 18 yes PCW-Dec During PCW-body-sign-decoding too many bits have been read from bitstream -- advice: skip non-PCW decoding 0x00080000 // 19 yes PCW-Dec During PCW-body-decoding too many bits
#define TOO_MANY_PCW_BODY_SIGN_ESC_BITS_DECODED 0x00020000 // 17 yes PCW-Dec During PCW-body-sign-esc-decoding too many bits have been read from bitstream -- advice: skip non-PCW decoding // have been read from bitstream -- advice: skip non-PCW decoding
#define TOO_MANY_PCW_BODY_SIGN_BITS_DECODED \
0x00040000 // 18 yes PCW-Dec During PCW-body-sign-decoding too many
// bits have been read from bitstream -- advice: skip non-PCW
// decoding
#define TOO_MANY_PCW_BODY_SIGN_ESC_BITS_DECODED \
0x00020000 // 17 yes PCW-Dec During PCW-body-sign-esc-decoding too
// many bits have been read from bitstream -- advice: skip
// non-PCW decoding
// 0x00010000 // 16 reserved // 0x00010000 // 16 reserved
#define STATE_ERROR_BODY_ONLY 0x00008000 // 15 no NonPCW-Dec State machine returned with error #define STATE_ERROR_BODY_ONLY \
#define STATE_ERROR_BODY_SIGN__BODY 0x00004000 // 14 no NonPCW-Dec State machine returned with error 0x00008000 // 15 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN__SIGN 0x00002000 // 13 no NonPCW-Dec State machine returned with error #define STATE_ERROR_BODY_SIGN__BODY \
#define STATE_ERROR_BODY_SIGN_ESC__BODY 0x00001000 // 12 no NonPCW-Dec State machine returned with error 0x00004000 // 14 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__SIGN 0x00000800 // 11 no NonPCW-Dec State machine returned with error #define STATE_ERROR_BODY_SIGN__SIGN \
#define STATE_ERROR_BODY_SIGN_ESC__ESC_PREFIX 0x00000400 // 10 no NonPCW-Dec State machine returned with error 0x00002000 // 13 no NonPCW-Dec State machine returned with error
#define STATE_ERROR_BODY_SIGN_ESC__ESC_WORD 0x00000200 // 9 no NonPCW-Dec State machine returned with error #define STATE_ERROR_BODY_SIGN_ESC__BODY \
#define HCR_SI_LENGTHS_FAILURE 0x00000100 // 8 yes Init-Dec LengthOfLongestCodeword must not be less than lenghtOfReorderedSpectralData 0x00001000 // 12 no NonPCW-Dec State machine returned with error
#define NUM_SECT_OUT_OF_RANGE_SHORT_BLOCK 0x00000080 // 7 yes Init-Dec The number of sections is not within the allowed range (short block) #define STATE_ERROR_BODY_SIGN_ESC__SIGN \
#define NUM_SECT_OUT_OF_RANGE_LONG_BLOCK 0x00000040 // 6 yes Init-Dec The number of sections is not within the allowed range (long block) 0x00000800 // 11 no NonPCW-Dec State machine returned with error
#define LINE_IN_SECT_OUT_OF_RANGE_SHORT_BLOCK 0x00000020 // 5 yes Init-Dec The number of lines per section is not within the allowed range (short block) #define STATE_ERROR_BODY_SIGN_ESC__ESC_PREFIX \
#define CB_OUT_OF_RANGE_SHORT_BLOCK 0x00000010 // 4 yes Init-Dec The codebook is not within the allowed range (short block) 0x00000400 // 10 no NonPCW-Dec State machine returned with error
#define LINE_IN_SECT_OUT_OF_RANGE_LONG_BLOCK 0x00000008 // 3 yes Init-Dec The number of lines per section is not within the allowed range (long block) #define STATE_ERROR_BODY_SIGN_ESC__ESC_WORD \
#define CB_OUT_OF_RANGE_LONG_BLOCK 0x00000004 // 2 yes Init-Dec The codebook is not within the allowed range (long block) 0x00000200 // 9 no NonPCW-Dec State machine returned with error
#define LAV_VIOLATION 0x00000002 // 1 no Final The absolute value of at least one decoded line was too high for the according codebook. #define HCR_SI_LENGTHS_FAILURE \
#define BIT_IN_SEGMENTATION_ERROR 0x00000001 // 0 no Final After PCW and non-PWC-decoding at least one segment is not zero (global check). 0x00000100 // 8 yes Init-Dec LengthOfLongestCodeword must not be
// less than lenghtOfReorderedSpectralData
#define NUM_SECT_OUT_OF_RANGE_SHORT_BLOCK \
0x00000080 // 7 yes Init-Dec The number of sections is not within
// the allowed range (short block)
#define NUM_SECT_OUT_OF_RANGE_LONG_BLOCK \
0x00000040 // 6 yes Init-Dec The number of sections is not within
// the allowed range (long block)
#define LINE_IN_SECT_OUT_OF_RANGE_SHORT_BLOCK \
0x00000020 // 5 yes Init-Dec The number of lines per section is not
// within the allowed range (short block)
#define CB_OUT_OF_RANGE_SHORT_BLOCK \
0x00000010 // 4 yes Init-Dec The codebook is not within the allowed
// range (short block)
#define LINE_IN_SECT_OUT_OF_RANGE_LONG_BLOCK \
0x00000008 // 3 yes Init-Dec The number of lines per section is not
// within the allowed range (long block)
#define CB_OUT_OF_RANGE_LONG_BLOCK \
0x00000004 // 2 yes Init-Dec The codebook is not within the allowed
// range (long block)
#define LAV_VIOLATION \
0x00000002 // 1 no Final The absolute value of at least one
// decoded line was too high for the according codebook.
#define BIT_IN_SEGMENTATION_ERROR \
0x00000001 // 0 no Final After PCW and non-PWC-decoding at least
// one segment is not zero (global check).
/*----------*/ /*----------*/
#define HCR_FATAL_PCW_ERROR_MASK 0x100E01FC #define HCR_FATAL_PCW_ERROR_MASK 0x100E01FC
typedef enum { PCW_BODY, PCW_BODY_SIGN, PCW_BODY_SIGN_ESC } PCW_TYPE;
typedef enum {
PCW_BODY,
PCW_BODY_SIGN,
PCW_BODY_SIGN_ESC
} PCW_TYPE;
/* interface Decoder <---> HCR */ /* interface Decoder <---> HCR */
typedef struct { typedef struct {
@ -277,7 +350,7 @@ typedef struct {
SHORT lengthOfReorderedSpectralData; SHORT lengthOfReorderedSpectralData;
SHORT numSection; SHORT numSection;
SHORT *pNumLineInSect; SHORT *pNumLineInSect;
USHORT bitstreamIndex; INT bitstreamIndex;
SCHAR lengthOfLongestCodeword; SCHAR lengthOfLongestCodeword;
UCHAR *pCodebook; UCHAR *pCodebook;
} HCR_INPUT_OUTPUT; } HCR_INPUT_OUTPUT;
@ -301,9 +374,8 @@ typedef struct{
UINT pSegmentBitfield[((1024 >> 1) / NUMBER_OF_BIT_IN_WORD + 1)]; UINT pSegmentBitfield[((1024 >> 1) / NUMBER_OF_BIT_IN_WORD + 1)];
UINT pCodewordBitfield[((1024 >> 1) / NUMBER_OF_BIT_IN_WORD + 1)]; UINT pCodewordBitfield[((1024 >> 1) / NUMBER_OF_BIT_IN_WORD + 1)];
UINT segmentOffset; UINT segmentOffset;
FIXP_DBL pTempValues[1024]; INT pLeftStartOfSegment[1024 >> 1];
USHORT pLeftStartOfSegment[1024>>1]; INT pRightStartOfSegment[1024 >> 1];
USHORT pRightStartOfSegment[1024>>1];
SCHAR pRemainingBitsInSegment[1024 >> 1]; SCHAR pRemainingBitsInSegment[1024 >> 1];
UCHAR readDirection; UCHAR readDirection;
UCHAR numWordForBitfield; UCHAR numWordForBitfield;
@ -311,7 +383,6 @@ typedef struct{
} HCR_SEGMENT_INFO; } HCR_SEGMENT_INFO;
typedef struct { typedef struct {
UINT numCodeword; UINT numCodeword;
UINT numSortedSection; UINT numSortedSection;
USHORT pNumCodewordInSection[MAX_SFB_HCR]; USHORT pNumCodewordInSection[MAX_SFB_HCR];
@ -325,10 +396,8 @@ typedef struct{
UCHAR pExtendedSortedCodebook[MAX_SFB_HCR + MAX_HCR_SETS]; UCHAR pExtendedSortedCodebook[MAX_SFB_HCR + MAX_HCR_SETS];
int extendedSortedCodebookIdx; int extendedSortedCodebookIdx;
#if DETECT_TOO_LONG_CW_READS
UCHAR pMaxLenOfCbInExtSrtSec[MAX_SFB_HCR + MAX_HCR_SETS]; UCHAR pMaxLenOfCbInExtSrtSec[MAX_SFB_HCR + MAX_HCR_SETS];
int maxLenOfCbInExtSrtSecIdx; int maxLenOfCbInExtSrtSecIdx;
#endif
UCHAR pCodebookSwitch[MAX_SFB_HCR]; UCHAR pCodebookSwitch[MAX_SFB_HCR];
} HCR_SECTION_INFO; } HCR_SECTION_INFO;
@ -336,31 +405,28 @@ typedef UINT (*STATEFUNC)(HANDLE_FDK_BITSTREAM, void*);
typedef struct { typedef struct {
/* worst-case and 1024/4 non-PCWs exist in worst-case */ /* worst-case and 1024/4 non-PCWs exist in worst-case */
FIXP_DBL *pResultBase; /* Base address for spectral data output target buffer */ FIXP_DBL
*pResultBase; /* Base address for spectral data output target buffer */
UINT iNode[1024 >> 2]; /* Helper indices for code books */ UINT iNode[1024 >> 2]; /* Helper indices for code books */
USHORT iResultPointer[1024>>2]; /* Helper indices for accessing pResultBase */ USHORT
iResultPointer[1024 >> 2]; /* Helper indices for accessing pResultBase */
UINT pEscapeSequenceInfo[1024 >> 2]; UINT pEscapeSequenceInfo[1024 >> 2];
UINT codewordOffset; UINT codewordOffset;
STATEFUNC pState; STATEFUNC pState;
UCHAR pCodebook[1024 >> 2]; UCHAR pCodebook[1024 >> 2];
UCHAR pCntSign[1024 >> 2]; UCHAR pCntSign[1024 >> 2];
/* this array holds the states coded as integer values within the range [0,1,..,7] */ /* this array holds the states coded as integer values within the range
* [0,1,..,7] */
SCHAR pSta[1024 >> 2]; SCHAR pSta[1024 >> 2];
} HCR_NON_PCW_SIDEINFO; } HCR_NON_PCW_SIDEINFO;
typedef struct { typedef struct {
HCR_INPUT_OUTPUT decInOut; HCR_INPUT_OUTPUT decInOut;
HCR_CB_PAIRS cbPairs;
HCR_TABLE_INFO tableInfo;
HCR_SEGMENT_INFO segmentInfo; HCR_SEGMENT_INFO segmentInfo;
HCR_SECTION_INFO sectionInfo; HCR_SECTION_INFO sectionInfo;
HCR_NON_PCW_SIDEINFO nonPcwSideinfo; HCR_NON_PCW_SIDEINFO nonPcwSideinfo;
INT globalHcrType;
} CErHcrInfo; } CErHcrInfo;
typedef CErHcrInfo *H_HCR_INFO; typedef CErHcrInfo *H_HCR_INFO;
#endif /* AACDEC_HCR_TYPES_H */
#endif /* _AACDEC_HCR_TYPES_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,50 +90,64 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder *************************** /**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions) Author(s): Robert Weidner (DSP Solutions)
Description: HCR Decoder: Defines of state-constants, masks and Description: HCR Decoder: Defines of state-constants, masks and
state-prototypes state-prototypes
*******************************************************************************/ *******************************************************************************/
#ifndef _AACDEC_HCRS_H_ #ifndef AACDEC_HCRS_H
#define _AACDEC_HCRS_H_ #define AACDEC_HCRS_H
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
#include "aacdec_hcr_types.h" #include "aacdec_hcr_types.h"
/* The four different kinds of types of states are: */ /* The four different kinds of types of states are: */
/* different states are defined as constants */ /* start middle=self next stop */ /* different states are defined as constants */ /* start middle=self next
#define STOP_THIS_STATE 0 /* */ stop */
#define BODY_ONLY 1 /* X X X */ #define STOP_THIS_STATE \
#define BODY_SIGN__BODY 2 /* X X X X [stop if no sign] */ 0 /* */
#define BODY_SIGN__SIGN 3 /* X X [stop if sign bits decoded] */ #define BODY_ONLY \
#define BODY_SIGN_ESC__BODY 4 /* X X X X [stop if no sign] */ 1 /* X X X */
#define BODY_SIGN_ESC__SIGN 5 /* X X X [stop if no escape sequence] */ #define BODY_SIGN__BODY \
#define BODY_SIGN_ESC__ESC_PREFIX 6 /* X X */ 2 /* X X X X [stop if no sign] */
#define BODY_SIGN_ESC__ESC_WORD 7 /* X X X [stop if abs(second qsc) != 16] */ #define BODY_SIGN__SIGN \
3 /* X X [stop if sign bits decoded] */
#define BODY_SIGN_ESC__BODY \
4 /* X X X X [stop if no sign] */
#define BODY_SIGN_ESC__SIGN \
5 /* X X X [stop if no escape sequence] */
#define BODY_SIGN_ESC__ESC_PREFIX \
6 /* X X */
#define BODY_SIGN_ESC__ESC_WORD \
7 /* X X X [stop if abs(second qsc) != 16] */
/* examples: */ /* examples: */
/* BODY_ONLY means only the codeword body will be decoded; no sign bits will follow and no escapesequence will follow */ /* BODY_ONLY means only the codeword body will be decoded; no
* sign bits will follow and no escapesequence will follow */
/* BODY_SIGN__BODY means that the codeword consists of two parts; body and sign part. The part '__BODY' after the two underscores shows */ /* BODY_SIGN__BODY means that the codeword consists of two parts;
/* that the bits which are currently decoded belong to the '__BODY' of the codeword and not to the sign part. */ * body and sign part. The part '__BODY' after the two underscores shows */
/* that the bits which are currently decoded belong
* to the '__BODY' of the codeword and not to the sign part. */
/* BODY_SIGN_ESC__ESC_PB means that the codeword consists of three parts; body, sign and (here: two) escape sequences; */ /* BODY_SIGN_ESC__ESC_PB means that the codeword consists of three parts;
* body, sign and (here: two) escape sequences; */
/* P = Prefix = ones */ /* P = Prefix = ones */
/* W = Escape Word */ /* W = Escape Word */
/* A = first possible (of two) Escape sequeces */ /* A = first possible (of two) Escape sequeces */
/* B = second possible (of two) Escape sequeces */ /* B = second possible (of two) Escape sequeces */
/* The part after the two underscores shows that the current bits which are decoded belong to the '__ESC_PB' - part of the */ /* The part after the two underscores shows that
/* codeword. That means the body and the sign bits are decoded completely and the bits which are decoded now belong to */ * the current bits which are decoded belong to the '__ESC_PB' - part of the */
/* the escape sequence [P = prefix; B=second possible escape sequence] */ /* codeword. That means the body and the sign bits
* are decoded completely and the bits which are decoded now belong to */
/* the escape sequence [P = prefix; B=second
* possible escape sequence] */
#define MSB_31_MASK 0x80000000 /* masks MSB (= Bit 31) in a 32 bit word */ #define MSB_31_MASK 0x80000000 /* masks MSB (= Bit 31) in a 32 bit word */
#define DIMENSION_OF_ESCAPE_CODEBOOK 2 /* for cb >= 11 is dimension 2 */ #define DIMENSION_OF_ESCAPE_CODEBOOK 2 /* for cb >= 11 is dimension 2 */
@ -138,7 +163,6 @@ amm-info@iis.fraunhofer.de
#define MASK_FLAG_A 0x00200000 #define MASK_FLAG_A 0x00200000
#define MASK_FLAG_B 0x00100000 #define MASK_FLAG_B 0x00100000
extern void DecodeNonPCWs(HANDLE_FDK_BITSTREAM bs, H_HCR_INFO hHcr); extern void DecodeNonPCWs(HANDLE_FDK_BITSTREAM bs, H_HCR_INFO hHcr);
UINT Hcr_State_BODY_ONLY(HANDLE_FDK_BITSTREAM, void*); UINT Hcr_State_BODY_ONLY(HANDLE_FDK_BITSTREAM, void*);
@ -149,5 +173,4 @@ UINT Hcr_State_BODY_SIGN_ESC__SIGN (HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__ESC_PREFIX(HANDLE_FDK_BITSTREAM, void*); UINT Hcr_State_BODY_SIGN_ESC__ESC_PREFIX(HANDLE_FDK_BITSTREAM, void*);
UINT Hcr_State_BODY_SIGN_ESC__ESC_WORD(HANDLE_FDK_BITSTREAM, void*); UINT Hcr_State_BODY_SIGN_ESC__ESC_WORD(HANDLE_FDK_BITSTREAM, void*);
#endif /* _AACDEC_HCRS_H_ */ #endif /* AACDEC_HCRS_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,18 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: perceptual noise substitution tool Description: perceptual noise substitution tool
******************************************************************************/ *******************************************************************************/
#include "aacdec_pns.h" #include "aacdec_pns.h"
#include "aac_ram.h" #include "aac_ram.h"
#include "aac_rom.h" #include "aac_rom.h"
#include "channelinfo.h" #include "channelinfo.h"
@ -99,7 +110,6 @@ amm-info@iis.fraunhofer.de
#include "genericStds.h" #include "genericStds.h"
#define NOISE_OFFSET 90 /* cf. ISO 14496-3 p. 175 */ #define NOISE_OFFSET 90 /* cf. ISO 14496-3 p. 175 */
/*! /*!
@ -107,11 +117,10 @@ amm-info@iis.fraunhofer.de
The function resets the InterChannel and PNS data The function resets the InterChannel and PNS data
*/ */
void CPns_ResetData( void CPns_ResetData(CPnsData *pPnsData,
CPnsData *pPnsData, CPnsInterChannelData *pPnsInterChannelData) {
CPnsInterChannelData *pPnsInterChannelData FDK_ASSERT(pPnsData != NULL);
) FDK_ASSERT(pPnsInterChannelData != NULL);
{
/* Assign pointer always, since pPnsData is not persistent data */ /* Assign pointer always, since pPnsData is not persistent data */
pPnsData->pPnsInterChannelData = pPnsInterChannelData; pPnsData->pPnsInterChannelData = pPnsInterChannelData;
pPnsData->PnsActive = 0; pPnsData->PnsActive = 0;
@ -122,18 +131,13 @@ void CPns_ResetData(
} }
/*! /*!
\brief Initialize PNS data \brief Update PNS noise generator state.
The function initializes the PNS data The function sets the seed for PNS noise generation.
It can be used to link two or more channels in terms of PNS.
*/ */
void CPns_InitPns( void CPns_UpdateNoiseState(CPnsData *pPnsData, INT *currentSeed,
CPnsData *pPnsData, INT *randomSeed) {
CPnsInterChannelData *pPnsInterChannelData,
INT* currentSeed, INT* randomSeed)
{
/* save pointer to inter channel data */
pPnsData->pPnsInterChannelData = pPnsInterChannelData;
/* use pointer because seed has to be /* use pointer because seed has to be
same, left and right channel ! */ same, left and right channel ! */
pPnsData->currentSeed = currentSeed; pPnsData->currentSeed = currentSeed;
@ -148,10 +152,7 @@ void CPns_InitPns(
\return PNS used \return PNS used
*/ */
int CPns_IsPnsUsed (const CPnsData *pPnsData, int CPns_IsPnsUsed(const CPnsData *pPnsData, const int group, const int band) {
const int group,
const int band)
{
unsigned pns_band = group * 16 + band; unsigned pns_band = group * 16 + band;
return pPnsData->pnsUsed[pns_band] & (UCHAR)1; return pPnsData->pnsUsed[pns_band] & (UCHAR)1;
@ -162,11 +163,8 @@ int CPns_IsPnsUsed (const CPnsData *pPnsData,
The function activates the noise correlation between the channel pair The function activates the noise correlation between the channel pair
*/ */
void CPns_SetCorrelation(CPnsData *pPnsData, void CPns_SetCorrelation(CPnsData *pPnsData, const int group, const int band,
const int group, const int outofphase) {
const int band,
const int outofphase)
{
CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData; CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData;
unsigned pns_band = group * 16 + band; unsigned pns_band = group * 16 + band;
@ -181,11 +179,8 @@ void CPns_SetCorrelation(CPnsData *pPnsData,
\return PNS is correlated \return PNS is correlated
*/ */
static static int CPns_IsCorrelated(const CPnsData *pPnsData, const int group,
int CPns_IsCorrelated(const CPnsData *pPnsData, const int band) {
const int group,
const int band)
{
CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData; CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData;
unsigned pns_band = group * 16 + band; unsigned pns_band = group * 16 + band;
@ -200,11 +195,8 @@ int CPns_IsCorrelated(const CPnsData *pPnsData,
\return PNS is out-of-phase \return PNS is out-of-phase
*/ */
static static int CPns_IsOutOfPhase(const CPnsData *pPnsData, const int group,
int CPns_IsOutOfPhase(const CPnsData *pPnsData, const int band) {
const int group,
const int band)
{
CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData; CPnsInterChannelData *pInterChannelData = pPnsData->pPnsInterChannelData;
unsigned pns_band = group * 16 + band; unsigned pns_band = group * 16 + band;
@ -216,14 +208,9 @@ int CPns_IsOutOfPhase(const CPnsData *pPnsData,
The function reads the PNS information from the bitstream The function reads the PNS information from the bitstream
*/ */
void CPns_Read (CPnsData *pPnsData, void CPns_Read(CPnsData *pPnsData, HANDLE_FDK_BITSTREAM bs,
HANDLE_FDK_BITSTREAM bs, const CodeBookDescription *hcb, SHORT *pScaleFactor,
const CodeBookDescription *hcb, UCHAR global_gain, int band, int group /* = 0 */) {
SHORT *pScaleFactor,
UCHAR global_gain,
int band,
int group /* = 0 */)
{
int delta; int delta;
UINT pns_band = group * 16 + band; UINT pns_band = group * 16 + band;
@ -245,7 +232,6 @@ void CPns_Read (CPnsData *pPnsData,
pPnsData->pnsUsed[pns_band] = 1; pPnsData->pnsUsed[pns_band] = 1;
} }
/** /**
* \brief Generate a vector of noise of given length. The noise values are * \brief Generate a vector of noise of given length. The noise values are
* scaled in order to yield a noise energy of 1.0 * scaled in order to yield a noise energy of 1.0
@ -254,10 +240,8 @@ void CPns_Read (CPnsData *pPnsData,
* \param pRandomState pointer to the state of the random generator being used. * \param pRandomState pointer to the state of the random generator being used.
* \return exponent of generated noise vector. * \return exponent of generated noise vector.
*/ */
static int GenerateRandomVector (FIXP_DBL *RESTRICT spec, static int GenerateRandomVector(FIXP_DBL *RESTRICT spec, int size,
int size, int *pRandomState) {
int *pRandomState)
{
int i, invNrg_e = 0, nrg_e = 0; int i, invNrg_e = 0, nrg_e = 0;
FIXP_DBL invNrg_m, nrg_m = FL2FXCONST_DBL(0.0f); FIXP_DBL invNrg_m, nrg_m = FL2FXCONST_DBL(0.0f);
FIXP_DBL *RESTRICT ptr = spec; FIXP_DBL *RESTRICT ptr = spec;
@ -266,9 +250,9 @@ static int GenerateRandomVector (FIXP_DBL *RESTRICT spec,
#define GEN_NOISE_NRG_SCALE 7 #define GEN_NOISE_NRG_SCALE 7
/* Generate noise and calculate energy. */ /* Generate noise and calculate energy. */
for (i=0; i<size; i++) for (i = 0; i < size; i++) {
{ randomState =
randomState = (1664525L * randomState) + 1013904223L; // Numerical Recipes (((INT64)1664525 * randomState) + (INT64)1013904223) & 0xFFFFFFFF;
nrg_m = fPow2AddDiv2(nrg_m, (FIXP_DBL)randomState >> GEN_NOISE_NRG_SCALE); nrg_m = fPow2AddDiv2(nrg_m, (FIXP_DBL)randomState >> GEN_NOISE_NRG_SCALE);
*ptr++ = (FIXP_DBL)randomState; *ptr++ = (FIXP_DBL)randomState;
} }
@ -278,8 +262,7 @@ static int GenerateRandomVector (FIXP_DBL *RESTRICT spec,
invNrg_m = invSqrtNorm2(nrg_m << 1, &invNrg_e); invNrg_m = invSqrtNorm2(nrg_m << 1, &invNrg_e);
invNrg_e += -((nrg_e - 1) >> 1); invNrg_e += -((nrg_e - 1) >> 1);
for (i=size; i--; ) for (i = size; i--;) {
{
spec[i] = fMult(spec[i], invNrg_m); spec[i] = fMult(spec[i], invNrg_m);
} }
@ -289,8 +272,8 @@ static int GenerateRandomVector (FIXP_DBL *RESTRICT spec,
return invNrg_e; return invNrg_e;
} }
static void ScaleBand (FIXP_DBL *RESTRICT spec, int size, int scaleFactor, int specScale, int noise_e, int out_of_phase) static void ScaleBand(FIXP_DBL *RESTRICT spec, int size, int scaleFactor,
{ int specScale, int noise_e, int out_of_phase) {
int i, shift, sfExponent; int i, shift, sfExponent;
FIXP_DBL sfMatissa; FIXP_DBL sfMatissa;
@ -321,7 +304,6 @@ static void ScaleBand (FIXP_DBL *RESTRICT spec, int size, int scaleFactor, int s
} }
} }
/*! /*!
\brief Apply PNS \brief Apply PNS
@ -329,51 +311,48 @@ static void ScaleBand (FIXP_DBL *RESTRICT spec, int size, int scaleFactor, int s
flagged as noisy bands flagged as noisy bands
*/ */
void CPns_Apply (const CPnsData *pPnsData, void CPns_Apply(const CPnsData *pPnsData, const CIcsInfo *pIcsInfo,
const CIcsInfo *pIcsInfo, SPECTRAL_PTR pSpectrum, const SHORT *pSpecScale,
SPECTRAL_PTR pSpectrum,
const SHORT *pSpecScale,
const SHORT *pScaleFactor, const SHORT *pScaleFactor,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength, const INT granuleLength, const int channel) {
const int channel)
{
if (pPnsData->PnsActive) { if (pPnsData->PnsActive) {
const short *BandOffsets = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo); const short *BandOffsets =
GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo);
int ScaleFactorBandsTransmitted = GetScaleFactorBandsTransmitted(pIcsInfo); int ScaleFactorBandsTransmitted = GetScaleFactorBandsTransmitted(pIcsInfo);
for (int window = 0, group = 0; group < GetWindowGroups(pIcsInfo); group++) { for (int window = 0, group = 0; group < GetWindowGroups(pIcsInfo);
for (int groupwin = 0; groupwin < GetWindowGroupLength(pIcsInfo, group); groupwin++, window++) { group++) {
for (int groupwin = 0; groupwin < GetWindowGroupLength(pIcsInfo, group);
groupwin++, window++) {
FIXP_DBL *spectrum = SPEC(pSpectrum, window, granuleLength); FIXP_DBL *spectrum = SPEC(pSpectrum, window, granuleLength);
for (int band = 0; band < ScaleFactorBandsTransmitted; band++) { for (int band = 0; band < ScaleFactorBandsTransmitted; band++) {
if (CPns_IsPnsUsed(pPnsData, group, band)) { if (CPns_IsPnsUsed(pPnsData, group, band)) {
UINT pns_band = group*16+band; UINT pns_band = window * 16 + band;
int bandWidth = BandOffsets[band + 1] - BandOffsets[band]; int bandWidth = BandOffsets[band + 1] - BandOffsets[band];
int noise_e; int noise_e;
FDK_ASSERT(bandWidth >= 0); FDK_ASSERT(bandWidth >= 0);
if (channel > 0 && CPns_IsCorrelated(pPnsData, group, band)) if (channel > 0 && CPns_IsCorrelated(pPnsData, group, band)) {
{ noise_e =
noise_e = GenerateRandomVector (spectrum + BandOffsets [band], bandWidth, GenerateRandomVector(spectrum + BandOffsets[band], bandWidth,
&pPnsData->randomSeed[pns_band]); &pPnsData->randomSeed[pns_band]);
} } else {
else
{
pPnsData->randomSeed[pns_band] = *pPnsData->currentSeed; pPnsData->randomSeed[pns_band] = *pPnsData->currentSeed;
noise_e = GenerateRandomVector (spectrum + BandOffsets [band], bandWidth, noise_e = GenerateRandomVector(spectrum + BandOffsets[band],
pPnsData->currentSeed) ; bandWidth, pPnsData->currentSeed);
} }
int outOfPhase = CPns_IsOutOfPhase(pPnsData, group, band); int outOfPhase = CPns_IsOutOfPhase(pPnsData, group, band);
ScaleBand(spectrum + BandOffsets[band], bandWidth, ScaleBand(spectrum + BandOffsets[band], bandWidth,
pScaleFactor[pns_band], pScaleFactor[group * 16 + band], pSpecScale[window],
pSpecScale[window], noise_e, outOfPhase) ; noise_e, outOfPhase);
} }
} }
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,21 +90,21 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: perceptual noise substitution tool Description: perceptual noise substitution tool
******************************************************************************/ *******************************************************************************/
#ifndef PNS_H #ifndef AACDEC_PNS_H
#define PNS_H #define AACDEC_PNS_H
#include "common_fix.h" #include "common_fix.h"
#define NO_OFBANDS ((8 * 16)) #define NO_OFBANDS ((8 * 16))
typedef struct { typedef struct {
@ -109,12 +120,10 @@ typedef struct {
INT *randomSeed; INT *randomSeed;
} CPnsData; } CPnsData;
void CPns_InitPns ( CPnsData *pPnsData, void CPns_UpdateNoiseState(CPnsData *pPnsData, INT *currentSeed,
CPnsInterChannelData *pPnsInterChannelData,
INT* currentSeed,
INT *randomSeed); INT *randomSeed);
void CPns_ResetData ( CPnsData *pPnsData, CPnsInterChannelData *pPnsInterChannelData ); void CPns_ResetData(CPnsData *pPnsData,
CPnsInterChannelData *pPnsInterChannelData);
#endif /* #ifndef AACDEC_PNS_H */
#endif /* #ifndef PNS_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,21 +90,24 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: temporal noise shaping tool Description: temporal noise shaping tool
******************************************************************************/ *******************************************************************************/
#include "aacdec_tns.h" #include "aacdec_tns.h"
#include "aac_rom.h" #include "aac_rom.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
#include "channelinfo.h" #include "channelinfo.h"
#include "FDK_lpc.h"
#define TNS_MAXIMUM_ORDER_AAC 12
/*! /*!
\brief Reset tns data \brief Reset tns data
@ -102,16 +116,17 @@ amm-info@iis.fraunhofer.de
\return none \return none
*/ */
void CTns_Reset(CTnsData *pTnsData) void CTns_Reset(CTnsData *pTnsData) {
{
/* Note: the following FDKmemclear should not be required. */ /* Note: the following FDKmemclear should not be required. */
FDKmemclear(pTnsData->Filter, TNS_MAX_WINDOWS*TNS_MAXIMUM_FILTERS*sizeof(CFilter)); FDKmemclear(pTnsData->Filter,
TNS_MAX_WINDOWS * TNS_MAXIMUM_FILTERS * sizeof(CFilter));
FDKmemclear(pTnsData->NumberOfFilters, TNS_MAX_WINDOWS * sizeof(UCHAR)); FDKmemclear(pTnsData->NumberOfFilters, TNS_MAX_WINDOWS * sizeof(UCHAR));
pTnsData->DataPresent = 0; pTnsData->DataPresent = 0;
pTnsData->Active = 0; pTnsData->Active = 0;
} }
void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */ void CTns_ReadDataPresentFlag(
HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
CTnsData *pTnsData) /*!< pointer to aac decoder channel info */ CTnsData *pTnsData) /*!< pointer to aac decoder channel info */
{ {
pTnsData->DataPresent = (UCHAR)FDKreadBits(bs, 1); pTnsData->DataPresent = (UCHAR)FDKreadBits(bs, 1);
@ -125,32 +140,33 @@ void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstr
\return none \return none
*/ */
AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs, AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs, CTnsData *pTnsData,
CTnsData *pTnsData, const CIcsInfo *pIcsInfo, const UINT flags) {
const CIcsInfo *pIcsInfo,
const UINT flags)
{
UCHAR n_filt, order; UCHAR n_filt, order;
UCHAR length, coef_res, coef_compress; UCHAR length, coef_res, coef_compress;
UCHAR window; UCHAR window;
UCHAR wins_per_frame = GetWindowsPerFrame(pIcsInfo); UCHAR wins_per_frame;
UCHAR isLongFlag = IsLongBlock(pIcsInfo); UCHAR isLongFlag;
UCHAR start_window;
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK; AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
if (!pTnsData->DataPresent) { if (!pTnsData->DataPresent) {
return ErrorStatus; return ErrorStatus;
} }
for (window = 0; window < wins_per_frame; window++)
{ {
pTnsData->NumberOfFilters[window] = n_filt = (UCHAR) FDKreadBits(bs, isLongFlag ? 2 : 1); start_window = 0;
wins_per_frame = GetWindowsPerFrame(pIcsInfo);
if (pTnsData->NumberOfFilters[window] > TNS_MAXIMUM_FILTERS){ isLongFlag = IsLongBlock(pIcsInfo);
pTnsData->NumberOfFilters[window] = n_filt = TNS_MAXIMUM_FILTERS;
} }
if (n_filt) pTnsData->GainLd = 0;
{
for (window = start_window; window < wins_per_frame; window++) {
pTnsData->NumberOfFilters[window] = n_filt =
(UCHAR)FDKreadBits(bs, isLongFlag ? 2 : 1);
if (n_filt) {
int index; int index;
UCHAR nextstopband; UCHAR nextstopband;
@ -158,8 +174,7 @@ AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
nextstopband = GetScaleFactorBandsTotal(pIcsInfo); nextstopband = GetScaleFactorBandsTotal(pIcsInfo);
for (index=0; index < n_filt; index++) for (index = 0; index < n_filt; index++) {
{
CFilter *filter = &pTnsData->Filter[window][index]; CFilter *filter = &pTnsData->Filter[window][index];
length = (UCHAR)FDKreadBits(bs, isLongFlag ? 6 : 4); length = (UCHAR)FDKreadBits(bs, isLongFlag ? 6 : 4);
@ -172,19 +187,25 @@ AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
filter->StopBand = nextstopband; filter->StopBand = nextstopband;
nextstopband = filter->StartBand; nextstopband = filter->StartBand;
{ if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) {
/* max(Order) = 15 (long), 7 (short) */
filter->Order = order = (UCHAR)FDKreadBits(bs, isLongFlag ? 4 : 3);
} else {
filter->Order = order = (UCHAR)FDKreadBits(bs, isLongFlag ? 5 : 3); filter->Order = order = (UCHAR)FDKreadBits(bs, isLongFlag ? 5 : 3);
}
if (filter->Order > TNS_MAXIMUM_ORDER) { if (filter->Order > TNS_MAXIMUM_ORDER) {
filter->Order = order = TNS_MAXIMUM_ORDER; ErrorStatus = AAC_DEC_TNS_READ_ERROR;
return ErrorStatus;
}
} }
if (order) FDK_ASSERT(order <=
{ TNS_MAXIMUM_ORDER); /* avoid illegal memory access */
if (order) {
UCHAR coef, s_mask; UCHAR coef, s_mask;
UCHAR i; UCHAR i;
SCHAR n_mask; SCHAR n_mask;
static const UCHAR sgn_mask[] = {0x2, 0x4, 0x8}; static const UCHAR sgn_mask[] = {0x2, 0x4, 0x8};
static const SCHAR neg_mask[] = {~0x3, ~0x7, ~0xF}; static const SCHAR neg_mask[] = {~0x3, ~0x7, ~0xF};
@ -197,11 +218,11 @@ AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
s_mask = sgn_mask[coef_res + 1 - coef_compress]; s_mask = sgn_mask[coef_res + 1 - coef_compress];
n_mask = neg_mask[coef_res + 1 - coef_compress]; n_mask = neg_mask[coef_res + 1 - coef_compress];
for (i=0; i < order; i++) for (i = 0; i < order; i++) {
{
coef = (UCHAR)FDKreadBits(bs, filter->Resolution - coef_compress); coef = (UCHAR)FDKreadBits(bs, filter->Resolution - coef_compress);
filter->Coeff[i] = (coef & s_mask) ? (coef | n_mask) : coef; filter->Coeff[i] = (coef & s_mask) ? (coef | n_mask) : coef;
} }
pTnsData->GainLd = 4;
} }
} }
} }
@ -212,115 +233,35 @@ AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs,
return ErrorStatus; return ErrorStatus;
} }
void CTns_ReadDataPresentUsac(HANDLE_FDK_BITSTREAM hBs, CTnsData *pTnsData0,
CTnsData *pTnsData1, UCHAR *ptns_on_lr,
const CIcsInfo *pIcsInfo, const UINT flags,
const UINT elFlags, const int fCommonWindow) {
int common_tns = 0;
static void CTns_Filter (FIXP_DBL *spec, int size, int inc, FIXP_TCC coeff [], int order) if (fCommonWindow) {
{ common_tns = FDKreadBit(hBs);
// - Simple all-pole filter of order "order" defined by
// y(n) = x(n) - a(2)*y(n-1) - ... - a(order+1)*y(n-order)
//
// - The state variables of the filter are initialized to zero every time
//
// - The output data is written over the input data ("in-place operation")
//
// - An input vector of "size" samples is processed and the index increment
// to the next data sample is given by "inc"
int i,j,N;
FIXP_DBL *pSpec;
FIXP_DBL maxVal=FL2FXCONST_DBL(0.0);
INT s;
FDK_ASSERT(order <= TNS_MAXIMUM_ORDER);
C_ALLOC_SCRATCH_START(state, FIXP_DBL, TNS_MAXIMUM_ORDER);
FDKmemclear(state, order*sizeof(FIXP_DBL));
for (i=0; i<size; i++) {
maxVal = fixMax(maxVal,fixp_abs(spec[i]));
}
if ( maxVal > FL2FXCONST_DBL(0.03125*0.70710678118) )
s = fixMax(CntLeadingZeros(maxVal)-6,0);
else
s = fixMax(CntLeadingZeros(maxVal)-5,0);
s = fixMin(s,2);
s = s-1;
if (inc == -1)
pSpec = &spec[size - 1];
else
pSpec = &spec[0];
FIXP_TCC *pCoeff;
#define FIRST_PART_FLTR \
FIXP_DBL x, *pState = state; \
pCoeff = coeff; \
\
if (s < 0) \
x = (pSpec [0]>>1) + fMultDiv2 (*pCoeff++, pState [0]) ; \
else \
x = (pSpec [0]<<s) + fMultDiv2 (*pCoeff++, pState [0]) ;
#define INNER_FLTR_INLINE \
x = fMultAddDiv2 (x, *pCoeff, pState [1]); \
pState [0] = pState [1] - (fMultDiv2 (*pCoeff++, x) <<2) ; \
pState++;
#define LAST_PART_FLTR \
if (s < 0) \
*pSpec = x << 1; \
else \
*pSpec = x >> s; \
*pState =(-x) << 1; \
pSpec += inc ;
if (order>8)
{
N = (order-1)&7;
for (i = size ; i != 0 ; i--)
{
FIRST_PART_FLTR
for (j = N; j > 0 ; j--) { INNER_FLTR_INLINE }
INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE
INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE
LAST_PART_FLTR
}
} else if (order>4) {
N = (order-1)&3;
for (i = size ; i != 0 ; i--)
{
FIRST_PART_FLTR
for (j = N; j > 0 ; j--) { INNER_FLTR_INLINE }
INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE INNER_FLTR_INLINE
LAST_PART_FLTR
} }
{ *ptns_on_lr = FDKreadBit(hBs); }
if (common_tns) {
pTnsData0->DataPresent = 1;
CTns_Read(hBs, pTnsData0, pIcsInfo, flags);
pTnsData0->DataPresent = 0;
pTnsData0->Active = 1;
*pTnsData1 = *pTnsData0;
} else { } else {
int tns_present_both;
N = order-1; tns_present_both = FDKreadBit(hBs);
if (tns_present_both) {
for (i = size ; i != 0 ; i--) pTnsData0->DataPresent = 1;
{ pTnsData1->DataPresent = 1;
FIRST_PART_FLTR } else {
pTnsData1->DataPresent = FDKreadBit(hBs);
for (j = N; j > 0 ; j--) { INNER_FLTR_INLINE } pTnsData0->DataPresent = !pTnsData1->DataPresent;
LAST_PART_FLTR
} }
} }
C_ALLOC_SCRATCH_END(state, FIXP_DBL, TNS_MAXIMUM_ORDER);
} }
/*! /*!
@ -330,83 +271,91 @@ static void CTns_Filter (FIXP_DBL *spec, int size, int inc, FIXP_TCC coeff [], i
\return none \return none
*/ */
void CTns_Apply ( void CTns_Apply(CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */
CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */ const CIcsInfo *pIcsInfo, SPECTRAL_PTR pSpectralCoefficient,
const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectralCoefficient,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength const INT granuleLength, const UCHAR nbands,
) const UCHAR igf_active, const UINT flags) {
{ int window, index, start, stop, size, start_window, wins_per_frame;
int window,index,start,stop,size;
if (pTnsData->Active) {
C_AALLOC_SCRATCH_START(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER)
if (pTnsData->Active)
{ {
C_AALLOC_SCRATCH_START(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER); start_window = 0;
wins_per_frame = GetWindowsPerFrame(pIcsInfo);
for (window=0; window < GetWindowsPerFrame(pIcsInfo); window++)
{
FIXP_DBL *pSpectrum = SPEC(pSpectralCoefficient, window, granuleLength);
for (index=0; index < pTnsData->NumberOfFilters[window]; index++)
{
CFilter *RESTRICT filter = &pTnsData->Filter[window][index];
if (filter->Order > 0)
{
FIXP_TCC *pCoeff;
int tns_max_bands;
pCoeff = &coeff[filter->Order-1];
if (filter->Resolution == 3)
{
int i;
for (i=0; i < filter->Order; i++)
*pCoeff-- = FDKaacDec_tnsCoeff3[filter->Coeff[i]+4];
} }
else
{ for (window = start_window; window < wins_per_frame; window++) {
FIXP_DBL *pSpectrum;
{ pSpectrum = SPEC(pSpectralCoefficient, window, granuleLength); }
for (index = 0; index < pTnsData->NumberOfFilters[window]; index++) {
CFilter *filter = &pTnsData->Filter[window][index];
if (filter->Order > 0) {
FIXP_TCC *pCoeff;
UCHAR tns_max_bands;
pCoeff = coeff;
if (filter->Resolution == 3) {
int i; int i;
for (i = 0; i < filter->Order; i++) for (i = 0; i < filter->Order; i++)
*pCoeff-- = FDKaacDec_tnsCoeff4[filter->Coeff[i]+8]; *pCoeff++ = FDKaacDec_tnsCoeff3[filter->Coeff[i] + 4];
} else {
int i;
for (i = 0; i < filter->Order; i++)
*pCoeff++ = FDKaacDec_tnsCoeff4[filter->Coeff[i] + 8];
} }
switch (granuleLength) { switch (granuleLength) {
case 480: case 480:
tns_max_bands = tns_max_bands_tbl_480[pSamplingRateInfo->samplingRateIndex]; tns_max_bands =
tns_max_bands_tbl_480[pSamplingRateInfo->samplingRateIndex];
break; break;
case 512: case 512:
tns_max_bands = tns_max_bands_tbl_512[pSamplingRateInfo->samplingRateIndex]; tns_max_bands =
tns_max_bands_tbl_512[pSamplingRateInfo->samplingRateIndex];
break; break;
default: default:
tns_max_bands = GetMaximumTnsBands(pIcsInfo, pSamplingRateInfo->samplingRateIndex); tns_max_bands = GetMaximumTnsBands(
pIcsInfo, pSamplingRateInfo->samplingRateIndex);
/* See redefinition of TNS_MAX_BANDS table */
if ((flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA)) &&
(pSamplingRateInfo->samplingRateIndex > 5)) {
tns_max_bands += 1;
}
break; break;
} }
start = fixMin( fixMin(filter->StartBand, tns_max_bands), start = fixMin(fixMin(filter->StartBand, tns_max_bands), nbands);
GetScaleFactorBandsTransmitted(pIcsInfo) );
start = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[start]; start = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[start];
stop = fixMin( fixMin(filter->StopBand, tns_max_bands), if (igf_active) {
GetScaleFactorBandsTransmitted(pIcsInfo) ); stop = fixMin(filter->StopBand, nbands);
} else {
stop = fixMin(fixMin(filter->StopBand, tns_max_bands), nbands);
}
stop = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[stop]; stop = GetScaleFactorBandOffsets(pIcsInfo, pSamplingRateInfo)[stop];
size = stop - start; size = stop - start;
if (size > 0) { if (size) {
CTns_Filter(&pSpectrum[start], C_ALLOC_SCRATCH_START(state, FIXP_DBL, TNS_MAXIMUM_ORDER)
size,
filter->Direction,
coeff,
filter->Order );
}
}
}
}
C_AALLOC_SCRATCH_END(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER);
}
FDKmemclear(state, TNS_MAXIMUM_ORDER * sizeof(FIXP_DBL));
CLpc_SynthesisLattice(pSpectrum + start, size, 0, 0,
filter->Direction, coeff, filter->Order,
state);
C_ALLOC_SCRATCH_END(state, FIXP_DBL, TNS_MAXIMUM_ORDER)
}
}
}
}
C_AALLOC_SCRATCH_END(coeff, FIXP_TCC, TNS_MAXIMUM_ORDER)
}
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,29 +90,37 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: temporal noise shaping tool Description: temporal noise shaping tool
******************************************************************************/ *******************************************************************************/
#ifndef TNS_H #ifndef AACDEC_TNS_H
#define TNS_H #define AACDEC_TNS_H
#include "common_fix.h" #include "common_fix.h"
enum enum {
{
TNS_MAX_WINDOWS = 8, /* 8 */ TNS_MAX_WINDOWS = 8, /* 8 */
TNS_MAXIMUM_ORDER = 20, /* 12 for AAC-LC and AAC-SSR. Set to 20 for AAC-Main (AOT 1). Some broken encoders also do order 20 for AAC-LC :( */
TNS_MAXIMUM_FILTERS = 3 TNS_MAXIMUM_FILTERS = 3
}; };
typedef struct /* TNS_MAXIMUM_ORDER (for memory allocation)
{ 12 for AAC-LC and AAC-SSR. Set to 20 for AAC-Main (AOT 1). Some broken
encoders also do order 20 for AAC-LC :( 15 for USAC (AOT 42)
*/
#define TNS_MAXIMUM_ORDER (20)
#if (TNS_MAXIMUM_ORDER < 15)
#error USAC: TNS filter order up 15 can be signaled!
#endif
typedef struct {
SCHAR Coeff[TNS_MAXIMUM_ORDER]; SCHAR Coeff[TNS_MAXIMUM_ORDER];
UCHAR StartBand; UCHAR StartBand;
@ -113,14 +132,18 @@ typedef struct
UCHAR Order; UCHAR Order;
} CFilter; } CFilter;
typedef struct typedef struct {
{
CFilter Filter[TNS_MAX_WINDOWS][TNS_MAXIMUM_FILTERS]; CFilter Filter[TNS_MAX_WINDOWS][TNS_MAXIMUM_FILTERS];
UCHAR NumberOfFilters[TNS_MAX_WINDOWS]; UCHAR NumberOfFilters[TNS_MAX_WINDOWS];
UCHAR DataPresent; UCHAR DataPresent;
UCHAR Active; UCHAR Active;
/* log2 of the maximum total filter gains. The value is required to
keep necessary mantissa headroom so that while applying the TNS predictor
the mantissas do not overflow. */
UCHAR GainLd;
} CTnsData; } CTnsData;
void CTns_Reset(CTnsData *pTnsData); void CTns_Reset(CTnsData *pTnsData);
#endif /* #ifndef TNS_H */ #endif /* #ifndef AACDEC_TNS_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 Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: Description:
******************************************************************************/ *******************************************************************************/
#ifndef AACDECODER_H #ifndef AACDECODER_H
#define AACDECODER_H #define AACDECODER_H
@ -104,42 +116,32 @@ amm-info@iis.fraunhofer.de
#include "genericStds.h" #include "genericStds.h"
#include "FDK_qmf_domain.h"
#include "sbrdecoder.h" #include "sbrdecoder.h"
#include "aacdec_drc.h" #include "aacdec_drc.h"
#include "pcmutils_lib.h" #include "pcmdmx_lib.h"
#include "FDK_drcDecLib.h"
#include "limiter.h" #include "limiter.h"
#include "FDK_delay.h"
/* Capabilities flags */ #define TIME_DATA_FLUSH_SIZE (128)
#define CAPF_AAC_LC 0x00000001 #define TIME_DATA_FLUSH_SIZE_SF (7)
#define CAPF_AAC_LD 0x00000002
#define CAPF_AAC_SCAL 0x00000004 #define AACDEC_MAX_NUM_PREROLL_AU_USAC (3)
#define CAPF_AAC_ER 0x00000008 #if (AACDEC_MAX_NUM_PREROLL_AU < 3)
#define CAPF_AAC_480 0x00000010 #undef AACDEC_MAX_NUM_PREROLL_AU
#define CAPF_AAC_512 0x00000020 #define AACDEC_MAX_NUM_PREROLL_AU AACDEC_MAX_NUM_PREROLL_AU_USAC
#define CAPF_AAC_960 0x00000040 #endif
#define CAPF_AAC_1024 0x00000080
#define CAPF_AAC_HCR 0x00000100
#define CAPF_AAC_VCB11 0x00000200
#define CAPF_AAC_RVLC 0x00000400
#define CAPF_AAC_MPEG4 0x00000800 /* PNS */
#define CAPF_AAC_DRC 0x00001000
#define CAPF_AAC_CONCEAL 0x00002000
#define CAPF_AAC_DRM_BSFORMAT 0x00004000
#define CAPF_AAC_BSAC 0x00008000
typedef struct AAC_DECODER_INSTANCE *HANDLE_AACDECODER; typedef struct AAC_DECODER_INSTANCE *HANDLE_AACDECODER;
enum { L = 0, R = 1 };
enum
{
L = 0,
R = 1
};
typedef struct { typedef struct {
unsigned char *buffer; unsigned char *buffer;
@ -148,90 +150,204 @@ typedef struct {
int nrElements; int nrElements;
} CAncData; } CAncData;
typedef enum { typedef enum { NOT_DEFINED = -1, MODE_HQ = 0, MODE_LP = 1 } QMF_MODE;
NOT_DEFINED = -1,
MODE_HQ = 0,
MODE_LP = 1
} QMF_MODE;
typedef struct { typedef struct {
int bsDelay; int bsDelay;
} SBR_PARAMS; } SBR_PARAMS;
enum {
AACDEC_FLUSH_OFF = 0,
AACDEC_RSV60_CFG_CHANGE_ATSC_FLUSH_ON = 1,
AACDEC_RSV60_DASH_IPF_ATSC_FLUSH_ON = 2,
AACDEC_USAC_DASH_IPF_FLUSH_ON = 3
};
enum {
AACDEC_BUILD_UP_OFF = 0,
AACDEC_RSV60_BUILD_UP_ON = 1,
AACDEC_RSV60_BUILD_UP_ON_IN_BAND = 2,
AACDEC_USAC_BUILD_UP_ON = 3,
AACDEC_RSV60_BUILD_UP_IDLE = 4,
AACDEC_RSV60_BUILD_UP_IDLE_IN_BAND = 5
};
typedef struct {
/* Usac Extension Elements */
USAC_EXT_ELEMENT_TYPE usacExtElementType[(3)];
UINT usacExtElementDefaultLength[(3)];
UCHAR usacExtElementPayloadFrag[(3)];
} CUsacCoreExtensions;
/* AAC decoder (opaque toward userland) struct declaration */ /* AAC decoder (opaque toward userland) struct declaration */
struct AAC_DECODER_INSTANCE { struct AAC_DECODER_INSTANCE {
INT aacChannels; /*!< Amount of AAC decoder channels allocated. */ INT aacChannels; /*!< Amount of AAC decoder channels allocated. */
INT ascChannels; /*!< Amount of AAC decoder channels signalled in ASC. */ INT ascChannels[(1 *
1)]; /*!< Amount of AAC decoder channels signalled in ASC. */
INT blockNumber; /*!< frame counter */ INT blockNumber; /*!< frame counter */
INT nrOfLayers; INT nrOfLayers;
INT outputInterleaved; /*!< PCM output format (interleaved/none interleaved). */ INT outputInterleaved; /*!< PCM output format (interleaved/none interleaved).
*/
HANDLE_TRANSPORTDEC hInput; /*!< Transport layer handle. */ HANDLE_TRANSPORTDEC hInput; /*!< Transport layer handle. */
SamplingRateInfo samplingRateInfo; /*!< Sampling Rate information table */ SamplingRateInfo
samplingRateInfo[(1 * 1)]; /*!< Sampling Rate information table */
UCHAR frameOK; /*!< Will be unset if a consistency check, e.g. CRC etc. fails */ UCHAR
frameOK; /*!< Will be unset if a consistency check, e.g. CRC etc. fails */
UINT flags; /*!< Flags for internal decoder use. DO NOT USE self::streaminfo::flags ! */ UINT flags[(1 * 1)]; /*!< Flags for internal decoder use. DO NOT USE
self::streaminfo::flags ! */
UINT elFlags[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Flags for internal decoder use (element specific). DO
NOT USE self::streaminfo::flags ! */
MP4_ELEMENT_ID elements[(8)]; /*!< Table where the element Id's are listed */ MP4_ELEMENT_ID elements[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
UCHAR elTags[(8)]; /*!< Table where the elements id Tags are listed */ 1)]; /*!< Table where the element Id's are listed */
UCHAR chMapping[(8)]; /*!< Table of MPEG canonical order to bitstream channel order mapping. */ UCHAR elTags[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Table where the elements id Tags are listed */
UCHAR chMapping[((8) * 2)]; /*!< Table of MPEG canonical order to bitstream
channel order mapping. */
AUDIO_CHANNEL_TYPE channelType[(8)]; /*!< Audio channel type of each output audio channel (from 0 upto numChannels). */ AUDIO_CHANNEL_TYPE channelType[(8)]; /*!< Audio channel type of each output
UCHAR channelIndices[(8)]; /*!< Audio channel index for each output audio channel (from 0 upto numChannels). */ audio channel (from 0 upto
/* See ISO/IEC 13818-7:2005(E), 8.5.3.2 Explicit channel mapping using a program_config_element() */ numChannels). */
UCHAR channelIndices[(8)]; /*!< Audio channel index for each output audio
channel (from 0 upto numChannels). */
/* See ISO/IEC 13818-7:2005(E), 8.5.3.2 Explicit channel mapping using a
* program_config_element() */
FDK_channelMapDescr mapDescr; /*!< Describes the output channel mapping. */
const UCHAR (*channelOutputMapping)[8]; /*!< Table for MPEG canonical order to output channel order mapping. */ UCHAR chMapIndex; /*!< Index to access one line of the channelOutputMapping
UCHAR chMapIndex; /*!< Index to access one line of the channelOutputMapping table. This is required table. This is required because not all 8 channel
because not all 8 channel configurations have the same output mapping. */ configurations have the same output mapping. */
INT sbrDataLen; /*!< Expected length of the SBR remaining in bitbuffer after
the AAC payload has been pared. */
CProgramConfig pce; CProgramConfig pce;
CStreamInfo streamInfo; /*!< pointer to StreamInfo data (read from the bitstream) */ CStreamInfo
CAacDecoderChannelInfo *pAacDecoderChannelInfo[(8)]; /*!< Temporal channel memory */ streamInfo; /*!< Pointer to StreamInfo data (read from the bitstream) */
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[(8)]; /*!< Persistent channel memory */ CAacDecoderChannelInfo
*pAacDecoderChannelInfo[(8)]; /*!< Temporal channel memory */
CAacDecoderStaticChannelInfo
*pAacDecoderStaticChannelInfo[(8)]; /*!< Persistent channel memory */
CAacDecoderCommonData aacCommonData; /*!< Temporal shared data for all channels hooked into pAacDecoderChannelInfo */ FIXP_DBL *workBufferCore2;
PCM_DEC *pTimeData2;
INT timeData2Size;
CpePersistentData *cpeStaticData[(
3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) +
1)]; /*!< Pointer to persistent data shared by both channels of a CPE.
This structure is allocated once for each CPE. */
CConcealParams concealCommonData; CConcealParams concealCommonData;
CConcealmentMethod concealMethodUser;
INT aacChannelsPrev; /*!< The amount of AAC core channels of the last successful decode call. */ CUsacCoreExtensions usacCoreExt; /*!< Data and handles to extend USAC FD/LPD
AUDIO_CHANNEL_TYPE channelTypePrev[(8)]; /*!< Array holding the channelType values of the last successful decode call. */ core decoder (SBR, MPS, ...) */
UCHAR channelIndicesPrev[(8)]; /*!< Array holding the channelIndices values of the last successful decode call. */ UINT numUsacElements[(1 * 1)];
UCHAR usacStereoConfigIndex[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)];
const CSUsacConfig *pUsacConfig[(1 * 1)];
INT nbDiv; /*!< number of frame divisions in LPD-domain */
UCHAR useLdQmfTimeAlign;
INT aacChannelsPrev; /*!< The amount of AAC core channels of the last
successful decode call. */
AUDIO_CHANNEL_TYPE channelTypePrev[(8)]; /*!< Array holding the channelType
values of the last successful
decode call. */
UCHAR
channelIndicesPrev[(8)]; /*!< Array holding the channelIndices values of
the last successful decode call. */
UCHAR
downscaleFactor; /*!< Variable to store a supported ELD downscale factor
of 1, 2, 3 or 4 */
UCHAR downscaleFactorInBS; /*!< Variable to store the (not necessarily
supported) ELD downscale factor discovered in
the bitstream */
HANDLE_SBRDECODER hSbrDecoder; /*!< SBR decoder handle. */ HANDLE_SBRDECODER hSbrDecoder; /*!< SBR decoder handle. */
UCHAR sbrEnabled; /*!< flag to store if SBR has been detected */ UCHAR sbrEnabled; /*!< flag to store if SBR has been detected */
UCHAR sbrEnabledPrev; /*!< flag to store if SBR has been detected from previous frame */ UCHAR sbrEnabledPrev; /*!< flag to store if SBR has been detected from
previous frame */
UCHAR psPossible; /*!< flag to store if PS is possible */ UCHAR psPossible; /*!< flag to store if PS is possible */
SBR_PARAMS sbrParams; /*!< struct to store all sbr parameters */ SBR_PARAMS sbrParams; /*!< struct to store all sbr parameters */
UCHAR *pDrmBsBuffer; /*!< Pointer to dynamic buffer which is used to reverse
the bits of the DRM SBR payload */
USHORT drmBsBufferSize; /*!< Size of the dynamic buffer which is used to
reverse the bits of the DRM SBR payload */
FDK_QMF_DOMAIN
qmfDomain; /*!< Instance of module for QMF domain data handling */
QMF_MODE qmfModeCurr; /*!< The current QMF mode */ QMF_MODE qmfModeCurr; /*!< The current QMF mode */
QMF_MODE qmfModeUser; /*!< The QMF mode requested by the library user */ QMF_MODE qmfModeUser; /*!< The QMF mode requested by the library user */
HANDLE_AAC_DRC hDrcInfo; /*!< handle to DRC data structure */ HANDLE_AAC_DRC hDrcInfo; /*!< handle to DRC data structure */
INT metadataExpiry; /*!< Metadata expiry time in milli-seconds. */
void *pMpegSurroundDecoder; /*!< pointer to mpeg surround decoder structure */
UCHAR mpsEnableUser; /*!< MPS enable user flag */
UCHAR mpsEnableCurr; /*!< MPS enable decoder state */
UCHAR mpsApplicable; /*!< MPS applicable */
SCHAR mpsOutputMode; /*!< setting: normal = 0, binaural = 1, stereo = 2, 5.1ch
= 3 */
INT mpsOutChannelsLast; /*!< The amount of channels returned by the last
successful MPS decoder call. */
INT mpsFrameSizeLast; /*!< The frame length returned by the last successful
MPS decoder call. */
CAncData ancData; /*!< structure to handle ancillary data */ CAncData ancData; /*!< structure to handle ancillary data */
HANDLE_PCM_DOWNMIX hPcmUtils; /*!< privat data for the PCM utils. */ HANDLE_PCM_DOWNMIX hPcmUtils; /*!< privat data for the PCM utils. */
TDLimiterPtr hLimiter; /*!< Handle of time domain limiter. */
UCHAR limiterEnableUser; /*!< The limiter configuration requested by the library user */
UCHAR limiterEnableCurr; /*!< The current limiter configuration. */
TDLimiterPtr hLimiter; /*!< Handle of time domain limiter. */
UCHAR limiterEnableUser; /*!< The limiter configuration requested by the
library user */
UCHAR limiterEnableCurr; /*!< The current limiter configuration. */
FIXP_DBL extGain[1]; /*!< Gain that must be applied to the output signal. */ FIXP_DBL extGain[1]; /*!< Gain that must be applied to the output signal. */
UINT extGainDelay; /*!< Delay that must be accounted for extGain. */ UINT extGainDelay; /*!< Delay that must be accounted for extGain. */
INT_PCM pcmOutputBuffer[(8)*(2048)]; INT_PCM pcmOutputBuffer[(8) * (1024 * 2)];
HANDLE_DRC_DECODER hUniDrcDecoder;
UCHAR multibandDrcPresent;
UCHAR numTimeSlots;
UINT loudnessInfoSetPosition[3];
SCHAR defaultTargetLoudness;
INT_PCM
*pTimeDataFlush[((8) * 2)]; /*!< Pointer to the flushed time data which
will be used for the crossfade in case of
an USAC DASH IPF config change */
UCHAR flushStatus; /*!< Indicates flush status: on|off */
SCHAR flushCnt; /*!< Flush frame counter */
UCHAR buildUpStatus; /*!< Indicates build up status: on|off */
SCHAR buildUpCnt; /*!< Build up frame counter */
UCHAR hasAudioPreRoll; /*!< Indicates preRoll status: on|off */
UINT prerollAULength[AACDEC_MAX_NUM_PREROLL_AU + 1]; /*!< Relative offset of
the prerollAU end
position to the AU
start position in the
bitstream */
INT accessUnit; /*!< Number of the actual processed preroll accessUnit */
UCHAR applyCrossfade; /*!< if set crossfade for seamless stream switching is
applied */
FDK_SignalDelay usacResidualDelay; /*!< Delay residual signal to compensate
for eSBR delay of DMX signal in case of
stereoConfigIndex==2. */
}; };
#define AAC_DEBUG_EXTHLP \
#define AAC_DEBUG_EXTHLP "\ "\
--- AAC-Core ---\n\ --- AAC-Core ---\n\
0x00010000 Header data\n\ 0x00010000 Header data\n\
0x00020000 CRC data\n\ 0x00020000 CRC data\n\
@ -272,7 +388,8 @@ void CAacDecoder_SignalInterruption(HANDLE_AACDECODER self);
\return Error code \return Error code
*/ */
AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData, unsigned char *buffer, int size); AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData,
unsigned char *buffer, int size);
/*! /*!
\brief Get one ancillary data element \brief Get one ancillary data element
@ -280,20 +397,22 @@ AAC_DECODER_ERROR CAacDecoder_AncDataInit(CAncData *ancData, unsigned char *buff
\ancData Pointer to ancillary data structure \ancData Pointer to ancillary data structure
\index Index of the anc data element to get \index Index of the anc data element to get
\ptr Pointer to a buffer receiving a pointer to the requested anc data element \ptr Pointer to a buffer receiving a pointer to the requested anc data element
\size Pointer to a buffer receiving the length of the requested anc data element \size Pointer to a buffer receiving the length of the requested anc data
element
\return Error code \return Error code
*/ */
AAC_DECODER_ERROR CAacDecoder_AncDataGet(CAncData *ancData, int index, unsigned char **ptr, int *size); AAC_DECODER_ERROR CAacDecoder_AncDataGet(CAncData *ancData, int index,
unsigned char **ptr, int *size);
/* initialization of aac decoder */ /* initialization of aac decoder */
LINKSPEC_H HANDLE_AACDECODER CAacDecoder_Open(TRANSPORT_TYPE bsFormat); LINKSPEC_H HANDLE_AACDECODER CAacDecoder_Open(TRANSPORT_TYPE bsFormat);
/* Initialization of stream-info elements */ /* Initialization of channel elements */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self, LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self,
const CSAudioSpecificConfig *asc); const CSAudioSpecificConfig *asc,
UCHAR configMode,
UCHAR *configChanged);
/*! /*!
\brief Decodes one aac frame \brief Decodes one aac frame
@ -308,12 +427,34 @@ LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_Init(HANDLE_AACDECODER self,
\return error status \return error status
*/ */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_DecodeFrame( LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
HANDLE_AACDECODER self, HANDLE_AACDECODER self, const UINT flags, FIXP_PCM *pTimeData,
const UINT flags, const INT timeDataSize, const int timeDataChannelOffset);
INT_PCM *pTimeData,
const INT timeDataSize, /* Free config dependent AAC memory */
const INT interleaved LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_FreeMem(HANDLE_AACDECODER self,
); const int subStreamIndex);
/* Prepare crossfade for USAC DASH IPF config change */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_PrepareCrossFade(
const INT_PCM *pTimeData, INT_PCM **pTimeDataFlush, const INT numChannels,
const INT frameSize, const INT interleaved);
/* Apply crossfade for USAC DASH IPF config change */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_ApplyCrossFade(
INT_PCM *pTimeData, INT_PCM **pTimeDataFlush, const INT numChannels,
const INT frameSize, const INT interleaved);
/* Set flush and build up mode */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_CtrlCFGChange(HANDLE_AACDECODER self,
UCHAR flushStatus,
SCHAR flushCnt,
UCHAR buildUpStatus,
SCHAR buildUpCnt);
/* Parse preRoll Extension Payload */
LINKSPEC_H AAC_DECODER_ERROR CAacDecoder_PreRollExtensionPayloadParse(
HANDLE_AACDECODER self, UINT *numPrerollAU, UINT *prerollAUOffset,
UINT *prerollAULength);
/* Destroy aac decoder */ /* Destroy aac decoder */
LINKSPEC_H void CAacDecoder_Close(HANDLE_AACDECODER self); LINKSPEC_H void CAacDecoder_Close(HANDLE_AACDECODER self);
@ -321,5 +462,4 @@ LINKSPEC_H void CAacDecoder_Close ( HANDLE_AACDECODER self );
/* get streaminfo handle from decoder */ /* get streaminfo handle from decoder */
LINKSPEC_H CStreamInfo *CAacDecoder_GetStreamInfo(HANDLE_AACDECODER self); LINKSPEC_H CStreamInfo *CAacDecoder_GetStreamInfo(HANDLE_AACDECODER self);
#endif /* #ifndef AACDECODER_H */ #endif /* #ifndef AACDECODER_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,16 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
/******************************** Fraunhofer IIS ***************************
Author(s): Arthur Tritthart Author(s): Arthur Tritthart
Description: (ARM optimised) Scaling of spectral data Description: (ARM optimised) Scaling of spectral data
******************************************************************************/ *******************************************************************************/
#define FUNCTION_CBlock_ScaleSpectralData_func1 #define FUNCTION_CBlock_ScaleSpectralData_func1
@ -97,26 +107,20 @@ amm-info@iis.fraunhofer.de
loop overhead per sample, that goes down to 1-cycle per sample loop overhead per sample, that goes down to 1-cycle per sample
with an optimal 4x-loop construct (do - 4x - while). with an optimal 4x-loop construct (do - 4x - while).
*/ */
static inline void CBlock_ScaleSpectralData_func1(
FDK_INLINE static void CBlock_ScaleSpectralData_func1( FIXP_DBL *pSpectrum, int maxSfbs, const SHORT *RESTRICT BandOffsets,
FIXP_DBL *pSpectrum, int SpecScale_window, const SHORT *RESTRICT pSfbScale, int window) {
int max_band,
const SHORT * RESTRICT BandOffsets,
int SpecScale_window,
const SHORT * RESTRICT pSfbScale,
int window)
{
int band_offset = 0; int band_offset = 0;
for (int band=0; band < max_band; band++) for (int band = 0; band < maxSfbs; band++) {
{
int runs = band_offset; int runs = band_offset;
band_offset = BandOffsets[band + 1]; band_offset = BandOffsets[band + 1];
runs = band_offset - runs; /* is always a multiple of 4 */ runs = band_offset - runs; /* is always a multiple of 4 */
int scale = SpecScale_window-pSfbScale[window*16+band]; FDK_ASSERT((runs & 3) == 0);
if (scale) int scale =
{ fMin(DFRACT_BITS - 1, SpecScale_window - pSfbScale[window * 16 + band]);
do
{ if (scale) {
do {
FIXP_DBL tmp0, tmp1, tmp2, tmp3; FIXP_DBL tmp0, tmp1, tmp2, tmp3;
tmp0 = pSpectrum[0]; tmp0 = pSpectrum[0];
tmp1 = pSpectrum[1]; tmp1 = pSpectrum[1];
@ -131,9 +135,7 @@ FDK_INLINE static void CBlock_ScaleSpectralData_func1(
*pSpectrum++ = tmp2; *pSpectrum++ = tmp2;
*pSpectrum++ = tmp3; *pSpectrum++ = tmp3;
} while ((runs = runs - 4) != 0); } while ((runs = runs - 4) != 0);
} } else {
else
{
pSpectrum += runs; pSpectrum += runs;
} }
} }

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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: long/short-block decoding Description: long/short-block decoding
******************************************************************************/ *******************************************************************************/
#ifndef BLOCK_H #ifndef BLOCK_H
#define BLOCK_H #define BLOCK_H
@ -97,25 +109,19 @@ amm-info@iis.fraunhofer.de
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
/* PNS (of block) */ /* PNS (of block) */
void CPns_Read (CPnsData *pPnsData, void CPns_Read(CPnsData *pPnsData, HANDLE_FDK_BITSTREAM bs,
HANDLE_FDK_BITSTREAM bs, const CodeBookDescription *hcb, SHORT *pScaleFactor,
const CodeBookDescription *hcb, UCHAR global_gain, int band, int group);
SHORT *pScaleFactor,
UCHAR global_gain,
int band,
int group);
void CPns_Apply(const CPnsData *pPnsData, const CIcsInfo *pIcsInfo,
void CPns_Apply (const CPnsData *pPnsData, SPECTRAL_PTR pSpectrum, const SHORT *pSpecScale,
const CIcsInfo *pIcsInfo,
SPECTRAL_PTR pSpectrum,
const SHORT *pSpecScale,
const SHORT *pScaleFactor, const SHORT *pScaleFactor,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength, const INT granuleLength, const int channel);
const int channel);
void CBlock_ApplyNoise(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
SamplingRateInfo *pSamplingRateInfo, ULONG *nfRandomSeed,
UCHAR *band_is_noise);
/* TNS (of block) */ /* TNS (of block) */
/*! /*!
@ -126,28 +132,21 @@ void CPns_Apply (const CPnsData *pPnsData,
\return none \return none
*/ */
void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, void CTns_ReadDataPresentFlag(HANDLE_FDK_BITSTREAM bs, CTnsData *pTnsData);
CTnsData *pTnsData);
void CTns_ReadDataPresentUsac( void CTns_ReadDataPresentUsac(HANDLE_FDK_BITSTREAM hBs, CTnsData *pTnsData0,
HANDLE_FDK_BITSTREAM hBs, CTnsData *pTnsData1, UCHAR *ptns_on_lr,
CTnsData *pTnsData0, const CIcsInfo *pIcsInfo, const UINT flags,
CTnsData *pTnsData1, const UINT elFlags, const int fCommonWindow);
const CIcsInfo *pIcsInfo,
const UINT flags,
const int fCommonWindow
);
AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs, AAC_DECODER_ERROR CTns_Read(HANDLE_FDK_BITSTREAM bs, CTnsData *pTnsData,
CTnsData *pTnsData, const CIcsInfo *pIcsInfo, const UINT flags);
const CIcsInfo *pIcsInfo,
const UINT flags);
void CTns_Apply(CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */ void CTns_Apply(CTnsData *RESTRICT pTnsData, /*!< pointer to aac decoder info */
const CIcsInfo *pIcsInfo, const CIcsInfo *pIcsInfo, SPECTRAL_PTR pSpectralCoefficient,
SPECTRAL_PTR pSpectralCoefficient,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
const INT granuleLength); const INT granuleLength, const UCHAR nbands,
const UCHAR igf_active, const UINT flags);
/* Block */ /* Block */
@ -155,17 +154,16 @@ LONG CBlock_GetEscape(HANDLE_FDK_BITSTREAM bs, const LONG q);
/** /**
* \brief Read scale factor data. See chapter 4.6.2.3.2 of ISO/IEC 14496-3. * \brief Read scale factor data. See chapter 4.6.2.3.2 of ISO/IEC 14496-3.
* The SF_OFFSET = 100 value referenced in chapter 4.6.2.3.3 is already substracted * The SF_OFFSET = 100 value referenced in chapter 4.6.2.3.3 is already
* from the scale factor values. Also includes PNS data reading. * substracted from the scale factor values. Also includes PNS data reading.
* \param bs bit stream handle data source * \param bs bit stream handle data source
* \param pAacDecoderChannelInfo channel context info were decoded data is stored into. * \param pAacDecoderChannelInfo channel context info were decoded data is
* stored into.
* \param flags the decoder flags. * \param flags the decoder flags.
*/ */
AAC_DECODER_ERROR CBlock_ReadScaleFactorData( AAC_DECODER_ERROR CBlock_ReadScaleFactorData(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo, HANDLE_FDK_BITSTREAM bs,
HANDLE_FDK_BITSTREAM bs, const UINT flags);
const UINT flags
);
/** /**
* \brief Read Huffman encoded spectral data. * \brief Read Huffman encoded spectral data.
@ -173,66 +171,80 @@ AAC_DECODER_ERROR CBlock_ReadScaleFactorData(
* \param pSamplingRateInfo sampling rate info (sfb offsets). * \param pSamplingRateInfo sampling rate info (sfb offsets).
* \param flags syntax flags. * \param flags syntax flags.
*/ */
AAC_DECODER_ERROR CBlock_ReadSpectralData(HANDLE_FDK_BITSTREAM bs, AAC_DECODER_ERROR CBlock_ReadSpectralData(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, HANDLE_FDK_BITSTREAM bs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo, const UINT flags);
const UINT flags);
AAC_DECODER_ERROR CBlock_ReadSectionData(HANDLE_FDK_BITSTREAM bs,
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo,
const UINT flags);
/** /**
* \brief find a common exponent (shift factor) for all sfb in each Spectral window, and store them into * \brief Read Arithmetic encoded spectral data.
* CAacDecoderChannelInfo::specScale.
* \param pAacDecoderChannelInfo channel context info. * \param pAacDecoderChannelInfo channel context info.
* \param pAacDecoderStaticChannelInfo static channel context info.
* \param pSamplingRateInfo sampling rate info (sfb offsets).
* \param frame_length spectral window length.
* \param flags syntax flags.
* \return error code.
*/
AAC_DECODER_ERROR CBlock_ReadAcSpectralData(
HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const UINT frame_length,
const UINT flags);
AAC_DECODER_ERROR CBlock_ReadSectionData(
HANDLE_FDK_BITSTREAM bs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const UINT flags);
/**
* \brief find a common exponent (shift factor) for all sfb in each Spectral
* window, and store them into CAacDecoderChannelInfo::specScale.
* \param pAacDecoderChannelInfo channel context info.
* \param UCHAR maxSfbs maximum number of SFBs to be processed (might differ
* from pAacDecoderChannelInfo->icsInfo.MaxSfBands)
* \param pSamplingRateInfo sampling rate info (sfb offsets). * \param pSamplingRateInfo sampling rate info (sfb offsets).
*/ */
void CBlock_ScaleSpectralData(CAacDecoderChannelInfo *pAacDecoderChannelInfo, SamplingRateInfo *pSamplingRateInfo); void CBlock_ScaleSpectralData(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UCHAR maxSfbs,
SamplingRateInfo *pSamplingRateInfo);
/** /**
* \brief Apply TNS and PNS tools. * \brief Apply TNS and PNS tools.
*/ */
void ApplyTools(CAacDecoderChannelInfo *pAacDecoderChannelInfo[], void ApplyTools(CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo, const UINT flags,
const UINT flags, const UINT elFlags, const int channel, const int maybe_jstereo);
const int channel );
/** /**
* \brief Transform MDCT spectral data into time domain * \brief Transform MDCT spectral data into time domain
*/ */
void CBlock_FrequencyToTime(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo, void CBlock_FrequencyToTime(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
INT_PCM outSamples[], CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
const SHORT frameLen, const SHORT frameLen, const int frameOk, FIXP_DBL *pWorkBuffer1,
const int stride, UINT elFlags, INT elCh);
const int frameOk,
FIXP_DBL *pWorkBuffer1);
/** /**
* \brief Transform double lapped MDCT (AAC-ELD) spectral data into time domain. * \brief Transform double lapped MDCT (AAC-ELD) spectral data into time domain.
*/ */
void CBlock_FrequencyToTimeLowDelay(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo, void CBlock_FrequencyToTimeLowDelay(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
INT_PCM outSamples[], CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM outSamples[],
const short frameLen, const short frameLen);
const char stride);
AAC_DECODER_ERROR CBlock_InverseQuantizeSpectralData(CAacDecoderChannelInfo *pAacDecoderChannelInfo, SamplingRateInfo *pSamplingRateInfo); AAC_DECODER_ERROR CBlock_InverseQuantizeSpectralData(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
SamplingRateInfo *pSamplingRateInfo, UCHAR *band_is_noise,
UCHAR active_band_search);
/** /**
* \brief Calculate 2^(lsb/4) * value^(4/3) * \brief Calculate 2^(lsb/4) * value^(4/3)
* \param pValue pointer to quantized value. The inverse quantized result is stored back here. * \param pValue pointer to quantized value. The inverse quantized result is
* \param lsb 2 LSBs of the scale factor (scaleFactor % 4) applied as power 2 factor to the * stored back here.
* resulting inverse quantized value. * \param lsb 2 LSBs of the scale factor (scaleFactor % 4) applied as power 2
* factor to the resulting inverse quantized value.
* \return the exponent of the result (mantissa) stored into *pValue. * \return the exponent of the result (mantissa) stored into *pValue.
*/ */
FDK_INLINE FDK_INLINE
int EvaluatePower43 ( FIXP_DBL *pValue, int EvaluatePower43(FIXP_DBL *pValue, UINT lsb) {
UINT lsb )
{
FIXP_DBL value; FIXP_DBL value;
UINT freeBits; UINT freeBits;
UINT exponent; UINT exponent;
@ -261,22 +273,21 @@ int EvaluatePower43 ( FIXP_DBL *pValue,
return ExponentTable[lsb][exponent] + 1; return ExponentTable[lsb][exponent] + 1;
} }
/* Recalculate gain */
FIXP_DBL get_gain(const FIXP_DBL *x, const FIXP_DBL *y, int n);
/** /**
* \brief determine the required shift scale for the given quantized value and scale (factor % 4) value. * \brief determine the required shift scale for the given quantized value and
* scale (factor % 4) value.
*/ */
FDK_INLINE int GetScaleFromValue (FIXP_DBL value, unsigned int lsb) FDK_INLINE int GetScaleFromValue(FIXP_DBL value, unsigned int lsb) {
{ if (value != (FIXP_DBL)0) {
if (value!=(FIXP_DBL)0)
{
int scale = EvaluatePower43(&value, lsb); int scale = EvaluatePower43(&value, lsb);
return CntLeadingZeros(value) - scale - 2; return CntLeadingZeros(value) - scale - 2;
} else
return 0; /* Return zero, because its useless to scale a zero value, saves
workload and avoids scaling overshifts. */
} }
else
return 0; /* Return zero, because its useless to scale a zero value, saves workload and avoids scaling overshifts. */
}
//#ifdef AACDEC_HUFFMANDECODER_ENABLE
/*! /*!
\brief Read huffman codeword \brief Read huffman codeword
@ -286,26 +297,23 @@ FDK_INLINE int GetScaleFromValue (FIXP_DBL value, unsigned int lsb)
\return index value \return index value
*/ */
inline int CBlock_DecodeHuffmanWord( HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */ inline int CBlock_DecodeHuffmanWord(
HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
const CodeBookDescription *hcb) /*!< pointer to codebook description */ const CodeBookDescription *hcb) /*!< pointer to codebook description */
{ {
UINT val; UINT val;
UINT index = 0; UINT index = 0;
const USHORT(*CodeBook)[HuffmanEntries] = hcb->CodeBook; const USHORT(*CodeBook)[HuffmanEntries] = hcb->CodeBook;
while (1) while (1) {
{ val = CodeBook[index]
val = CodeBook[index][FDKreadBits(bs,HuffmanBits)]; /* Expensive memory access */ [FDKreadBits(bs, HuffmanBits)]; /* Expensive memory access */
if ((val & 1) == 0) if ((val & 1) == 0) {
{
index = val >> 2; index = val >> 2;
continue; continue;
} } else {
else if (val & 2) {
{
if (val & 2)
{
FDKpushBackCache(bs, 1); FDKpushBackCache(bs, 1);
} }
@ -316,7 +324,22 @@ inline int CBlock_DecodeHuffmanWord( HANDLE_FDK_BITSTREAM bs,
return val; return val;
} }
inline int CBlock_DecodeHuffmanWordCB(
HANDLE_FDK_BITSTREAM bs, /*!< pointer to bitstream */
const USHORT (
*CodeBook)[HuffmanEntries]) /*!< pointer to codebook description */
{
UINT index = 0;
//#endif /* AACDEC_HUFFMANDECODER_ENABLE */ while (1) {
index = CodeBook[index][FDKread2Bits(bs)]; /* Expensive memory access */
if (index & 1) break;
index >>= 2;
}
if (index & 2) {
FDKpushBackCache(bs, 1);
}
return index >> 2;
}
#endif /* #ifndef BLOCK_H */ #endif /* #ifndef BLOCK_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,70 +90,71 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: Description:
******************************************************************************/ *******************************************************************************/
#ifndef CHANNEL_H #ifndef CHANNEL_H
#define CHANNEL_H #define CHANNEL_H
#include "common_fix.h" #include "common_fix.h"
#include "FDK_bitstream.h" #include "FDK_tools_rom.h"
#include "channelinfo.h" #include "channelinfo.h"
#include "tpdec_lib.h" #include "tpdec_lib.h"
/** /**
* \brief Init codeBook SFB indices (section data) with HCB_ESC. Useful for bitstreams * \brief Init codeBook SFB indices (section data) with HCB_ESC. Useful for
* which do not have any section data, but still SFB's (scale factor bands). This has * bitstreams which do not have any section data, but still SFB's (scale factor
* the effect that upto the amount of transmitted SFB are treated as non-zero. * bands). This has the effect that upto the amount of transmitted SFB are
* \param pAacDecoderChannelInfo channel info structure containing a valid icsInfo struct. * treated as non-zero.
* \param pAacDecoderChannelInfo channel info structure containing a valid
* icsInfo struct.
*/ */
void CChannel_CodebookTableInit(CAacDecoderChannelInfo *pAacDecoderChannelInfo); void CChannel_CodebookTableInit(CAacDecoderChannelInfo *pAacDecoderChannelInfo);
/** /**
* \brief decode a channel element. To be called after CChannelElement_Read() * \brief decode a channel element. To be called after CChannelElement_Read()
* \param pAacDecoderChannelInfo pointer to channel data struct. Depending on el_channels either one or two. * \param pAacDecoderChannelInfo pointer to channel data struct. Depending on
* el_channels either one or two.
* \param pSamplingRateInfo pointer to sample rate information structure * \param pSamplingRateInfo pointer to sample rate information structure
* \param el_channels amount of channels of the element to be decoded. * \param el_channels amount of channels of the element to be decoded.
* \param output pointer to time domain output buffer (ACELP) * \param output pointer to time domain output buffer (ACELP)
* \param stride factor for accessing output
*/ */
void CChannelElement_Decode ( CAacDecoderChannelInfo *pAacDecoderChannelInfo[2], void CChannelElement_Decode(
CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2], CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2],
SamplingRateInfo *pSamplingRateInfo, SamplingRateInfo *pSamplingRateInfo, UINT flags, UINT elFlags,
UINT flags,
int el_channels); int el_channels);
/** /**
* \brief Read channel element of given type from bitstream. * \brief Read channel element of given type from bitstream.
* \param hBs bitstream handle to access bitstream data. * \param hBs bitstream handle to access bitstream data.
* \param pAacDecoderChannelInfo pointer array to store channel information. * \param pAacDecoderChannelInfo pointer array to store channel information.
* \param aot Audio Object Type * \param aot Audio Object Type
* \param pSamplingRateInfo sampling rate info table. * \param pSamplingRateInfo sampling rate info table.
* \param flags parser guidance flags * \param flags common parser guidance flags
* \param numberOfChannels amoun of channels contained in the object to be parsed. * \param elFlags element specific parser guidance flags
* \param epConfig the current epConfig value obtained from the Audio Specific Config. * \param numberOfChannels amoun of channels contained in the object to be
* parsed.
* \param epConfig the current epConfig value obtained from the Audio Specific
* Config.
* \param pTp transport decoder handle required for ADTS CRC checking. * \param pTp transport decoder handle required for ADTS CRC checking.
* ... * ...
* \return an AAC_DECODER_ERROR error code. * \return an AAC_DECODER_ERROR error code.
*/ */
AAC_DECODER_ERROR CChannelElement_Read(HANDLE_FDK_BITSTREAM hBs, AAC_DECODER_ERROR CChannelElement_Read(
CAacDecoderChannelInfo *pAacDecoderChannelInfo[], HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[], CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
const AUDIO_OBJECT_TYPE aot, const AUDIO_OBJECT_TYPE aot, SamplingRateInfo *pSamplingRateInfo,
const SamplingRateInfo *pSamplingRateInfo, const UINT flags, const UINT elFlags, const UINT frame_length,
const UINT flags, const UCHAR numberOfChannels, const SCHAR epConfig,
const UINT frame_length, HANDLE_TRANSPORTDEC pTpDec);
const UCHAR numberOfChannels,
const SCHAR epConfig,
HANDLE_TRANSPORTDEC pTpDec
);
#endif /* #ifndef CHANNEL_H */ #endif /* #ifndef CHANNEL_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,27 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: individual channel stream info Description: individual channel stream info
******************************************************************************/ *******************************************************************************/
#include "channelinfo.h" #include "channelinfo.h"
#include "aac_rom.h" #include "aac_rom.h"
#include "aac_ram.h" #include "aac_ram.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
AAC_DECODER_ERROR IcsReadMaxSfb(HANDLE_FDK_BITSTREAM bs, CIcsInfo *pIcsInfo,
AAC_DECODER_ERROR IcsReadMaxSfb ( const SamplingRateInfo *pSamplingRateInfo) {
HANDLE_FDK_BITSTREAM bs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo
)
{
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK; AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
int nbits; int nbits;
@ -119,26 +126,21 @@ AAC_DECODER_ERROR IcsReadMaxSfb (
return ErrorStatus; return ErrorStatus;
} }
AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs, CIcsInfo *pIcsInfo,
AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo,
const UINT flags) const UINT flags) {
{
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK; AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
pIcsInfo->Valid = 0; pIcsInfo->Valid = 0;
if (flags & AC_ELD) { if (flags & AC_ELD) {
pIcsInfo->WindowSequence = OnlyLongSequence; pIcsInfo->WindowSequence = BLOCK_LONG;
pIcsInfo->WindowShape = 0; pIcsInfo->WindowShape = 0;
} } else {
else { if (!(flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA))) {
if ( !(flags & (AC_USAC|AC_RSVD50)) ) {
FDKreadBits(bs, 1); FDKreadBits(bs, 1);
} }
pIcsInfo->WindowSequence = (UCHAR) FDKreadBits(bs,2); pIcsInfo->WindowSequence = (BLOCK_TYPE)FDKreadBits(bs, 2);
pIcsInfo->WindowShape = (UCHAR)FDKreadBits(bs, 1); pIcsInfo->WindowShape = (UCHAR)FDKreadBits(bs, 1);
if (flags & AC_LD) { if (flags & AC_LD) {
if (pIcsInfo->WindowShape) { if (pIcsInfo->WindowShape) {
@ -148,8 +150,8 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
} }
/* Sanity check */ /* Sanity check */
if ( (flags & (AC_ELD|AC_LD)) && pIcsInfo->WindowSequence != OnlyLongSequence) { if ((flags & (AC_ELD | AC_LD)) && pIcsInfo->WindowSequence != BLOCK_LONG) {
pIcsInfo->WindowSequence = OnlyLongSequence; pIcsInfo->WindowSequence = BLOCK_LONG;
ErrorStatus = AAC_DEC_PARSE_ERROR; ErrorStatus = AAC_DEC_PARSE_ERROR;
goto bail; goto bail;
} }
@ -159,9 +161,10 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
goto bail; goto bail;
} }
if (IsLongBlock(pIcsInfo)) if (IsLongBlock(pIcsInfo)) {
{ if (!(flags & (AC_ELD | AC_SCALABLE | AC_BSAC | AC_USAC | AC_RSVD50 |
if ( !(flags & (AC_ELD|AC_SCALABLE|AC_BSAC|AC_USAC|AC_RSVD50)) ) /* If not ELD nor Scalable nor BSAC nor USAC syntax then ... */ AC_RSV603DA))) /* If not ELD nor Scalable nor BSAC nor USAC
syntax then ... */
{ {
if ((UCHAR)FDKreadBits(bs, 1) != 0) /* UCHAR PredictorDataPresent */ if ((UCHAR)FDKreadBits(bs, 1) != 0) /* UCHAR PredictorDataPresent */
{ {
@ -172,9 +175,7 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
pIcsInfo->WindowGroups = 1; pIcsInfo->WindowGroups = 1;
pIcsInfo->WindowGroupLength[0] = 1; pIcsInfo->WindowGroupLength[0] = 1;
} } else {
else
{
INT i; INT i;
UINT mask; UINT mask;
@ -182,17 +183,13 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
pIcsInfo->WindowGroups = 0; pIcsInfo->WindowGroups = 0;
for (i=0; i < (8-1); i++) for (i = 0; i < (8 - 1); i++) {
{
mask = 1 << (6 - i); mask = 1 << (6 - i);
pIcsInfo->WindowGroupLength[i] = 1; pIcsInfo->WindowGroupLength[i] = 1;
if (pIcsInfo->ScaleFactorGrouping & mask) if (pIcsInfo->ScaleFactorGrouping & mask) {
{
pIcsInfo->WindowGroupLength[pIcsInfo->WindowGroups]++; pIcsInfo->WindowGroupLength[pIcsInfo->WindowGroups]++;
} } else {
else
{
pIcsInfo->WindowGroups++; pIcsInfo->WindowGroups++;
} }
} }
@ -202,15 +199,12 @@ AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs,
pIcsInfo->WindowGroups++; pIcsInfo->WindowGroups++;
} }
bail: bail:
if (ErrorStatus == AAC_DEC_OK) if (ErrorStatus == AAC_DEC_OK) pIcsInfo->Valid = 1;
pIcsInfo->Valid = 1;
return ErrorStatus; return ErrorStatus;
} }
/* /*
interleave codebooks the following way interleave codebooks the following way
@ -224,20 +218,34 @@ bail:
(270w) (271w) (270w) (271w)
*/ */
/* /*
Table entries are sorted as following: Table entries are sorted as following:
| num_swb_long_window | sfbands_long | num_swb_short_window | sfbands_short | | num_swb_long_window | sfbands_long | num_swb_short_window | sfbands_short |
*/ */
AAC_DECODER_ERROR getSamplingRateInfo( AAC_DECODER_ERROR getSamplingRateInfo(SamplingRateInfo *t, UINT samplesPerFrame,
SamplingRateInfo *t,
UINT samplesPerFrame,
UINT samplingRateIndex, UINT samplingRateIndex,
UINT samplingRate UINT samplingRate) {
)
{
int index = 0; int index = 0;
/* Search closest samplerate according to ISO/IEC 13818-7:2005(E) 8.2.4 (Table
* 38): */
if ((samplingRateIndex >= 15) || (samplesPerFrame == 768)) {
const UINT borders[] = {(UINT)-1, 92017, 75132, 55426, 46009, 37566,
27713, 23004, 18783, 13856, 11502, 9391};
UINT i, samplingRateSearch = samplingRate;
if (samplesPerFrame == 768) {
samplingRateSearch = (samplingRate * 4) / 3;
}
for (i = 0; i < 11; i++) {
if (borders[i] > samplingRateSearch &&
samplingRateSearch >= borders[i + 1]) {
break;
}
}
samplingRateIndex = i;
}
t->samplingRateIndex = samplingRateIndex; t->samplingRateIndex = samplingRateIndex;
t->samplingRate = samplingRate; t->samplingRate = samplingRate;
@ -249,6 +257,9 @@ AAC_DECODER_ERROR getSamplingRateInfo(
case 960: case 960:
index = 1; index = 1;
break; break;
case 768:
index = 2;
break;
case 512: case 512:
index = 3; index = 3;
break; break;
@ -260,17 +271,27 @@ AAC_DECODER_ERROR getSamplingRateInfo(
return AAC_DEC_UNSUPPORTED_FORMAT; return AAC_DEC_UNSUPPORTED_FORMAT;
} }
t->ScaleFactorBands_Long = sfbOffsetTables[index][samplingRateIndex].sfbOffsetLong; t->ScaleFactorBands_Long =
t->ScaleFactorBands_Short = sfbOffsetTables[index][samplingRateIndex].sfbOffsetShort; sfbOffsetTables[index][samplingRateIndex].sfbOffsetLong;
t->NumberOfScaleFactorBands_Long = sfbOffsetTables[index][samplingRateIndex].numberOfSfbLong; t->ScaleFactorBands_Short =
t->NumberOfScaleFactorBands_Short = sfbOffsetTables[index][samplingRateIndex].numberOfSfbShort; sfbOffsetTables[index][samplingRateIndex].sfbOffsetShort;
t->NumberOfScaleFactorBands_Long =
sfbOffsetTables[index][samplingRateIndex].numberOfSfbLong;
t->NumberOfScaleFactorBands_Short =
sfbOffsetTables[index][samplingRateIndex].numberOfSfbShort;
if (t->ScaleFactorBands_Long == NULL || t->NumberOfScaleFactorBands_Long == 0) { if (t->ScaleFactorBands_Long == NULL ||
t->NumberOfScaleFactorBands_Long == 0) {
t->samplingRate = 0;
return AAC_DEC_UNSUPPORTED_FORMAT; return AAC_DEC_UNSUPPORTED_FORMAT;
} }
FDK_ASSERT(t->ScaleFactorBands_Long[t->NumberOfScaleFactorBands_Long] == samplesPerFrame); FDK_ASSERT((UINT)t->ScaleFactorBands_Long[t->NumberOfScaleFactorBands_Long] ==
FDK_ASSERT(t->ScaleFactorBands_Short == NULL || t->ScaleFactorBands_Short[t->NumberOfScaleFactorBands_Short]*8 == samplesPerFrame); samplesPerFrame);
FDK_ASSERT(
t->ScaleFactorBands_Short == NULL ||
(UINT)t->ScaleFactorBands_Short[t->NumberOfScaleFactorBands_Short] * 8 ==
samplesPerFrame);
return AAC_DEC_OK; return AAC_DEC_OK;
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: individual channel stream info Description: individual channel stream info
******************************************************************************/ *******************************************************************************/
#ifndef CHANNELINFO_H #ifndef CHANNELINFO_H
#define CHANNELINFO_H #define CHANNELINFO_H
@ -108,11 +120,22 @@ amm-info@iis.fraunhofer.de
#include "aacdec_hcr_types.h" #include "aacdec_hcr_types.h"
#include "rvlc_info.h" #include "rvlc_info.h"
#include "usacdec_acelp.h"
#include "usacdec_const.h"
#include "usacdec_rom.h"
#include "ac_arith_coder.h"
#include "conceal_types.h" #include "conceal_types.h"
#include "aacdec_drc_types.h" #include "aacdec_drc_types.h"
#define WB_SECTION_SIZE (1024 * 2)
#define DRM_BS_BUFFER_SIZE \
(512) /* size of the dynamic buffer which is used to reverse the bits of \
the DRM SBR payload */
/* Output rendering mode */ /* Output rendering mode */
typedef enum { typedef enum {
AACDEC_RENDER_INVALID = 0, AACDEC_RENDER_INVALID = 0,
@ -122,21 +145,11 @@ typedef enum {
AACDEC_RENDER_INTIMDCT AACDEC_RENDER_INTIMDCT
} AACDEC_RENDER_MODE; } AACDEC_RENDER_MODE;
enum { enum { MAX_QUANTIZED_VALUE = 8191 };
MAX_QUANTIZED_VALUE = 8191
};
enum typedef enum { FD_LONG, FD_SHORT, LPD } USAC_COREMODE;
{
OnlyLongSequence = 0,
LongStartSequence,
EightShortSequence,
LongStopSequence
};
typedef struct {
typedef struct
{
const SHORT *ScaleFactorBands_Long; const SHORT *ScaleFactorBands_Long;
const SHORT *ScaleFactorBands_Short; const SHORT *ScaleFactorBands_Short;
UCHAR NumberOfScaleFactorBands_Long; UCHAR NumberOfScaleFactorBands_Long;
@ -145,31 +158,28 @@ typedef struct
UINT samplingRate; UINT samplingRate;
} SamplingRateInfo; } SamplingRateInfo;
typedef struct typedef struct {
{
UCHAR CommonWindow; UCHAR CommonWindow;
UCHAR GlobalGain; UCHAR GlobalGain;
} CRawDataInfo; } CRawDataInfo;
typedef struct typedef struct {
{
UCHAR WindowGroupLength[8]; UCHAR WindowGroupLength[8];
UCHAR WindowGroups; UCHAR WindowGroups;
UCHAR Valid; UCHAR Valid;
UCHAR WindowShape; /* 0: sine window, 1: KBD, 2: low overlap */ UCHAR WindowShape; /* 0: sine window, 1: KBD, 2: low overlap */
UCHAR WindowSequence; /* See enum above, 0: long, 1: start, 2: short, 3: stop */ BLOCK_TYPE WindowSequence; /* mdct.h; 0: long, 1: start, 2: short, 3: stop */
UCHAR MaxSfBands; UCHAR MaxSfBands;
UCHAR max_sfb_ste;
UCHAR ScaleFactorGrouping; UCHAR ScaleFactorGrouping;
UCHAR TotalSfBands; UCHAR TotalSfBands;
} CIcsInfo; } CIcsInfo;
enum {
enum
{
ZERO_HCB = 0, ZERO_HCB = 0,
ESCBOOK = 11, ESCBOOK = 11,
NSPECBOOKS = ESCBOOK + 1, NSPECBOOKS = ESCBOOK + 1,
@ -180,69 +190,137 @@ enum
LAST_HCB LAST_HCB
}; };
#define TNS_SCALE 3 /* This struct holds the persistent data shared by both channels of a CPE.
It needs to be allocated for each CPE. */
typedef struct {
CJointStereoPersistentData jointStereoPersistentData;
} CpePersistentData;
/* /*
* This struct must be allocated one for every channel and must be persistent. * This struct must be allocated one for every channel and must be persistent.
*/ */
typedef struct typedef struct {
{
FIXP_DBL *pOverlapBuffer; FIXP_DBL *pOverlapBuffer;
mdct_t IMdct; mdct_t IMdct;
CArcoData *hArCo;
INT pnsCurrentSeed;
/* LPD memory */
FIXP_DBL old_synth[PIT_MAX_MAX - L_SUBFR];
INT old_T_pf[SYN_SFD];
FIXP_DBL old_gain_pf[SYN_SFD];
FIXP_DBL mem_bpf[L_FILT + L_SUBFR];
UCHAR
old_bpf_control_info; /* (1: enable, 0: disable) bpf for past superframe
*/
USAC_COREMODE last_core_mode; /* core mode used by the decoder in previous
frame. (not signalled by the bitstream, see
CAacDecoderChannelInfo::core_mode_last !! )
*/
UCHAR last_lpd_mode; /* LPD mode used by the decoder in last LPD subframe
(not signalled by the bitstream, see
CAacDecoderChannelInfo::lpd_mode_last !! ) */
UCHAR last_last_lpd_mode; /* LPD mode used in second last LPD subframe
(not signalled by the bitstream) */
UCHAR last_lpc_lost; /* Flag indicating that the previous LPC is lost */
FIXP_LPC
lpc4_lsf[M_LP_FILTER_ORDER]; /* Last LPC4 coefficients in LSF domain. */
FIXP_LPC lsf_adaptive_mean[M_LP_FILTER_ORDER]; /* Adaptive mean of LPC
coefficients in LSF domain
for concealment. */
FIXP_LPC lp_coeff_old[2][M_LP_FILTER_ORDER]; /* Last LPC coefficients in LP
domain. lp_coeff_old[0] is lpc4 (coeffs for
right folding point of last tcx frame),
lp_coeff_old[1] are coeffs for left folding
point of last tcx frame */
INT lp_coeff_old_exp[2];
FIXP_SGL
oldStability; /* LPC coeff stability value from last frame (required for
TCX concealment). */
UINT numLostLpdFrames; /* Number of consecutive lost subframes. */
/* TCX memory */
FIXP_DBL last_tcx_gain;
INT last_tcx_gain_e;
FIXP_DBL last_alfd_gains[32]; /* Scaled by one bit. */
SHORT last_tcx_pitch;
UCHAR last_tcx_noise_factor;
/* ACELP memory */
CAcelpStaticMem acelp;
ULONG nfRandomSeed; /* seed value for USAC noise filling random generator */
CDrcChannelData drcData; CDrcChannelData drcData;
CConcealmentInfo concealmentInfo; CConcealmentInfo concealmentInfo;
} CAacDecoderStaticChannelInfo; CpePersistentData *pCpeStaticData;
} CAacDecoderStaticChannelInfo;
/* /*
* This union must be allocated for every element (up to 2 channels). * This union must be allocated for every element (up to 2 channels).
*/ */
typedef struct { typedef struct {
/* Common bit stream data */ /* Common bit stream data */
SHORT aScaleFactor[(8*16)]; /* Spectral scale factors for each sfb in each window. */ SHORT aScaleFactor[(
8 * 16)]; /* Spectral scale factors for each sfb in each window. */
SHORT aSfbScale[(8 * 16)]; /* could be free after ApplyTools() */ SHORT aSfbScale[(8 * 16)]; /* could be free after ApplyTools() */
UCHAR aCodeBook[(8*16)]; /* section data: codebook for each window and sfb. */ UCHAR
aCodeBook[(8 * 16)]; /* section data: codebook for each window and sfb. */
UCHAR band_is_noise[(8 * 16)];
CTnsData TnsData; CTnsData TnsData;
CRawDataInfo RawDataInfo; CRawDataInfo RawDataInfo;
shouldBeUnion { shouldBeUnion {
struct { struct {
CPulseData PulseData; CPulseData PulseData;
SHORT aNumLineInSec4Hcr[MAX_SFB_HCR]; /* needed once for all channels except for Drm syntax */ SHORT aNumLineInSec4Hcr[MAX_SFB_HCR]; /* needed once for all channels
UCHAR aCodeBooks4Hcr[MAX_SFB_HCR]; /* needed once for all channels except for Drm syntax. Same as "aCodeBook" ? */ except for Drm syntax */
UCHAR
aCodeBooks4Hcr[MAX_SFB_HCR]; /* needed once for all channels except for
Drm syntax. Same as "aCodeBook" ? */
SHORT lenOfReorderedSpectralData; SHORT lenOfReorderedSpectralData;
SCHAR lenOfLongestCodeword; SCHAR lenOfLongestCodeword;
SCHAR numberSection; SCHAR numberSection;
SCHAR rvlcCurrentScaleFactorOK; SCHAR rvlcCurrentScaleFactorOK;
SCHAR rvlcIntensityUsed; SCHAR rvlcIntensityUsed;
} aac; } aac;
} specificTo; struct {
UCHAR fd_noise_level_and_offset;
UCHAR tns_active;
UCHAR tns_on_lr;
UCHAR tcx_noise_factor[4];
UCHAR tcx_global_gain[4];
} usac;
}
specificTo;
} CAacDecoderDynamicData; } CAacDecoderDynamicData;
typedef shouldBeUnion { typedef shouldBeUnion {
CAacDecoderDynamicData pAacDecoderDynamicData[2]; UCHAR DrmBsBuffer[DRM_BS_BUFFER_SIZE];
/* Common signal data, can be used once the bit stream data from above is not used anymore. */ /* Common signal data, can be used once the bit stream data from above is not
* used anymore. */
FIXP_DBL mdctOutTemp[1024]; FIXP_DBL mdctOutTemp[1024];
FIXP_DBL sbrWorkBuffer[1024*2];
} CWorkBufferCore1; FIXP_DBL synth_buf[(PIT_MAX_MAX + SYN_DELAY + L_FRAME_PLUS)];
FIXP_DBL workBuffer[WB_SECTION_SIZE];
}
CWorkBufferCore1;
/* Common data referenced by all channels */ /* Common data referenced by all channels */
typedef struct { typedef struct {
CAacDecoderDynamicData pAacDecoderDynamicData[2];
CWorkBufferCore1 *workBufferCore1;
FIXP_DBL* workBufferCore2;
CPnsInterChannelData pnsInterChannelData; CPnsInterChannelData pnsInterChannelData;
INT pnsCurrentSeed;
INT pnsRandomSeed[(8 * 16)]; INT pnsRandomSeed[(8 * 16)];
CJointStereoData jointStereoData; /* One for one element */ CJointStereoData jointStereoData; /* One for one element */
@ -255,22 +333,73 @@ typedef struct {
SHORT aRvlcScfFwd[RVLC_MAX_SFB]; /* needed once for all channels */ SHORT aRvlcScfFwd[RVLC_MAX_SFB]; /* needed once for all channels */
SHORT aRvlcScfBwd[RVLC_MAX_SFB]; /* needed once for all channels */ SHORT aRvlcScfBwd[RVLC_MAX_SFB]; /* needed once for all channels */
} aac; } aac;
}
} overlay; overlay;
} CAacDecoderCommonData; } CAacDecoderCommonData;
typedef struct {
CWorkBufferCore1 *pWorkBufferCore1;
CCplxPredictionData *cplxPredictionData;
} CAacDecoderCommonStaticData;
/* /*
* This struct must be allocated one for every channels of every element and must be persistent. * This struct must be allocated one for every channel of every element and must
* Among its members, the following memory areas can be overwritten under the given conditions: * be persistent. Among its members, the following memory areas can be
* - pSpectralCoefficient The memory pointed to can be overwritten after time signal rendering. * overwritten under the given conditions:
* - pSpectralCoefficient The memory pointed to can be overwritten after time
* signal rendering.
* - data can be overwritten after time signal rendering. * - data can be overwritten after time signal rendering.
* - pDynData memory pointed to can be overwritten after each CChannelElement_Decode() call. * - pDynData memory pointed to can be overwritten after each
* - pComData->overlay memory pointed to can be overwritten after each CChannelElement_Decode() call.. * CChannelElement_Decode() call.
* - pComData->overlay memory pointed to can be overwritten after each
* CChannelElement_Decode() call..
*/ */
typedef struct typedef struct {
{ shouldBeUnion {
struct {
FIXP_DBL fac_data0[LFAC];
UCHAR fac_data_e[4];
FIXP_DBL
*fac_data[4]; /* Pointers to unused parts of pSpectralCoefficient */
UCHAR core_mode; /* current core mode */
USAC_COREMODE
core_mode_last; /* previous core mode, signalled in the bitstream
(not done by the decoder, see
CAacDecoderStaticChannelInfo::last_core_mode !!)*/
UCHAR lpd_mode_last; /* previous LPD mode, signalled in the bitstream
(not done by the decoder, see
CAacDecoderStaticChannelInfo::last_core_mode !!)*/
UCHAR mod[4];
UCHAR bpf_control_info; /* (1: enable, 0: disable) bpf for current
superframe */
FIXP_LPC lsp_coeff[5][M_LP_FILTER_ORDER]; /* linear prediction
coefficients in LSP domain */
FIXP_LPC
lp_coeff[5][M_LP_FILTER_ORDER]; /* linear prediction coefficients in
LP domain */
INT lp_coeff_exp[5];
FIXP_LPC lsf_adaptive_mean_cand
[M_LP_FILTER_ORDER]; /* concealment: is copied to
CAacDecoderStaticChannelInfo->lsf_adaptive_mean once frame is
assumed to be correct*/
FIXP_SGL aStability[4]; /* LPC coeff stability values required for ACELP
and TCX (concealment) */
CAcelpChannelData acelp[4];
FIXP_DBL tcx_gain[4];
SCHAR tcx_gain_e[4];
} usac;
struct {
CPnsData PnsData; /* Not required for USAC */
} aac;
}
data;
SPECTRAL_PTR pSpectralCoefficient; /* Spectral coefficients of each window */ SPECTRAL_PTR pSpectralCoefficient; /* Spectral coefficients of each window */
SHORT specScale[8]; /* Scale shift values of each spectrum window */ SHORT specScale[8]; /* Scale shift values of each spectrum window */
CIcsInfo icsInfo; CIcsInfo icsInfo;
@ -279,43 +408,38 @@ typedef struct
AACDEC_RENDER_MODE renderMode; /* Output signal rendering mode */ AACDEC_RENDER_MODE renderMode; /* Output signal rendering mode */
shouldBeUnion { CAacDecoderDynamicData *
struct { pDynData; /* Data required for one element and discarded after decoding */
CPnsData PnsData; /* Not required for USAC */ CAacDecoderCommonData
} aac; *pComData; /* Data required for one channel at a time during decode */
CAacDecoderCommonStaticData *pComStaticData; /* Persistent data required for
one channel at a time during
decode */
struct { int currAliasingSymmetry; /* required for RSVD60 MCT */
} usac;
} data;
CAacDecoderDynamicData *pDynData; /* Data required for one element and discarded after decoding */
CAacDecoderCommonData *pComData; /* Data required for one channel at a time during decode */
} CAacDecoderChannelInfo; } CAacDecoderChannelInfo;
/* channelinfo.cpp */ /* channelinfo.cpp */
AAC_DECODER_ERROR getSamplingRateInfo(SamplingRateInfo *t, UINT samplesPerFrame, UINT samplingRateIndex, UINT samplingRate); AAC_DECODER_ERROR getSamplingRateInfo(SamplingRateInfo *t, UINT samplesPerFrame,
UINT samplingRateIndex,
UINT samplingRate);
/** /**
* \brief Read max SFB from bit stream and assign TotalSfBands according * \brief Read max SFB from bit stream and assign TotalSfBands according
* to the window sequence and sample rate. * to the window sequence and sample rate.
* \param hBs bit stream handle as data source * \param hBs bit stream handle as data source
* \param pIcsInfo IcsInfo structure to read the window sequence and store MaxSfBands and TotalSfBands * \param pIcsInfo IcsInfo structure to read the window sequence and store
* MaxSfBands and TotalSfBands
* \param pSamplingRateInfo read only * \param pSamplingRateInfo read only
*/ */
AAC_DECODER_ERROR IcsReadMaxSfb ( AAC_DECODER_ERROR IcsReadMaxSfb(HANDLE_FDK_BITSTREAM hBs, CIcsInfo *pIcsInfo,
HANDLE_FDK_BITSTREAM hBs, const SamplingRateInfo *pSamplingRateInfo);
CIcsInfo *pIcsInfo,
const SamplingRateInfo *pSamplingRateInfo
);
AAC_DECODER_ERROR IcsRead( AAC_DECODER_ERROR IcsRead(HANDLE_FDK_BITSTREAM bs, CIcsInfo *pIcsInfo,
HANDLE_FDK_BITSTREAM bs,
CIcsInfo *pIcsInfo,
const SamplingRateInfo *SamplingRateInfoTable, const SamplingRateInfo *SamplingRateInfoTable,
const UINT flags const UINT flags);
);
/* stereo.cpp, only called from this file */ /* stereo.cpp, only called from this file */
@ -328,17 +452,21 @@ AAC_DECODER_ERROR IcsRead(
\param pScaleFactorBandOffsets pointer to scalefactor band offsets. \param pScaleFactorBandOffsets pointer to scalefactor band offsets.
\param pWindowGroupLength pointer to window group length array. \param pWindowGroupLength pointer to window group length array.
\param windowGroups number of window groups. \param windowGroups number of window groups.
\param scaleFactorBandsTransmittedL number of transmitted scalefactor bands in left channel. \param scaleFactorBandsTransmittedL number of transmitted scalefactor bands in
\param scaleFactorBandsTransmittedR number of transmitted scalefactor bands in right channel. left channel. \param scaleFactorBandsTransmittedR number of transmitted
May differ from scaleFactorBandsTransmittedL only for USAC. scalefactor bands in right channel. May differ from
\return none scaleFactorBandsTransmittedL only for USAC. \return none
*/ */
void CJointStereo_ApplyMS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2], void CJointStereo_ApplyMS(
const short *pScaleFactorBandOffsets, CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
const UCHAR *pWindowGroupLength, CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[2],
const int windowGroups, FIXP_DBL *spectrumL, FIXP_DBL *spectrumR, SHORT *SFBleftScale,
SHORT *SFBrightScale, SHORT *specScaleL, SHORT *specScaleR,
const SHORT *pScaleFactorBandOffsets, const UCHAR *pWindowGroupLength,
const int windowGroups, const int max_sfb_ste_outside,
const int scaleFactorBandsTransmittedL, const int scaleFactorBandsTransmittedL,
const int scaleFactorBandsTransmittedR); const int scaleFactorBandsTransmittedR, FIXP_DBL *store_dmx_re_prev,
SHORT *store_dmx_re_prev_e, const int mainband_flag);
/*! /*!
\brief Applies intensity stereo \brief Applies intensity stereo
@ -360,91 +488,79 @@ void CJointStereo_ApplyIS(CAacDecoderChannelInfo *pAacDecoderChannelInfo[2],
const int scaleFactorBandsTransmitted, const int scaleFactorBandsTransmitted,
const UINT CommonWindow); const UINT CommonWindow);
/* aacdec_pns.cpp */ /* aacdec_pns.cpp */
int CPns_IsPnsUsed (const CPnsData *pPnsData, int CPns_IsPnsUsed(const CPnsData *pPnsData, const int group, const int band);
const int group,
const int band);
void CPns_SetCorrelation(CPnsData *pPnsData, void CPns_SetCorrelation(CPnsData *pPnsData, const int group, const int band,
const int group,
const int band,
const int outofphase); const int outofphase);
/****************** inline functions ******************/ /****************** inline functions ******************/
inline UCHAR IsValid(const CIcsInfo *pIcsInfo) inline UCHAR IsValid(const CIcsInfo *pIcsInfo) { return pIcsInfo->Valid; }
{
return pIcsInfo->Valid; inline UCHAR IsLongBlock(const CIcsInfo *pIcsInfo) {
return (pIcsInfo->WindowSequence != BLOCK_SHORT);
} }
inline UCHAR IsLongBlock(const CIcsInfo *pIcsInfo) inline UCHAR GetWindowShape(const CIcsInfo *pIcsInfo) {
{
return (pIcsInfo->WindowSequence != EightShortSequence);
}
inline UCHAR GetWindowShape(const CIcsInfo *pIcsInfo)
{
return pIcsInfo->WindowShape; return pIcsInfo->WindowShape;
} }
inline UCHAR GetWindowSequence(const CIcsInfo *pIcsInfo) inline BLOCK_TYPE GetWindowSequence(const CIcsInfo *pIcsInfo) {
{
return pIcsInfo->WindowSequence; return pIcsInfo->WindowSequence;
} }
inline const SHORT *GetScaleFactorBandOffsets(const CIcsInfo *pIcsInfo, const SamplingRateInfo* samplingRateInfo) inline const SHORT *GetScaleFactorBandOffsets(
{ const CIcsInfo *pIcsInfo, const SamplingRateInfo *samplingRateInfo) {
if (IsLongBlock(pIcsInfo)) if (IsLongBlock(pIcsInfo)) {
{
return samplingRateInfo->ScaleFactorBands_Long; return samplingRateInfo->ScaleFactorBands_Long;
} } else {
else
{
return samplingRateInfo->ScaleFactorBands_Short; return samplingRateInfo->ScaleFactorBands_Short;
} }
} }
inline int GetWindowsPerFrame(const CIcsInfo *pIcsInfo) inline UCHAR GetNumberOfScaleFactorBands(
{ const CIcsInfo *pIcsInfo, const SamplingRateInfo *samplingRateInfo) {
return (pIcsInfo->WindowSequence == EightShortSequence) ? 8 : 1; if (IsLongBlock(pIcsInfo)) {
return samplingRateInfo->NumberOfScaleFactorBands_Long;
} else {
return samplingRateInfo->NumberOfScaleFactorBands_Short;
}
} }
inline UCHAR GetWindowGroups(const CIcsInfo *pIcsInfo) inline int GetWindowsPerFrame(const CIcsInfo *pIcsInfo) {
{ return (pIcsInfo->WindowSequence == BLOCK_SHORT) ? 8 : 1;
}
inline UCHAR GetWindowGroups(const CIcsInfo *pIcsInfo) {
return pIcsInfo->WindowGroups; return pIcsInfo->WindowGroups;
} }
inline UCHAR GetWindowGroupLength(const CIcsInfo *pIcsInfo, const INT index) inline UCHAR GetWindowGroupLength(const CIcsInfo *pIcsInfo, const INT index) {
{
return pIcsInfo->WindowGroupLength[index]; return pIcsInfo->WindowGroupLength[index];
} }
inline const UCHAR *GetWindowGroupLengthTable(const CIcsInfo *pIcsInfo) inline const UCHAR *GetWindowGroupLengthTable(const CIcsInfo *pIcsInfo) {
{
return pIcsInfo->WindowGroupLength; return pIcsInfo->WindowGroupLength;
} }
inline UCHAR GetScaleFactorBandsTransmitted(const CIcsInfo *pIcsInfo) inline UCHAR GetScaleFactorBandsTransmitted(const CIcsInfo *pIcsInfo) {
{
return pIcsInfo->MaxSfBands; return pIcsInfo->MaxSfBands;
} }
inline UCHAR GetScaleMaxFactorBandsTransmitted(const CIcsInfo *pIcsInfo0, const CIcsInfo *pIcsInfo1) inline UCHAR GetScaleMaxFactorBandsTransmitted(const CIcsInfo *pIcsInfo0,
{ const CIcsInfo *pIcsInfo1) {
return fMax(pIcsInfo0->MaxSfBands, pIcsInfo1->MaxSfBands); return fMax(pIcsInfo0->MaxSfBands, pIcsInfo1->MaxSfBands);
} }
inline UCHAR GetScaleFactorBandsTotal(const CIcsInfo *pIcsInfo) inline UCHAR GetScaleFactorBandsTotal(const CIcsInfo *pIcsInfo) {
{
return pIcsInfo->TotalSfBands; return pIcsInfo->TotalSfBands;
} }
/* Note: This function applies to AAC-LC only ! */ /* Note: This function applies to AAC-LC only ! */
inline UCHAR GetMaximumTnsBands(const CIcsInfo *pIcsInfo, const int samplingRateIndex) inline UCHAR GetMaximumTnsBands(const CIcsInfo *pIcsInfo,
{ const int samplingRateIndex) {
return tns_max_bands_tbl[samplingRateIndex][!IsLongBlock(pIcsInfo)]; return tns_max_bands_tbl[samplingRateIndex][!IsLongBlock(pIcsInfo)];
} }
#endif /* #ifndef CHANNELINFO_H */ #endif /* #ifndef CHANNELINFO_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,19 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: independent channel concealment Description: independent channel concealment
******************************************************************************/ *******************************************************************************/
#ifndef _CONCEAL_H_ #ifndef CONCEAL_H
#define _CONCEAL_H_ #define CONCEAL_H
#include "aacdecoder_lib.h"
#include "channelinfo.h" #include "channelinfo.h"
@ -101,48 +111,42 @@ void CConcealment_InitCommonData (CConcealParams *pConcealCommonData);
void CConcealment_InitChannelData(CConcealmentInfo *hConcealmentInfo, void CConcealment_InitChannelData(CConcealmentInfo *hConcealmentInfo,
CConcealParams *pConcealCommonData, CConcealParams *pConcealCommonData,
AACDEC_RENDER_MODE initRenderMode,
int samplesPerFrame); int samplesPerFrame);
CConcealmentMethod CConcealmentMethod CConcealment_GetMethod(CConcealParams *pConcealCommonData);
CConcealment_GetMethod (CConcealParams *pConcealCommonData);
UINT UINT CConcealment_GetDelay(CConcealParams *pConcealCommonData);
CConcealment_GetDelay (CConcealParams *pConcealCommonData);
AAC_DECODER_ERROR AAC_DECODER_ERROR
CConcealment_SetParams (CConcealParams *concealParams, CConcealment_SetParams(CConcealParams *concealParams, int method,
int method, int fadeOutSlope, int fadeInSlope, int muteRelease,
int fadeOutSlope, FIXP_DBL comfNoiseLevel);
int fadeInSlope,
int muteRelease,
int comfNoiseLevel);
CConcealmentState CConcealmentState CConcealment_GetState(CConcealmentInfo *hConcealmentInfo);
CConcealment_GetState (CConcealmentInfo *hConcealmentInfo);
AAC_DECODER_ERROR AAC_DECODER_ERROR
CConcealment_SetAttenuation(CConcealParams *concealParams, CConcealment_SetAttenuation(CConcealParams *concealParams,
SHORT *fadeOutAttenuationVector, const SHORT *fadeOutAttenuationVector,
SHORT *fadeInAttenuationVector); const SHORT *fadeInAttenuationVector);
void CConcealment_Store (CConcealmentInfo *hConcealmentInfo, void CConcealment_Store(
CConcealmentInfo *hConcealmentInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo); CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
int CConcealment_Apply (CConcealmentInfo *hConcealmentInfo, int CConcealment_Apply(
CConcealmentInfo *hConcealmentInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo, CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, const SamplingRateInfo *pSamplingRateInfo, const int samplesPerFrame,
const int samplesPerFrame, const UCHAR lastLpdMode, const int FrameOk, const UINT flags);
const UCHAR lastLpdMode,
const int FrameOk,
const UINT flags);
FIXP_DBL
CConcealment_GetFadeFactor (CConcealmentInfo *hConcealmentInfo,
const int fPreviousFactor);
int CConcealment_GetLastFrameOk(CConcealmentInfo *hConcealmentInfo, int CConcealment_GetLastFrameOk(CConcealmentInfo *hConcealmentInfo,
const int fBeforeApply); const int fBeforeApply);
#endif /* #ifndef _CONCEAL_H_ */ INT CConcealment_TDFading(
int len, CAacDecoderStaticChannelInfo **ppAacDecoderStaticChannelInfo,
FIXP_PCM *pcmdata, FIXP_PCM *pcmdata_1);
#endif /* #ifndef CONCEAL_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,27 +90,27 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Christian Griebel Author(s): Christian Griebel
Description: Error concealment structs and types Description: Error concealment structs and types
******************************************************************************/ *******************************************************************************/
#ifndef CONCEAL_TYPES_H #ifndef CONCEAL_TYPES_H
#define CONCEAL_TYPES_H #define CONCEAL_TYPES_H
#include "machine_type.h" #include "machine_type.h"
#include "common_fix.h" #include "common_fix.h"
#include "rvlc_info.h" #include "rvlc_info.h"
#include "usacdec_lpc.h"
#define CONCEAL_MAX_NUM_FADE_FACTORS ( 16 ) #define CONCEAL_MAX_NUM_FADE_FACTORS (32)
#define FIXP_CNCL FIXP_DBL #define FIXP_CNCL FIXP_DBL
#define FL2FXCONST_CNCL FL2FXCONST_DBL #define FL2FXCONST_CNCL FL2FXCONST_DBL
@ -108,8 +119,7 @@ amm-info@iis.fraunhofer.de
#define CNCL_FRACT_BITS DFRACT_BITS #define CNCL_FRACT_BITS DFRACT_BITS
/* Warning: Do not ever change these values. */ /* Warning: Do not ever change these values. */
typedef enum typedef enum {
{
ConcealMethodNone = -1, ConcealMethodNone = -1,
ConcealMethodMute = 0, ConcealMethodMute = 0,
ConcealMethodNoise = 1, ConcealMethodNoise = 1,
@ -118,9 +128,7 @@ typedef enum
} CConcealmentMethod; } CConcealmentMethod;
typedef enum {
typedef enum
{
ConcealState_Ok, ConcealState_Ok,
ConcealState_Single, ConcealState_Single,
ConcealState_FadeIn, ConcealState_FadeIn,
@ -129,9 +137,7 @@ typedef enum
} CConcealmentState; } CConcealmentState;
typedef struct {
typedef struct
{
FIXP_SGL fadeOutFactor[CONCEAL_MAX_NUM_FADE_FACTORS]; FIXP_SGL fadeOutFactor[CONCEAL_MAX_NUM_FADE_FACTORS];
FIXP_SGL fadeInFactor[CONCEAL_MAX_NUM_FADE_FACTORS]; FIXP_SGL fadeInFactor[CONCEAL_MAX_NUM_FADE_FACTORS];
@ -140,14 +146,17 @@ typedef struct
int numFadeOutFrames; int numFadeOutFrames;
int numFadeInFrames; int numFadeInFrames;
int numMuteReleaseFrames; int numMuteReleaseFrames;
int comfortNoiseLevel; FIXP_DBL comfortNoiseLevel;
} CConcealParams; } CConcealParams;
typedef enum {
FADE_TIMEDOMAIN_TOSPECTRALMUTE = 1,
FADE_TIMEDOMAIN_FROMSPECTRALMUTE,
FADE_TIMEDOMAIN
} TDfadingType;
typedef struct {
typedef struct
{
CConcealParams *pConcealParams; CConcealParams *pConcealParams;
FIXP_CNCL spectralCoefficient[1024]; FIXP_CNCL spectralCoefficient[1024];
@ -155,24 +164,40 @@ typedef struct
INT iRandomPhase; INT iRandomPhase;
INT prevFrameOk[2]; INT prevFrameOk[2];
INT cntFadeFrames;
INT cntValidFrames; INT cntValidFrames;
INT cntFadeFrames; /* State for signal fade-in/out */
/* States for signal fade-out of frames with more than one window/subframe -
[0] used by Update CntFadeFrames mode of CConcealment_ApplyFadeOut, [1] used
by FadeOut mode */
int winGrpOffset[2]; /* State for signal fade-out of frames with more than one
window/subframe */
int attGrpOffset[2]; /* State for faster signal fade-out of frames with
transient signal parts */
SCHAR lastRenderMode;
UCHAR windowShape;
BLOCK_TYPE windowSequence;
UCHAR lastWinGrpLen;
CConcealmentState concealState;
CConcealmentState concealState_old;
FIXP_DBL fade_old; /* last fading factor */
TDfadingType lastFadingType; /* last fading type */
SHORT aRvlcPreviousScaleFactor[RVLC_MAX_SFB]; /* needed once per channel */ SHORT aRvlcPreviousScaleFactor[RVLC_MAX_SFB]; /* needed once per channel */
UCHAR aRvlcPreviousCodebook[RVLC_MAX_SFB]; /* needed once per channel */ UCHAR aRvlcPreviousCodebook[RVLC_MAX_SFB]; /* needed once per channel */
SCHAR rvlcPreviousScaleFactorOK; SCHAR rvlcPreviousScaleFactorOK;
SCHAR rvlcPreviousBlockType; SCHAR rvlcPreviousBlockType;
FIXP_LPC lsf4[M_LP_FILTER_ORDER];
SCHAR lastRenderMode; FIXP_DBL last_tcx_gain;
INT last_tcx_gain_e;
UCHAR windowShape; ULONG TDNoiseSeed;
UCHAR windowSequence; FIXP_PCM TDNoiseStates[3];
UCHAR lastWinGrpLen; FIXP_SGL TDNoiseCoef[3];
FIXP_SGL TDNoiseAtt;
CConcealmentState concealState;
} CConcealmentInfo; } CConcealmentInfo;
#endif /* #ifndef CONCEAL_TYPES_H */ #endif /* #ifndef CONCEAL_TYPES_H */

View File

@ -1,97 +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): Josef Hoepfl
Description: debug output
******************************************************************************/
#ifndef DEBUG_H
#define DEBUG_H
#include "machine_type.h"
#endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,19 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************************************************************\ /**************************** AAC decoder library ******************************
*
* filename: ldfiltbank.c Author(s):
* project : MPEG-4 Audio Decoder
* contents/description: low delay filterbank Description: low delay filterbank
*
\***************************************************************************/ *******************************************************************************/
#include "ldfiltbank.h" #include "ldfiltbank.h"
#include "aac_rom.h" #include "aac_rom.h"
#include "dct.h" #include "dct.h"
#include "FDK_tools_rom.h" #include "FDK_tools_rom.h"
@ -99,110 +109,166 @@ amm-info@iis.fraunhofer.de
#define LDFB_HEADROOM 2 #define LDFB_HEADROOM 2
static void multE2_DinvF_fdk(INT_PCM *output, FIXP_DBL* x, const FIXP_WTB* fb, FIXP_DBL* z, const int N, const int stride) #if defined(__arm__)
{ #endif
int i, scale;
static void multE2_DinvF_fdk(FIXP_PCM *output, FIXP_DBL *x, const FIXP_WTB *fb,
FIXP_DBL *z, const int N) {
int i;
/* scale for FIXP_DBL -> INT_PCM conversion. */ /* scale for FIXP_DBL -> INT_PCM conversion. */
scale = (DFRACT_BITS - SAMPLE_BITS) - LDFB_HEADROOM; const int scale = (DFRACT_BITS - SAMPLE_BITS) - LDFB_HEADROOM;
#if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FIXP_DBL rnd_val_wts0 = (FIXP_DBL)0;
FIXP_DBL rnd_val_wts1 = (FIXP_DBL)0;
if (-WTS0 - 1 + scale)
rnd_val_wts0 = (FIXP_DBL)(1 << (-WTS0 - 1 + scale - 1));
if (-WTS1 - 1 + scale)
rnd_val_wts1 = (FIXP_DBL)(1 << (-WTS1 - 1 + scale - 1));
#endif
for(i=0;i<N/4;i++) for (i = 0; i < N / 4; i++) {
{
FIXP_DBL z0, z2, tmp; FIXP_DBL z0, z2, tmp;
z2 = x[N / 2 + i]; z2 = x[N / 2 + i];
z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1)); z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
z[N/2+i] = x[N/2-1-i] + ( fMultDiv2(z[N + i], fb[2*N + N/2 + i]) >> (-WTS2-1) ); z[N / 2 + i] = x[N / 2 - 1 - i] +
(fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
tmp = ( fMultDiv2(z[N/2+i], fb[N+N/2-1-i]) + fMultDiv2(z[i], fb[N+N/2+i]) ) ; tmp = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N + N / 2 + i]));
#if (SAMPLE_BITS <= 16) #if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FDK_ASSERT((-WTS1 - 1 + scale) >= 0); FDK_ASSERT((-WTS1 - 1 + scale) >= 0);
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp, -WTS1-1 + scale, SAMPLE_BITS); FDK_ASSERT(tmp <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts1)); /* rounding must not cause overflow */
output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
#else #else
FDK_ASSERT((WTS1 + 1 - scale) >= 0); FDK_ASSERT((WTS1 + 1 - scale) >= 0);
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp, WTS1+1 - scale, SAMPLE_BITS); output[(N * 3 / 4 - 1 - i)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp, WTS1 + 1 - scale, PCM_OUT_BITS);
#endif #endif
z[i] = z0; z[i] = z0;
z[N + i] = z2; z[N + i] = z2;
} }
for(i=N/4;i<N/2;i++) for (i = N / 4; i < N / 2; i++) {
{
FIXP_DBL z0, z2, tmp0, tmp1; FIXP_DBL z0, z2, tmp0, tmp1;
z2 = x[N / 2 + i]; z2 = x[N / 2 + i];
z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1)); z0 = z2 + (fMultDiv2(z[N / 2 + i], fb[2 * N + i]) >> (-WTS2 - 1));
z[N/2+i] = x[N/2-1-i] + ( fMultDiv2(z[N + i], fb[2*N + N/2 + i]) >> (-WTS2-1) ); z[N / 2 + i] = x[N / 2 - 1 - i] +
(fMultDiv2(z[N + i], fb[2 * N + N / 2 + i]) >> (-WTS2 - 1));
tmp0 = ( fMultDiv2(z[N/2+i], fb[N/2-1-i]) + fMultDiv2(z[i], fb[N/2+i]) ) ; tmp0 = (fMultDiv2(z[N / 2 + i], fb[N / 2 - 1 - i]) +
tmp1 = ( fMultDiv2(z[N/2+i], fb[N+N/2-1-i]) + fMultDiv2(z[i], fb[N+N/2+i]) ) ; fMultDiv2(z[i], fb[N / 2 + i]));
tmp1 = (fMultDiv2(z[N / 2 + i], fb[N + N / 2 - 1 - i]) +
fMultDiv2(z[i], fb[N + N / 2 + i]));
#if (SAMPLE_BITS <= 16) #if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FDK_ASSERT((-WTS0 - 1 + scale) >= 0); FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
output[(i-N/4)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp0, -WTS0-1 + scale, SAMPLE_BITS); FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp1, -WTS1-1 + scale, SAMPLE_BITS); rnd_val_wts0)); /* rounding must not cause overflow */
FDK_ASSERT(tmp1 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts1)); /* rounding must not cause overflow */
output[(i - N / 4)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
output[(N * 3 / 4 - 1 - i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp1 + rnd_val_wts1, -WTS1 - 1 + scale, PCM_OUT_BITS);
#else #else
FDK_ASSERT((WTS0 + 1 - scale) >= 0); FDK_ASSERT((WTS0 + 1 - scale) >= 0);
output[(i-N/4)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0+1 - scale, SAMPLE_BITS); output[(i - N / 4)] =
output[(N*3/4-1-i)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp1, WTS1+1 - scale, SAMPLE_BITS); (FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
output[(N * 3 / 4 - 1 - i)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp1, WTS1 + 1 - scale, PCM_OUT_BITS);
#endif #endif
z[i] = z0; z[i] = z0;
z[N + i] = z2; z[N + i] = z2;
} }
/* Exchange quarter parts of x to bring them in the "right" order */ /* Exchange quarter parts of x to bring them in the "right" order */
for(i=0;i<N/4;i++) for (i = 0; i < N / 4; i++) {
{
FIXP_DBL tmp0 = fMultDiv2(z[i], fb[N / 2 + i]); FIXP_DBL tmp0 = fMultDiv2(z[i], fb[N / 2 + i]);
#if (SAMPLE_BITS <= 16) #if ((DFRACT_BITS - SAMPLE_BITS - LDFB_HEADROOM) > 0)
FDK_ASSERT((-WTS0 - 1 + scale) >= 0); FDK_ASSERT((-WTS0 - 1 + scale) >= 0);
output[(N*3/4 + i)*stride] = (INT_PCM)SATURATE_RIGHT_SHIFT(tmp0, -WTS0-1 + scale, SAMPLE_BITS); FDK_ASSERT(tmp0 <= ((FIXP_DBL)0x7FFFFFFF -
rnd_val_wts0)); /* rounding must not cause overflow */
output[(N * 3 / 4 + i)] = (FIXP_PCM)SATURATE_RIGHT_SHIFT(
tmp0 + rnd_val_wts0, -WTS0 - 1 + scale, PCM_OUT_BITS);
#else #else
FDK_ASSERT((WTS0 + 1 - scale) >= 0); FDK_ASSERT((WTS0 + 1 - scale) >= 0);
output[(N*3/4 + i)*stride] = (INT_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0+1 - scale, SAMPLE_BITS); output[(N * 3 / 4 + i)] =
(FIXP_PCM)SATURATE_LEFT_SHIFT(tmp0, WTS0 + 1 - scale, PCM_OUT_BITS);
#endif #endif
} }
} }
int InvMdctTransformLowDelay_fdk (FIXP_DBL *mdctData, const int mdctData_e, INT_PCM *output, FIXP_DBL *fs_buffer, const int stride, const int N) { int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctData, const int mdctData_e,
FIXP_PCM *output, FIXP_DBL *fs_buffer,
const int N) {
const FIXP_WTB *coef; const FIXP_WTB *coef;
FIXP_DBL gain = (FIXP_DBL)0; FIXP_DBL gain = (FIXP_DBL)0;
int scale = mdctData_e + MDCT_OUT_HEADROOM - LDFB_HEADROOM; /* The LDFB_HEADROOM is compensated inside multE2_DinvF_fdk() below */ int scale = mdctData_e + MDCT_OUT_HEADROOM -
LDFB_HEADROOM; /* The LDFB_HEADROOM is compensated inside
multE2_DinvF_fdk() below */
/* Select LD window slope */ /* Select LD window slope */
if (N == 512) switch (N) {
coef = (FIXP_WTB*)LowDelaySynthesis512; case 256:
else coef = LowDelaySynthesis256;
coef = (FIXP_WTB*)LowDelaySynthesis480; break;
case 240:
coef = LowDelaySynthesis240;
break;
case 160:
coef = LowDelaySynthesis160;
break;
case 128:
coef = LowDelaySynthesis128;
break;
case 120:
coef = LowDelaySynthesis120;
break;
case 512:
coef = LowDelaySynthesis512;
break;
case 480:
default:
coef = LowDelaySynthesis480;
break;
}
/* /*
Apply exponent and 1/N factor. Apply exponent and 1/N factor.
Note: "scale" is off by one because for LD_MDCT the window length is twice Note: "scale" is off by one because for LD_MDCT the window length is twice
the window length of a regular MDCT. This is corrected inside multE2_DinvF_fdk(). the window length of a regular MDCT. This is corrected inside
Refer to ISO/IEC 14496-3:2009 page 277, chapter 4.6.20.2 "Low Delay Window". multE2_DinvF_fdk(). Refer to ISO/IEC 14496-3:2009 page 277,
chapter 4.6.20.2 "Low Delay Window".
*/ */
imdct_gain(&gain, &scale, N); imdct_gain(&gain, &scale, N);
dct_IV(mdctData, N, &scale); dct_IV(mdctData, N, &scale);
if (N == 256 || N == 240 || N == 160) {
scale -= 1;
} else if (N == 128 || N == 120) {
scale -= 2;
}
if (gain != (FIXP_DBL)0) { if (gain != (FIXP_DBL)0) {
scaleValuesWithFactor(mdctData, gain, N, scale); scaleValuesWithFactor(mdctData, gain, N, scale);
} else { } else {
scaleValues(mdctData, N, scale); scaleValues(mdctData, N, scale);
} }
/* Since all exponent and factors have been applied, current exponent is zero. */ /* Since all exponent and factors have been applied, current exponent is zero.
multE2_DinvF_fdk(output, mdctData, coef, fs_buffer, N, stride); */
multE2_DinvF_fdk(output, mdctData, coef, fs_buffer, N);
return (1); return (1);
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,31 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************************************************************\ /**************************** AAC decoder library ******************************
*
* filename: ldfiltbank.h Author(s):
* project : MPEG-4 Audio Decoder
* contents/description: low delay filterbank interface
*
\***************************************************************************/
#ifndef _LDFILTBANK_H Description: low delay filterbank interface
#define _LDFILTBANK_H
*******************************************************************************/
#ifndef LDFILTBANK_H
#define LDFILTBANK_H
#include "common_fix.h" #include "common_fix.h"
int InvMdctTransformLowDelay_fdk(FIXP_DBL *mdctdata_m, const int mdctdata_e,
int InvMdctTransformLowDelay_fdk ( FIXP_PCM *mdctOut, FIXP_DBL *fs_buffer,
FIXP_DBL *mdctdata_m, const int frameLength);
const int mdctdata_e,
INT_PCM *mdctOut,
FIXP_DBL *fs_buffer,
const int stride,
const int frameLength
);
#endif #endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,21 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: Description:
******************************************************************************/ *******************************************************************************/
#ifndef OVERLAPADD_H #ifndef OVERLAPADD_H
#define OVERLAPADD_H #define OVERLAPADD_H
#include "common_fix.h" #include "common_fix.h"
#define OverlapBufferSize (1024*2) /* ELD uses different overlap which is twice the frame size: */
#define OverlapBufferSize (768)
typedef FIXP_DBL SPECTRUM[1024]; typedef FIXP_DBL SPECTRUM[1024];
typedef FIXP_DBL* SPECTRAL_PTR; typedef FIXP_DBL* SPECTRAL_PTR;
@ -101,5 +114,7 @@ typedef FIXP_DBL * SPECTRAL_PTR;
#define SPEC_LONG(ptr) (ptr) #define SPEC_LONG(ptr) (ptr)
#define SPEC(ptr, w, gl) ((ptr) + ((w) * (gl))) #define SPEC(ptr, w, gl) ((ptr) + ((w) * (gl)))
#define SPEC_TCX(ptr, f, gl, fb) \
((ptr) + ((f) * (gl * 2) * (((fb) == 0) ? 1 : 2)))
#endif /* #ifndef OVERLAPADD_H */ #endif /* #ifndef OVERLAPADD_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,37 +90,32 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: pulse data tool Description: pulse data tool
******************************************************************************/ *******************************************************************************/
#include "pulsedata.h" #include "pulsedata.h"
#include "channelinfo.h" #include "channelinfo.h"
INT CPulseData_Read(HANDLE_FDK_BITSTREAM bs, CPulseData *const PulseData,
INT CPulseData_Read( const SHORT *sfb_startlines, const void *pIcsInfo,
HANDLE_FDK_BITSTREAM bs, const SHORT frame_length) {
CPulseData *const PulseData,
const SHORT *sfb_startlines,
const void *pIcsInfo,
const SHORT frame_length
)
{
int i, k = 0; int i, k = 0;
const UINT MaxSfBands = GetScaleFactorBandsTransmitted((CIcsInfo*)pIcsInfo); const UINT MaxSfBands =
GetScaleFactorBandsTransmitted((const CIcsInfo *)pIcsInfo);
/* reset pulse data flag */ /* reset pulse data flag */
PulseData->PulseDataPresent = 0; PulseData->PulseDataPresent = 0;
if ((PulseData->PulseDataPresent = (UCHAR)FDKreadBit(bs)) != 0) { if ((PulseData->PulseDataPresent = (UCHAR)FDKreadBit(bs)) != 0) {
if (!IsLongBlock((CIcsInfo*)pIcsInfo)) { if (!IsLongBlock((const CIcsInfo *)pIcsInfo)) {
return AAC_DEC_DECODE_FRAME_ERROR; return AAC_DEC_DECODE_FRAME_ERROR;
} }
@ -133,26 +139,26 @@ INT CPulseData_Read(
} }
} }
return 0; return 0;
} }
void CPulseData_Apply(CPulseData *PulseData, /*!< pointer to pulse data side info */ void CPulseData_Apply(
const short *pScaleFactorBandOffsets, /*!< pointer to scalefactor band offsets */ CPulseData *PulseData, /*!< pointer to pulse data side info */
const short
*pScaleFactorBandOffsets, /*!< pointer to scalefactor band offsets */
FIXP_DBL *coef) /*!< pointer to spectrum */ FIXP_DBL *coef) /*!< pointer to spectrum */
{ {
int i, k; int i, k;
if (PulseData->PulseDataPresent) if (PulseData->PulseDataPresent) {
{
k = pScaleFactorBandOffsets[PulseData->PulseStartBand]; k = pScaleFactorBandOffsets[PulseData->PulseStartBand];
for (i=0; i<=PulseData->NumberPulse; i++) for (i = 0; i <= PulseData->NumberPulse; i++) {
{
k += PulseData->PulseOffset[i]; k += PulseData->PulseOffset[i];
if (coef [k] > (FIXP_DBL)0) coef[k] += (FIXP_DBL)(int)PulseData->PulseAmp[i]; if (coef[k] > (FIXP_DBL)0)
else coef[k] -= (FIXP_DBL)(int)PulseData->PulseAmp[i]; coef[k] += (FIXP_DBL)(int)PulseData->PulseAmp[i];
else
coef[k] -= (FIXP_DBL)(int)PulseData->PulseAmp[i];
} }
} }
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,27 +90,25 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: pulse data tool Description: pulse data tool
******************************************************************************/ *******************************************************************************/
#ifndef PULSEDATA_H #ifndef PULSEDATA_H
#define PULSEDATA_H #define PULSEDATA_H
#include "common_fix.h" #include "common_fix.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
#define N_MAX_LINES 4 #define N_MAX_LINES 4
typedef struct typedef struct {
{
UCHAR PulseDataPresent; UCHAR PulseDataPresent;
UCHAR NumberPulse; UCHAR NumberPulse;
UCHAR PulseStartBand; UCHAR PulseStartBand;
@ -114,17 +123,14 @@ typedef struct
* the bitstream. * the bitstream.
* *
* \param bs bit stream handle data source. * \param bs bit stream handle data source.
* \param PulseData pointer to a CPulseData were the decoded data is stored into. * \param PulseData pointer to a CPulseData were the decoded data is stored
* into.
* \param MaxSfBands max number of scale factor bands. * \param MaxSfBands max number of scale factor bands.
* \return 0 on success, != 0 on parse error. * \return 0 on success, != 0 on parse error.
*/ */
INT CPulseData_Read( INT CPulseData_Read(const HANDLE_FDK_BITSTREAM bs, CPulseData *const PulseData,
const HANDLE_FDK_BITSTREAM bs, const SHORT *sfb_startlines, const void *pIcsInfo,
CPulseData *const PulseData, const SHORT frame_length);
const SHORT *sfb_startlines,
const void *pIcsInfo,
const SHORT frame_length
);
/** /**
* \brief Apply pulse data to spectral lines * \brief Apply pulse data to spectral lines
@ -134,12 +140,11 @@ INT CPulseData_Read(
* *
* \param PulseData pointer to the previously decoded pulse data. * \param PulseData pointer to the previously decoded pulse data.
* \param pScaleFactorBandOffsets scale factor band line offset table. * \param pScaleFactorBandOffsets scale factor band line offset table.
* \param coef pointer to the spectral data were pulse data should be applied to. * \param coef pointer to the spectral data were pulse data should be applied
* to.
* \return none * \return none
*/ */
void CPulseData_Apply(CPulseData *PulseData, void CPulseData_Apply(CPulseData *PulseData,
const short *pScaleFactorBandOffsets, const short *pScaleFactorBandOffsets, FIXP_DBL *coef);
FIXP_DBL *coef);
#endif /* #ifndef PULSEDATA_H */ #endif /* #ifndef PULSEDATA_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*! /*!
\file \file
@ -90,8 +109,6 @@ amm-info@iis.fraunhofer.de
#ifndef RVLC_H #ifndef RVLC_H
#define RVLC_H #define RVLC_H
#include "aacdecoder.h" #include "aacdecoder.h"
#include "channel.h" #include "channel.h"
#include "rvlc_info.h" #include "rvlc_info.h"
@ -100,13 +117,19 @@ amm-info@iis.fraunhofer.de
/* errorLogRvlc: A word of 32 bits used for logging possible errors */ /* errorLogRvlc: A word of 32 bits used for logging possible errors */
/* within RVLC in case of distorted bitstreams. */ /* within RVLC in case of distorted bitstreams. */
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
#define RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID 0x80000000 /* ESC-Dec During RVLC-Escape-decoding there have been more bits decoded as there are available */ #define RVLC_ERROR_ALL_ESCAPE_WORDS_INVALID \
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_FWD 0x40000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding (long+shrt) */ 0x80000000 /* ESC-Dec During RVLC-Escape-decoding there have been more \
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_BWD 0x20000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding (long+shrt) */ bits decoded as there are available */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD 0x08000000 /* RVL-Dec forbidden codeword detected fwd (long+shrt) */ #define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_FWD \
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD 0x04000000 /* RVL-Dec forbidden codeword detected bwd (long+shrt) */ 0x40000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding \
(long+shrt) */
#define RVLC_ERROR_RVL_SUM_BIT_COUNTER_BELOW_ZERO_BWD \
0x20000000 /* RVL-Dec negative sum-bitcounter during RVL-fwd-decoding \
(long+shrt) */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_FWD \
0x08000000 /* RVL-Dec forbidden codeword detected fwd (long+shrt) */
#define RVLC_ERROR_FORBIDDEN_CW_DETECTED_BWD \
0x04000000 /* RVL-Dec forbidden codeword detected bwd (long+shrt) */
void CRvlc_Read(CAacDecoderChannelInfo *pAacDecoderChannelInfo, void CRvlc_Read(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
HANDLE_FDK_BITSTREAM bs); HANDLE_FDK_BITSTREAM bs);
@ -116,7 +139,8 @@ void CRvlc_Decode (CAacDecoderChannelInfo *pAacDecoderChannelInfo,
HANDLE_FDK_BITSTREAM bs); HANDLE_FDK_BITSTREAM bs);
/** /**
* \brief performe sanity checks to the channel data corresponding to one channel element. * \brief performe sanity checks to the channel data corresponding to one
* channel element.
* \param pAacDecoderChannelInfo * \param pAacDecoderChannelInfo
* \param pAacDecoderStaticChannelInfo * \param pAacDecoderStaticChannelInfo
* \param elChannels amount of channels of the channel element. * \param elChannels amount of channels of the channel element.
@ -124,11 +148,6 @@ void CRvlc_Decode (CAacDecoderChannelInfo *pAacDecoderChannelInfo,
void CRvlc_ElementCheck( void CRvlc_ElementCheck(
CAacDecoderChannelInfo *pAacDecoderChannelInfo[], CAacDecoderChannelInfo *pAacDecoderChannelInfo[],
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[], CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo[],
const UINT flags, const UINT flags, const INT elChannels);
const INT elChannels
);
#endif /* RVLC_H */ #endif /* RVLC_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*! /*!
\file \file
@ -89,17 +108,20 @@ amm-info@iis.fraunhofer.de
#ifndef RVLC_INFO_H #ifndef RVLC_INFO_H
#define RVLC_INFO_H #define RVLC_INFO_H
#define FWD 0 /* bitstream decoding direction forward (RVL coded part) */ #define FWD 0 /* bitstream decoding direction forward (RVL coded part) */
#define BWD 1 /* bitstream decoding direction backward (RVL coded part) */ #define BWD 1 /* bitstream decoding direction backward (RVL coded part) */
#define MAX_RVL 7 /* positive RVLC escape */ #define MAX_RVL 7 /* positive RVLC escape */
#define MIN_RVL -7 /* negative RVLC escape */ #define MIN_RVL -7 /* negative RVLC escape */
#define MAX_ALLOWED_DPCM_INDEX 14 /* the maximum allowed index of a decoded dpcm value (offset 'TABLE_OFFSET' incl --> must be subtracted) */ #define MAX_ALLOWED_DPCM_INDEX \
#define TABLE_OFFSET 7 /* dpcm offset of valid output values of rvl table decoding, the rvl table ouly returns positive values, therefore the offset */ 14 /* the maximum allowed index of a decoded dpcm value (offset \
'TABLE_OFFSET' incl --> must be subtracted) */
#define TABLE_OFFSET \
7 /* dpcm offset of valid output values of rvl table decoding, the rvl table \
ouly returns positive values, therefore the offset */
#define MAX_LEN_RVLC_CODE_WORD 9 /* max length of a RVL codeword in bits */ #define MAX_LEN_RVLC_CODE_WORD 9 /* max length of a RVL codeword in bits */
#define MAX_LEN_RVLC_ESCAPE_WORD 20 /* max length of huffman coded RVLC escape word in bits */ #define MAX_LEN_RVLC_ESCAPE_WORD \
20 /* max length of huffman coded RVLC escape word in bits */
#define DPCM_NOISE_NRG_BITS 9 #define DPCM_NOISE_NRG_BITS 9
#define SF_OFFSET 100 /* offset for correcting scf value */ #define SF_OFFSET 100 /* offset for correcting scf value */
@ -110,12 +132,16 @@ amm-info@iis.fraunhofer.de
#define RVLC_MAX_SFB ((8) * (16)) #define RVLC_MAX_SFB ((8) * (16))
/* sideinfo of RVLC */ /* sideinfo of RVLC */
typedef struct typedef struct {
{ /* ------- ESC 1 Data: --------- */ /* order of RVLC-bitstream components in
/* ------- ESC 1 Data: --------- */ /* order of RVLC-bitstream components in bitstream (RVLC-initialization), every component appears only once in bitstream */ bitstream (RVLC-initialization), every
component appears only once in
bitstream */
INT sf_concealment; /* 1 */ INT sf_concealment; /* 1 */
INT rev_global_gain; /* 2 */ INT rev_global_gain; /* 2 */
SHORT length_of_rvlc_sf; /* 3 */ /* original value, gets modified (subtract 9) in case of noise (PNS); is kept for later use */ SHORT length_of_rvlc_sf; /* 3 */ /* original value, gets modified
(subtract 9) in case of noise
(PNS); is kept for later use */
INT dpcm_noise_nrg; /* 4 optional */ INT dpcm_noise_nrg; /* 4 optional */
INT sf_escapes_present; /* 5 */ INT sf_escapes_present; /* 5 */
SHORT length_of_rvlc_escapes; /* 6 optional */ SHORT length_of_rvlc_escapes; /* 6 optional */
@ -124,11 +150,12 @@ typedef struct
INT dpcm_is_last_position; INT dpcm_is_last_position;
SHORT length_of_rvlc_sf_fwd; /* length_of_rvlc_sf used for forward decoding */ SHORT length_of_rvlc_sf_fwd; /* length_of_rvlc_sf used for forward decoding */
SHORT length_of_rvlc_sf_bwd; /* length_of_rvlc_sf used for backward decoding */ SHORT
length_of_rvlc_sf_bwd; /* length_of_rvlc_sf used for backward decoding */
/* for RVL-Codeword decoder to distinguish between fwd and bwd decoding */ /* for RVL-Codeword decoder to distinguish between fwd and bwd decoding */
SHORT *pRvlBitCnt_RVL; SHORT *pRvlBitCnt_RVL;
USHORT *pBitstrIndxRvl_RVL; INT *pBitstrIndxRvl_RVL;
UCHAR numWindowGroups; UCHAR numWindowGroups;
UCHAR maxSfbTransmitted; UCHAR maxSfbTransmitted;
@ -137,9 +164,11 @@ typedef struct
UCHAR direction; UCHAR direction;
/* bitstream indices */ /* bitstream indices */
USHORT bitstreamIndexRvlFwd; /* base address of RVL-coded-scalefactor data (ESC 2) for forward decoding */ INT bitstreamIndexRvlFwd; /* base address of RVL-coded-scalefactor data (ESC
USHORT bitstreamIndexRvlBwd; /* base address of RVL-coded-scalefactor data (ESC 2) for backward decoding */ 2) for forward decoding */
USHORT bitstreamIndexEsc; /* base address where RVLC-escapes start (ESC 2) */ INT bitstreamIndexRvlBwd; /* base address of RVL-coded-scalefactor data (ESC
2) for backward decoding */
INT bitstreamIndexEsc; /* base address where RVLC-escapes start (ESC 2) */
/* decoding trees */ /* decoding trees */
const UINT *pHuffTreeRvlCodewds; const UINT *pHuffTreeRvlCodewds;
@ -171,6 +200,4 @@ typedef struct
typedef CErRvlcInfo RVLC_INFO; /* temp */ typedef CErRvlcInfo RVLC_INFO; /* temp */
#endif /* RVLC_INFO_H */ #endif /* RVLC_INFO_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*! /*!
\file \file
@ -89,24 +108,23 @@ amm-info@iis.fraunhofer.de
#include "rvlcbit.h" #include "rvlcbit.h"
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
function: rvlcReadBitFromBitstream function: rvlcReadBitFromBitstream
description: This function returns a bit from the bitstream according to read direction. description: This function returns a bit from the bitstream according to
It is called very often, therefore it makes sense to inline it (runtime). read direction. It is called very often, therefore it makes sense to inline it
(runtime).
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
input: - bitstream input: - bitstream
- pPosition - pPosition
- readDirection - readDirection
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - bit from bitstream return: - bit from bitstream
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
UCHAR rvlcReadBitFromBitstream (HANDLE_FDK_BITSTREAM bs, UCHAR rvlcReadBitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pPosition,
USHORT *pPosition, UCHAR readDirection) {
UCHAR readDirection)
{
UINT bit; UINT bit;
INT readBitOffset = *pPosition - FDKgetBitCnt(bs); INT readBitOffset = *pPosition - FDKgetBitCnt(bs);
@ -128,4 +146,3 @@ UCHAR rvlcReadBitFromBitstream (HANDLE_FDK_BITSTREAM bs,
return (bit); return (bit);
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,11 +90,12 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder *************************** /**************************** AAC decoder library ******************************
Author(s): Robert Weidner (DSP Solutions) Author(s): Robert Weidner (DSP Solutions)
Description: RVLC Decoder: Bitstream reading Description: RVLC Decoder: Bitstream reading
*******************************************************************************/ *******************************************************************************/
@ -91,13 +103,9 @@ amm-info@iis.fraunhofer.de
#ifndef RVLCBIT_H #ifndef RVLCBIT_H
#define RVLCBIT_H #define RVLCBIT_H
#include "rvlc.h" #include "rvlc.h"
UCHAR rvlcReadBitFromBitstream (HANDLE_FDK_BITSTREAM bs, UCHAR rvlcReadBitFromBitstream(HANDLE_FDK_BITSTREAM bs, INT *pPosition,
USHORT *pPosition,
UCHAR readDirection); UCHAR readDirection);
#endif /* RVLCBIT_H */ #endif /* RVLCBIT_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*! /*!
\file \file
@ -89,37 +108,33 @@ amm-info@iis.fraunhofer.de
#include "rvlcconceal.h" #include "rvlcconceal.h"
#include "block.h" #include "block.h"
#include "rvlc.h" #include "rvlc.h"
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
function: calcRefValFwd function: calcRefValFwd
description: The function determines the scalefactor which is closed to the scalefactorband description: The function determines the scalefactor which is closed to the
conceal_min. The same is done for intensity data and noise energies. scalefactorband conceal_min. The same is done for intensity data and noise
energies.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
output: - reference value scf output: - reference value scf
- reference value internsity data - reference value internsity data
- reference value noise energy - reference value noise energy
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - return: -
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
static static void calcRefValFwd(CErRvlcInfo *pRvlc,
void calcRefValFwd (CErRvlcInfo *pRvlc,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
int *refIsFwd, int *refIsFwd, int *refNrgFwd, int *refScfFwd) {
int *refNrgFwd,
int *refScfFwd)
{
int band, bnds, group, startBand; int band, bnds, group, startBand;
int idIs, idNrg, idScf; int idIs, idNrg, idScf;
int conceal_min, conceal_group_min; int conceal_min, conceal_group_min;
int MaximumScaleFactorBands; int MaximumScaleFactorBands;
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == BLOCK_SHORT)
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence)
MaximumScaleFactorBands = 16; MaximumScaleFactorBands = 16;
else else
MaximumScaleFactorBands = 64; MaximumScaleFactorBands = 64;
@ -132,8 +147,10 @@ void calcRefValFwd (CErRvlcInfo *pRvlc,
/* set reference values */ /* set reference values */
*refIsFwd = -SF_OFFSET; *refIsFwd = -SF_OFFSET;
*refNrgFwd = pAacDecoderChannelInfo->pDynData->RawDataInfo.GlobalGain - SF_OFFSET - 90 - 256; *refNrgFwd = pAacDecoderChannelInfo->pDynData->RawDataInfo.GlobalGain -
*refScfFwd = pAacDecoderChannelInfo->pDynData->RawDataInfo.GlobalGain - SF_OFFSET; SF_OFFSET - 90 - 256;
*refScfFwd =
pAacDecoderChannelInfo->pDynData->RawDataInfo.GlobalGain - SF_OFFSET;
startBand = conceal_min - 1; startBand = conceal_min - 1;
for (group = conceal_group_min; group >= 0; group--) { for (group = conceal_group_min; group >= 0; group--) {
@ -145,19 +162,22 @@ void calcRefValFwd (CErRvlcInfo *pRvlc,
case INTENSITY_HCB: case INTENSITY_HCB:
case INTENSITY_HCB2: case INTENSITY_HCB2:
if (idIs) { if (idIs) {
*refIsFwd = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; *refIsFwd =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
idIs = 0; /* reference value has been set */ idIs = 0; /* reference value has been set */
} }
break; break;
case NOISE_HCB: case NOISE_HCB:
if (idNrg) { if (idNrg) {
*refNrgFwd = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; *refNrgFwd =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
idNrg = 0; /* reference value has been set */ idNrg = 0; /* reference value has been set */
} }
break; break;
default: default:
if (idScf) { if (idScf) {
*refScfFwd = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; *refScfFwd =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
idScf = 0; /* reference value has been set */ idScf = 0; /* reference value has been set */
} }
break; break;
@ -165,35 +185,32 @@ void calcRefValFwd (CErRvlcInfo *pRvlc,
} }
startBand = pRvlc->maxSfbTransmitted - 1; startBand = pRvlc->maxSfbTransmitted - 1;
} }
} }
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
function: calcRefValBwd function: calcRefValBwd
description: The function determines the scalefactor which is closed to the scalefactorband description: The function determines the scalefactor which is closed to the
conceal_max. The same is done for intensity data and noise energies. scalefactorband conceal_max. The same is done for intensity data and noise
energies.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
output: - reference value scf output: - reference value scf
- reference value internsity data - reference value internsity data
- reference value noise energy - reference value noise energy
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - return: -
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
static static void calcRefValBwd(CErRvlcInfo *pRvlc,
void calcRefValBwd (CErRvlcInfo *pRvlc,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
int *refIsBwd, int *refIsBwd, int *refNrgBwd, int *refScfBwd) {
int *refNrgBwd,
int *refScfBwd)
{
int band, bnds, group, startBand; int band, bnds, group, startBand;
int idIs, idNrg, idScf; int idIs, idNrg, idScf;
int conceal_max, conceal_group_max; int conceal_max, conceal_group_max;
int MaximumScaleFactorBands; int MaximumScaleFactorBands;
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence) if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == BLOCK_SHORT)
MaximumScaleFactorBands = 16; MaximumScaleFactorBands = 16;
else else
MaximumScaleFactorBands = 64; MaximumScaleFactorBands = 64;
@ -206,7 +223,8 @@ void calcRefValBwd (CErRvlcInfo *pRvlc,
/* set reference values */ /* set reference values */
*refIsBwd = pRvlc->dpcm_is_last_position - SF_OFFSET; *refIsBwd = pRvlc->dpcm_is_last_position - SF_OFFSET;
*refNrgBwd = pRvlc->rev_global_gain + pRvlc->dpcm_noise_last_position - SF_OFFSET - 90 - 256 + pRvlc->dpcm_noise_nrg; *refNrgBwd = pRvlc->rev_global_gain + pRvlc->dpcm_noise_last_position -
SF_OFFSET - 90 - 256 + pRvlc->dpcm_noise_nrg;
*refScfBwd = pRvlc->rev_global_gain - SF_OFFSET; *refScfBwd = pRvlc->rev_global_gain - SF_OFFSET;
startBand = conceal_max + 1; startBand = conceal_max + 1;
@ -221,19 +239,22 @@ void calcRefValBwd (CErRvlcInfo *pRvlc,
case INTENSITY_HCB: case INTENSITY_HCB:
case INTENSITY_HCB2: case INTENSITY_HCB2:
if (idIs) { if (idIs) {
*refIsBwd = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; *refIsBwd =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
idIs = 0; /* reference value has been set */ idIs = 0; /* reference value has been set */
} }
break; break;
case NOISE_HCB: case NOISE_HCB:
if (idNrg) { if (idNrg) {
*refNrgBwd = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; *refNrgBwd =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
idNrg = 0; /* reference value has been set */ idNrg = 0; /* reference value has been set */
} }
break; break;
default: default:
if (idScf) { if (idScf) {
*refScfBwd = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; *refScfBwd =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
idScf = 0; /* reference value has been set */ idScf = 0; /* reference value has been set */
} }
break; break;
@ -241,51 +262,52 @@ void calcRefValBwd (CErRvlcInfo *pRvlc,
} }
startBand = 0; startBand = 0;
} }
} }
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
function: BidirectionalEstimation_UseLowerScfOfCurrentFrame function: BidirectionalEstimation_UseLowerScfOfCurrentFrame
description: This approach by means of bidirectional estimation is generally performed when description: This approach by means of bidirectional estimation is generally
a single bit error has been detected, the bit error can be isolated between performed when a single bit error has been detected, the bit error can be
'conceal_min' and 'conceal_max' and the 'sf_concealment' flag is not set. The isolated between 'conceal_min' and 'conceal_max' and the 'sf_concealment' flag
sets of scalefactors decoded in forward and backward direction are compared is not set. The sets of scalefactors decoded in forward and backward direction
with each other. The smaller scalefactor will be considered as the correct one are compared with each other. The smaller scalefactor will be considered as the
respectively. The reconstruction of the scalefactors with this approach archieve correct one respectively. The reconstruction of the scalefactors with this
good results in audio quality. The strategy must be applied to scalefactors, approach archieve good results in audio quality. The strategy must be applied to
intensity data and noise energy seperately. scalefactors, intensity data and noise energy seperately.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
output: Concealed scalefactor, noise energy and intensity data between conceal_min and output: Concealed scalefactor, noise energy and intensity data between
conceal_max conceal_min and conceal_max
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - return: -
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
void BidirectionalEstimation_UseLowerScfOfCurrentFrame (CAacDecoderChannelInfo *pAacDecoderChannelInfo) void BidirectionalEstimation_UseLowerScfOfCurrentFrame(
{ CAacDecoderChannelInfo *pAacDecoderChannelInfo) {
CErRvlcInfo *pRvlc = &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo; CErRvlcInfo *pRvlc =
&pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo;
int band, bnds, startBand, endBand, group; int band, bnds, startBand, endBand, group;
int conceal_min, conceal_max; int conceal_min, conceal_max;
int conceal_group_min, conceal_group_max; int conceal_group_min, conceal_group_max;
int MaximumScaleFactorBands; int MaximumScaleFactorBands;
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence) { if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == BLOCK_SHORT) {
MaximumScaleFactorBands = 16; MaximumScaleFactorBands = 16;
} } else {
else {
MaximumScaleFactorBands = 64; MaximumScaleFactorBands = 64;
} }
/* If an error was detected just in forward or backward direction, set the corresponding border for concealment to a /* If an error was detected just in forward or backward direction, set the
appropriate scalefactor band. The border is set to first or last sfb respectively, because the error will possibly corresponding border for concealment to a appropriate scalefactor band. The
not follow directly after the corrupt bit but just after decoding some more (wrong) scalefactors. */ border is set to first or last sfb respectively, because the error will
if (pRvlc->conceal_min == CONCEAL_MIN_INIT) possibly not follow directly after the corrupt bit but just after decoding
pRvlc->conceal_min = 0; some more (wrong) scalefactors. */
if (pRvlc->conceal_min == CONCEAL_MIN_INIT) pRvlc->conceal_min = 0;
if (pRvlc->conceal_max == CONCEAL_MAX_INIT) if (pRvlc->conceal_max == CONCEAL_MAX_INIT)
pRvlc->conceal_max = (pRvlc->numWindowGroups-1)*16+pRvlc->maxSfbTransmitted-1; pRvlc->conceal_max =
(pRvlc->numWindowGroups - 1) * 16 + pRvlc->maxSfbTransmitted - 1;
conceal_min = pRvlc->conceal_min % MaximumScaleFactorBands; conceal_min = pRvlc->conceal_min % MaximumScaleFactorBands;
conceal_group_min = pRvlc->conceal_min / MaximumScaleFactorBands; conceal_group_min = pRvlc->conceal_min / MaximumScaleFactorBands;
@ -293,13 +315,14 @@ void BidirectionalEstimation_UseLowerScfOfCurrentFrame (CAacDecoderChannelInfo *
conceal_group_max = pRvlc->conceal_max / MaximumScaleFactorBands; conceal_group_max = pRvlc->conceal_max / MaximumScaleFactorBands;
if (pRvlc->conceal_min == pRvlc->conceal_max) { if (pRvlc->conceal_min == pRvlc->conceal_max) {
int refIsFwd, refNrgFwd, refScfFwd; int refIsFwd, refNrgFwd, refScfFwd;
int refIsBwd, refNrgBwd, refScfBwd; int refIsBwd, refNrgBwd, refScfBwd;
bnds = pRvlc->conceal_min; bnds = pRvlc->conceal_min;
calcRefValFwd(pRvlc,pAacDecoderChannelInfo,&refIsFwd,&refNrgFwd,&refScfFwd); calcRefValFwd(pRvlc, pAacDecoderChannelInfo, &refIsFwd, &refNrgFwd,
calcRefValBwd(pRvlc,pAacDecoderChannelInfo,&refIsBwd,&refNrgBwd,&refScfBwd); &refScfFwd);
calcRefValBwd(pRvlc, pAacDecoderChannelInfo, &refIsBwd, &refNrgBwd,
&refScfBwd);
switch (pAacDecoderChannelInfo->pDynData->aCodeBook[bnds]) { switch (pAacDecoderChannelInfo->pDynData->aCodeBook[bnds]) {
case ZERO_HCB: case ZERO_HCB:
@ -324,12 +347,18 @@ void BidirectionalEstimation_UseLowerScfOfCurrentFrame (CAacDecoderChannelInfo *
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = refScfBwd; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = refScfBwd;
break; break;
} }
} } else {
else { pAacDecoderChannelInfo->pComData->overlay.aac
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[pRvlc->conceal_max] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[pRvlc->conceal_max]; .aRvlcScfFwd[pRvlc->conceal_max] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[pRvlc->conceal_min] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[pRvlc->conceal_min]; pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[pRvlc->conceal_max];
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[pRvlc->conceal_min] =
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfFwd[pRvlc->conceal_min];
/* consider the smaller of the forward and backward decoded value as the correct one */ /* consider the smaller of the forward and backward decoded value as the
* correct one */
startBand = conceal_min; startBand = conceal_min;
if (conceal_group_min == conceal_group_max) if (conceal_group_min == conceal_group_max)
endBand = conceal_max; endBand = conceal_max;
@ -339,14 +368,16 @@ void BidirectionalEstimation_UseLowerScfOfCurrentFrame (CAacDecoderChannelInfo *
for (group = conceal_group_min; group <= conceal_group_max; group++) { for (group = conceal_group_min; group <= conceal_group_max; group++) {
for (band = startBand; band <= endBand; band++) { for (band = startBand; band <= endBand; band++) {
bnds = 16 * group + band; bnds = 16 * group + band;
if (pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds] < pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]) if (pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds] <
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds])
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
else else
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
} }
startBand = 0; startBand = 0;
if ((group+1) == conceal_group_max) if ((group + 1) == conceal_group_max) endBand = conceal_max;
endBand = conceal_max;
} }
} }
@ -358,17 +389,18 @@ void BidirectionalEstimation_UseLowerScfOfCurrentFrame (CAacDecoderChannelInfo *
for (group = 0; group <= conceal_group_min; group++) { for (group = 0; group <= conceal_group_min; group++) {
for (band = 0; band < endBand; band++) { for (band = 0; band < endBand; band++) {
bnds = 16 * group + band; bnds = 16 * group + band;
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
} }
if ((group+1) == conceal_group_min) if ((group + 1) == conceal_group_min) endBand = conceal_min;
endBand = conceal_min;
} }
startBand = conceal_max + 1; startBand = conceal_max + 1;
for (group = conceal_group_max; group < pRvlc->numWindowGroups; group++) { for (group = conceal_group_max; group < pRvlc->numWindowGroups; group++) {
for (band = startBand; band < pRvlc->maxSfbTransmitted; band++) { for (band = startBand; band < pRvlc->maxSfbTransmitted; band++) {
bnds = 16 * group + band; bnds = 16 * group + band;
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
} }
startBand = 0; startBand = 0;
} }
@ -377,62 +409,70 @@ void BidirectionalEstimation_UseLowerScfOfCurrentFrame (CAacDecoderChannelInfo *
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
function: BidirectionalEstimation_UseScfOfPrevFrameAsReference function: BidirectionalEstimation_UseScfOfPrevFrameAsReference
description: This approach by means of bidirectional estimation is generally performed when description: This approach by means of bidirectional estimation is generally
a single bit error has been detected, the bit error can be isolated between performed when a single bit error has been detected, the bit error can be
'conceal_min' and 'conceal_max', the 'sf_concealment' flag is set and the isolated between 'conceal_min' and 'conceal_max', the 'sf_concealment' flag is
previous frame has the same block type as the current frame. The scalefactor set and the previous frame has the same block type as the current frame. The
decoded in forward and backward direction and the scalefactor of the previous scalefactor decoded in forward and backward direction and the scalefactor of the
frame are compared with each other. The smaller scalefactor will be considered previous frame are compared with each other. The smaller scalefactor will be
as the correct one. At this the codebook of the previous and current frame must considered as the correct one. At this the codebook of the previous and current
be of the same set (scf, nrg, is) in each scalefactorband. Otherwise the frame must be of the same set (scf, nrg, is) in each scalefactorband. Otherwise
scalefactor of the previous frame is not considered in the minimum calculation. the scalefactor of the previous frame is not considered in the minimum
The reconstruction of the scalefactors with this approach archieve good results calculation. The reconstruction of the scalefactors with this approach archieve
in audio quality. The strategy must be applied to scalefactors, intensity data good results in audio quality. The strategy must be applied to scalefactors,
and noise energy seperately. intensity data and noise energy seperately.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
output: Concealed scalefactor, noise energy and intensity data between conceal_min and output: Concealed scalefactor, noise energy and intensity data between
conceal_max conceal_min and conceal_max
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - return: -
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
void BidirectionalEstimation_UseScfOfPrevFrameAsReference( void BidirectionalEstimation_UseScfOfPrevFrameAsReference(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo) {
) CErRvlcInfo *pRvlc =
{ &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo;
CErRvlcInfo *pRvlc = &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo;
int band, bnds, startBand, endBand, group; int band, bnds, startBand, endBand, group;
int conceal_min, conceal_max; int conceal_min, conceal_max;
int conceal_group_min, conceal_group_max; int conceal_group_min, conceal_group_max;
int MaximumScaleFactorBands; int MaximumScaleFactorBands;
int commonMin; SHORT commonMin;
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence) { if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == BLOCK_SHORT) {
MaximumScaleFactorBands = 16; MaximumScaleFactorBands = 16;
} } else {
else {
MaximumScaleFactorBands = 64; MaximumScaleFactorBands = 64;
} }
/* If an error was detected just in forward or backward direction, set the corresponding border for concealment to a /* If an error was detected just in forward or backward direction, set the
appropriate scalefactor band. The border is set to first or last sfb respectively, because the error will possibly corresponding border for concealment to a appropriate scalefactor band. The
not follow directly after the corrupt bit but just after decoding some more (wrong) scalefactors. */ border is set to first or last sfb respectively, because the error will
if (pRvlc->conceal_min == CONCEAL_MIN_INIT) possibly not follow directly after the corrupt bit but just after decoding
pRvlc->conceal_min = 0; some more (wrong) scalefactors. */
if (pRvlc->conceal_min == CONCEAL_MIN_INIT) pRvlc->conceal_min = 0;
if (pRvlc->conceal_max == CONCEAL_MAX_INIT) if (pRvlc->conceal_max == CONCEAL_MAX_INIT)
pRvlc->conceal_max = (pRvlc->numWindowGroups-1)*16+pRvlc->maxSfbTransmitted-1; pRvlc->conceal_max =
(pRvlc->numWindowGroups - 1) * 16 + pRvlc->maxSfbTransmitted - 1;
conceal_min = pRvlc->conceal_min % MaximumScaleFactorBands; conceal_min = pRvlc->conceal_min % MaximumScaleFactorBands;
conceal_group_min = pRvlc->conceal_min / MaximumScaleFactorBands; conceal_group_min = pRvlc->conceal_min / MaximumScaleFactorBands;
conceal_max = pRvlc->conceal_max % MaximumScaleFactorBands; conceal_max = pRvlc->conceal_max % MaximumScaleFactorBands;
conceal_group_max = pRvlc->conceal_max / MaximumScaleFactorBands; conceal_group_max = pRvlc->conceal_max / MaximumScaleFactorBands;
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[pRvlc->conceal_max] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[pRvlc->conceal_max]; pAacDecoderChannelInfo->pComData->overlay.aac
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[pRvlc->conceal_min] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[pRvlc->conceal_min]; .aRvlcScfFwd[pRvlc->conceal_max] =
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[pRvlc->conceal_max];
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[pRvlc->conceal_min] =
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfFwd[pRvlc->conceal_min];
/* consider the smaller of the forward and backward decoded value as the correct one */ /* consider the smaller of the forward and backward decoded value as the
* correct one */
startBand = conceal_min; startBand = conceal_min;
if (conceal_group_min == conceal_group_max) if (conceal_group_min == conceal_group_max)
endBand = conceal_max; endBand = conceal_max;
@ -449,41 +489,70 @@ void BidirectionalEstimation_UseScfOfPrevFrameAsReference (
case INTENSITY_HCB: case INTENSITY_HCB:
case INTENSITY_HCB2: case INTENSITY_HCB2:
if ( (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]==INTENSITY_HCB) || (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]==INTENSITY_HCB2) ) { if ((pAacDecoderStaticChannelInfo->concealmentInfo
commonMin = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); .aRvlcPreviousCodebook[bnds] == INTENSITY_HCB) ||
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousScaleFactor[bnds]); (pAacDecoderStaticChannelInfo->concealmentInfo
} .aRvlcPreviousCodebook[bnds] == INTENSITY_HCB2)) {
else { commonMin = fMin(
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
fMin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousScaleFactor[bnds]);
} else {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
} }
break; break;
case NOISE_HCB: case NOISE_HCB:
if ( pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]==NOISE_HCB ) { if (pAacDecoderStaticChannelInfo->concealmentInfo
commonMin = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); .aRvlcPreviousCodebook[bnds] == NOISE_HCB) {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousScaleFactor[bnds]); commonMin = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
fMin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousScaleFactor[bnds]);
} else { } else {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
} }
break; break;
default: default:
if ( (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=ZERO_HCB) if ((pAacDecoderStaticChannelInfo->concealmentInfo
&& (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=NOISE_HCB) .aRvlcPreviousCodebook[bnds] != ZERO_HCB) &&
&& (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=INTENSITY_HCB) (pAacDecoderStaticChannelInfo->concealmentInfo
&& (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=INTENSITY_HCB2) ) .aRvlcPreviousCodebook[bnds] != NOISE_HCB) &&
{ (pAacDecoderStaticChannelInfo->concealmentInfo
commonMin = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds], pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); .aRvlcPreviousCodebook[bnds] != INTENSITY_HCB) &&
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousScaleFactor[bnds]); (pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousCodebook[bnds] != INTENSITY_HCB2)) {
commonMin = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
fMin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousScaleFactor[bnds]);
} else { } else {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
} }
break; break;
} }
} }
startBand = 0; startBand = 0;
if ((group+1) == conceal_group_max) if ((group + 1) == conceal_group_max) endBand = conceal_max;
endBand = conceal_max;
} }
/* now copy all data to the output buffer which needs not to be concealed */ /* now copy all data to the output buffer which needs not to be concealed */
@ -494,17 +563,18 @@ void BidirectionalEstimation_UseScfOfPrevFrameAsReference (
for (group = 0; group <= conceal_group_min; group++) { for (group = 0; group <= conceal_group_min; group++) {
for (band = 0; band < endBand; band++) { for (band = 0; band < endBand; band++) {
bnds = 16 * group + band; bnds = 16 * group + band;
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
} }
if ((group+1) == conceal_group_min) if ((group + 1) == conceal_group_min) endBand = conceal_min;
endBand = conceal_min;
} }
startBand = conceal_max + 1; startBand = conceal_max + 1;
for (group = conceal_group_max; group < pRvlc->numWindowGroups; group++) { for (group = conceal_group_max; group < pRvlc->numWindowGroups; group++) {
for (band = startBand; band < pRvlc->maxSfbTransmitted; band++) { for (band = startBand; band < pRvlc->maxSfbTransmitted; band++) {
bnds = 16 * group + band; bnds = 16 * group + band;
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
} }
startBand = 0; startBand = 0;
} }
@ -513,41 +583,39 @@ void BidirectionalEstimation_UseScfOfPrevFrameAsReference (
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
function: StatisticalEstimation function: StatisticalEstimation
description: This approach by means of statistical estimation is generally performed when description: This approach by means of statistical estimation is generally
both the start value and the end value are different and no further errors have performed when both the start value and the end value are different and no
been detected. Considering the forward and backward decoded scalefactors, the further errors have been detected. Considering the forward and backward decoded
set with the lower scalefactors in sum will be considered as the correct one. scalefactors, the set with the lower scalefactors in sum will be considered as
The scalefactors are differentially encoded. Normally it would reach to compare the correct one. The scalefactors are differentially encoded. Normally it would
one pair of the forward and backward decoded scalefactors to specify the lower reach to compare one pair of the forward and backward decoded scalefactors to
set. But having detected no further errors does not necessarily mean the absence specify the lower set. But having detected no further errors does not
of errors. Therefore all scalefactors decoded in forward and backward direction necessarily mean the absence of errors. Therefore all scalefactors decoded in
are summed up seperately. The set with the lower sum will be used. The strategy forward and backward direction are summed up seperately. The set with the lower
must be applied to scalefactors, intensity data and noise energy seperately. sum will be used. The strategy must be applied to scalefactors, intensity data
and noise energy seperately.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
output: Concealed scalefactor, noise energy and intensity data output: Concealed scalefactor, noise energy and intensity data
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - return: -
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
void StatisticalEstimation (CAacDecoderChannelInfo *pAacDecoderChannelInfo) void StatisticalEstimation(CAacDecoderChannelInfo *pAacDecoderChannelInfo) {
{ CErRvlcInfo *pRvlc =
CErRvlcInfo *pRvlc = &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo; &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo;
int band, bnds, group; int band, bnds, group;
int sumIsFwd, sumIsBwd; /* sum of intensity data forward/backward */ int sumIsFwd, sumIsBwd; /* sum of intensity data forward/backward */
int sumNrgFwd, sumNrgBwd; /* sum of noise energy data forward/backward */ int sumNrgFwd, sumNrgBwd; /* sum of noise energy data forward/backward */
int sumScfFwd, sumScfBwd; /* sum of scalefactor data forward/backward */ int sumScfFwd, sumScfBwd; /* sum of scalefactor data forward/backward */
int useIsFwd,useNrgFwd,useScfFwd; /* the flags signals the elements which are used for the final result */ int useIsFwd, useNrgFwd, useScfFwd; /* the flags signals the elements which
int MaximumScaleFactorBands; are used for the final result */
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence)
MaximumScaleFactorBands = 16;
else
MaximumScaleFactorBands = 64;
sumIsFwd = sumIsBwd = sumNrgFwd = sumNrgBwd = sumScfFwd = sumScfBwd = 0; sumIsFwd = sumIsBwd = sumNrgFwd = sumNrgBwd = sumScfFwd = sumScfBwd = 0;
useIsFwd = useNrgFwd = useScfFwd = 0; useIsFwd = useNrgFwd = useScfFwd = 0;
/* calculate sum of each group (scf,nrg,is) of forward and backward direction */ /* calculate sum of each group (scf,nrg,is) of forward and backward direction
*/
for (group = 0; group < pRvlc->numWindowGroups; group++) { for (group = 0; group < pRvlc->numWindowGroups; group++) {
for (band = 0; band < pRvlc->maxSfbTransmitted; band++) { for (band = 0; band < pRvlc->maxSfbTransmitted; band++) {
bnds = 16 * group + band; bnds = 16 * group + band;
@ -557,32 +625,35 @@ void StatisticalEstimation (CAacDecoderChannelInfo *pAacDecoderChannelInfo)
case INTENSITY_HCB: case INTENSITY_HCB:
case INTENSITY_HCB2: case INTENSITY_HCB2:
sumIsFwd += pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; sumIsFwd +=
sumIsBwd += pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
sumIsBwd +=
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
break; break;
case NOISE_HCB: case NOISE_HCB:
sumNrgFwd += pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; sumNrgFwd +=
sumNrgBwd += pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
sumNrgBwd +=
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
break; break;
default: default:
sumScfFwd += pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; sumScfFwd +=
sumScfBwd += pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
sumScfBwd +=
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
break; break;
} }
} }
} }
/* find for each group (scf,nrg,is) the correct direction */ /* find for each group (scf,nrg,is) the correct direction */
if ( sumIsFwd < sumIsBwd ) if (sumIsFwd < sumIsBwd) useIsFwd = 1;
useIsFwd = 1;
if ( sumNrgFwd < sumNrgBwd ) if (sumNrgFwd < sumNrgBwd) useNrgFwd = 1;
useNrgFwd = 1;
if ( sumScfFwd < sumScfBwd ) if (sumScfFwd < sumScfBwd) useScfFwd = 1;
useScfFwd = 1;
/* conceal each group (scf,nrg,is) */ /* conceal each group (scf,nrg,is) */
for (group = 0; group < pRvlc->numWindowGroups; group++) { for (group = 0; group < pRvlc->numWindowGroups; group++) {
@ -595,59 +666,59 @@ void StatisticalEstimation (CAacDecoderChannelInfo *pAacDecoderChannelInfo)
case INTENSITY_HCB: case INTENSITY_HCB:
case INTENSITY_HCB2: case INTENSITY_HCB2:
if (useIsFwd) if (useIsFwd)
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
else else
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
break; break;
case NOISE_HCB: case NOISE_HCB:
if (useNrgFwd) if (useNrgFwd)
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
else else
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
break; break;
default: default:
if (useScfFwd) if (useScfFwd)
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds];
else else
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds];
break; break;
} }
} }
} }
} }
/*--------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------------------------
description: Approach by means of predictive interpolation description: Approach by means of predictive interpolation
This approach by means of predictive estimation is generally performed when This approach by means of predictive estimation is generally
the error cannot be isolated between 'conceal_min' and 'conceal_max', the performed when the error cannot be isolated between 'conceal_min' and
'sf_concealment' flag is set and the previous frame has the same block type 'conceal_max', the 'sf_concealment' flag is set and the previous frame has the
as the current frame. Check for each scalefactorband if the same type of data same block type as the current frame. Check for each scalefactorband if the same
(scalefactor, internsity data, noise energies) is transmitted. If so use the type of data (scalefactor, internsity data, noise energies) is transmitted. If
scalefactor (intensity data, noise energy) in the current frame. Otherwise set so use the scalefactor (intensity data, noise energy) in the current frame.
the scalefactor (intensity data, noise energy) for this scalefactorband to zero. Otherwise set the scalefactor (intensity data, noise energy) for this
scalefactorband to zero.
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
output: Concealed scalefactor, noise energy and intensity data output: Concealed scalefactor, noise energy and intensity data
----------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------
return: - return: -
-------------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------------
*/
void PredictiveInterpolation( void PredictiveInterpolation(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo) {
) CErRvlcInfo *pRvlc =
{ &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo;
CErRvlcInfo *pRvlc = &pAacDecoderChannelInfo->pComData->overlay.aac.erRvlcInfo;
int band, bnds, group; int band, bnds, group;
int MaximumScaleFactorBands; SHORT commonMin;
int commonMin;
if (GetWindowSequence(&pAacDecoderChannelInfo->icsInfo) == EightShortSequence)
MaximumScaleFactorBands = 16;
else
MaximumScaleFactorBands = 64;
for (group = 0; group < pRvlc->numWindowGroups; group++) { for (group = 0; group < pRvlc->numWindowGroups; group++) {
for (band = 0; band < pRvlc->maxSfbTransmitted; band++) { for (band = 0; band < pRvlc->maxSfbTransmitted; band++) {
@ -659,34 +730,54 @@ void PredictiveInterpolation (
case INTENSITY_HCB: case INTENSITY_HCB:
case INTENSITY_HCB2: case INTENSITY_HCB2:
if ( (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]==INTENSITY_HCB) || (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]==INTENSITY_HCB2) ) { if ((pAacDecoderStaticChannelInfo->concealmentInfo
commonMin = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); .aRvlcPreviousCodebook[bnds] == INTENSITY_HCB) ||
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousScaleFactor[bnds]); (pAacDecoderStaticChannelInfo->concealmentInfo
} .aRvlcPreviousCodebook[bnds] == INTENSITY_HCB2)) {
else { commonMin = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
fMin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousScaleFactor[bnds]);
} else {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = -110; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = -110;
} }
break; break;
case NOISE_HCB: case NOISE_HCB:
if ( pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]==NOISE_HCB ) { if (pAacDecoderStaticChannelInfo->concealmentInfo
commonMin = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); .aRvlcPreviousCodebook[bnds] == NOISE_HCB) {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousScaleFactor[bnds]); commonMin = fMin(
} pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
else { pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
fMin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousScaleFactor[bnds]);
} else {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = -110; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = -110;
} }
break; break;
default: default:
if ( (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=ZERO_HCB) if ((pAacDecoderStaticChannelInfo->concealmentInfo
&& (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=NOISE_HCB) .aRvlcPreviousCodebook[bnds] != ZERO_HCB) &&
&& (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=INTENSITY_HCB) (pAacDecoderStaticChannelInfo->concealmentInfo
&& (pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousCodebook[bnds]!=INTENSITY_HCB2) ) { .aRvlcPreviousCodebook[bnds] != NOISE_HCB) &&
commonMin = FDKmin(pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfBwd[bnds]); (pAacDecoderStaticChannelInfo->concealmentInfo
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = FDKmin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo.aRvlcPreviousScaleFactor[bnds]); .aRvlcPreviousCodebook[bnds] != INTENSITY_HCB) &&
} (pAacDecoderStaticChannelInfo->concealmentInfo
else { .aRvlcPreviousCodebook[bnds] != INTENSITY_HCB2)) {
commonMin = fMin(
pAacDecoderChannelInfo->pComData->overlay.aac.aRvlcScfFwd[bnds],
pAacDecoderChannelInfo->pComData->overlay.aac
.aRvlcScfBwd[bnds]);
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] =
fMin(commonMin, pAacDecoderStaticChannelInfo->concealmentInfo
.aRvlcPreviousScaleFactor[bnds]);
} else {
pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = 0; pAacDecoderChannelInfo->pDynData->aScaleFactor[bnds] = 0;
} }
break; break;
@ -694,4 +785,3 @@ void PredictiveInterpolation (
} }
} }
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,7 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description:
*******************************************************************************/
/*! /*!
\file \file
@ -90,23 +109,19 @@ amm-info@iis.fraunhofer.de
#ifndef RVLCCONCEAL_H #ifndef RVLCCONCEAL_H
#define RVLCCONCEAL_H #define RVLCCONCEAL_H
#include "rvlc.h" #include "rvlc.h"
void BidirectionalEstimation_UseLowerScfOfCurrentFrame(CAacDecoderChannelInfo *pAacDecoderChannelInfo); void BidirectionalEstimation_UseLowerScfOfCurrentFrame(
CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void BidirectionalEstimation_UseScfOfPrevFrameAsReference( void BidirectionalEstimation_UseScfOfPrevFrameAsReference(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
);
void StatisticalEstimation(CAacDecoderChannelInfo *pAacDecoderChannelInfo); void StatisticalEstimation(CAacDecoderChannelInfo *pAacDecoderChannelInfo);
void PredictiveInterpolation( void PredictiveInterpolation(
CAacDecoderChannelInfo *pAacDecoderChannelInfo, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
);
#endif /* RVLCCONCEAL_H */ #endif /* RVLCCONCEAL_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,35 +90,100 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Decoder ************************** /**************************** AAC decoder library ******************************
Author(s): Josef Hoepfl Author(s): Josef Hoepfl
Description: joint stereo processing Description: joint stereo processing
******************************************************************************/ *******************************************************************************/
#ifndef STEREO_H #ifndef STEREO_H
#define STEREO_H #define STEREO_H
#include "machine_type.h" #include "machine_type.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
#include "common_fix.h"
enum #define SFB_PER_PRED_BAND 2
{
JointStereoMaximumGroups = 8,
JointStereoMaximumBands = 64
};
typedef struct #define SR_FNA_OUT \
{ 0 /* Additional scaling of the CJointStereo_filterAndAdd()-output to avoid \
overflows. */
/* The scaling factor can be set to 0 if the coefficients are prescaled
* appropriately. */
/* Prescaling via factor SF_FNA_COEFFS is done at compile-time but should only
* be */
/* utilized if the coefficients are stored as FIXP_DBL. (cp. aac_rom.cpp/.h) */
/* The NO_CPLX_PRED_BUGFIX-switch was introduced to enable decoding of
conformance-streams in way that they are comparable to buggy
reference-streams. This is established by storing the prediction direction
for computation of the "downmix MDCT of previous frame". This is not standard
compliant. Once correct reference-streams for complex-stereo-prediction are
available this switch becomes obsolete.
*/
/*#define NO_CPLX_PRED_BUGFIX*/
enum { JointStereoMaximumGroups = 8, JointStereoMaximumBands = 64 };
typedef struct {
UCHAR pred_dir; // 0 = prediction from mid to side channel, 1 = vice versa
UCHAR
igf_pred_dir; // 0 = prediction from mid to side channel, 1 = vice versa
UCHAR complex_coef; // 0 = alpha_q_im[x] is 0 for all prediction bands, 1 =
// alpha_q_im[x] is transmitted via bitstream
UCHAR use_prev_frame; // 0 = use current frame for MDST estimation, 1 = use
// current and previous frame
SHORT alpha_q_re[JointStereoMaximumGroups][JointStereoMaximumBands];
SHORT alpha_q_im[JointStereoMaximumGroups][JointStereoMaximumBands];
} CCplxPredictionData;
/* joint stereo scratch memory (valid for this frame) */
typedef struct {
UCHAR MsMaskPresent; UCHAR MsMaskPresent;
UCHAR MsUsed[JointStereoMaximumBands]; /*!< every arry element contains flags for up to 8 groups */ UCHAR MsUsed[JointStereoMaximumBands]; /*!< every arry element contains flags
for up to 8 groups. this array is
also utilized for complex stereo
prediction. */
UCHAR IGF_MsMaskPresent;
UCHAR cplx_pred_flag; /* stereo complex prediction was signalled for this
frame */
UCHAR igf_cplx_pred_flag;
/* The following array and variable are needed for the case when INF is
* active */
FIXP_DBL store_dmx_re_prev[1024];
SHORT store_dmx_re_prev_e;
} CJointStereoData; } CJointStereoData;
/* joint stereo persistent memory */
typedef struct {
UCHAR clearSpectralCoeffs; /* indicates that the spectral coeffs must be
cleared because the transform splitting active
flag of the left and right channel was different
*/
FIXP_DBL *scratchBuffer; /* pointer to scratch buffer */
FIXP_DBL
*spectralCoeffs[2]; /* spectral coefficients of this channel utilized by
complex stereo prediction */
SHORT *specScale[2];
SHORT alpha_q_re_prev[JointStereoMaximumGroups][JointStereoMaximumBands];
SHORT alpha_q_im_prev[JointStereoMaximumGroups][JointStereoMaximumBands];
UCHAR winSeqPrev;
UCHAR winShapePrev;
UCHAR winGroupsPrev;
} CJointStereoPersistentData;
/*! /*!
\brief Read joint stereo data from bitstream \brief Read joint stereo data from bitstream
@ -115,20 +191,21 @@ typedef struct
The function reads joint stereo data from bitstream. The function reads joint stereo data from bitstream.
\param bs bit stream handle data source. \param bs bit stream handle data source.
\param pJointStereoData pointer to stereo data structure to receive decoded data. \param pJointStereoData pointer to stereo data structure to receive decoded
\param windowGroups number of window groups. data. \param windowGroups number of window groups. \param
\param scaleFactorBandsTransmitted number of transmitted scalefactor bands. scaleFactorBandsTransmitted number of transmitted scalefactor bands. \param
\param flags decoder flags flags decoder flags
\return 0 on success, -1 on error. \return 0 on success, -1 on error.
*/ */
int CJointStereo_Read( int CJointStereo_Read(HANDLE_FDK_BITSTREAM bs,
HANDLE_FDK_BITSTREAM bs,
CJointStereoData *pJointStereoData, CJointStereoData *pJointStereoData,
int windowGroups, const int windowGroups,
int scaleFactorBandsTransmitted, const int scaleFactorBandsTransmitted,
UINT flags const int max_sfb_ste_clear,
); CJointStereoPersistentData *pJointStereoPersistentData,
CCplxPredictionData *cplxPredictionData,
int cplxPredictionActiv, int scaleFactorBandsTotal,
int windowSequence, const UINT flags);
#endif /* #ifndef STEREO_H */ #endif /* #ifndef STEREO_H */

View File

@ -0,0 +1,439 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description: ACELP
*******************************************************************************/
#include "usacdec_ace_d4t64.h"
#define L_SUBFR 64 /* Subframe size */
/*
* D_ACELP_add_pulse
*
* Parameters:
* pos I: position of pulse
* nb_pulse I: number of pulses
* track I: track
* code O: fixed codebook
*
* Function:
* Add pulses to fixed codebook
*
* Returns:
* void
*/
static void D_ACELP_add_pulse(SHORT pos[], SHORT nb_pulse, SHORT track,
FIXP_COD code[]) {
SHORT i, k;
for (k = 0; k < nb_pulse; k++) {
/* i = ((pos[k] & (16-1))*NB_TRACK) + track; */
i = ((pos[k] & (16 - 1)) << 2) + track;
if ((pos[k] & 16) == 0) {
code[i] = code[i] + (FIXP_COD)(512 << (COD_BITS - FRACT_BITS));
} else {
code[i] = code[i] - (FIXP_COD)(512 << (COD_BITS - FRACT_BITS));
}
}
return;
}
/*
* D_ACELP_decode_1p_N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 1 pulse with N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_1p_N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT pos1;
LONG i, mask;
mask = ((1 << N) - 1);
/*
* Decode 1 pulse with N+1 bits
*/
pos1 = (SHORT)((index & mask) + offset);
i = ((index >> N) & 1);
if (i == 1) {
pos1 += 16;
}
pos[0] = pos1;
return;
}
/*
* D_ACELP_decode_2p_2N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 2 pulses with 2*N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_2p_2N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT pos1, pos2;
LONG mask, i;
mask = ((1 << N) - 1);
/*
* Decode 2 pulses with 2*N+1 bits
*/
pos1 = (SHORT)(((index >> N) & mask) + offset);
i = (index >> (2 * N)) & 1;
pos2 = (SHORT)((index & mask) + offset);
if ((pos2 - pos1) < 0) {
if (i == 1) {
pos1 += 16;
} else {
pos2 += 16;
}
} else {
if (i == 1) {
pos1 += 16;
pos2 += 16;
}
}
pos[0] = pos1;
pos[1] = pos2;
return;
}
/*
* D_ACELP_decode_3p_3N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 3 pulses with 3*N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_3p_3N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT j;
LONG mask, idx;
/*
* Decode 3 pulses with 3*N+1 bits
*/
mask = ((1 << ((2 * N) - 1)) - 1);
idx = index & mask;
j = offset;
if (((index >> ((2 * N) - 1)) & 1) == 1) {
j += (1 << (N - 1));
}
D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
mask = ((1 << (N + 1)) - 1);
idx = (index >> (2 * N)) & mask;
D_ACELP_decode_1p_N1(idx, N, offset, pos + 2);
return;
}
/*
* D_ACELP_decode_4p_4N1
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 4 pulses with 4*N+1 bits
*
* Returns:
* void
*/
static void D_ACELP_decode_4p_4N1(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT j;
LONG mask, idx;
/*
* Decode 4 pulses with 4*N+1 bits
*/
mask = ((1 << ((2 * N) - 1)) - 1);
idx = index & mask;
j = offset;
if (((index >> ((2 * N) - 1)) & 1) == 1) {
j += (1 << (N - 1));
}
D_ACELP_decode_2p_2N1(idx, N - 1, j, pos);
mask = ((1 << ((2 * N) + 1)) - 1);
idx = (index >> (2 * N)) & mask;
D_ACELP_decode_2p_2N1(idx, N, offset, pos + 2);
return;
}
/*
* D_ACELP_decode_4p_4N
*
* Parameters:
* index I: pulse index
* N I: number of bits for position
* offset I: offset
* pos O: position of the pulse
*
* Function:
* Decode 4 pulses with 4*N bits
*
* Returns:
* void
*/
static void D_ACELP_decode_4p_4N(LONG index, SHORT N, SHORT offset,
SHORT pos[]) {
SHORT j, n_1;
/*
* Decode 4 pulses with 4*N bits
*/
n_1 = N - 1;
j = offset + (1 << n_1);
switch ((index >> ((4 * N) - 2)) & 3) {
case 0:
if (((index >> ((4 * n_1) + 1)) & 1) == 0) {
D_ACELP_decode_4p_4N1(index, n_1, offset, pos);
} else {
D_ACELP_decode_4p_4N1(index, n_1, j, pos);
}
break;
case 1:
D_ACELP_decode_1p_N1((index >> ((3 * n_1) + 1)), n_1, offset, pos);
D_ACELP_decode_3p_3N1(index, n_1, j, pos + 1);
break;
case 2:
D_ACELP_decode_2p_2N1((index >> ((2 * n_1) + 1)), n_1, offset, pos);
D_ACELP_decode_2p_2N1(index, n_1, j, pos + 2);
break;
case 3:
D_ACELP_decode_3p_3N1((index >> (n_1 + 1)), n_1, offset, pos);
D_ACELP_decode_1p_N1(index, n_1, j, pos + 3);
break;
}
return;
}
/*
* D_ACELP_decode_4t
*
* Parameters:
* index I: index
* mode I: speech mode
* code I: (Q9) algebraic (fixed) codebook excitation
*
* Function:
* 20, 36, 44, 52, 64, 72, 88 bits algebraic codebook.
* 4 tracks x 16 positions per track = 64 samples.
*
* 20 bits 5+5+5+5 --> 4 pulses in a frame of 64 samples.
* 36 bits 9+9+9+9 --> 8 pulses in a frame of 64 samples.
* 44 bits 13+9+13+9 --> 10 pulses in a frame of 64 samples.
* 52 bits 13+13+13+13 --> 12 pulses in a frame of 64 samples.
* 64 bits 2+2+2+2+14+14+14+14 --> 16 pulses in a frame of 64 samples.
* 72 bits 10+2+10+2+10+14+10+14 --> 18 pulses in a frame of 64 samples.
* 88 bits 11+11+11+11+11+11+11+11 --> 24 pulses in a frame of 64 samples.
*
* All pulses can have two (2) possible amplitudes: +1 or -1.
* Each pulse can sixteen (16) possible positions.
*
* codevector length 64
* number of track 4
* number of position 16
*
* Returns:
* void
*/
void D_ACELP_decode_4t64(SHORT index[], int nbits, FIXP_COD code[]) {
LONG L_index;
SHORT k, pos[6];
FDKmemclear(code, L_SUBFR * sizeof(FIXP_COD));
/* decode the positions and signs of pulses and build the codeword */
switch (nbits) {
case 12:
for (k = 0; k < 4; k += 2) {
L_index = index[2 * (k / 2) + 1];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, 2 * (index[2 * (k / 2)]) + k / 2, code);
}
break;
case 16: {
int i = 0;
int offset = index[i++];
offset = (offset == 0) ? 1 : 3;
for (k = 0; k < 4; k++) {
if (k != offset) {
L_index = index[i++];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, k, code);
}
}
} break;
case 20:
for (k = 0; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, k, code);
}
break;
case 28:
for (k = 0; k < 4 - 2; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 2, k, code);
}
for (k = 2; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_1p_N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 1, k, code);
}
break;
case 36:
for (k = 0; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 2, k, code);
}
break;
case 44:
for (k = 0; k < 4 - 2; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 3, k, code);
}
for (k = 2; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_2p_2N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 2, k, code);
}
break;
case 52:
for (k = 0; k < 4; k++) {
L_index = (LONG)index[k];
D_ACELP_decode_3p_3N1(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 3, k, code);
}
break;
case 64:
for (k = 0; k < 4; k++) {
L_index = (((LONG)index[k] << 14) + (LONG)index[k + 4]);
D_ACELP_decode_4p_4N(L_index, 4, 0, pos);
D_ACELP_add_pulse(pos, 4, k, code);
}
break;
default:
FDK_ASSERT(0);
}
return;
}

View File

@ -0,0 +1,117 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s):
Description: ACELP
*******************************************************************************/
#ifndef USACDEC_ACE_D4T64_H
#define USACDEC_ACE_D4T64_H
#include "common_fix.h"
/* Data type definition for the fixed codebook vector */
#define FIXP_COD FIXP_SGL
#define FX_COD2FX_DBL(x) (FX_SGL2FX_DBL(x))
#define FX_DBL2FX_COD(x) FX_DBL2FX_SGL((x) + (FIXP_DBL)0x8000)
#define FX_SGL2FX_COD(x) (x)
#define COD_BITS FRACT_BITS
void D_ACELP_decode_4t64(SHORT index[], int nbits, FIXP_COD code[]);
#endif /* USACDEC_ACE_D4T64_H */

View File

@ -0,0 +1,229 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description: USAC ACELP LTP filter
*******************************************************************************/
#include "usacdec_ace_ltp.h"
#include "genericStds.h"
#include "common_fix.h"
#define UP_SAMP 4
#define L_INTERPOL2 16
#define L_SUBFR 64
#define A2 FL2FX_SGL(2 * 0.18f)
#define B FL2FX_SGL(0.64f)
static const LONG Pred_lt4_inter4_2[UP_SAMP][L_INTERPOL2] = {
{(LONG)0x0000FFFC, (LONG)0x0008FFFC, (LONG)0xFFEB004C, (LONG)0xFF50014A,
(LONG)0xFDD90351, (LONG)0xFB2A06CD, (LONG)0xF6920D46, (LONG)0xEBB42B35,
(LONG)0x6D9EEF39, (LONG)0x0618FE0F, (LONG)0xFFE00131, (LONG)0xFE5501C5,
(LONG)0xFE5E015D, (LONG)0xFEF700B6, (LONG)0xFF920037, (LONG)0xFFEC0003},
{(LONG)0x0002FFF2, (LONG)0x0026FFBD, (LONG)0x005DFF98, (LONG)0x0055FFEF,
(LONG)0xFF89015F, (LONG)0xFD3A04E5, (LONG)0xF7D90DAA, (LONG)0xE67A50EE,
(LONG)0x50EEE67A, (LONG)0x0DAAF7D9, (LONG)0x04E5FD3A, (LONG)0x015FFF89,
(LONG)0xFFEF0055, (LONG)0xFF98005D, (LONG)0xFFBD0026, (LONG)0xFFF20002},
{(LONG)0x0003FFEC, (LONG)0x0037FF92, (LONG)0x00B6FEF7, (LONG)0x015DFE5E,
(LONG)0x01C5FE55, (LONG)0x0131FFE0, (LONG)0xFE0F0618, (LONG)0xEF396D9E,
(LONG)0x2B35EBB4, (LONG)0x0D46F692, (LONG)0x06CDFB2A, (LONG)0x0351FDD9,
(LONG)0x014AFF50, (LONG)0x004CFFEB, (LONG)0xFFFC0008, (LONG)0xFFFC0000},
{(LONG)0x0002FFF2, (LONG)0x002BFF9E, (LONG)0x00B9FECE, (LONG)0x01CFFD75,
(LONG)0x035EFBC1, (LONG)0x0521FA0C, (LONG)0x06AAF8C9, (LONG)0x07907852,
(LONG)0x0790F8C9, (LONG)0x06AAFA0C, (LONG)0x0521FBC1, (LONG)0x035EFD75,
(LONG)0x01CFFECE, (LONG)0x00B9FF9E, (LONG)0x002BFFF2, (LONG)0x00020000}};
void Pred_lt4(FIXP_DBL exc[], /* in/out: excitation buffer */
int T0, /* input : integer pitch lag */
int frac /* input : fraction of lag in range 0..3 */
) {
int j;
FIXP_DBL *x;
const LONG *interpol;
FIXP_DBL L_sumb, L_sumt;
x = &exc[-T0 - L_INTERPOL2 + 1];
/* remap frac and x:
0 -> 3 x (unchanged)
1 -> 0 x--
2 -> 1 x--
3 -> 2 x--
*/
if (--frac < 0)
frac += UP_SAMP;
else
x--;
j = L_SUBFR + 1;
do {
LONG filt;
FIXP_DBL x0, x1;
FIXP_DBL *xi = x++;
interpol = Pred_lt4_inter4_2[frac];
int i = 3;
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultDiv2(x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultDiv2(x1, (FIXP_SGL)((SHORT)filt));
do {
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
filt = *interpol++;
x0 = *xi++;
x1 = *xi++;
L_sumt = fMultAddDiv2(L_sumt, x0, (FIXP_SGL)((SHORT)(filt >> 16)));
L_sumb = fMultAddDiv2(L_sumb, x1, (FIXP_SGL)((SHORT)filt));
} while (--i != 0);
L_sumb <<= 1;
L_sumb = fAddSaturate(L_sumt << 1, L_sumb);
*exc++ = L_sumb;
} while (--j != 0);
return;
}
void Pred_lt4_postfilter(FIXP_DBL exc[] /* in/out: excitation buffer */
) {
/*
exc[i] = A*exc[i-1] + B*exc[i] + A*exc[i+1]
exc[i+1] = A*exc[i] + B*exc[i+1] + A*exc[i+2] ; i = 0:2:62
*/
int i;
FIXP_DBL sum0, sum1, a_exc0, a_exc1;
a_exc0 = fMultDiv2(A2, exc[-1]);
a_exc1 = fMultDiv2(A2, exc[0]);
/* ARM926: 22 cycles/iteration */
for (i = 0; i < L_SUBFR; i += 2) {
sum0 = a_exc0 + fMult(B, exc[i]);
sum1 = a_exc1 + fMult(B, exc[i + 1]);
a_exc0 = fMultDiv2(A2, exc[i + 1]);
a_exc1 = fMultDiv2(A2, exc[i + 2]);
exc[i] = sum0 + a_exc0;
exc[i + 1] = sum1 + a_exc1;
}
return;
}

View File

@ -0,0 +1,128 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description: USAC ACELP LTP filter
*******************************************************************************/
#ifndef USACDEC_ACE_LTP_H
#define USACDEC_ACE_LTP_H
#include "common_fix.h"
/**
* \brief Compute the initial adaptive codebook excitation v'(n) by
* interpolating the past excitation vector u'(n).
* \param exc points to adaptive codebook of current subframe (input/output)
* \param T0 integer part of decoded pitch lag (input)
* \param frac fractional part of decoded pitch lag (0..3) (input)
*/
void Pred_lt4(FIXP_DBL exc[], /* in/out: excitation buffer */
int T0, /* input : integer pitch lag */
int frac /* input : fraction of lag */
);
/**
* \brief Compute the adaptive codebook excitation v(n) in case of
* ltp_filtering_flag == 0.
* \param exc points to adaptive codebook of current subframe (input/output)
*/
void Pred_lt4_postfilter(FIXP_DBL exc[] /* in/out: excitation buffer */
);
#endif /* USACDEC_ACE_LTP_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,280 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand
Description: USAC ACELP frame decoder
*******************************************************************************/
#ifndef USACDEC_ACELP_H
#define USACDEC_ACELP_H
#include "common_fix.h"
#include "FDK_bitstream.h"
#include "usacdec_const.h"
#include "usacdec_rom.h"
//#define ENHANCED_TCX_TD_CONCEAL_ENABLE
/** Structure which holds the ACELP internal persistent memory */
typedef struct {
FIXP_DBL old_exc_mem[PIT_MAX_MAX + L_INTERPOL];
FIXP_DBL old_syn_mem[M_LP_FILTER_ORDER]; /* synthesis filter states */
FIXP_SGL A[M_LP_FILTER_ORDER];
INT A_exp;
FIXP_DBL gc_threshold;
FIXP_DBL de_emph_mem;
FIXP_SGL past_gpit;
FIXP_DBL past_gcode;
USHORT old_T0;
UCHAR old_T0_frac;
FIXP_DBL deemph_mem_wsyn;
FIXP_DBL wsyn_rms;
SHORT seed_ace;
} CAcelpStaticMem;
/** Structure which holds the parameter data needed to decode one ACELP frame.
*/
typedef struct {
UCHAR
acelp_core_mode; /**< mean excitation energy index for whole ACELP frame
*/
UCHAR mean_energy; /**< acelp core mode for whole ACELP frame */
USHORT T0[NB_SUBFR];
UCHAR T0_frac[NB_SUBFR];
UCHAR ltp_filtering_flag[NB_SUBFR]; /**< controlls whether LTP postfilter is
active for each ACELP subframe */
SHORT icb_index[NB_SUBFR]
[8]; /**< innovative codebook index for each ACELP subframe */
UCHAR gains[NB_SUBFR]; /**< gain index for each ACELP subframe */
} CAcelpChannelData;
/**
* \brief Read the acelp_coding() bitstream part.
* \param[in] hBs bitstream handle to read data from.
* \param[out] acelpData pointer to structure to store the parsed data of one
* ACELP frame.
* \param[in] acelp_core_mode the ACELP core mode index.
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
INT CLpd_AcelpRead(HANDLE_FDK_BITSTREAM hBs, CAcelpChannelData *acelpData,
INT acelp_core_mode, INT i_offset, INT coreCoderFrameLength);
/**
* \brief Initialization of memory before one LPD frame is decoded
* \param[out] synth_buf synthesis buffer to be initialized, exponent = SF_SYNTH
* \param[in] old_synth past synthesis of previous LPD frame, exponent =
* SF_SYNTH
* \param[out] synth_buf_fb fullband synthesis buffer to be initialized,
* exponent = SF_SYNTH
* \param[in] old_synth_fb past fullband synthesis of previous LPD frame,
* exponent = SF_SYNTH
* \param[out] pitch vector where decoded pitch lag values are stored
* \param[in] old_T_pf past pitch lag values of previous LPD frame
* \param[in] samplingRate sampling rate for pitch lag offset calculation
* \param[out] i_offset pitch lag offset for the decoding of the pitch lag
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
void Acelp_PreProcessing(FIXP_DBL *synth_buf, FIXP_DBL *old_synth, INT *pitch,
INT *old_T_pf, FIXP_DBL *pit_gain,
FIXP_DBL *old_gain_pf, INT samplingRate, INT *i_offset,
INT coreCoderFrameLength, INT synSfd,
INT nbSubfrSuperfr);
/**
* \brief Save tail of buffers for the initialization of the next LPD frame
* \param[in] synth_buf synthesis of current LPD frame, exponent = SF_SYNTH
* \param[out] old_synth memory where tail of fullband synth_buf is stored,
* exponent = SF_SYNTH
* \param[in] synth_buf_fb fullband synthesis of current LPD frame, exponent =
* SF_SYNTH
* \param[out] old_synth_fb memory where tail of fullband synth_buf is stored,
* exponent = SF_SYNTH
* \param[in] pitch decoded pitch lag values of current LPD frame
* \param[out] old_T_pf memory where last SYN_SFD pitch lag values are stored
*/
void Acelp_PostProcessing(FIXP_DBL *synth_buf, FIXP_DBL *old_synth, INT *pitch,
INT *old_T_pf, INT coreCoderFrameLength, INT synSfd,
INT nbSubfrSuperfr);
/**
* \brief Decode one ACELP frame (three or four ACELP subframes with 64 samples
* each)
* \param[in,out] acelp_mem pointer to ACELP memory structure
* \param[in] i_offset pitch lag offset
* \param[in] lsp_old LPC filter in LSP domain corresponding to previous frame
* \param[in] lsp_new LPC filter in LSP domain corresponding to current frame
* \param[in] stab_fac stability factor constrained by 0<=stab_fac<=1.0,
* exponent = SF_STAB
* \param[in] acelpData pointer to struct with data which is needed for decoding
* one ACELP frame
* \param[out] synth ACELP output signal
* \param[out] pT four decoded pitch lag values
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
void CLpd_AcelpDecode(CAcelpStaticMem *acelp_mem, INT i_offset,
const FIXP_LPC lsp_old[M_LP_FILTER_ORDER],
const FIXP_LPC lsp_new[M_LP_FILTER_ORDER],
FIXP_SGL stab_fac, CAcelpChannelData *acelpData,
INT numLostSubframes, int lastLpcLost, int frameCnt,
FIXP_DBL synth[], int pT[], FIXP_DBL *pit_gain,
INT coreCoderFrameLength);
/**
* \brief Reset ACELP internal memory.
* \param[out] acelp_mem pointer to ACELP memory structure
*/
void CLpd_AcelpReset(CAcelpStaticMem *acelp_mem);
/**
* \brief Initialize ACELP internal memory in case of FAC before ACELP decoder
* is called
* \param[in] synth points to end+1 of past valid synthesis signal, exponent =
* SF_SYNTH
* \param[in] last_lpd_mode last lpd mode
* \param[in] last_last_lpd_mode lpd mode before last_lpd_mode
* \param[in] A_new LP synthesis filter coeffs corresponding to last frame,
* exponent = SF_A_COEFFS
* \param[in] A_old LP synthesis filter coeffs corresponding to the frame before
* last frame, exponent = SF_A_COEFFS
* \param[in,out] acelp_mem pointer to ACELP memory structure
* \param[in] coreCoderFrameLength length of core coder frame (1024|768)
*/
void CLpd_AcelpPrepareInternalMem(const FIXP_DBL *synth, UCHAR last_lpd_mode,
UCHAR last_last_lpd_mode,
const FIXP_LPC *A_new, const INT A_new_exp,
const FIXP_LPC *A_old, const INT A_old_exp,
CAcelpStaticMem *acelp_mem,
INT coreCoderFrameLength, UCHAR lpd_mode);
/**
* \brief Calculate zero input response (zir) of the acelp synthesis filter
* \param[in] A LP synthesis filter coefficients, exponent = SF_A_COEFFS
* \param[in,out] acelp_mem pointer to ACELP memory structure
* \param[in] length length of zir
* \param[out] zir pointer to zir output buffer, exponent = SF_SYNTH
*/
void CLpd_Acelp_Zir(const FIXP_LPC A[], const INT A_exp,
CAcelpStaticMem *acelp_mem, const INT length,
FIXP_DBL zir[], int doDeemph);
/**
* \brief Borrow static excitation memory from ACELP decoder
* \param[in] acelp_mem pointer to ACELP memory structure
* \param[in] length number of requested FIXP_DBL values
* \return pointer to requested memory
*
* The caller has to take care not to overwrite valid memory areas.
* During TCX/FAC calculations and before CLpd_AcelpPrepareInternalMem() is
* called, the following memory size is available:
* - 256 samples in case of ACELP -> TCX20 -> ACELP transition
* - PIT_MAX_MAX+L_INTERPOL samples in all other cases
*/
FIXP_DBL *CLpd_ACELP_GetFreeExcMem(CAcelpStaticMem *acelp_mem, INT length);
void CLpd_TcxTDConceal(CAcelpStaticMem *acelp_mem, SHORT *pitch,
const FIXP_LPC lsp_old[M_LP_FILTER_ORDER],
const FIXP_LPC lsp_new[M_LP_FILTER_ORDER],
const FIXP_SGL stab_fac, INT numLostSubframes,
FIXP_DBL synth[], INT coreCoderFrameLength,
UCHAR last_tcx_noise_factor);
inline SHORT E_UTIL_random(SHORT *seed) {
*seed = (SHORT)((((LONG)*seed * (LONG)31821) >> 1) + (LONG)13849);
return (*seed);
}
#endif /* USACDEC_ACELP_H */

View File

@ -0,0 +1,202 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC related constants
*******************************************************************************/
#ifndef USACDEC_CONST_H
#define USACDEC_CONST_H
/* scale factors */
#define SF_CODE 6 /* exponent of code[], fixed codebook vector */
#define SF_GAIN_C 16 /* exponent of gain code and smoothed gain code */
#define SF_EXC 16 /* exponent of exc[] and exc2[], excitation buffer */
#define SF_GAIN_P 1 /* exponent of gain_pit */
#define SF_PFAC 0 /* exponent of period/voicing factor */
#define SF_SYNTH SF_EXC /* exponent of synthesis buffer */
#define SF_A_COEFFS 3 /* exponent of LP domain synthesis filter coefficient */
#define SF_STAB 1 /* exponent of stability factor */
/* definitions which are independent of coreCoderFrameLength */
#define M_LP_FILTER_ORDER 16 /* LP filter order */
#define PIT_MIN_12k8 34 /* Minimum pitch lag with resolution 1/4 */
#define PIT_MAX_12k8 231 /* Maximum pitch lag for fs=12.8kHz */
#define FSCALE_DENOM 12800 /* Frequency scale denominator */
#define FAC_FSCALE_MIN \
6000 /* Minimum allowed frequency scale for acelp decoder */
#if !defined(LPD_MAX_CORE_SR)
#define LPD_MAX_CORE_SR 24000 /* Default value from ref soft */
#endif
#define FAC_FSCALE_MAX \
LPD_MAX_CORE_SR /* Maximum allowed frequency scale for acelp decoder */
/* Maximum pitch lag (= 411 for fs_max = 24000) */
#define PIT_MAX_TMP \
(PIT_MAX_12k8 + \
(6 * \
((((FAC_FSCALE_MAX * PIT_MIN_12k8) + (FSCALE_DENOM / 2)) / FSCALE_DENOM) - \
PIT_MIN_12k8)))
#if (PIT_MAX_TMP < \
256) /* cannot be smaller because of tcx time domain concealment */
#define PIT_MAX_MAX 256
#else
#define PIT_MAX_MAX PIT_MAX_TMP
#endif
#define NB_DIV 4 /* number of division (20ms) per 80ms frame */
#define L_SUBFR 64 /* subframe size (5ms) */
#define BPF_SFD 1 /* bass postfilter delay (subframe) */
#define BPF_DELAY (BPF_SFD * L_SUBFR) /* bass postfilter delay (samples) */
#define L_FILT 12 /* Delay of up-sampling filter (bass post-filter) */
#define L_EXTRA 96 /* for bass post-filter */
#define L_INTERPOL \
(16 + 1) /* Length of filter for interpolation (acelp decoder) */
/* definitions for coreCoderFrameLength = 1024 */
#define L_FRAME_PLUS_1024 1024 /* length of one 80ms superframe */
#define L_DIV_1024 \
(L_FRAME_PLUS_1024 / NB_DIV) /* length of one acelp or tcx20 frame */
#define NB_SUBFR_1024 \
(L_DIV_1024 / L_SUBFR) /* number of 5ms subframe per division */
#define NB_SUBFR_SUPERFR_1024 \
(L_FRAME_PLUS_1024 / L_SUBFR) /* number of 5ms subframe per 80ms frame */
#define AAC_SFD_1024 (NB_SUBFR_SUPERFR_1024 / 2) /* AAC delay (subframe) */
#define AAC_DELAY_1024 (AAC_SFD_1024 * L_SUBFR) /* AAC delay (samples) */
#define SYN_SFD_1024 (AAC_SFD_1024 - BPF_SFD) /* synthesis delay (subframe) */
#define SYN_DELAY_1024 \
(SYN_SFD_1024 * L_SUBFR) /* synthesis delay (samples) \
*/
#define LFAC_1024 (L_DIV_1024 / 2) /* FAC frame length */
#define LFAC_SHORT_1024 \
(L_DIV_1024 / 4) /* for transitions EIGHT_SHORT FD->LPD and vv. */
#define FDNS_NPTS_1024 64 /* FD noise shaping resolution (64=100Hz/point) */
/* definitions for coreCoderFrameLength = 768 */
#define L_FRAME_PLUS_768 768
#define L_DIV_768 \
(L_FRAME_PLUS_768 / NB_DIV) /* length of one acelp or tcx20 frame */
#define NB_SUBFR_768 \
(L_DIV_768 / L_SUBFR) /* number of 5ms subframe per division */
#define NB_SUBFR_SUPERFR_768 \
(L_FRAME_PLUS_768 / L_SUBFR) /* number of 5ms subframe per 80ms frame */
#define AAC_SFD_768 (NB_SUBFR_SUPERFR_768 / 2) /* AAC delay (subframe) */
#define AAC_DELAY_768 (AAC_SFD_768 * L_SUBFR) /* AAC delay (samples) */
#define SYN_SFD_768 (AAC_SFD_768 - BPF_SFD) /* synthesis delay (subframe) */
#define SYN_DELAY_768 (SYN_SFD_768 * L_SUBFR) /* synthesis delay (samples) */
#define LFAC_768 (L_DIV_768 / 2) /* FAC frame length */
#define LFAC_SHORT_768 \
(L_DIV_768 / 4) /* for transitions EIGHT_SHORT FD->LPD and vv. */
/* maximum (used for memory allocation) */
#define L_FRAME_PLUS L_FRAME_PLUS_1024
#define L_DIV L_DIV_1024
#define NB_SUBFR NB_SUBFR_1024
#define NB_SUBFR_SUPERFR NB_SUBFR_SUPERFR_1024
#define AAC_SFD AAC_SFD_1024
#define AAC_DELAY AAC_DELAY_1024
#define SYN_SFD SYN_SFD_1024
#define SYN_DELAY SYN_DELAY_1024
#define LFAC LFAC_1024
#define LFAC_SHORT LFAC_SHORT_1024
#define FDNS_NPTS FDNS_NPTS_1024
#endif /* USACDEC_CONST_H */

View File

@ -0,0 +1,743 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC FAC
*******************************************************************************/
#include "usacdec_fac.h"
#include "usacdec_const.h"
#include "usacdec_lpc.h"
#include "usacdec_acelp.h"
#include "usacdec_rom.h"
#include "dct.h"
#include "FDK_tools_rom.h"
#include "mdct.h"
#define SPEC_FAC(ptr, i, gl) ((ptr) + ((i) * (gl)))
FIXP_DBL *CLpd_FAC_GetMemory(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UCHAR mod[NB_DIV], int *pState) {
FIXP_DBL *ptr;
int i;
int k = 0;
int max_windows = 8;
FDK_ASSERT(*pState >= 0 && *pState < max_windows);
/* Look for free space to store FAC data. 2 FAC data blocks fit into each TCX
* spectral data block. */
for (i = *pState; i < max_windows; i++) {
if (mod[i >> 1] == 0) {
break;
}
}
*pState = i + 1;
if (i == max_windows) {
ptr = pAacDecoderChannelInfo->data.usac.fac_data0;
} else {
FDK_ASSERT(mod[(i >> 1)] == 0);
ptr = SPEC_FAC(pAacDecoderChannelInfo->pSpectralCoefficient, i,
pAacDecoderChannelInfo->granuleLength << k);
}
return ptr;
}
int CLpd_FAC_Read(HANDLE_FDK_BITSTREAM hBs, FIXP_DBL *pFac, UCHAR *pFacScale,
int length, int use_gain, int frame) {
FIXP_DBL fac_gain;
int fac_gain_e = 0;
if (use_gain) {
CLpd_DecodeGain(&fac_gain, &fac_gain_e, FDKreadBits(hBs, 7));
}
if (CLpc_DecodeAVQ(hBs, pFac, 1, 1, length) != 0) {
return -1;
}
{
int scale;
scale = getScalefactor(pFac, length);
scaleValues(pFac, length, scale);
pFacScale[frame] = DFRACT_BITS - 1 - scale;
}
if (use_gain) {
int i;
pFacScale[frame] += fac_gain_e;
for (i = 0; i < length; i++) {
pFac[i] = fMult(pFac[i], fac_gain);
}
}
return 0;
}
/**
* \brief Apply synthesis filter with zero input to x. The overall filter gain
* is 1.0.
* \param a LPC filter coefficients.
* \param length length of the input/output data vector x.
* \param x input/output vector, where the synthesis filter is applied in place.
*/
static void Syn_filt_zero(const FIXP_LPC a[], const INT a_exp, INT length,
FIXP_DBL x[]) {
int i, j;
FIXP_DBL L_tmp;
for (i = 0; i < length; i++) {
L_tmp = (FIXP_DBL)0;
for (j = 0; j < fMin(i, M_LP_FILTER_ORDER); j++) {
L_tmp -= fMultDiv2(a[j], x[i - (j + 1)]);
}
L_tmp = scaleValue(L_tmp, a_exp + 1);
x[i] = scaleValueSaturate((x[i] >> 1) + (L_tmp >> 1),
1); /* Avoid overflow issues and saturate. */
}
}
/* Table is also correct for coreCoderFrameLength = 768. Factor 3/4 is canceled
out: gainFac = 0.5 * sqrt(fac_length/lFrame)
*/
static const FIXP_DBL gainFac[4] = {0x40000000, 0x2d413ccd, 0x20000000,
0x16a09e66};
void CFac_ApplyGains(FIXP_DBL fac_data[LFAC], const INT fac_length,
const FIXP_DBL tcx_gain, const FIXP_DBL alfd_gains[],
const INT mod) {
FIXP_DBL facFactor;
int i;
FDK_ASSERT((fac_length == 128) || (fac_length == 96));
/* 2) Apply gain factor to FAC data */
facFactor = fMult(gainFac[mod], tcx_gain);
for (i = 0; i < fac_length; i++) {
fac_data[i] = fMult(fac_data[i], facFactor);
}
/* 3) Apply spectrum deshaping using alfd_gains */
for (i = 0; i < fac_length / 4; i++) {
int k;
k = i >> (3 - mod);
fac_data[i] = fMult(fac_data[i], alfd_gains[k])
<< 1; /* alfd_gains is scaled by one bit. */
}
}
static void CFac_CalcFacSignal(FIXP_DBL *pOut, FIXP_DBL *pFac,
const int fac_scale, const int fac_length,
const FIXP_LPC A[M_LP_FILTER_ORDER],
const INT A_exp, const int fAddZir,
const int isFdFac) {
FIXP_LPC wA[M_LP_FILTER_ORDER];
FIXP_DBL tf_gain = (FIXP_DBL)0;
int wlength;
int scale = fac_scale;
/* obtain tranform gain. */
imdct_gain(&tf_gain, &scale, isFdFac ? 0 : fac_length);
/* 4) Compute inverse DCT-IV of FAC data. Output scale of DCT IV is 16 bits.
*/
dct_IV(pFac, fac_length, &scale);
/* dct_IV scale = log2(fac_length). "- 7" is a factor of 2/128 */
if (tf_gain != (FIXP_DBL)0) { /* non-radix 2 transform gain */
int i;
for (i = 0; i < fac_length; i++) {
pFac[i] = fMult(tf_gain, pFac[i]);
}
}
scaleValuesSaturate(pOut, pFac, fac_length,
scale); /* Avoid overflow issues and saturate. */
E_LPC_a_weight(wA, A, M_LP_FILTER_ORDER);
/* We need the output of the IIR filter to be longer than "fac_length".
For this reason we run it with zero input appended to the end of the input
sequence, i.e. we generate its ZIR and extend the output signal.*/
FDKmemclear(pOut + fac_length, fac_length * sizeof(FIXP_DBL));
wlength = 2 * fac_length;
/* 5) Apply weighted synthesis filter to FAC data, including optional Zir (5.
* item 4). */
Syn_filt_zero(wA, A_exp, wlength, pOut);
}
INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac,
const int fac_scale, FIXP_LPC *A, INT A_exp,
INT nrOutSamples, const INT fac_length,
const INT isFdFac, UCHAR prevWindowShape) {
FIXP_DBL *pOvl;
FIXP_DBL *pOut0;
const FIXP_WTP *pWindow;
int i, fl, nrSamples = 0;
FDK_ASSERT(fac_length <= 1024 / (4 * 2));
fl = fac_length * 2;
pWindow = FDKgetWindowSlope(fl, prevWindowShape);
/* Adapt window slope length in case of frame loss. */
if (hMdct->prev_fr != fl) {
int nl = 0;
imdct_adapt_parameters(hMdct, &fl, &nl, fac_length, pWindow, nrOutSamples);
FDK_ASSERT(nl == 0);
}
if (nrSamples < nrOutSamples) {
pOut0 = output;
nrSamples += hMdct->ov_offset;
/* Purge buffered output. */
FDKmemcpy(pOut0, hMdct->overlap.time, hMdct->ov_offset * sizeof(pOut0[0]));
hMdct->ov_offset = 0;
}
pOvl = hMdct->overlap.freq + hMdct->ov_size - 1;
if (nrSamples >= nrOutSamples) {
pOut0 = hMdct->overlap.time + hMdct->ov_offset;
hMdct->ov_offset += hMdct->prev_nr + fl / 2;
} else {
pOut0 = output + nrSamples;
nrSamples += hMdct->prev_nr + fl / 2;
}
if (hMdct->prevPrevAliasSymmetry == 0) {
for (i = 0; i < hMdct->prev_nr; i++) {
FIXP_DBL x = -(*pOvl--);
*pOut0 = IMDCT_SCALE_DBL(x);
pOut0++;
}
} else {
for (i = 0; i < hMdct->prev_nr; i++) {
FIXP_DBL x = (*pOvl--);
*pOut0 = IMDCT_SCALE_DBL(x);
pOut0++;
}
}
hMdct->prev_nr = 0;
{
if (pFac != NULL) {
/* Note: The FAC gain might have been applied directly after bit stream
* parse in this case. */
CFac_CalcFacSignal(pOut0, pFac, fac_scale, fac_length, A, A_exp, 0,
isFdFac);
} else {
/* Clear buffer because of the overlap and ADD! */
FDKmemclear(pOut0, fac_length * sizeof(FIXP_DBL));
}
}
i = 0;
if (hMdct->prevPrevAliasSymmetry == 0) {
for (; i < fl / 2; i++) {
FIXP_DBL x0;
/* Overlap Add */
x0 = -fMult(*pOvl--, pWindow[i].v.re);
*pOut0 += IMDCT_SCALE_DBL(x0);
pOut0++;
}
} else {
for (; i < fl / 2; i++) {
FIXP_DBL x0;
/* Overlap Add */
x0 = fMult(*pOvl--, pWindow[i].v.re);
*pOut0 += IMDCT_SCALE_DBL(x0);
pOut0++;
}
}
if (hMdct->pFacZir !=
0) { /* this should only happen for ACELP -> TCX20 -> ACELP transition */
FIXP_DBL *pOut = pOut0 - fl / 2; /* fl/2 == fac_length */
for (i = 0; i < fl / 2; i++) {
pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
}
hMdct->pFacZir = NULL;
}
hMdct->prev_fr = 0;
hMdct->prev_nr = 0;
hMdct->prev_tl = 0;
hMdct->prevPrevAliasSymmetry = hMdct->prevAliasSymmetry;
return nrSamples;
}
INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *_pSpec,
const SHORT spec_scale[], const int nSpec,
FIXP_DBL *pFac, const int fac_scale,
const INT fac_length, INT noOutSamples, const INT tl,
const FIXP_WTP *wrs, const INT fr, FIXP_LPC A[16],
INT A_exp, CAcelpStaticMem *acelp_mem,
const FIXP_DBL gain, const int last_frame_lost,
const int isFdFac, const UCHAR last_lpd_mode,
const int k, int currAliasingSymmetry) {
FIXP_DBL *pCurr, *pOvl, *pSpec;
const FIXP_WTP *pWindow;
const FIXP_WTB *FacWindowZir_conceal;
UCHAR doFacZirConceal = 0;
int doDeemph = 1;
const FIXP_WTB *FacWindowZir, *FacWindowSynth;
FIXP_DBL *pOut0 = output, *pOut1;
int w, i, fl, nl, nr, f_len, nrSamples = 0, s = 0, scale, total_gain_e;
FIXP_DBL *pF, *pFAC_and_FAC_ZIR = NULL;
FIXP_DBL total_gain = gain;
FDK_ASSERT(fac_length <= 1024 / (4 * 2));
switch (fac_length) {
/* coreCoderFrameLength = 1024 */
case 128:
pWindow = SineWindow256;
FacWindowZir = FacWindowZir128;
FacWindowSynth = FacWindowSynth128;
break;
case 64:
pWindow = SineWindow128;
FacWindowZir = FacWindowZir64;
FacWindowSynth = FacWindowSynth64;
break;
case 32:
pWindow = SineWindow64;
FacWindowZir = FacWindowZir32;
FacWindowSynth = FacWindowSynth32;
break;
/* coreCoderFrameLength = 768 */
case 96:
pWindow = SineWindow192;
FacWindowZir = FacWindowZir96;
FacWindowSynth = FacWindowSynth96;
break;
case 48:
pWindow = SineWindow96;
FacWindowZir = FacWindowZir48;
FacWindowSynth = FacWindowSynth48;
break;
default:
FDK_ASSERT(0);
return 0;
}
FacWindowZir_conceal = FacWindowSynth;
/* Derive NR and NL */
fl = fac_length * 2;
nl = (tl - fl) >> 1;
nr = (tl - fr) >> 1;
if (noOutSamples > nrSamples) {
/* Purge buffered output. */
FDKmemcpy(pOut0, hMdct->overlap.time, hMdct->ov_offset * sizeof(pOut0[0]));
nrSamples = hMdct->ov_offset;
hMdct->ov_offset = 0;
}
if (nrSamples >= noOutSamples) {
pOut1 = hMdct->overlap.time + hMdct->ov_offset;
if (hMdct->ov_offset < fac_length) {
pOut0 = output + nrSamples;
} else {
pOut0 = pOut1;
}
hMdct->ov_offset += fac_length + nl;
} else {
pOut1 = output + nrSamples;
pOut0 = output + nrSamples;
}
{
pFAC_and_FAC_ZIR = CLpd_ACELP_GetFreeExcMem(acelp_mem, 2 * fac_length);
{
const FIXP_DBL *pTmp1, *pTmp2;
doFacZirConceal |= ((last_frame_lost != 0) && (k == 0));
doDeemph &= (last_lpd_mode != 4);
if (doFacZirConceal) {
/* ACELP contribution in concealment case:
Use ZIR with a modified ZIR window to preserve some more energy.
Dont use FAC, which contains wrong information for concealed frame
Dont use last ACELP samples, but double ZIR, instead (afterwards) */
FDKmemclear(pFAC_and_FAC_ZIR, 2 * fac_length * sizeof(FIXP_DBL));
FacWindowSynth = (FIXP_WTB *)pFAC_and_FAC_ZIR;
FacWindowZir = FacWindowZir_conceal;
} else {
CFac_CalcFacSignal(pFAC_and_FAC_ZIR, pFac, fac_scale + s, fac_length, A,
A_exp, 1, isFdFac);
}
/* 6) Get windowed past ACELP samples and ACELP ZIR signal */
/*
* Get ACELP ZIR (pFac[]) and ACELP past samples (pOut0[]) and add them
* to the FAC synth signal contribution on pOut1[].
*/
{
{
CLpd_Acelp_Zir(A, A_exp, acelp_mem, fac_length, pFac, doDeemph);
pTmp1 = pOut0;
pTmp2 = pFac;
}
for (i = 0, w = 0; i < fac_length; i++) {
FIXP_DBL x;
/* Div2 is compensated by table scaling */
x = fMultDiv2(pTmp2[i], FacWindowZir[w]);
x += fMultDiv2(pTmp1[-i - 1], FacWindowSynth[w]);
x += pFAC_and_FAC_ZIR[i];
pOut1[i] = x;
w++;
}
}
if (doFacZirConceal) {
/* ZIR is the only ACELP contribution, so double it */
scaleValues(pOut1, fac_length, 1);
}
}
}
if (nrSamples < noOutSamples) {
nrSamples += fac_length + nl;
}
/* Obtain transform gain */
total_gain = gain;
total_gain_e = 0;
imdct_gain(&total_gain, &total_gain_e, tl);
/* IMDCT overlap add */
scale = total_gain_e;
pSpec = _pSpec;
/* Note:when comming from an LPD frame (TCX/ACELP) the previous alisaing
* symmetry must always be 0 */
if (currAliasingSymmetry == 0) {
dct_IV(pSpec, tl, &scale);
} else {
FIXP_DBL _tmp[1024 + ALIGNMENT_DEFAULT / sizeof(FIXP_DBL)];
FIXP_DBL *tmp = (FIXP_DBL *)ALIGN_PTR(_tmp);
C_ALLOC_ALIGNED_REGISTER(tmp, sizeof(_tmp));
dst_III(pSpec, tmp, tl, &scale);
C_ALLOC_ALIGNED_UNREGISTER(tmp);
}
/* Optional scaling of time domain - no yet windowed - of current spectrum */
if (total_gain != (FIXP_DBL)0) {
scaleValuesWithFactor(pSpec, total_gain, tl, spec_scale[0] + scale);
} else {
scaleValues(pSpec, tl, spec_scale[0] + scale);
}
pOut1 += fl / 2 - 1;
pCurr = pSpec + tl - fl / 2;
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x1;
/* FAC signal is already on pOut1, because of that the += operator. */
x1 = fMult(*pCurr++, pWindow[i].v.re);
FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
pOut1 < hMdct->overlap.time + hMdct->ov_size) ||
(pOut1 >= output && pOut1 < output + 1024));
*pOut1 += IMDCT_SCALE_DBL(-x1);
pOut1--;
}
/* NL output samples TL/2+FL/2..TL. - current[FL/2..0] */
pOut1 += (fl / 2) + 1;
pFAC_and_FAC_ZIR += fac_length; /* set pointer to beginning of FAC ZIR */
if (nl == 0) {
/* save pointer to write FAC ZIR data later */
hMdct->pFacZir = pFAC_and_FAC_ZIR;
} else {
FDK_ASSERT(nl >= fac_length);
/* FAC ZIR will be added now ... */
hMdct->pFacZir = NULL;
}
pF = pFAC_and_FAC_ZIR;
f_len = fac_length;
pCurr = pSpec + tl - fl / 2 - 1;
for (i = 0; i < nl; i++) {
FIXP_DBL x = -(*pCurr--);
/* 5) (item 4) Synthesis filter Zir component, FAC ZIR (another one). */
if (i < f_len) {
x += *pF++;
}
FDK_ASSERT((pOut1 >= hMdct->overlap.time &&
pOut1 < hMdct->overlap.time + hMdct->ov_size) ||
(pOut1 >= output && pOut1 < output + 1024));
*pOut1 = IMDCT_SCALE_DBL(x);
pOut1++;
}
hMdct->prev_nr = nr;
hMdct->prev_fr = fr;
hMdct->prev_wrs = wrs;
hMdct->prev_tl = tl;
hMdct->prevPrevAliasSymmetry = hMdct->prevAliasSymmetry;
hMdct->prevAliasSymmetry = currAliasingSymmetry;
fl = fr;
nl = nr;
pOvl = pSpec + tl / 2 - 1;
pOut0 = pOut1;
for (w = 1; w < nSpec; w++) /* for ACELP -> FD short */
{
const FIXP_WTP *pWindow_prev;
/* Setup window pointers */
pWindow_prev = hMdct->prev_wrs;
/* Current spectrum */
pSpec = _pSpec + w * tl;
scale = total_gain_e;
/* For the second, third, etc. short frames the alisaing symmetry is equal,
* either (0,0) or (1,1) */
if (currAliasingSymmetry == 0) {
/* DCT IV of current spectrum */
dct_IV(pSpec, tl, &scale);
} else {
dst_IV(pSpec, tl, &scale);
}
/* Optional scaling of time domain - no yet windowed - of current spectrum
*/
/* and de-scale current spectrum signal (time domain, no yet windowed) */
if (total_gain != (FIXP_DBL)0) {
scaleValuesWithFactor(pSpec, total_gain, tl, spec_scale[w] + scale);
} else {
scaleValues(pSpec, tl, spec_scale[w] + scale);
}
if (noOutSamples <= nrSamples) {
/* Divert output first half to overlap buffer if we already got enough
* output samples. */
pOut0 = hMdct->overlap.time + hMdct->ov_offset;
hMdct->ov_offset += hMdct->prev_nr + fl / 2;
} else {
/* Account output samples */
nrSamples += hMdct->prev_nr + fl / 2;
}
/* NR output samples 0 .. NR. -overlap[TL/2..TL/2-NR] */
for (i = 0; i < hMdct->prev_nr; i++) {
FIXP_DBL x = -(*pOvl--);
*pOut0 = IMDCT_SCALE_DBL(x);
pOut0++;
}
if (noOutSamples <= nrSamples) {
/* Divert output second half to overlap buffer if we already got enough
* output samples. */
pOut1 = hMdct->overlap.time + hMdct->ov_offset + fl / 2 - 1;
hMdct->ov_offset += fl / 2 + nl;
} else {
pOut1 = pOut0 + (fl - 1);
nrSamples += fl / 2 + nl;
}
/* output samples before window crossing point NR .. TL/2.
* -overlap[TL/2-NR..TL/2-NR-FL/2] + current[NR..TL/2] */
/* output samples after window crossing point TL/2 .. TL/2+FL/2.
* -overlap[0..FL/2] - current[TL/2..FL/2] */
pCurr = pSpec + tl - fl / 2;
if (currAliasingSymmetry == 0) {
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x0, x1;
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
*pOut0 = IMDCT_SCALE_DBL(x0);
*pOut1 = IMDCT_SCALE_DBL(-x1);
pOut0++;
pOut1--;
}
} else {
if (hMdct->prevPrevAliasSymmetry == 0) {
/* Jump DST II -> DST IV for the second window */
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x0, x1;
cplxMult(&x1, &x0, *pCurr++, -*pOvl--, pWindow_prev[i]);
*pOut0 = IMDCT_SCALE_DBL(x0);
*pOut1 = IMDCT_SCALE_DBL(x1);
pOut0++;
pOut1--;
}
} else {
/* Jump DST IV -> DST IV from the second window on */
for (i = 0; i < fl / 2; i++) {
FIXP_DBL x0, x1;
cplxMult(&x1, &x0, *pCurr++, *pOvl--, pWindow_prev[i]);
*pOut0 = IMDCT_SCALE_DBL(x0);
*pOut1 = IMDCT_SCALE_DBL(x1);
pOut0++;
pOut1--;
}
}
}
if (hMdct->pFacZir != 0) {
/* add FAC ZIR of previous ACELP -> mdct transition */
FIXP_DBL *pOut = pOut0 - fl / 2;
FDK_ASSERT(fl / 2 <= 128);
for (i = 0; i < fl / 2; i++) {
pOut[i] += IMDCT_SCALE_DBL(hMdct->pFacZir[i]);
}
hMdct->pFacZir = NULL;
}
pOut0 += (fl / 2);
/* NL output samples TL/2+FL/2..TL. - current[FL/2..0] */
pOut1 += (fl / 2) + 1;
pCurr = pSpec + tl - fl / 2 - 1;
for (i = 0; i < nl; i++) {
FIXP_DBL x = -(*pCurr--);
*pOut1 = IMDCT_SCALE_DBL(x);
pOut1++;
}
/* Set overlap source pointer for next window pOvl = pSpec + tl/2 - 1; */
pOvl = pSpec + tl / 2 - 1;
/* Previous window values. */
hMdct->prev_nr = nr;
hMdct->prev_fr = fr;
hMdct->prev_tl = tl;
hMdct->prev_wrs = pWindow_prev;
hMdct->prevPrevAliasSymmetry = hMdct->prevAliasSymmetry;
hMdct->prevAliasSymmetry = currAliasingSymmetry;
}
/* Save overlap */
pOvl = hMdct->overlap.freq + hMdct->ov_size - tl / 2;
FDK_ASSERT(pOvl >= hMdct->overlap.time + hMdct->ov_offset);
FDK_ASSERT(tl / 2 <= hMdct->ov_size);
for (i = 0; i < tl / 2; i++) {
pOvl[i] = _pSpec[i + (w - 1) * tl];
}
return nrSamples;
}

191
libAACdec/src/usacdec_fac.h Normal file
View File

@ -0,0 +1,191 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC FAC
*******************************************************************************/
#ifndef USACDEC_FAC_H
#define USACDEC_FAC_H
#include "channelinfo.h"
#include "FDK_bitstream.h"
/**
* \brief Get the address of a memory area of the spectral data memory were the
* FAC data can be stored into.
* \param spec SPECTRAL_PTR pointing to the current spectral data.
* \param mod the current LPD mod array.
* \param pState pointer to a private state variable which must be 0 for the
* first call and not changed externally.
* \param isFullbandLPD is 1 if fullband LPD mode is on, otherwise it is 0.
*/
FIXP_DBL *CLpd_FAC_GetMemory(CAacDecoderChannelInfo *pAacDecoderChannelInfo,
UCHAR mod[NB_SUBFR], int *pState);
/**
* \brief read a fac bitstream data block.
* \param hBs a bit stream handle, where the fac bitstream data is located.
* \param pFac pointer to were the FAC data will be stored into.
* \param pFacScale pointer to were the FAC data scale value will be stored
* into.
* \param tcx_gain value to be used as FAC gain. If zero, read fac_gain from
* bitstream.
* \param tcx_gain_e exponen value of tcx_gain.
* \param frame the subframe to be considered from the current superframe.
* Always 0 for FD case.
* \return 0 on success, -1 on error.
*/
int CLpd_FAC_Read(HANDLE_FDK_BITSTREAM hBs, FIXP_DBL *pFac, UCHAR *pFacScale,
int length, int use_gain, int frame);
/**
* \brief Apply TCX and ALFD gains to FAC data.
* \param fac_data pointer to FAC data.
* \param fac_length FAC length (128 or 96).
* \param tcx_gain TCX gain
* \param alfd_gains pointer to alfd gains.
* \param mod mod value (1,2,3) of TCX frame where the FAC signal needs to be
* applied.
*/
void CFac_ApplyGains(FIXP_DBL fac_data[LFAC], const INT fac_length,
const FIXP_DBL tcx_gain, const FIXP_DBL alfd_gains[],
const INT mod);
/**
* \brief Do FAC transition from frequency domain to ACELP domain.
*/
INT CLpd_FAC_Mdct2Acelp(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pFac_data,
const int fac_data_e, FIXP_LPC *A, INT A_exp,
INT nrOutSamples, const INT fac_length,
const INT isFdFac, UCHAR prevWindowShape);
/**
* \brief Do FAC transition from ACELP domain to frequency domain.
* \param hMdct MDCT context.
* \param output pointer for time domain output.
* \param pSpec pointer to MDCT spectrum input.
* \param spec_scale MDCT spectrum exponents.
* \param nSpec amount of contiguos MDCT spectra.
* \param pFac pointer to FAC MDCT domain data.
* \param fac_scale exponent of FAC data.
* \param fac_length length of FAC data.
* \param nrSamples room in samples in output buffer.
* \param tl MDCT transform length of pSpec.
* \param wrs right MDCT window slope.
* \param fr right MDCT window slope length.
* \param A LP domain filter coefficients.
* \param deemph_mem deemphasis filter state.
* \param gain gain to be applied to FAC data before overlap add.
* \param old_syn_mem Synthesis filter state.
* \param isFdFac indicates fac processing from or to FD.
* \param pFacData fac data stored for fullband LPD.
* \param elFlags element specific parser guidance flags.
* \param isFacForFullband indicates that fac is processed for fullband LPD.
*/
INT CLpd_FAC_Acelp2Mdct(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *pSpec,
const SHORT spec_scale[], const int nSpec,
FIXP_DBL *pFac_data, const int fac_data_e,
const INT fac_length, INT nrSamples, const INT tl,
const FIXP_WTP *wrs, const INT fr, FIXP_LPC A[16],
INT A_exp, CAcelpStaticMem *acelp_mem,
const FIXP_DBL gain, const int last_frame_lost,
const int isFdFac, const UCHAR last_lpd, const int k,
int currAliasingSymmetry);
#endif /* USACDEC_FAC_H */

File diff suppressed because it is too large Load Diff

190
libAACdec/src/usacdec_lpc.h Normal file
View File

@ -0,0 +1,190 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Matthias Hildenbrand, Manuel Jander
Description: USAC LPC/AVQ decode
*******************************************************************************/
#ifndef USACDEC_LPC_H
#define USACDEC_LPC_H
#include "channelinfo.h"
#include "common_fix.h"
#include "FDK_bitstream.h"
#include "usacdec_rom.h"
#define LSPARG_SCALE 10
/**
* \brief AVQ (refinement) decode
* \param hBs bitstream handle
* \param lsfq buffer for AVQ decode output.
* \param nk_mode quantization mode.
* \param nqn amount of split/interleaved RE8 vectors.
* \param total amount of individual data values to decode.
* \return 0 on success, -1 on error.
*/
int CLpc_DecodeAVQ(HANDLE_FDK_BITSTREAM hBs, FIXP_DBL *lsfq, int nk_mode,
int nqn, int length);
/**
* \brief Read and decode LPC coeficient sets. First stage approximation + AVQ
* decode.
* \param[in] hBs bitstream handle to read data from.
* \param[out] lsp buffer into which the decoded LSP coefficients will be stored
* into.
* \param[in,out] lpc4_lsf buffer into which the decoded LCP4 LSF coefficients
* will be stored into (persistent).
* \param[out] lsf_adaptive_mean_cand lsf adaptive mean vector needed for
* concealment.
* \param[out] pStability array with stability values for the ACELP decoder (and
* concealment).
* \param[in] mod array which defines modes (ACELP, TCX20|40|80) are used in
* the current superframe.
* \param[in] first_lpd_flag indicates the presence of LPC0
* \param[in] last_lpc_lost indicate that LPC4 of previous frame was lost.
* \param[in] last_frame_ok indicate that the last frame was ok.
* \return 0 on success, -1 on error.
*/
int CLpc_Read(HANDLE_FDK_BITSTREAM hBs, FIXP_LPC lsp[][M_LP_FILTER_ORDER],
FIXP_LPC lpc4_lsf[M_LP_FILTER_ORDER],
FIXP_LPC lsf_adaptive_mean_cand[M_LP_FILTER_ORDER],
FIXP_SGL pStability[], UCHAR *mod, int first_lpd_flag,
int last_lpc_lost, int last_frame_ok);
/**
* \brief Generate LPC coefficient sets in case frame loss.
* \param lsp buffer into which the decoded LSP coefficients will be stored
* into.
* \param lpc4_lsf buffer into which the decoded LCP4 LSF coefficients will be
* stored into (persistent).
* \param isf_adaptive_mean
* \param first_lpd_flag indicates the previous LSF4 coefficients lpc4_lsf[] are
* not valid.
*/
void CLpc_Conceal(FIXP_LPC lsp[][M_LP_FILTER_ORDER],
FIXP_LPC lpc4_lsf[M_LP_FILTER_ORDER],
FIXP_LPC isf_adaptive_mean[M_LP_FILTER_ORDER],
const int first_lpd_flag);
/**
* \brief apply absolute weighting
* \param A weighted LPC coefficient vector output. The first coeffcient is
* implicitly 1.0
* \param A LPC coefficient vector. The first coeffcient is implicitly 1.0
* \param m length of vector A
*/
/* static */
void E_LPC_a_weight(FIXP_LPC *wA, const FIXP_LPC *A, const int m);
/**
* \brief decode TCX/FAC gain. In case of TCX the lg/sqrt(rms) part
* must still be applied to obtain the gain value.
* \param gain (o) pointer were the gain mantissa is stored into.
* \param gain_e (o) pointer were the gain exponent is stored into.
* \param gain_code (i) the 7 bit binary word from the bitstream
* representing the gain.
*/
void CLpd_DecodeGain(FIXP_DBL *gain, INT *gain_e, int gain_code);
/**
* \brief convert LSP coefficients into LP domain.
*/
void E_LPC_f_lsp_a_conversion(FIXP_LPC *lsp, FIXP_LPC *a, INT *a_exp);
#endif /* USACDEC_LPC_H */

File diff suppressed because it is too large Load Diff

198
libAACdec/src/usacdec_lpd.h Normal file
View File

@ -0,0 +1,198 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): Manuel Jander
Description: USAC Linear Prediction Domain coding
*******************************************************************************/
#ifndef USACDEC_LPD_H
#define USACDEC_LPD_H
#include "channelinfo.h"
#define OPTIMIZE_AVG_PERFORMANCE
/**
* \brief read a lpd_channel_stream.
* \param hBs a bit stream handle, where the lpd_channel_stream is located.
* \param pAacDecoderChannelInfo the channel context structure for storing read
* data.
* \param flags bit stream syntax flags.
* \return AAC_DECODER_ERROR error code.
*/
AAC_DECODER_ERROR CLpdChannelStream_Read(
HANDLE_FDK_BITSTREAM hBs, CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
const SamplingRateInfo *pSamplingRateInfo, UINT flags);
/**
* \brief decode one lpd_channel_stream and render the audio output.
* \param pAacDecoderChannelInfo struct holding the channel information to be
* rendered.
* \param pAacDecoderStaticChannelInfo struct holding the persistent channel
* information to be rendered.
* \param pSamplingRateInfo holds the sampling rate information
* \param elFlags holds the internal decoder flags
*/
void CLpdChannelStream_Decode(
CAacDecoderChannelInfo *pAacDecoderChannelInfo,
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo, UINT flags);
/**
* \brief generate time domain output signal for LPD channel streams
* \param pAacDecoderStaticChannelInfo
* \param pAacDecoderChannelInfo
* \param pTimeData pointer to output buffer
* \param samplesPerFrame amount of output samples
* \param pSamplingRateInfo holds the sampling rate information
* \param pWorkBuffer1 pointer to work buffer for temporal data
*/
AAC_DECODER_ERROR CLpd_RenderTimeSignal(
CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo,
CAacDecoderChannelInfo *pAacDecoderChannelInfo, FIXP_PCM *pTimeData,
INT samplesPerFrame, SamplingRateInfo *pSamplingRateInfo, UINT frameOk,
UINT flags, UINT strmFlags);
static inline INT CLpd_FAC_getLength(int fNotShortBlock, int fac_length_long) {
if (fNotShortBlock) {
return (fac_length_long);
} else {
return fac_length_long / 2;
}
}
void filtLP(const FIXP_DBL *syn, FIXP_PCM *syn_out, FIXP_DBL *noise,
const FIXP_SGL *filt, INT stop, int len);
/**
* \brief perform a low-frequency pitch enhancement on time domain signal
* \param[in] syn pointer to time domain input signal
* \param[in] synFB pointer to time domain input signal
* \param[in] upsampling factor
* \param[in] T_sf array with past decoded pitch period values for each subframe
* \param[in] non_zero_gain_flags indicates whether pitch gains of past
* subframes are zero or not, msb -> [1 BPF_DELAY subfr][7 SYN_DELAY subfr][16
* new subfr] <- lsb
* \param[in] l_frame length of filtering, must be multiple of L_SUBFR
* \param[in] l_next length of allowed look ahead on syn[i], i < l_frame+l_next
* \param[out] synth_out pointer to time domain output signal
* \param[in,out] mem_bpf pointer to filter memory (L_FILT+L_SUBFR)
*/
void bass_pf_1sf_delay(FIXP_DBL syn[], const INT T_sf[], FIXP_DBL *pit_gain,
const int frame_length, const INT l_frame,
const INT l_next, FIXP_PCM *synth_out,
FIXP_DBL mem_bpf[]);
/**
* \brief random sign generator for FD and TCX noise filling
* \param[in,out] seed pointer to random seed
* \return if return value is zero use positive sign
* \Note: This code is also implemented as a copy in block.cpp, grep for
* "UsacRandomSign"
*/
FDK_INLINE
int UsacRandomSign(ULONG *seed) {
*seed = (ULONG)((UINT64)(*seed) * 69069 + 5);
return (int)((*seed) & 0x10000);
}
void CFdp_Reset(CAacDecoderStaticChannelInfo *pAacDecoderStaticChannelInfo);
#endif /* USACDEC_LPD_H */

File diff suppressed because it is too large Load Diff

154
libAACdec/src/usacdec_rom.h Normal file
View File

@ -0,0 +1,154 @@
/* -----------------------------------------------------------------------------
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
----------------------------------------------------------------------------- */
/**************************** AAC decoder library ******************************
Author(s): M. Jander
Description: re8.h
*******************************************************************************/
#ifndef USACDEC_ROM_H
#define USACDEC_ROM_H
#include "common_fix.h"
#include "FDK_lpc.h"
#include "usacdec_const.h"
/* RE8 lattice quantiser constants */
#define NB_SPHERE 32
#define NB_LEADER 37
#define NB_LDSIGN 226
#define NB_LDQ3 9
#define NB_LDQ4 28
#define LSF_SCALE 13
/* RE8 lattice quantiser tables */
extern const UINT fdk_dec_tab_factorial[8];
extern const UCHAR fdk_dec_Ia[NB_LEADER];
extern const UCHAR fdk_dec_Ds[NB_LDSIGN];
extern const USHORT fdk_dec_Is[NB_LDSIGN];
extern const UCHAR fdk_dec_Ns[], fdk_dec_A3[], fdk_dec_A4[];
extern const UCHAR fdk_dec_Da[][8];
extern const USHORT fdk_dec_I3[], fdk_dec_I4[];
/* temp float tables for LPC decoding */
extern const FIXP_LPC fdk_dec_lsf_init[16];
extern const FIXP_LPC fdk_dec_dico_lsf_abs_8b[16 * 256];
/* ACELP tables */
#define SF_QUA_GAIN7B 4
extern const FIXP_SGL t_qua_gain7b[128 * 2];
extern const FIXP_SGL lsp_interpol_factor[2][NB_SUBFR];
/* For bass post filter */
#define L_FILT 12 /* Delay of up-sampling filter */
extern const FIXP_SGL fdk_dec_filt_lp[1 + L_FILT];
extern const FIXP_WTB FacWindowSynth128[128];
extern const FIXP_WTB FacWindowZir128[128];
extern const FIXP_WTB FacWindowSynth64[64];
extern const FIXP_WTB FacWindowZir64[64];
extern const FIXP_WTB FacWindowSynth32[32];
extern const FIXP_WTB FacWindowZir32[32];
extern const FIXP_WTB FacWindowSynth96[96];
extern const FIXP_WTB FacWindowZir96[96];
extern const FIXP_WTB FacWindowSynth48[48];
extern const FIXP_WTB FacWindowZir48[48];
#endif /* USACDEC_ROM_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,16 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/****************************************************************************** /**************************** AAC encoder library ******************************
Initial authors: M. Lohwasser, M. Gayer Author(s): M. Lohwasser, M. Gayer
Contents/description:
Description:
*******************************************************************************/
******************************************************************************/
/*! /*!
\file \file
\brief Memory layout \brief Memory layout
@ -98,28 +111,28 @@ amm-info@iis.fraunhofer.de
C_AALLOC_MEM(AACdynamic_RAM, FIXP_DBL, AAC_ENC_DYN_RAM_SIZE / sizeof(FIXP_DBL)) C_AALLOC_MEM(AACdynamic_RAM, FIXP_DBL, AAC_ENC_DYN_RAM_SIZE / sizeof(FIXP_DBL))
/* /*
Static memory areas, must not be overwritten in other sections of the decoder ! Static memory areas, must not be overwritten in other sections of the decoder
!
*/ */
/* /*
The structure AacEncoder contains all Encoder structures. The structure AacEncoder contains all Encoder structures.
*/ */
C_ALLOC_MEM (Ram_aacEnc_AacEncoder, AAC_ENC, 1) C_ALLOC_MEM(Ram_aacEnc_AacEncoder, struct AAC_ENC, 1)
/* /*
The structure PSY_INTERNAl contains all psych configuration and data pointer. The structure PSY_INTERNAl contains all psych configuration and data pointer.
* PsyStatic holds last and current Psych data. * PsyStatic holds last and current Psych data.
* PsyInputBuffer contains time input. Signal is needed at the beginning of Psych. * PsyInputBuffer contains time input. Signal is needed at the beginning of
Memory can be reused after signal is in time domain. Psych. Memory can be reused after signal is in time domain.
* PsyData contains spectral, nrg and threshold information. Necessary data are * PsyData contains spectral, nrg and threshold information. Necessary data
copied into PsyOut, so memory is available after leaving psych. are copied into PsyOut, so memory is available after leaving psych.
* TnsData, ChaosMeasure, PnsData are temporarily necessary, e.g. use memory from * TnsData, ChaosMeasure, PnsData are temporarily necessary, e.g. use memory
PsyInputBuffer. from PsyInputBuffer.
*/ */
C_ALLOC_MEM2 (Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, (8)) C_ALLOC_MEM2(Ram_aacEnc_PsyElement, PSY_ELEMENT, 1, ((8)))
C_ALLOC_MEM(Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1) C_ALLOC_MEM(Ram_aacEnc_PsyInternal, PSY_INTERNAL, 1)
C_ALLOC_MEM2(Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8)) C_ALLOC_MEM2(Ram_aacEnc_PsyStatic, PSY_STATIC, 1, (8))
@ -128,67 +141,68 @@ C_ALLOC_MEM2 (Ram_aacEnc_PsyInputBuffer, INT_PCM, MAX_INPUT_BUFFER_SIZE, (8))
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic(int n, UCHAR *dynamic_RAM) { PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0); FDK_ASSERT(dynamic_RAM != 0);
return ((PSY_DYNAMIC*) (dynamic_RAM + P_BUF_1 + n*sizeof(PSY_DYNAMIC))); /* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_1 + n*sizeof(PSY_DYNAMIC)) is sufficiently aligned, so
* the cast is safe */
return reinterpret_cast<PSY_DYNAMIC *>(reinterpret_cast<void *>(
dynamic_RAM + P_BUF_1 + n * sizeof(PSY_DYNAMIC)));
} }
C_ALLOC_MEM (Ram_bsOutbuffer, UCHAR, OUTPUTBUFFER_SIZE)
/* /*
The structure PSY_OUT holds all psychoaccoustic data needed The structure PSY_OUT holds all psychoaccoustic data needed
in quantization module in quantization module
*/ */
C_ALLOC_MEM2(Ram_aacEnc_PsyOut, PSY_OUT, 1, (1)) C_ALLOC_MEM2(Ram_aacEnc_PsyOut, PSY_OUT, 1, (1))
C_ALLOC_MEM2 (Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1)*(8)) C_ALLOC_MEM2(Ram_aacEnc_PsyOutElements, PSY_OUT_ELEMENT, 1, (1) * ((8)))
C_ALLOC_MEM2(Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1) * (8)) C_ALLOC_MEM2(Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL, 1, (1) * (8))
/* /*
The structure QC_STATE contains preinitialized settings and quantizer structures. The structure QC_STATE contains preinitialized settings and quantizer
structures.
* AdjustThreshold structure contains element-wise settings. * AdjustThreshold structure contains element-wise settings.
* ElementBits contains elemnt-wise bit consumption settings. * ElementBits contains elemnt-wise bit consumption settings.
* When CRC is active, lookup table is necessary for fast crc calculation. * When CRC is active, lookup table is necessary for fast crc calculation.
* Bitcounter contains buffer to find optimal codebooks and minimal bit consumption. * Bitcounter contains buffer to find optimal codebooks and minimal bit
Values are temporarily, so dynamic memory can be used. consumption. Values are temporarily, so dynamic memory can be used.
*/ */
C_ALLOC_MEM(Ram_aacEnc_QCstate, QC_STATE, 1) C_ALLOC_MEM(Ram_aacEnc_QCstate, QC_STATE, 1)
C_ALLOC_MEM(Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1) C_ALLOC_MEM(Ram_aacEnc_AdjustThreshold, ADJ_THR_STATE, 1)
C_ALLOC_MEM2 (Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, (8)) C_ALLOC_MEM2(Ram_aacEnc_AdjThrStateElement, ATS_ELEMENT, 1, ((8)))
C_ALLOC_MEM2 (Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, (8)) C_ALLOC_MEM2(Ram_aacEnc_ElementBits, ELEMENT_BITS, 1, ((8)))
C_ALLOC_MEM (Ram_aacEnc_BitCntrState, BITCNTR_STATE, 1) C_ALLOC_MEM(Ram_aacEnc_BitCntrState, struct BITCNTR_STATE, 1)
INT *GetRam_aacEnc_BitLookUp(int n, UCHAR *dynamic_RAM) { INT *GetRam_aacEnc_BitLookUp(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0); FDK_ASSERT(dynamic_RAM != 0);
return ((INT*) (dynamic_RAM + P_BUF_1)); /* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_1) is sufficiently aligned, so the cast is safe */
return reinterpret_cast<INT *>(
reinterpret_cast<void *>(dynamic_RAM + P_BUF_1));
} }
INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR *dynamic_RAM) { INT *GetRam_aacEnc_MergeGainLookUp(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0); FDK_ASSERT(dynamic_RAM != 0);
return ((INT*) (dynamic_RAM + P_BUF_1 + sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)))); /* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_1 + sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)))
* is sufficiently aligned, so the cast is safe */
return reinterpret_cast<INT *>(reinterpret_cast<void *>(
dynamic_RAM + P_BUF_1 +
sizeof(INT) * (MAX_SFB_LONG * (CODE_BOOK_ESC_NDX + 1))));
} }
/* /*
The structure QC_OUT contains settings and structures holding all necessary information The structure QC_OUT contains settings and structures holding all necessary
needed in bitstreamwriter. information needed in bitstreamwriter.
*/ */
C_ALLOC_MEM2(Ram_aacEnc_QCout, QC_OUT, 1, (1)) C_ALLOC_MEM2(Ram_aacEnc_QCout, QC_OUT, 1, (1))
C_ALLOC_MEM2 (Ram_aacEnc_QCelement, QC_OUT_ELEMENT, (1), (8)) C_ALLOC_MEM2(Ram_aacEnc_QCelement, QC_OUT_ELEMENT, 1, (1) * ((8)))
QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel(int n, UCHAR *dynamic_RAM) { QC_OUT_CHANNEL *GetRam_aacEnc_QCchannel(int n, UCHAR *dynamic_RAM) {
FDK_ASSERT(dynamic_RAM != 0); FDK_ASSERT(dynamic_RAM != 0);
return ((QC_OUT_CHANNEL*) (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL))); /* The reinterpret_cast is used to suppress a compiler warning. We know that
* (dynamic_RAM + P_BUF_0 + n*sizeof(QC_OUT_CHANNEL)) is sufficiently aligned,
* so the cast is safe */
return reinterpret_cast<QC_OUT_CHANNEL *>(reinterpret_cast<void *>(
dynamic_RAM + P_BUF_0 + n * sizeof(QC_OUT_CHANNEL)));
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/****************************************************************************** /**************************** AAC encoder library ******************************
Initial authors: M. Lohwasser, M. Gayer Author(s): M. Lohwasser, M. Gayer
Contents/description:
******************************************************************************/ Description:
*******************************************************************************/
/*! /*!
\file \file
@ -94,8 +106,8 @@ amm-info@iis.fraunhofer.de
\author Markus Lohwasser \author Markus Lohwasser
*/ */
#ifndef AAC_ENC_RAM_H #ifndef AACENC_RAM_H
#define AAC_ENC_RAM_H #define AACENC_RAM_H
#include "common_fix.h" #include "common_fix.h"
@ -107,24 +119,27 @@ amm-info@iis.fraunhofer.de
#include "bit_cnt.h" #include "bit_cnt.h"
#include "psy_const.h" #include "psy_const.h"
#define OUTPUTBUFFER_SIZE (8192) /*!< Output buffer size has to be at least 6144 bits per channel (768 bytes). FDK bitbuffer implementation expects buffer of size 2^n. */ #define OUTPUTBUFFER_SIZE \
(8192) /*!< Output buffer size has to be at least 6144 bits per channel \
(768 bytes). FDK bitbuffer implementation expects buffer of \
size 2^n. */
/* /*
Moved AAC_ENC struct definition from aac_enc.cpp into aacEnc_ram.h to get size and respective Moved AAC_ENC struct definition from aac_enc.cpp into aacEnc_ram.h to get size
static memory in aacEnc_ram.cpp. and respective static memory in aacEnc_ram.cpp. aac_enc.h is the outward
aac_enc.h is the outward visible header file and putting the struct into would cause necessity visible header file and putting the struct into would cause necessity of
of additional visible header files outside library. additional visible header files outside library.
*/ */
/* define hBitstream size: max AAC framelength is 6144 bits/channel */ /* define hBitstream size: max AAC framelength is 6144 bits/channel */
/*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) / bbWordSize))*/ /*#define BUFFER_BITSTR_SIZE ((6400*(8)/bbWordSize) +((bbWordSize - 1) /
* bbWordSize))*/
struct AAC_ENC { struct AAC_ENC {
AACENC_CONFIG *config; AACENC_CONFIG *config;
INT ancillaryBitsPerFrame; /* ancillary bits per frame calculated from ancillary rate */ INT ancillaryBitsPerFrame; /* ancillary bits per frame calculated from
ancillary rate */
CHANNEL_MAPPING channelMapping; CHANNEL_MAPPING channelMapping;
@ -144,45 +159,56 @@ struct AAC_ENC {
FIXP_DBL *dynamic_RAM; FIXP_DBL *dynamic_RAM;
INT maxChannels; /* used while allocation */ INT maxChannels; /* used while allocation */
INT maxElements; INT maxElements;
INT maxFrames; INT maxFrames;
AUDIO_OBJECT_TYPE aot; /* AOT to be used while encoding. */ AUDIO_OBJECT_TYPE aot; /* AOT to be used while encoding. */
}; };
#define maxSize(a, b) (((a) > (b)) ? (a) : (b)) #define maxSize(a, b) (((a) > (b)) ? (a) : (b))
#define BIT_LOOK_UP_SIZE ( sizeof(INT)*(MAX_SFB_LONG*(CODE_BOOK_ESC_NDX+1)) ) #define BIT_LOOK_UP_SIZE \
(sizeof(INT) * (MAX_SFB_LONG * (CODE_BOOK_ESC_NDX + 1)))
#define MERGE_GAIN_LOOK_UP_SIZE (sizeof(INT) * MAX_SFB_LONG) #define MERGE_GAIN_LOOK_UP_SIZE (sizeof(INT) * MAX_SFB_LONG)
/* Size of AhFlag buffer in function FDKaacEnc_adaptThresholdsToPe() */
#define ADJ_THR_AH_FLAG_SIZE (sizeof(UCHAR) * ((8)) * (2) * MAX_GROUPED_SFB)
/* Size of ThrExp buffer in function FDKaacEnc_adaptThresholdsToPe() */
#define ADJ_THR_THR_EXP_SIZE (sizeof(FIXP_DBL) * ((8)) * (2) * MAX_GROUPED_SFB)
/* Size of sfbNActiveLinesLdData buffer in function FDKaacEnc_correctThresh() */
#define ADJ_THR_ACT_LIN_LD_DATA_SIZE \
(sizeof(FIXP_DBL) * ((8)) * (2) * MAX_GROUPED_SFB)
/* Total amount of dynamic buffer needed in adjust thresholds functionality */
#define ADJ_THR_SIZE \
(ADJ_THR_AH_FLAG_SIZE + ADJ_THR_THR_EXP_SIZE + ADJ_THR_ACT_LIN_LD_DATA_SIZE)
/* Dynamic RAM - Allocation */ /* Dynamic RAM - Allocation */
/* /*
++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++
| P_BUF_0 | P_BUF_1 | | P_BUF_0 | P_BUF_1 |
++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++
| QC_OUT_CH | PSY_DYN | | QC_OUT_CH | PSY_DYN |
++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++
| | BitLookUp+MergeGainLookUp | | | BitLookUp+MergeGainLookUp |
++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++
| | AH_FLAG | THR_EXP | ACT_LIN_LD_DATA |
+++++++++++++++++++++++++++++++++++++++++++++++++++++
| | Bitstream output buffer | | | Bitstream output buffer |
++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++
*/ */
#define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL) * (8))) #define BUF_SIZE_0 (ALIGN_SIZE(sizeof(QC_OUT_CHANNEL) * (8)))
#define BUF_SIZE_1 ( ALIGN_SIZE(maxSize(sizeof(PSY_DYNAMIC), \ #define BUF_SIZE_1 \
(BIT_LOOK_UP_SIZE+MERGE_GAIN_LOOK_UP_SIZE))) ) (ALIGN_SIZE(maxSize(maxSize(sizeof(PSY_DYNAMIC), \
(BIT_LOOK_UP_SIZE + MERGE_GAIN_LOOK_UP_SIZE)), \
ADJ_THR_SIZE)))
#define P_BUF_0 (0) #define P_BUF_0 (0)
#define P_BUF_1 (P_BUF_0 + BUF_SIZE_0) #define P_BUF_1 (P_BUF_0 + BUF_SIZE_0)
#define AAC_ENC_DYN_RAM_SIZE (BUF_SIZE_0 + BUF_SIZE_1) #define AAC_ENC_DYN_RAM_SIZE (BUF_SIZE_0 + BUF_SIZE_1)
H_ALLOC_MEM(AACdynamic_RAM, FIXP_DBL) H_ALLOC_MEM(AACdynamic_RAM, FIXP_DBL)
/* /*
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -200,7 +226,6 @@ END - Dynamic RAM - Allocation */
H_ALLOC_MEM(Ram_aacEnc_PsyInputBuffer, INT_PCM) H_ALLOC_MEM(Ram_aacEnc_PsyInputBuffer, INT_PCM)
PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic(int n, UCHAR *dynamic_RAM); PSY_DYNAMIC *GetRam_aacEnc_PsyDynamic(int n, UCHAR *dynamic_RAM);
H_ALLOC_MEM (Ram_bsOutbuffer, UCHAR)
H_ALLOC_MEM(Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL) H_ALLOC_MEM(Ram_aacEnc_PsyOutChannel, PSY_OUT_CHANNEL)
@ -221,6 +246,4 @@ END - Dynamic RAM - Allocation */
H_ALLOC_MEM(Ram_aacEnc_QCout, QC_OUT) H_ALLOC_MEM(Ram_aacEnc_QCout, QC_OUT)
H_ALLOC_MEM(Ram_aacEnc_QCelement, QC_OUT_ELEMENT) H_ALLOC_MEM(Ram_aacEnc_QCelement, QC_OUT_ELEMENT)
#endif /* #ifndef AACENC_RAM_H */
#endif /* #ifndef AAC_ENC_RAM_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 Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,28 +90,31 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/****************************************************************************** /**************************** AAC encoder library ******************************
Initial authors: M. Lohwasser, M. Gayer Author(s): M. Lohwasser, M. Gayer
Contents/description:
Description:
*******************************************************************************/
******************************************************************************/
/*! /*!
\file \file
\brief Memory layout \brief Memory layout
\author Markus Lohwasser \author Markus Lohwasser
*/ */
#ifndef AAC_ENC_ROM_H #ifndef AACENC_ROM_H
#define AAC_ENC_ROM_H #define AACENC_ROM_H
#include "common_fix.h" #include "common_fix.h"
#include "psy_const.h" #include "psy_const.h"
#include "psy_configuration.h" #include "psy_configuration.h"
#include "FDK_tools_rom.h" #include "FDK_tools_rom.h"
#include "FDK_lpc.h"
/* /*
Huffman Tables Huffman Tables
@ -147,13 +161,11 @@ extern const FIXP_DBL FDKaacEnc_mTab_4_3Elc[512];
extern const FIXP_DBL FDKaacEnc_specExpMantTableCombElc[4][14]; extern const FIXP_DBL FDKaacEnc_specExpMantTableCombElc[4][14];
extern const UCHAR FDKaacEnc_specExpTableComb[4][14]; extern const UCHAR FDKaacEnc_specExpTableComb[4][14];
/* /*
table to count used number of bits table to count used number of bits
*/ */
extern const SHORT FDKaacEnc_sideInfoTabLong[MAX_SFB_LONG + 1]; extern const SHORT FDKaacEnc_sideInfoTabLong[];
extern const SHORT FDKaacEnc_sideInfoTabShort[MAX_SFB_SHORT + 1]; extern const SHORT FDKaacEnc_sideInfoTabShort[];
/* /*
Psy Configuration constants Psy Configuration constants
@ -183,14 +195,13 @@ extern const SFB_PARAM_SHORT p_FDKaacEnc_88200_short_128;
extern const SFB_PARAM_LONG p_FDKaacEnc_96000_long_1024; extern const SFB_PARAM_LONG p_FDKaacEnc_96000_long_1024;
extern const SFB_PARAM_SHORT p_FDKaacEnc_96000_short_128; extern const SFB_PARAM_SHORT p_FDKaacEnc_96000_short_128;
/* /*
TNS filter coefficients TNS filter coefficients
*/ */
extern const FIXP_DBL FDKaacEnc_tnsEncCoeff3[8]; extern const FIXP_LPC FDKaacEnc_tnsEncCoeff3[8];
extern const FIXP_DBL FDKaacEnc_tnsCoeff3Borders[8]; extern const FIXP_LPC FDKaacEnc_tnsCoeff3Borders[8];
extern const FIXP_DBL FDKaacEnc_tnsEncCoeff4[16]; extern const FIXP_LPC FDKaacEnc_tnsEncCoeff4[16];
extern const FIXP_DBL FDKaacEnc_tnsCoeff4Borders[16]; extern const FIXP_LPC FDKaacEnc_tnsCoeff4Borders[16];
#define WTC0 WTC #define WTC0 WTC
#define WTC1 WTC #define WTC1 WTC
@ -198,6 +209,9 @@ extern const FIXP_DBL FDKaacEnc_tnsCoeff4Borders[16];
extern const FIXP_WTB ELDAnalysis512[1536]; extern const FIXP_WTB ELDAnalysis512[1536];
extern const FIXP_WTB ELDAnalysis480[1440]; extern const FIXP_WTB ELDAnalysis480[1440];
extern const FIXP_WTB ELDAnalysis256[768];
extern const FIXP_WTB ELDAnalysis240[720];
extern const FIXP_WTB ELDAnalysis128[384];
extern const FIXP_WTB ELDAnalysis120[360];
#endif /* #ifndef AACENC_ROM_H */
#endif /* #ifndef AAC_ENC_ROM_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 Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder ********************** /**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel Author(s): M. Schug / A. Groeschel
contents/description: fast aac coder interface library functions
******************************************************************************/ Description: fast aac coder interface library functions
#ifndef _aacenc_h_ *******************************************************************************/
#define _aacenc_h_
#ifndef AACENC_H
#define AACENC_H
#include "common_fix.h" #include "common_fix.h"
#include "FDK_audio.h" #include "FDK_audio.h"
@ -98,10 +110,7 @@ amm-info@iis.fraunhofer.de
#include "sbr_encoder.h" #include "sbr_encoder.h"
#define BITRES_MAX_LD 4000 #define MIN_BUFSIZE_PER_EFF_CHAN 6144
#define BITRES_MIN_LD 500
#define BITRATE_MAX_LD 70000 /* Max assumed bitrate for bitres calculation */
#define BITRATE_MIN_LD 12000 /* Min assumed bitrate for bitres calculation */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -113,25 +122,41 @@ extern "C" {
typedef enum { typedef enum {
AAC_ENC_OK = 0x0000, /*!< All fine. */ AAC_ENC_OK = 0x0000, /*!< All fine. */
AAC_ENC_UNKNOWN = 0x0002, /*!< Error condition is of unknown reason, or from another module. */ AAC_ENC_UNKNOWN = 0x0002, /*!< Error condition is of unknown reason, or from
another module. */
/* initialization errors */ /* initialization errors */
aac_enc_init_error_start = 0x2000, aac_enc_init_error_start = 0x2000,
AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call was invalid (probably NULL). */ AAC_ENC_INVALID_HANDLE = 0x2020, /*!< The handle passed to the function call
AAC_ENC_INVALID_FRAME_LENGTH = 0x2080, /*!< Invalid frame length. */ was invalid (probably NULL). */
AAC_ENC_INVALID_N_CHANNELS = 0x20e0, /*!< Invalid amount of audio input channels. */ AAC_ENC_INVALID_FRAME_LENGTH =
0x2080, /*!< Invalid frame length (must be 1024 or 960). */
AAC_ENC_INVALID_N_CHANNELS =
0x20e0, /*!< Invalid amount of audio input channels. */
AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */ AAC_ENC_INVALID_SFB_TABLE = 0x2140, /*!< Internal encoder error. */
AAC_ENC_UNSUPPORTED_AOT = 0x3000, /*!< The Audio Object Type (AOT) is not supported. */ AAC_ENC_UNSUPPORTED_AOT =
AAC_ENC_UNSUPPORTED_BITRATE = 0x3020, /*!< The chosen bitrate is not supported. */ 0x3000, /*!< The Audio Object Type (AOT) is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE_MODE = 0x3028, /*!< Unsupported bit rate mode (CBR or VBR). */ AAC_ENC_UNSUPPORTED_FILTERBANK =
AAC_ENC_UNSUPPORTED_ANC_BITRATE = 0x3040, /*!< Unsupported ancillay bitrate. */ 0x3010, /*!< Filterbank type is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE =
0x3020, /*!< The chosen bitrate is not supported. */
AAC_ENC_UNSUPPORTED_BITRATE_MODE =
0x3028, /*!< Unsupported bit rate mode (CBR or VBR). */
AAC_ENC_UNSUPPORTED_ANC_BITRATE =
0x3040, /*!< Unsupported ancillay bitrate. */
AAC_ENC_UNSUPPORTED_ANC_MODE = 0x3060, AAC_ENC_UNSUPPORTED_ANC_MODE = 0x3060,
AAC_ENC_UNSUPPORTED_TRANSPORT_TYPE = 0x3080, /*!< The bitstream format is not supported. */ AAC_ENC_UNSUPPORTED_TRANSPORT_TYPE =
AAC_ENC_UNSUPPORTED_ER_FORMAT = 0x30a0, /*!< The error resilience tool format is not supported. */ 0x3080, /*!< The bitstream format is not supported. */
AAC_ENC_UNSUPPORTED_EPCONFIG = 0x30c0, /*!< The error protection format is not supported. */ AAC_ENC_UNSUPPORTED_ER_FORMAT =
AAC_ENC_UNSUPPORTED_CHANNELCONFIG = 0x30e0, /*!< The channel configuration (either number or arrangement) is not supported. */ 0x30a0, /*!< The error resilience tool format is not supported. */
AAC_ENC_UNSUPPORTED_SAMPLINGRATE = 0x3100, /*!< Sample rate of audio input is not supported. */ AAC_ENC_UNSUPPORTED_EPCONFIG =
0x30c0, /*!< The error protection format is not supported. */
AAC_ENC_UNSUPPORTED_CHANNELCONFIG =
0x30e0, /*!< The channel configuration (either number or arrangement) is
not supported. */
AAC_ENC_UNSUPPORTED_SAMPLINGRATE =
0x3100, /*!< Sample rate of audio input is not supported. */
AAC_ENC_NO_MEMORY = 0x3120, /*!< Could not allocate memory. */ AAC_ENC_NO_MEMORY = 0x3120, /*!< Could not allocate memory. */
AAC_ENC_PE_INIT_TABLE_NOT_FOUND = 0x3140, /*!< Internal encoder error. */ AAC_ENC_PE_INIT_TABLE_NOT_FOUND = 0x3140, /*!< Internal encoder error. */
@ -140,7 +165,8 @@ typedef enum {
/* encode errors */ /* encode errors */
aac_enc_error_start = 0x4000, aac_enc_error_start = 0x4000,
AAC_ENC_QUANT_ERROR = 0x4020, /*!< Too many bits used in quantization. */ AAC_ENC_QUANT_ERROR = 0x4020, /*!< Too many bits used in quantization. */
AAC_ENC_WRITTEN_BITS_ERROR = 0x4040, /*!< Unexpected number of written bits, differs to AAC_ENC_WRITTEN_BITS_ERROR =
0x4040, /*!< Unexpected number of written bits, differs to
calculated number of bits. */ calculated number of bits. */
AAC_ENC_PNS_TABLE_ERROR = 0x4060, /*!< PNS level out of range. */ AAC_ENC_PNS_TABLE_ERROR = 0x4060, /*!< PNS level out of range. */
AAC_ENC_GLOBAL_GAIN_TOO_HIGH = 0x4080, /*!< Internal quantizer error. */ AAC_ENC_GLOBAL_GAIN_TOO_HIGH = 0x4080, /*!< Internal quantizer error. */
@ -159,26 +185,29 @@ typedef enum {
#define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */ #define ANC_DATA_BUFFERSIZE 1024 /* ancBuffer size */
#define MAX_TOTAL_EXT_PAYLOADS (((8) * (1)) + (2+2)) #define MAX_TOTAL_EXT_PAYLOADS ((((8)) * (1)) + (2 + 2))
typedef enum { typedef enum {
AACENC_BR_MODE_INVALID = -1, /*!< Invalid bitrate mode. */ AACENC_BR_MODE_INVALID = -1, /*!< Invalid bitrate mode. */
AACENC_BR_MODE_CBR = 0, /*!< Constant bitrate mode. */ AACENC_BR_MODE_CBR = 0, /*!< Constant bitrate mode. */
AACENC_BR_MODE_VBR_1 = 1, /*!< Variable bitrate mode, about 32 kbps/channel. */ AACENC_BR_MODE_VBR_1 = 1, /*!< Variable bitrate mode, very low bitrate. */
AACENC_BR_MODE_VBR_2 = 2, /*!< Variable bitrate mode, about 40 kbps/channel. */ AACENC_BR_MODE_VBR_2 = 2, /*!< Variable bitrate mode, low bitrate. */
AACENC_BR_MODE_VBR_3 = 3, /*!< Variable bitrate mode, about 48-56 kbps/channel. */ AACENC_BR_MODE_VBR_3 = 3, /*!< Variable bitrate mode, medium bitrate. */
AACENC_BR_MODE_VBR_4 = 4, /*!< Variable bitrate mode, about 64 kbps/channel. */ AACENC_BR_MODE_VBR_4 = 4, /*!< Variable bitrate mode, high bitrate. */
AACENC_BR_MODE_VBR_5 = 5, /*!< Variable bitrate mode, about 80-96 kbps/channel. */ AACENC_BR_MODE_VBR_5 = 5, /*!< Variable bitrate mode, very high bitrate. */
AACENC_BR_MODE_FF = 6, /*!< Fixed frame mode. */ AACENC_BR_MODE_FF = 6, /*!< Fixed frame mode. */
AACENC_BR_MODE_SFR = 7 /*!< Superframe mode. */ AACENC_BR_MODE_SFR = 7 /*!< Superframe mode. */
} AACENC_BITRATE_MODE; } AACENC_BITRATE_MODE;
#define AACENC_BR_MODE_IS_VBR(brMode) ((brMode >= 1) && (brMode <= 5))
typedef enum { typedef enum {
CH_ORDER_MPEG = 0, /*!< MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE) */ CH_ORDER_MPEG =
CH_ORDER_WAV /*!< WAV fileformat channel ordering (e. g. 5.1: L, R, C, LFE, SL, SR) */ 0, /*!< MPEG channel ordering (e. g. 5.1: C, L, R, SL, SR, LFE) */
CH_ORDER_WAV /*!< WAV fileformat channel ordering (e. g. 5.1: L, R, C, LFE,
SL, SR) */
} CHANNEL_ORDER; } CHANNEL_ORDER;
@ -187,15 +216,17 @@ typedef enum {
struct AACENC_CONFIG { struct AACENC_CONFIG {
INT sampleRate; /* encoder sample rate */ INT sampleRate; /* encoder sample rate */
INT bitRate; /* encoder bit rate in bits/sec */ INT bitRate; /* encoder bit rate in bits/sec */
INT ancDataBitRate; /* additional bits consumed by anc data or sbr have to be consiedered while configuration */ INT ancDataBitRate; /* additional bits consumed by anc data or sbr have to be
consiedered while configuration */
INT nSubFrames; /* number of frames in super frame (not ADTS/LATM subframes !) */ INT nSubFrames; /* number of frames in super frame (not ADTS/LATM subframes !)
*/
AUDIO_OBJECT_TYPE audioObjectType; /* Audio Object Type */ AUDIO_OBJECT_TYPE audioObjectType; /* Audio Object Type */
INT averageBits; /* encoder bit rate in bits/superframe */ INT averageBits; /* encoder bit rate in bits/superframe */
INT bitrateMode; /* encoder bitrate mode (CBR/VBR) */ AACENC_BITRATE_MODE bitrateMode; /* encoder bitrate mode (CBR/VBR) */
INT nChannels; /* number of channels to process */ INT nChannels; /* number of channels to process */
CHANNEL_ORDER channelOrder; /* Input Channel ordering scheme. */ CHANNEL_ORDER channelOrder; /* input Channel ordering scheme. */
INT bandWidth; /* targeted audio bandwidth in Hz */ INT bandWidth; /* targeted audio bandwidth in Hz */
CHANNEL_MODE channelMode; /* encoder channel mode configuration */ CHANNEL_MODE channelMode; /* encoder channel mode configuration */
INT framelength; /* used frame size */ INT framelength; /* used frame size */
@ -203,11 +234,11 @@ struct AACENC_CONFIG {
UINT syntaxFlags; /* bitstreams syntax configuration */ UINT syntaxFlags; /* bitstreams syntax configuration */
SCHAR epConfig; /* error protection configuration */ SCHAR epConfig; /* error protection configuration */
INT anc_Rate; /* ancillary rate, 0 (disabled), -1 (default) else desired rate */ INT anc_Rate; /* ancillary rate, 0 (disabled), -1 (default) else desired rate
*/
UINT maxAncBytesPerAU; UINT maxAncBytesPerAU;
INT minBitsPerFrame; /* minimum number of bits in AU */ INT minBitsPerFrame; /* minimum number of bits in AU */
INT maxBitsPerFrame; /* maximum number of bits in AU */ INT maxBitsPerFrame; /* maximum number of bits in AU */
INT bitreservoir; /* size of bitreservoir */
INT audioMuxVersion; /* audio mux version in loas/latm transport format */ INT audioMuxVersion; /* audio mux version in loas/latm transport format */
@ -216,21 +247,26 @@ struct AACENC_CONFIG {
UCHAR useTns; /* flag: use temporal noise shaping */ UCHAR useTns; /* flag: use temporal noise shaping */
UCHAR usePns; /* flag: use perceptual noise substitution */ UCHAR usePns; /* flag: use perceptual noise substitution */
UCHAR useIS; /* flag: use intensity coding */ UCHAR useIS; /* flag: use intensity coding */
UCHAR useMS; /* flag: use ms stereo tool */
UCHAR useRequant; /* flag: use afterburner */ UCHAR useRequant; /* flag: use afterburner */
UINT downscaleFactor;
}; };
typedef struct { typedef struct {
UCHAR *pData; /* pointer to extension payload data */ UCHAR *pData; /* pointer to extension payload data */
UINT dataSize; /* extension payload data size in bits */ UINT dataSize; /* extension payload data size in bits */
EXT_PAYLOAD_TYPE dataType; /* extension payload data type */ EXT_PAYLOAD_TYPE dataType; /* extension payload data type */
INT associatedChElement; /* number of the channel element the data is assigned to */ INT associatedChElement; /* number of the channel element the data is assigned
to */
} AACENC_EXT_PAYLOAD; } AACENC_EXT_PAYLOAD;
typedef struct AAC_ENC *HANDLE_AAC_ENC; typedef struct AAC_ENC *HANDLE_AAC_ENC;
/** /**
* \brief Calculate framesize in bits for given bit rate, frame length and sampling rate. * \brief Calculate framesize in bits for given bit rate, frame length and
* sampling rate.
* *
* \param bitRate Ttarget bitrate in bits per second. * \param bitRate Ttarget bitrate in bits per second.
* \param frameLength Number of audio samples in one frame. * \param frameLength Number of audio samples in one frame.
@ -238,53 +274,52 @@ typedef struct AAC_ENC *HANDLE_AAC_ENC;
* *
* \return Framesize in bits per frame. * \return Framesize in bits per frame.
*/ */
INT FDKaacEnc_CalcBitsPerFrame( INT FDKaacEnc_CalcBitsPerFrame(const INT bitRate, const INT frameLength,
const INT bitRate, const INT samplingRate);
const INT frameLength,
const INT samplingRate
);
/** /**
* \brief Calculate bitrate in bits per second for given framesize, frame length and sampling rate. * \brief Calculate bitrate in bits per second for given framesize, frame length
* and sampling rate.
* *
* \param bitsPerFrame Framesize in bits per frame. * \param bitsPerFrame Framesize in bits per frame
* \param frameLength Number of audio samples in one frame. * \param frameLength Number of audio samples in one frame.
* \param samplingRate Sampling rate in Hz. * \param samplingRate Sampling rate in Hz.
* *
* \return Bitrate in bits per second. * \return Bitrate in bits per second.
*/ */
INT FDKaacEnc_CalcBitrate( INT FDKaacEnc_CalcBitrate(const INT bitsPerFrame, const INT frameLength,
const INT bitsPerFrame, const INT samplingRate);
const INT frameLength,
const INT samplingRate
);
/** /**
* \brief Limit given bit rate to a valid value * \brief Limit given bit rate to a valid value
* \param hTpEnc transport encoder handle * \param hTpEnc transport encoder handle
* \param aot audio object type
* \param coreSamplingRate the sample rate to be used for the AAC encoder * \param coreSamplingRate the sample rate to be used for the AAC encoder
* \param frameLength the frameLength to be used for the AAC encoder * \param frameLength the frameLength to be used for the AAC encoder
* \param nChannels number of total channels * \param nChannels number of total channels
* \param nChannelsEff number of effective channels * \param nChannelsEff number of effective channels
* \param bitRate the initial bit rate value for which the closest valid bit rate value is searched for * \param bitRate the initial bit rate value for which the closest valid bit
* \param averageBits average bits per frame for fixed framing. Set to -1 if not available. * rate value is searched for
* \param averageBits average bits per frame for fixed framing. Set to -1 if not
* available.
* \param optional pointer where the current bits per frame are stored into. * \param optional pointer where the current bits per frame are stored into.
* \param bitrateMode the current bit rate mode * \param bitrateMode the current bit rate mode
* \param nSubFrames number of sub frames for super framing (not transport frames). * \param nSubFrames number of sub frames for super framing (not transport
* frames).
* \return a valid bit rate value as close as possible or identical to bitRate * \return a valid bit rate value as close as possible or identical to bitRate
*/ */
INT FDKaacEnc_LimitBitrate( INT FDKaacEnc_LimitBitrate(HANDLE_TRANSPORTENC hTpEnc, AUDIO_OBJECT_TYPE aot,
HANDLE_TRANSPORTENC hTpEnc, INT coreSamplingRate, INT frameLength, INT nChannels,
INT coreSamplingRate, INT nChannelsEff, INT bitRate, INT averageBits,
INT frameLength,
INT nChannels,
INT nChannelsEff,
INT bitRate,
INT averageBits,
INT *pAverageBitsPerFrame, INT *pAverageBitsPerFrame,
INT bitrateMode, AACENC_BITRATE_MODE bitrateMode, INT nSubFrames);
INT nSubFrames
); /**
* \brief Get current state of the bit reservoir
* \param hAacEncoder encoder handle
* \return bit reservoir state in bits
*/
INT FDKaacEnc_GetBitReservoirState(const HANDLE_AAC_ENC hAacEncoder);
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@ -295,8 +330,8 @@ INT FDKaacEnc_LimitBitrate(
returns: vbr bitrate returns: vbr bitrate
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
INT FDKaacEnc_GetVBRBitrate(INT bitrateMode, CHANNEL_MODE channelMode); INT FDKaacEnc_GetVBRBitrate(AACENC_BITRATE_MODE bitrateMode,
CHANNEL_MODE channelMode);
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
@ -314,17 +349,18 @@ void FDKaacEnc_AacInitDefaultConfig(AACENC_CONFIG *config);
returns: 0 if success returns: 0 if success
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
AAC_ENCODER_ERROR FDKaacEnc_Open(HANDLE_AAC_ENC *phAacEnc, /* pointer to an encoder handle, initialized on return */ AAC_ENCODER_ERROR FDKaacEnc_Open(
HANDLE_AAC_ENC
*phAacEnc, /* pointer to an encoder handle, initialized on return */
const INT nElements, /* number of maximal elements in instance to support */ const INT nElements, /* number of maximal elements in instance to support */
const INT nChannels, /* number of maximal channels in instance to support */ const INT nChannels, /* number of maximal channels in instance to support */
const INT nSubFrames); /* support superframing in instance */ const INT nSubFrames); /* support superframing in instance */
AAC_ENCODER_ERROR FDKaacEnc_Initialize(
AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEncoder, /* pointer to an encoder handle, initialized on return */ HANDLE_AAC_ENC
hAacEncoder, /* pointer to an encoder handle, initialized on return */
AACENC_CONFIG *config, /* pre-initialized config struct */ AACENC_CONFIG *config, /* pre-initialized config struct */
HANDLE_TRANSPORTENC hTpEnc, HANDLE_TRANSPORTENC hTpEnc, ULONG initFlags);
ULONG initFlags);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
@ -334,12 +370,11 @@ AAC_ENCODER_ERROR FDKaacEnc_Initialize(HANDLE_AAC_ENC hAacEncoder, /* poin
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame( HANDLE_AAC_ENC hAacEnc, /* encoder handle */ AAC_ENCODER_ERROR FDKaacEnc_EncodeFrame(
HANDLE_TRANSPORTENC hTpEnc, HANDLE_AAC_ENC hAacEnc, /* encoder handle */
INT_PCM* inputBuffer, HANDLE_TRANSPORTENC hTpEnc, INT_PCM *inputBuffer,
INT* numOutBytes, const UINT inputBufferBufSize, INT *numOutBytes,
AACENC_EXT_PAYLOAD extPayload[MAX_TOTAL_EXT_PAYLOADS] AACENC_EXT_PAYLOAD extPayload[MAX_TOTAL_EXT_PAYLOADS]);
);
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
@ -355,5 +390,4 @@ void FDKaacEnc_Close( HANDLE_AAC_ENC* phAacEnc); /* encoder handle */
} }
#endif #endif
#endif /* _aacenc_h_ */ #endif /* AACENC_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,43 +90,37 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Lohwasser Author(s): M. Lohwasser
contents/description: pns.c
******************************************************************************/ Description: pns.c
*******************************************************************************/
#include "aacenc_pns.h" #include "aacenc_pns.h"
#include "psy_data.h" #include "psy_data.h"
#include "pnsparam.h" #include "pnsparam.h"
#include "noisedet.h" #include "noisedet.h"
#include "bit_cnt.h" #include "bit_cnt.h"
#include "interface.h" #include "interface.h"
/* minCorrelationEnergy = (1.0e-10f)^2 ~ 2^-67 = 2^-47 * 2^-20 */ /* minCorrelationEnergy = (1.0e-10f)^2 ~ 2^-67 = 2^-47 * 2^-20 */
static const FIXP_DBL minCorrelationEnergy = FL2FXCONST_DBL(0.0); /* FL2FXCONST_DBL((float)FDKpow(2.0,-47)); */ static const FIXP_DBL minCorrelationEnergy =
FL2FXCONST_DBL(0.0); /* FL2FXCONST_DBL((float)FDKpow(2.0,-47)); */
/* noiseCorrelationThresh = 0.6^2 */ /* noiseCorrelationThresh = 0.6^2 */
static const FIXP_DBL noiseCorrelationThresh = FL2FXCONST_DBL(0.36); static const FIXP_DBL noiseCorrelationThresh = FL2FXCONST_DBL(0.36);
static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf, static void FDKaacEnc_FDKaacEnc_noiseDetection(
PNS_DATA *pnsData, PNS_CONFIG *pnsConf, PNS_DATA *pnsData, const INT sfbActive,
const INT sfbActive, const INT *sfbOffset, INT tnsOrder, INT tnsPredictionGain, INT tnsActive,
const INT *sfbOffset, FIXP_DBL *mdctSpectrum, INT *sfbMaxScaleSpec, FIXP_SGL *sfbtonality);
INT tnsOrder,
INT tnsPredictionGain,
INT tnsActive,
FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
FIXP_SGL *sfbtonality );
static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive, static void FDKaacEnc_CalcNoiseNrgs(const INT sfbActive, INT *pnsFlag,
INT *pnsFlag, FIXP_DBL *sfbEnergyLdData, INT *noiseNrg);
FIXP_DBL *sfbEnergyLdData,
INT *noiseNrg );
/***************************************************************************** /*****************************************************************************
@ -129,28 +134,15 @@ static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive,
*****************************************************************************/ *****************************************************************************/
AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(PNS_CONFIG *pnsConf, AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(
INT bitRate, PNS_CONFIG *pnsConf, INT bitRate, INT sampleRate, INT usePns, INT sfbCnt,
INT sampleRate, const INT *sfbOffset, const INT numChan, const INT isLC) {
INT usePns,
INT sfbCnt,
const INT *sfbOffset,
const INT numChan,
const INT isLC)
{
AAC_ENCODER_ERROR ErrorStatus; AAC_ENCODER_ERROR ErrorStatus;
/* init noise detection */ /* init noise detection */
ErrorStatus = FDKaacEnc_GetPnsParam(&pnsConf->np, ErrorStatus = FDKaacEnc_GetPnsParam(&pnsConf->np, bitRate, sampleRate, sfbCnt,
bitRate, sfbOffset, &usePns, numChan, isLC);
sampleRate, if (ErrorStatus != AAC_ENC_OK) return ErrorStatus;
sfbCnt,
sfbOffset,
&usePns,
numChan,
isLC);
if (ErrorStatus != AAC_ENC_OK)
return ErrorStatus;
pnsConf->minCorrelationEnergy = minCorrelationEnergy; pnsConf->minCorrelationEnergy = minCorrelationEnergy;
pnsConf->noiseCorrelationThresh = noiseCorrelationThresh; pnsConf->noiseCorrelationThresh = noiseCorrelationThresh;
@ -160,8 +152,6 @@ AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(PNS_CONFIG *pnsConf,
return AAC_ENC_OK; return AAC_ENC_OK;
} }
/***************************************************************************** /*****************************************************************************
functionname: FDKaacEnc_PnsDetect functionname: FDKaacEnc_PnsDetect
@ -180,71 +170,53 @@ AAC_ENCODER_ERROR FDKaacEnc_InitPnsConfiguration(PNS_CONFIG *pnsConf,
output: pnsFlag in pns data structure output: pnsFlag in pns data structure
*****************************************************************************/ *****************************************************************************/
void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf, void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf, PNS_DATA *pnsData,
PNS_DATA *pnsData, const INT lastWindowSequence, const INT sfbActive,
const INT lastWindowSequence, const INT maxSfbPerGroup, FIXP_DBL *sfbThresholdLdData,
const INT sfbActive, const INT *sfbOffset, FIXP_DBL *mdctSpectrum,
const INT maxSfbPerGroup, INT *sfbMaxScaleSpec, FIXP_SGL *sfbtonality,
FIXP_DBL *sfbThresholdLdData, INT tnsOrder, INT tnsPredictionGain, INT tnsActive,
const INT *sfbOffset, FIXP_DBL *sfbEnergyLdData, INT *noiseNrg)
FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
FIXP_SGL *sfbtonality,
INT tnsOrder,
INT tnsPredictionGain,
INT tnsActive,
FIXP_DBL *sfbEnergyLdData,
INT *noiseNrg )
{ {
int sfb; int sfb;
int startNoiseSfb; int startNoiseSfb;
if (pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMLEXITY) { /* Reset pns info. */
if ( (!pnsConf->usePns) || /* pns enabled? */ FDKmemclear(pnsData->pnsFlag, sizeof(pnsData->pnsFlag));
(lastWindowSequence == SHORT_WINDOW) ) /* currently only long blocks */
{
FDKmemclear(pnsData->pnsFlag, MAX_GROUPED_SFB*sizeof(INT)); /* clear all pnsFlags */
for (sfb = 0; sfb < MAX_GROUPED_SFB; sfb++) { for (sfb = 0; sfb < MAX_GROUPED_SFB; sfb++) {
noiseNrg[sfb] = NO_NOISE_PNS; /* clear nrg's of previous frame */ noiseNrg[sfb] = NO_NOISE_PNS;
} }
return;
}
}
else {
if(!pnsConf->usePns)
return;
/* PNS only for long Windows */ /* Disable PNS and skip detection in certain cases. */
if (pnsConf->np.detectionAlgorithmFlags & JUST_LONG_WINDOW) { if (pnsConf->usePns == 0) {
if(lastWindowSequence != LONG_WINDOW) { return;
for (sfb = 0; sfb < sfbActive; sfb++) { } else {
pnsData->pnsFlag[sfb] = 0; /* clear all pnsFlags */ /* AAC - LC core encoder */
if ((pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMPLEXITY) &&
(lastWindowSequence == SHORT_WINDOW)) {
return;
} }
/* AAC - (E)LD core encoder */
if (!(pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMPLEXITY) &&
(pnsConf->np.detectionAlgorithmFlags & JUST_LONG_WINDOW) &&
(lastWindowSequence != LONG_WINDOW)) {
return; return;
} }
} }
}
/* /*
call noise detection call noise detection
*/ */
FDKaacEnc_FDKaacEnc_noiseDetection( pnsConf, FDKaacEnc_FDKaacEnc_noiseDetection(
pnsData, pnsConf, pnsData, sfbActive, sfbOffset, tnsOrder, tnsPredictionGain,
sfbActive, tnsActive, mdctSpectrum, sfbMaxScaleSpec, sfbtonality);
sfbOffset,
tnsOrder,
tnsPredictionGain,
tnsActive,
mdctSpectrum,
sfbMaxScaleSpec,
sfbtonality );
/* set startNoiseSfb (long) */ /* set startNoiseSfb (long) */
startNoiseSfb = pnsConf->np.startSfb; startNoiseSfb = pnsConf->np.startSfb;
/* Set noise substitution status */ /* Set noise substitution status */
for (sfb = 0; sfb < sfbActive; sfb++) { for (sfb = 0; sfb < sfbActive; sfb++) {
/* No PNS below startNoiseSfb */ /* No PNS below startNoiseSfb */
if (sfb < startNoiseSfb) { if (sfb < startNoiseSfb) {
pnsData->pnsFlag[sfb] = 0; pnsData->pnsFlag[sfb] = 0;
@ -259,16 +231,16 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
*/ */
if ((pnsData->noiseFuzzyMeasure[sfb] > FL2FXCONST_SGL(0.5)) && if ((pnsData->noiseFuzzyMeasure[sfb] > FL2FXCONST_SGL(0.5)) &&
( (sfbThresholdLdData[sfb] + FL2FXCONST_DBL(0.5849625f/64.0f)) /* thr * 1.5 = thrLd +ld(1.5)/64 */ ((sfbThresholdLdData[sfb] +
< sfbEnergyLdData[sfb] ) ) FL2FXCONST_DBL(0.5849625f /
{ 64.0f)) /* thr * 1.5 = thrLd +ld(1.5)/64 */
< sfbEnergyLdData[sfb])) {
/* /*
mark in psyout flag array that we will code mark in psyout flag array that we will code
this band with PNS this band with PNS
*/ */
pnsData->pnsFlag[sfb] = 1; /* PNS_ON */ pnsData->pnsFlag[sfb] = 1; /* PNS_ON */
} } else {
else{
pnsData->pnsFlag[sfb] = 0; /* PNS_OFF */ pnsData->pnsFlag[sfb] = 0; /* PNS_OFF */
} }
@ -276,7 +248,8 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
} }
/* avoid PNS holes */ /* avoid PNS holes */
if((pnsData->noiseFuzzyMeasure[0]>FL2FXCONST_SGL(0.5f)) && (pnsData->pnsFlag[1])) { if ((pnsData->noiseFuzzyMeasure[0] > FL2FXCONST_SGL(0.5f)) &&
(pnsData->pnsFlag[1])) {
pnsData->pnsFlag[0] = 1; pnsData->pnsFlag[0] = 1;
} }
@ -289,7 +262,9 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
if (maxSfbPerGroup > 0) { if (maxSfbPerGroup > 0) {
/* avoid PNS hole */ /* avoid PNS hole */
if((pnsData->noiseFuzzyMeasure[maxSfbPerGroup-1]>pnsConf->np.gapFillThr) && (pnsData->pnsFlag[maxSfbPerGroup-2])) { if ((pnsData->noiseFuzzyMeasure[maxSfbPerGroup - 1] >
pnsConf->np.gapFillThr) &&
(pnsData->pnsFlag[maxSfbPerGroup - 2])) {
pnsData->pnsFlag[maxSfbPerGroup - 1] = 1; pnsData->pnsFlag[maxSfbPerGroup - 1] = 1;
} }
/* avoid single PNS band */ /* avoid single PNS band */
@ -309,17 +284,13 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
} }
} }
/* /*
calculate noiseNrg's calculate noiseNrg's
*/ */
FDKaacEnc_CalcNoiseNrgs( sfbActive, FDKaacEnc_CalcNoiseNrgs(sfbActive, pnsData->pnsFlag, sfbEnergyLdData,
pnsData->pnsFlag,
sfbEnergyLdData,
noiseNrg); noiseNrg);
} }
/***************************************************************************** /*****************************************************************************
functionname:FDKaacEnc_FDKaacEnc_noiseDetection functionname:FDKaacEnc_FDKaacEnc_noiseDetection
@ -335,19 +306,12 @@ void FDKaacEnc_PnsDetect(PNS_CONFIG *pnsConf,
flags tonal / nontonal flags tonal / nontonal
*****************************************************************************/ *****************************************************************************/
static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf, static void FDKaacEnc_FDKaacEnc_noiseDetection(
PNS_DATA *pnsData, PNS_CONFIG *pnsConf, PNS_DATA *pnsData, const INT sfbActive,
const INT sfbActive, const INT *sfbOffset, int tnsOrder, INT tnsPredictionGain, INT tnsActive,
const INT *sfbOffset, FIXP_DBL *mdctSpectrum, INT *sfbMaxScaleSpec, FIXP_SGL *sfbtonality) {
int tnsOrder,
INT tnsPredictionGain,
INT tnsActive,
FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
FIXP_SGL *sfbtonality )
{
INT condition = TRUE; INT condition = TRUE;
if ( !(pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMLEXITY) ) { if (!(pnsConf->np.detectionAlgorithmFlags & IS_LOW_COMPLEXITY)) {
condition = (tnsOrder > 3); condition = (tnsOrder > 3);
} }
/* /*
@ -356,28 +320,22 @@ static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf,
*/ */
if ((pnsConf->np.detectionAlgorithmFlags & USE_TNS_GAIN_THR) && if ((pnsConf->np.detectionAlgorithmFlags & USE_TNS_GAIN_THR) &&
(tnsPredictionGain >= pnsConf->np.tnsGainThreshold) && condition && (tnsPredictionGain >= pnsConf->np.tnsGainThreshold) && condition &&
!((pnsConf->np.detectionAlgorithmFlags & USE_TNS_PNS) && (tnsPredictionGain >= pnsConf->np.tnsPNSGainThreshold) && (tnsActive)) ) !((pnsConf->np.detectionAlgorithmFlags & USE_TNS_PNS) &&
{ (tnsPredictionGain >= pnsConf->np.tnsPNSGainThreshold) &&
(tnsActive))) {
/* clear all noiseFuzzyMeasure */ /* clear all noiseFuzzyMeasure */
FDKmemclear(pnsData->noiseFuzzyMeasure, sfbActive * sizeof(FIXP_SGL)); FDKmemclear(pnsData->noiseFuzzyMeasure, sfbActive * sizeof(FIXP_SGL));
} } else {
else
{
/* /*
call noise detection, output in pnsData->noiseFuzzyMeasure, call noise detection, output in pnsData->noiseFuzzyMeasure,
use real mdct spectral data use real mdct spectral data
*/ */
FDKaacEnc_noiseDetect( mdctSpectrum, FDKaacEnc_noiseDetect(mdctSpectrum, sfbMaxScaleSpec, sfbActive, sfbOffset,
sfbMaxScaleSpec, pnsData->noiseFuzzyMeasure, &pnsConf->np,
sfbActive,
sfbOffset,
pnsData->noiseFuzzyMeasure,
&pnsConf->np,
sfbtonality); sfbtonality);
} }
} }
/***************************************************************************** /*****************************************************************************
functionname:FDKaacEnc_CalcNoiseNrgs functionname:FDKaacEnc_CalcNoiseNrgs
@ -391,23 +349,21 @@ static void FDKaacEnc_FDKaacEnc_noiseDetection( PNS_CONFIG *pnsConf,
*****************************************************************************/ *****************************************************************************/
static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive, static void FDKaacEnc_CalcNoiseNrgs(const INT sfbActive, INT *RESTRICT pnsFlag,
INT *RESTRICT pnsFlag,
FIXP_DBL *RESTRICT sfbEnergyLdData, FIXP_DBL *RESTRICT sfbEnergyLdData,
INT *RESTRICT noiseNrg ) INT *RESTRICT noiseNrg) {
{
int sfb; int sfb;
INT tmp = (-LOG_NORM_PCM) << 2; INT tmp = (-LOG_NORM_PCM) << 2;
for (sfb = 0; sfb < sfbActive; sfb++) { for (sfb = 0; sfb < sfbActive; sfb++) {
if (pnsFlag[sfb]) { if (pnsFlag[sfb]) {
INT nrg = (-sfbEnergyLdData[sfb]+FL2FXCONST_DBL(0.5f/64.0f))>>(DFRACT_BITS-1-7); INT nrg = (-sfbEnergyLdData[sfb] + FL2FXCONST_DBL(0.5f / 64.0f)) >>
(DFRACT_BITS - 1 - 7);
noiseNrg[sfb] = tmp - nrg; noiseNrg[sfb] = tmp - nrg;
} }
} }
} }
/***************************************************************************** /*****************************************************************************
functionname:FDKaacEnc_CodePnsChannel functionname:FDKaacEnc_CodePnsChannel
@ -422,13 +378,11 @@ static void FDKaacEnc_CalcNoiseNrgs( const INT sfbActive,
*****************************************************************************/ *****************************************************************************/
void FDKaacEnc_CodePnsChannel(const INT sfbActive, void FDKaacEnc_CodePnsChannel(const INT sfbActive, PNS_CONFIG *pnsConf,
PNS_CONFIG *pnsConf,
INT *RESTRICT pnsFlag, INT *RESTRICT pnsFlag,
FIXP_DBL *RESTRICT sfbEnergyLdData, FIXP_DBL *RESTRICT sfbEnergyLdData,
INT *RESTRICT noiseNrg, INT *RESTRICT noiseNrg,
FIXP_DBL *RESTRICT sfbThresholdLdData) FIXP_DBL *RESTRICT sfbThresholdLdData) {
{
INT sfb; INT sfb;
INT lastiNoiseEnergy = 0; INT lastiNoiseEnergy = 0;
INT firstPNSband = 1; /* TRUE for first PNS-coded band */ INT firstPNSband = 1; /* TRUE for first PNS-coded band */
@ -447,7 +401,8 @@ void FDKaacEnc_CodePnsChannel(const INT sfbActive,
if (pnsFlag[sfb]) { if (pnsFlag[sfb]) {
/* high sfbThreshold causes pe = 0 */ /* high sfbThreshold causes pe = 0 */
if (noiseNrg[sfb] != NO_NOISE_PNS) if (noiseNrg[sfb] != NO_NOISE_PNS)
sfbThresholdLdData[sfb] = sfbEnergyLdData[sfb] + FL2FXCONST_DBL(1.0f/LD_DATA_SCALING); sfbThresholdLdData[sfb] =
sfbEnergyLdData[sfb] + FL2FXCONST_DBL(1.0f / LD_DATA_SCALING);
/* set noiseNrg in valid region */ /* set noiseNrg in valid region */
if (!firstPNSband) { if (!firstPNSband) {
@ -457,20 +412,17 @@ void FDKaacEnc_CodePnsChannel(const INT sfbActive,
noiseNrg[sfb] -= deltaiNoiseEnergy - CODE_BOOK_PNS_LAV; noiseNrg[sfb] -= deltaiNoiseEnergy - CODE_BOOK_PNS_LAV;
else if (deltaiNoiseEnergy < -CODE_BOOK_PNS_LAV) else if (deltaiNoiseEnergy < -CODE_BOOK_PNS_LAV)
noiseNrg[sfb] -= deltaiNoiseEnergy + CODE_BOOK_PNS_LAV; noiseNrg[sfb] -= deltaiNoiseEnergy + CODE_BOOK_PNS_LAV;
} } else {
else {
firstPNSband = 0; firstPNSband = 0;
} }
lastiNoiseEnergy = noiseNrg[sfb]; lastiNoiseEnergy = noiseNrg[sfb];
} } else {
else {
/* no PNS coding */ /* no PNS coding */
noiseNrg[sfb] = NO_NOISE_PNS; noiseNrg[sfb] = NO_NOISE_PNS;
} }
} }
} }
/***************************************************************************** /*****************************************************************************
functionname:FDKaacEnc_PreProcessPnsChannelPair functionname:FDKaacEnc_PreProcessPnsChannelPair
@ -486,24 +438,21 @@ void FDKaacEnc_CodePnsChannel(const INT sfbActive,
*****************************************************************************/ *****************************************************************************/
void FDKaacEnc_PreProcessPnsChannelPair(const INT sfbActive, void FDKaacEnc_PreProcessPnsChannelPair(
FIXP_DBL *RESTRICT sfbEnergyLeft, const INT sfbActive, FIXP_DBL *RESTRICT sfbEnergyLeft,
FIXP_DBL *RESTRICT sfbEnergyRight, FIXP_DBL *RESTRICT sfbEnergyRight, FIXP_DBL *RESTRICT sfbEnergyLeftLD,
FIXP_DBL *RESTRICT sfbEnergyLeftLD, FIXP_DBL *RESTRICT sfbEnergyRightLD, FIXP_DBL *RESTRICT sfbEnergyMid,
FIXP_DBL *RESTRICT sfbEnergyRightLD, PNS_CONFIG *RESTRICT pnsConf, PNS_DATA *pnsDataLeft,
FIXP_DBL *RESTRICT sfbEnergyMid, PNS_DATA *pnsDataRight) {
PNS_CONFIG *RESTRICT pnsConf,
PNS_DATA *pnsDataLeft,
PNS_DATA *pnsDataRight)
{
INT sfb; INT sfb;
FIXP_DBL ccf; FIXP_DBL ccf;
if(!pnsConf->usePns) if (!pnsConf->usePns) return;
return;
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationL = pnsDataLeft->noiseEnergyCorrelation; FIXP_DBL *RESTRICT pNoiseEnergyCorrelationL =
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationR = pnsDataRight->noiseEnergyCorrelation; pnsDataLeft->noiseEnergyCorrelation;
FIXP_DBL *RESTRICT pNoiseEnergyCorrelationR =
pnsDataRight->noiseEnergyCorrelation;
for (sfb = 0; sfb < sfbActive; sfb++) { for (sfb = 0; sfb < sfbActive; sfb++) {
FIXP_DBL quot = (sfbEnergyLeftLD[sfb] >> 1) + (sfbEnergyRightLD[sfb] >> 1); FIXP_DBL quot = (sfbEnergyLeftLD[sfb] >> 1) + (sfbEnergyRightLD[sfb] >> 1);
@ -511,12 +460,18 @@ void FDKaacEnc_PreProcessPnsChannelPair(const INT sfbActive,
if (quot < FL2FXCONST_DBL(-32.0f / (float)LD_DATA_SCALING)) if (quot < FL2FXCONST_DBL(-32.0f / (float)LD_DATA_SCALING))
ccf = FL2FXCONST_DBL(0.0f); ccf = FL2FXCONST_DBL(0.0f);
else { else {
FIXP_DBL accu = sfbEnergyMid[sfb]- (((sfbEnergyLeft[sfb]>>1)+(sfbEnergyRight[sfb]>>1))>>1); FIXP_DBL accu =
sfbEnergyMid[sfb] -
(((sfbEnergyLeft[sfb] >> 1) + (sfbEnergyRight[sfb] >> 1)) >> 1);
INT sign = (accu < FL2FXCONST_DBL(0.0f)) ? 1 : 0; INT sign = (accu < FL2FXCONST_DBL(0.0f)) ? 1 : 0;
accu = fixp_abs(accu); accu = fixp_abs(accu);
ccf = CalcLdData(accu) + FL2FXCONST_DBL((float)1.0f/(float)LD_DATA_SCALING) - quot; /* ld(accu*2) = ld(accu) + 1 */ ccf = CalcLdData(accu) +
ccf = (ccf>=FL2FXCONST_DBL(0.0)) ? ((FIXP_DBL)MAXVAL_DBL) : (sign) ? -CalcInvLdData(ccf) : CalcInvLdData(ccf); FL2FXCONST_DBL((float)1.0f / (float)LD_DATA_SCALING) -
quot; /* ld(accu*2) = ld(accu) + 1 */
ccf = (ccf >= FL2FXCONST_DBL(0.0))
? ((FIXP_DBL)MAXVAL_DBL)
: (sign) ? -CalcInvLdData(ccf) : CalcInvLdData(ccf);
} }
pNoiseEnergyCorrelationL[sfb] = ccf; pNoiseEnergyCorrelationL[sfb] = ccf;
@ -524,8 +479,6 @@ void FDKaacEnc_PreProcessPnsChannelPair(const INT sfbActive,
} }
} }
/***************************************************************************** /*****************************************************************************
functionname:FDKaacEnc_PostProcessPnsChannelPair functionname:FDKaacEnc_PostProcessPnsChannelPair
@ -546,29 +499,25 @@ void FDKaacEnc_PostProcessPnsChannelPair(const INT sfbActive,
PNS_CONFIG *pnsConf, PNS_CONFIG *pnsConf,
PNS_DATA *pnsDataLeft, PNS_DATA *pnsDataLeft,
PNS_DATA *pnsDataRight, PNS_DATA *pnsDataRight,
INT *RESTRICT msMask, INT *RESTRICT msMask, INT *msDigest) {
INT *msDigest )
{
INT sfb; INT sfb;
if(!pnsConf->usePns) if (!pnsConf->usePns) return;
return;
for (sfb = 0; sfb < sfbActive; sfb++) { for (sfb = 0; sfb < sfbActive; sfb++) {
/* /*
MS post processing MS post processing
*/ */
if (msMask[sfb]) { if (msMask[sfb]) {
if( (pnsDataLeft->pnsFlag[sfb]) && if ((pnsDataLeft->pnsFlag[sfb]) && (pnsDataRight->pnsFlag[sfb])) {
(pnsDataRight->pnsFlag[sfb]) ) {
/* AAC only: Standard */ /* AAC only: Standard */
/* do this to avoid ms flags in layers that should not have it */ /* do this to avoid ms flags in layers that should not have it */
if(pnsDataLeft->noiseEnergyCorrelation[sfb] <= pnsConf->noiseCorrelationThresh){ if (pnsDataLeft->noiseEnergyCorrelation[sfb] <=
pnsConf->noiseCorrelationThresh) {
msMask[sfb] = 0; msMask[sfb] = 0;
*msDigest = MS_SOME; *msDigest = MS_SOME;
} }
} } else {
else {
/* /*
No PNS coding No PNS coding
*/ */
@ -582,7 +531,8 @@ void FDKaacEnc_PostProcessPnsChannelPair(const INT sfbActive,
pns is active in both channels pns is active in both channels
*/ */
if ((pnsDataLeft->pnsFlag[sfb]) && (pnsDataRight->pnsFlag[sfb])) { if ((pnsDataLeft->pnsFlag[sfb]) && (pnsDataRight->pnsFlag[sfb])) {
if(pnsDataLeft->noiseEnergyCorrelation[sfb] > pnsConf->noiseCorrelationThresh) { if (pnsDataLeft->noiseEnergyCorrelation[sfb] >
pnsConf->noiseCorrelationThresh) {
msMask[sfb] = 1; msMask[sfb] = 1;
*msDigest = MS_SOME; *msDigest = MS_SOME;
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,20 +90,20 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Lohwasser Author(s): M. Lohwasser
contents/description: pns.h
******************************************************************************/ Description: pns.h
#ifndef __PNS_H *******************************************************************************/
#define __PNS_H
#ifndef AACENC_PNS_H
#define AACENC_PNS_H
#include "common_fix.h" #include "common_fix.h"
#include "pnsparam.h" #include "pnsparam.h"
#define NO_NOISE_PNS FDK_INT_MIN #define NO_NOISE_PNS FDK_INT_MIN
@ -110,4 +121,4 @@ typedef struct{
INT pnsFlag[MAX_GROUPED_SFB]; INT pnsFlag[MAX_GROUPED_SFB];
} PNS_DATA; } PNS_DATA;
#endif #endif /* AACENC_PNS_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 Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,23 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: Alex Groeschel Author(s): Alex Groeschel
contents/description: Temporal noise shaping
******************************************************************************/ Description: Temporal noise shaping
#ifndef _TNS_H *******************************************************************************/
#define _TNS_H
#ifndef AACENC_TNS_H
#define AACENC_TNS_H
#include "common_fix.h" #include "common_fix.h"
#include "psy_const.h" #include "psy_const.h"
#ifndef PI #ifndef PI
#define PI 3.1415926535897931f #define PI 3.1415926535897931f
#endif #endif
@ -114,25 +125,26 @@ amm-info@iis.fraunhofer.de
/* TNS max filter order for Low Complexity MPEG4 profile */ /* TNS max filter order for Low Complexity MPEG4 profile */
#define TNS_MAX_ORDER 12 #define TNS_MAX_ORDER 12
#define MAX_NUM_OF_FILTERS 2 #define MAX_NUM_OF_FILTERS 2
#define HIFILT 0 /* index of higher filter */ #define HIFILT 0 /* index of higher filter */
#define LOFILT 1 /* index of lower filter */ #define LOFILT 1 /* index of lower filter */
typedef struct { /* stuff that is tabulated dependent on bitrate etc. */ typedef struct { /* stuff that is tabulated dependent on bitrate etc. */
INT filterEnabled[MAX_NUM_OF_FILTERS]; INT filterEnabled[MAX_NUM_OF_FILTERS];
INT threshOn[MAX_NUM_OF_FILTERS]; /* min. prediction gain for using tns TABUL*/ INT threshOn[MAX_NUM_OF_FILTERS]; /* min. prediction gain for using tns
TABUL*/
INT filterStartFreq[MAX_NUM_OF_FILTERS]; /* lowest freq for lpc TABUL*/ INT filterStartFreq[MAX_NUM_OF_FILTERS]; /* lowest freq for lpc TABUL*/
INT tnsLimitOrder[MAX_NUM_OF_FILTERS]; /* Limit for TNS order TABUL*/ INT tnsLimitOrder[MAX_NUM_OF_FILTERS]; /* Limit for TNS order TABUL*/
INT tnsFilterDirection[MAX_NUM_OF_FILTERS]; /* Filtering direction, 0=up, 1=down TABUL */ INT tnsFilterDirection[MAX_NUM_OF_FILTERS]; /* Filtering direction, 0=up,
1=down TABUL */
INT acfSplit[MAX_NUM_OF_FILTERS]; INT acfSplit[MAX_NUM_OF_FILTERS];
FIXP_DBL tnsTimeResolution[MAX_NUM_OF_FILTERS]; /* TNS max. time resolution TABUL. Should be fract but MSVC won't compile then */ FIXP_DBL tnsTimeResolution[MAX_NUM_OF_FILTERS]; /* TNS max. time resolution
TABUL. Should be fract but
MSVC won't compile then */
INT seperateFiltersAllowed; INT seperateFiltersAllowed;
} TNS_PARAMETER_TABULATED; } TNS_PARAMETER_TABULATED;
typedef struct { /*assigned at InitTime*/ typedef struct { /*assigned at InitTime*/
TNS_PARAMETER_TABULATED confTab; TNS_PARAMETER_TABULATED confTab;
INT isLowDelay; INT isLowDelay;
@ -150,7 +162,6 @@ typedef struct { /*assigned at InitTime*/
} TNS_CONFIG; } TNS_CONFIG;
typedef struct { typedef struct {
INT tnsActive[MAX_NUM_OF_FILTERS]; INT tnsActive[MAX_NUM_OF_FILTERS];
INT predictionGain[MAX_NUM_OF_FILTERS]; INT predictionGain[MAX_NUM_OF_FILTERS];
@ -170,7 +181,8 @@ typedef struct{ /*changed at runTime*/
typedef shouldBeUnion { typedef shouldBeUnion {
TNS_DATA_LONG Long; TNS_DATA_LONG Long;
TNS_DATA_SHORT Short; TNS_DATA_SHORT Short;
}TNS_DATA_RAW; }
TNS_DATA_RAW;
typedef struct { typedef struct {
INT numOfSubblocks; INT numOfSubblocks;
@ -187,16 +199,15 @@ typedef struct{
INT direction[TRANS_FAC][MAX_NUM_OF_FILTERS]; INT direction[TRANS_FAC][MAX_NUM_OF_FILTERS];
INT coefCompress[TRANS_FAC][MAX_NUM_OF_FILTERS]; INT coefCompress[TRANS_FAC][MAX_NUM_OF_FILTERS];
/* for Long: length TNS_MAX_ORDER (12 for LC) is required -> 12 */ /* for Long: length TNS_MAX_ORDER (12 for LC) is required -> 12 */
/* for Short: length TRANS_FAC*TNS_MAX_ORDER (only 5 for short LC) is required -> 8*5=40 */ /* for Short: length TRANS_FAC*TNS_MAX_ORDER (only 5 for short LC) is required
/* Currently TRANS_FAC*TNS_MAX_ORDER = 8*12 = 96 (for LC) is used (per channel)! Memory could be saved here! */ * -> 8*5=40 */
/* Currently TRANS_FAC*TNS_MAX_ORDER = 8*12 = 96 (for LC) is used (per
* channel)! Memory could be saved here! */
INT coef[TRANS_FAC][MAX_NUM_OF_FILTERS][TNS_MAX_ORDER]; INT coef[TRANS_FAC][MAX_NUM_OF_FILTERS][TNS_MAX_ORDER];
} TNS_INFO; } TNS_INFO;
INT FDKaacEnc_FreqToBandWithRounding( INT FDKaacEnc_FreqToBandWidthRounding(const INT freq, const INT fs,
const INT freq,
const INT fs,
const INT numOfBands, const INT numOfBands,
const INT *bandStartOffset const INT *bandStartOffset);
);
#endif /* _TNS_H */ #endif /* AACENC_TNS_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 Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,71 +90,77 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Werner Author(s): M. Werner
contents/description: Threshold compensation
******************************************************************************/ Description: Threshold compensation
#ifndef __ADJ_THR_H *******************************************************************************/
#define __ADJ_THR_H
#ifndef ADJ_THR_H
#define ADJ_THR_H
#include "common_fix.h"
#include "adj_thr_data.h" #include "adj_thr_data.h"
#include "qc_data.h" #include "qc_data.h"
#include "line_pe.h" #include "line_pe.h"
#include "interface.h" #include "interface.h"
/*****************************************************************************
functionname: FDKaacEnc_peCalculation
description:
*****************************************************************************/
void FDKaacEnc_peCalculation(PE_DATA *const peData,
const PSY_OUT_CHANNEL *const psyOutChannel[(2)],
QC_OUT_CHANNEL *const qcOutChannel[(2)],
const struct TOOLSINFO *const toolsInfo,
ATS_ELEMENT *const adjThrStateElement,
const INT nChannels);
void FDKaacEnc_peCalculation( /*****************************************************************************
PE_DATA *peData, functionname: FDKaacEnc_AdjThrNew
PSY_OUT_CHANNEL* psyOutChannel[(2)], description: allocate ADJ_THR_STATE
QC_OUT_CHANNEL* qcOutChannel[(2)], *****************************************************************************/
struct TOOLSINFO *toolsInfo, INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE **phAdjThr, INT nElements);
ATS_ELEMENT* adjThrStateElement,
const INT nChannels
);
INT FDKaacEnc_AdjThrNew(ADJ_THR_STATE** phAdjThr, /*****************************************************************************
INT nElements); functionname: FDKaacEnc_AdjThrInit
description: initialize ADJ_THR_STATE
*****************************************************************************/
void FDKaacEnc_AdjThrInit(
ADJ_THR_STATE *const hAdjThr, const INT meanPe, const INT invQuant,
const CHANNEL_MAPPING *const channelMapping, const INT sampleRate,
const INT totalBitrate, const INT isLowDelay,
const AACENC_BITRES_MODE bitResMode, const INT dZoneQuantEnable,
const INT bitDistributionMode, const FIXP_DBL vbrQualFactor);
void FDKaacEnc_AdjThrInit(ADJ_THR_STATE *hAdjThr, /*****************************************************************************
const INT peMean, functionname: FDKaacEnc_DistributeBits
ELEMENT_BITS* elBits[(8)], description:
INT invQuant, *****************************************************************************/
INT nElements, void FDKaacEnc_DistributeBits(
INT nChannelsEff, ADJ_THR_STATE *adjThrState, ATS_ELEMENT *AdjThrStateElement,
INT sampleRate, PSY_OUT_CHANNEL *psyOutChannel[(2)], PE_DATA *peData, INT *grantedPe,
INT advancedBitsToPe, INT *grantedPeCorr, const INT nChannels, const INT commonWindow,
FIXP_DBL vbrQualFactor, const INT avgBits, const INT bitresBits, const INT maxBitresBits,
const INT dZoneQuantEnable); const FIXP_DBL maxBitFac, const AACENC_BITRES_MODE bitResMode);
/*****************************************************************************
functionname: FDKaacEnc_AdjustThresholds
description: adjust thresholds
*****************************************************************************/
void FDKaacEnc_AdjustThresholds(
ADJ_THR_STATE *const hAdjThr, QC_OUT_ELEMENT *const qcElement[((8))],
QC_OUT *const qcOut, const PSY_OUT_ELEMENT *const psyOutElement[((8))],
const INT CBRbitrateMode, const CHANNEL_MAPPING *const cm);
void FDKaacEnc_DistributeBits(ADJ_THR_STATE *adjThrState, /*****************************************************************************
ATS_ELEMENT *AdjThrStateElement, functionname: FDKaacEnc_AdjThrClose
PSY_OUT_CHANNEL *psyOutChannel[(2)], description:
PE_DATA *peData, *****************************************************************************/
INT *grantedPe,
INT *grantedPeCorr,
const INT nChannels,
const INT commonWindow,
const INT avgBits,
const INT bitresBits,
const INT maxBitresBits,
const FIXP_DBL maxBitFac,
const INT bitDistributionMode);
void FDKaacEnc_AdjustThresholds(ATS_ELEMENT* AdjThrStateElement[(8)],
QC_OUT_ELEMENT* qcElement[(8)],
QC_OUT* qcOut,
PSY_OUT_ELEMENT* psyOutElement[(8)],
INT CBRbitrateMode,
INT maxIter2ndGuess,
CHANNEL_MAPPING* cm);
void FDKaacEnc_AdjThrClose(ADJ_THR_STATE **hAdjThr); void FDKaacEnc_AdjThrClose(ADJ_THR_STATE **hAdjThr);
#endif #endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,21 +90,32 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder ********************** /**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel Author(s): M. Schug / A. Groeschel
contents/description: threshold calculations
******************************************************************************/ Description: threshold calculations
#ifndef __ADJ_THR_DATA_H *******************************************************************************/
#define __ADJ_THR_DATA_H
#ifndef ADJ_THR_DATA_H
#define ADJ_THR_DATA_H
#include "psy_const.h" #include "psy_const.h"
typedef enum {
AACENC_BD_MODE_INTER_ELEMENT = 0,
AACENC_BD_MODE_INTRA_ELEMENT = 1
} AACENC_BIT_DISTRIBUTION_MODE;
typedef enum {
AACENC_BR_MODE_FULL = 0,
AACENC_BR_MODE_REDUCED = 1,
AACENC_BR_MODE_DISABLED = 2
} AACENC_BITRES_MODE;
typedef struct { typedef struct {
FIXP_DBL clipSaveLow, clipSaveHigh; FIXP_DBL clipSaveLow, clipSaveHigh;
FIXP_DBL minBitSave, maxBitSave; FIXP_DBL minBitSave, maxBitSave;
@ -124,9 +146,10 @@ typedef struct {
INT bits2PeFactor_e; INT bits2PeFactor_e;
/* avoid hole parameters */ /* avoid hole parameters */
AH_PARAM ahParam; AH_PARAM ahParam;
/* values for correction of pe */ /* parameters for adaptation of minSnr */
/* paramters for adaptation of minSnr */
MINSNR_ADAPT_PARAM minSnrAdaptParam; MINSNR_ADAPT_PARAM minSnrAdaptParam;
/* values for correction of pe */
INT peLast; INT peLast;
INT dynBitsLast; INT dynBitsLast;
FIXP_DBL peCorrectionFactor_m; FIXP_DBL peCorrectionFactor_m;
@ -144,7 +167,8 @@ typedef struct {
typedef struct { typedef struct {
BRES_PARAM bresParamLong, bresParamShort; BRES_PARAM bresParamLong, bresParamShort;
ATS_ELEMENT* adjThrStateElem[(8)]; ATS_ELEMENT* adjThrStateElem[((8))];
AACENC_BIT_DISTRIBUTION_MODE bitDistributionMode;
INT maxIter2ndGuess; INT maxIter2ndGuess;
} ADJ_THR_STATE; } ADJ_THR_STATE;

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,41 +90,44 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Werner Author(s): M. Werner
contents/description: Band/Line energy calculations
******************************************************************************/ Description: Band/Line energy calculations
*******************************************************************************/
#include "band_nrg.h" #include "band_nrg.h"
/***************************************************************************** /*****************************************************************************
functionname: FDKaacEnc_CalcSfbMaxScaleSpec functionname: FDKaacEnc_CalcSfbMaxScaleSpec
description: description:
input: input:
output: output:
*****************************************************************************/ *****************************************************************************/
void void FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *RESTRICT mdctSpectrum,
FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *RESTRICT mdctSpectrum,
const INT *RESTRICT bandOffset, const INT *RESTRICT bandOffset,
INT *RESTRICT sfbMaxScaleSpec, INT *RESTRICT sfbMaxScaleSpec,
const INT numBands) const INT numBands) {
{
INT i, j; INT i, j;
FIXP_DBL maxSpc, tmp; FIXP_DBL maxSpc, tmp;
for (i = 0; i < numBands; i++) { for (i = 0; i < numBands; i++) {
maxSpc = (FIXP_DBL)0; maxSpc = (FIXP_DBL)0;
DWORD_ALIGNED(mdctSpectrum);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) { for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
tmp = fixp_abs(mdctSpectrum[j]); tmp = fixp_abs(mdctSpectrum[j]);
maxSpc = fixMax(maxSpc, tmp); maxSpc = fixMax(maxSpc, tmp);
} }
sfbMaxScaleSpec[i] = (maxSpc==(FIXP_DBL)0) ? (DFRACT_BITS-2) : CntLeadingZeros(maxSpc)-1; j = CntLeadingZeros(maxSpc) - 1;
/* CountLeadingBits() is not necessary here since test value is always > 0 */ sfbMaxScaleSpec[i] = fixMin((DFRACT_BITS - 2), j);
/* CountLeadingBits() is not necessary here since test value is always > 0
*/
} }
} }
@ -124,14 +138,13 @@ FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *RESTRICT mdctSpectrum,
output: output:
*****************************************************************************/ *****************************************************************************/
FIXP_DBL FIXP_DBL
FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *RESTRICT mdctSpectrum, FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *const RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec, const INT *const RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset, const INT *const RESTRICT bandOffset,
const INT numBands, const INT numBands,
FIXP_DBL *RESTRICT bandEnergy, FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData, FIXP_DBL *RESTRICT bandEnergyLdData,
INT minSpecShift) const INT minSpecShift) {
{
INT i, j, scale, nr = 0; INT i, j, scale, nr = 0;
FIXP_DBL maxNrgLd = FL2FXCONST_DBL(-1.0f); FIXP_DBL maxNrgLd = FL2FXCONST_DBL(-1.0f);
FIXP_DBL maxNrg = 0; FIXP_DBL maxNrg = 0;
@ -140,6 +153,9 @@ FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *RESTRICT mdctSpectrum,
for (i = 0; i < numBands; i++) { for (i = 0; i < numBands; i++) {
scale = fixMax(0, sfbMaxScaleSpec[i] - 4); scale = fixMax(0, sfbMaxScaleSpec[i] - 4);
FIXP_DBL tmp = 0; FIXP_DBL tmp = 0;
DWORD_ALIGNED(mdctSpectrum);
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) { for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
spec = mdctSpectrum[j] << scale; spec = mdctSpectrum[j] << scale;
tmp = fPow2AddDiv2(tmp, spec); tmp = fPow2AddDiv2(tmp, spec);
@ -173,23 +189,23 @@ FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *RESTRICT mdctSpectrum,
input: input:
output: output:
*****************************************************************************/ *****************************************************************************/
INT INT FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *RESTRICT mdctSpectrum,
FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec, INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset, const INT *RESTRICT bandOffset,
const INT numBands, const INT numBands,
FIXP_DBL *RESTRICT bandEnergy, FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData) FIXP_DBL *RESTRICT bandEnergyLdData) {
{
INT i, j, shiftBits = 0; INT i, j, shiftBits = 0;
FIXP_DBL maxNrgLd = FL2FXCONST_DBL(0.0f); FIXP_DBL maxNrgLd = FL2FXCONST_DBL(0.0f);
FIXP_DBL spec; FIXP_DBL spec;
for (i = 0; i < numBands; i++) { for (i = 0; i < numBands; i++) {
INT leadingBits = sfbMaxScaleSpec[i]-4; /* max sfbWidth = 96 ; 2^7=128 => 7/2 = 4 (spc*spc) */ INT leadingBits = sfbMaxScaleSpec[i] -
4; /* max sfbWidth = 96 ; 2^7=128 => 7/2 = 4 (spc*spc) */
FIXP_DBL tmp = FL2FXCONST_DBL(0.0); FIXP_DBL tmp = FL2FXCONST_DBL(0.0);
/* don't use scaleValue() here, it increases workload quite sufficiently... */ /* don't use scaleValue() here, it increases workload quite sufficiently...
*/
if (leadingBits >= 0) { if (leadingBits >= 0) {
for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) { for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
spec = mdctSpectrum[j] << leadingBits; spec = mdctSpectrum[j] << leadingBits;
@ -210,31 +226,28 @@ FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *RESTRICT mdctSpectrum,
for (i = numBands; i-- != 0;) { for (i = numBands; i-- != 0;) {
FIXP_DBL scaleDiff = (sfbMaxScaleSpec[i] - 4) * FL2FXCONST_DBL(2.0 / 64); FIXP_DBL scaleDiff = (sfbMaxScaleSpec[i] - 4) * FL2FXCONST_DBL(2.0 / 64);
bandEnergyLdData[i] = (bandEnergyLdData[i] >= ((FL2FXCONST_DBL(-1.f)>>1) + (scaleDiff>>1))) bandEnergyLdData[i] = (bandEnergyLdData[i] >=
? bandEnergyLdData[i]-scaleDiff : FL2FXCONST_DBL(-1.f); ((FL2FXCONST_DBL(-1.f) >> 1) + (scaleDiff >> 1)))
? bandEnergyLdData[i] - scaleDiff
: FL2FXCONST_DBL(-1.f);
/* find maxNrgLd */ /* find maxNrgLd */
maxNrgLd = fixMax(maxNrgLd, bandEnergyLdData[i]); maxNrgLd = fixMax(maxNrgLd, bandEnergyLdData[i]);
} }
if (maxNrgLd<=(FIXP_DBL)0) if (maxNrgLd <= (FIXP_DBL)0) {
{ for (i = numBands; i-- != 0;) {
for(i=numBands; i--!=0; )
{
INT scale = fixMin((sfbMaxScaleSpec[i] - 4) << 1, (DFRACT_BITS - 1)); INT scale = fixMin((sfbMaxScaleSpec[i] - 4) << 1, (DFRACT_BITS - 1));
bandEnergy[i] = scaleValue(bandEnergy[i], -scale); bandEnergy[i] = scaleValue(bandEnergy[i], -scale);
} }
return 0; return 0;
} } else { /* scale down NRGs */
else while (maxNrgLd > FL2FXCONST_DBL(0.0f)) {
{ /* scale down NRGs */
while (maxNrgLd>FL2FXCONST_DBL(0.0f))
{
maxNrgLd -= FL2FXCONST_DBL(2.0 / 64); maxNrgLd -= FL2FXCONST_DBL(2.0 / 64);
shiftBits++; shiftBits++;
} }
for(i=numBands; i--!=0; ) for (i = numBands; i-- != 0;) {
{ INT scale = fixMin(((sfbMaxScaleSpec[i] - 4) + shiftBits) << 1,
INT scale = fixMin( ((sfbMaxScaleSpec[i]-4)+shiftBits)<<1, (DFRACT_BITS-1)); (DFRACT_BITS - 1));
bandEnergyLdData[i] -= shiftBits * FL2FXCONST_DBL(2.0 / 64); bandEnergyLdData[i] -= shiftBits * FL2FXCONST_DBL(2.0 / 64);
bandEnergy[i] = scaleValue(bandEnergy[i], -scale); bandEnergy[i] = scaleValue(bandEnergy[i], -scale);
} }
@ -242,66 +255,56 @@ FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *RESTRICT mdctSpectrum,
} }
} }
/***************************************************************************** /*****************************************************************************
functionname: FDKaacEnc_CalcBandEnergyOptimShort functionname: FDKaacEnc_CalcBandEnergyOptimShort
description: description:
input: input:
output: output:
*****************************************************************************/ *****************************************************************************/
void void FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *RESTRICT mdctSpectrum,
FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *RESTRICT mdctSpectrum,
INT *RESTRICT sfbMaxScaleSpec, INT *RESTRICT sfbMaxScaleSpec,
const INT *RESTRICT bandOffset, const INT *RESTRICT bandOffset,
const INT numBands, const INT numBands,
FIXP_DBL *RESTRICT bandEnergy) FIXP_DBL *RESTRICT bandEnergy) {
{
INT i, j; INT i, j;
for(i=0; i<numBands; i++) for (i = 0; i < numBands; i++) {
{ int leadingBits = sfbMaxScaleSpec[i] -
int leadingBits = sfbMaxScaleSpec[i]-3; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */ 3; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
FIXP_DBL tmp = FL2FXCONST_DBL(0.0); FIXP_DBL tmp = FL2FXCONST_DBL(0.0);
for (j=bandOffset[i];j<bandOffset[i+1];j++) for (j = bandOffset[i]; j < bandOffset[i + 1]; j++) {
{
FIXP_DBL spec = scaleValue(mdctSpectrum[j], leadingBits); FIXP_DBL spec = scaleValue(mdctSpectrum[j], leadingBits);
tmp = fPow2AddDiv2(tmp, spec); tmp = fPow2AddDiv2(tmp, spec);
} }
bandEnergy[i] = tmp; bandEnergy[i] = tmp;
} }
for(i=0; i<numBands; i++) for (i = 0; i < numBands; i++) {
{ INT scale = (2 * (sfbMaxScaleSpec[i] - 3)) -
INT scale = (2*(sfbMaxScaleSpec[i]-3))-1; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */ 1; /* max sfbWidth = 36 ; 2^6=64 => 6/2 = 3 (spc*spc) */
scale = fixMax(fixMin(scale, (DFRACT_BITS - 1)), -(DFRACT_BITS - 1)); scale = fixMax(fixMin(scale, (DFRACT_BITS - 1)), -(DFRACT_BITS - 1));
bandEnergy[i] = scaleValueSaturate(bandEnergy[i], -scale); bandEnergy[i] = scaleValueSaturate(bandEnergy[i], -scale);
} }
} }
/***************************************************************************** /*****************************************************************************
functionname: FDKaacEnc_CalcBandNrgMSOpt functionname: FDKaacEnc_CalcBandNrgMSOpt
description: description:
input: input:
output: output:
*****************************************************************************/ *****************************************************************************/
void FDKaacEnc_CalcBandNrgMSOpt(const FIXP_DBL *RESTRICT mdctSpectrumLeft, void FDKaacEnc_CalcBandNrgMSOpt(
const FIXP_DBL *RESTRICT mdctSpectrumLeft,
const FIXP_DBL *RESTRICT mdctSpectrumRight, const FIXP_DBL *RESTRICT mdctSpectrumRight,
INT *RESTRICT sfbMaxScaleSpecLeft, INT *RESTRICT sfbMaxScaleSpecLeft, INT *RESTRICT sfbMaxScaleSpecRight,
INT *RESTRICT sfbMaxScaleSpecRight, const INT *RESTRICT bandOffset, const INT numBands,
const INT *RESTRICT bandOffset, FIXP_DBL *RESTRICT bandEnergyMid, FIXP_DBL *RESTRICT bandEnergySide,
const INT numBands, INT calcLdData, FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergyMid, FIXP_DBL *RESTRICT bandEnergySideLdData) {
FIXP_DBL *RESTRICT bandEnergySide,
INT calcLdData,
FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergySideLdData)
{
INT i, j, minScale; INT i, j, minScale;
FIXP_DBL NrgMid, NrgSide, specm, specs; FIXP_DBL NrgMid, NrgSide, specm, specs;
for (i = 0; i < numBands; i++) { for (i = 0; i < numBands; i++) {
NrgMid = NrgSide = FL2FXCONST_DBL(0.0); NrgMid = NrgSide = FL2FXCONST_DBL(0.0);
minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]) - 4; minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]) - 4;
minScale = fixMax(0, minScale); minScale = fixMax(0, minScale);
@ -325,8 +328,8 @@ void FDKaacEnc_CalcBandNrgMSOpt(const FIXP_DBL *RESTRICT mdctSpectrumLeft,
NrgSide = fPow2AddDiv2(NrgSide, specs); NrgSide = fPow2AddDiv2(NrgSide, specs);
} }
} }
bandEnergyMid[i] = NrgMid<<1; bandEnergyMid[i] = fMin(NrgMid, (FIXP_DBL)MAXVAL_DBL >> 1) << 1;
bandEnergySide[i] = NrgSide<<1; bandEnergySide[i] = fMin(NrgSide, (FIXP_DBL)MAXVAL_DBL >> 1) << 1;
} }
if (calcLdData) { if (calcLdData) {
@ -334,15 +337,14 @@ void FDKaacEnc_CalcBandNrgMSOpt(const FIXP_DBL *RESTRICT mdctSpectrumLeft,
LdDataVector(bandEnergySide, bandEnergySideLdData, numBands); LdDataVector(bandEnergySide, bandEnergySideLdData, numBands);
} }
for (i=0; i<numBands; i++) for (i = 0; i < numBands; i++) {
{ minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]);
INT minScale = fixMin(sfbMaxScaleSpecLeft[i], sfbMaxScaleSpecRight[i]);
INT scale = fixMax(0, 2 * (minScale - 4)); INT scale = fixMax(0, 2 * (minScale - 4));
if (calcLdData) if (calcLdData) {
{ /* using the minimal scaling of left and right channel can cause very
/* using the minimal scaling of left and right channel can cause very small energies; small energies; check ldNrg before subtract scaling multiplication:
check ldNrg before subtract scaling multiplication: fract*INT we don't need fMult */ fract*INT we don't need fMult */
int minus = scale * FL2FXCONST_DBL(1.0 / 64); int minus = scale * FL2FXCONST_DBL(1.0 / 64);

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,71 +90,53 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Author(s): M. Werner Author(s): M. Werner
Description: Band/Line energy calculation Description: Band/Line energy calculation
******************************************************************************/ *******************************************************************************/
#ifndef _BAND_NRG_H #ifndef BAND_NRG_H
#define _BAND_NRG_H #define BAND_NRG_H
#include "common_fix.h" #include "common_fix.h"
void FDKaacEnc_CalcSfbMaxScaleSpec(const FIXP_DBL *mdctSpectrum,
void const INT *bandOffset, INT *sfbMaxScaleSpec,
FDKaacEnc_CalcSfbMaxScaleSpec( const INT numBands);
const FIXP_DBL *mdctSpectrum,
const INT *bandOffset,
INT *sfbMaxScaleSpec,
const INT numBands
);
FIXP_DBL FIXP_DBL
FDKaacEnc_CheckBandEnergyOptim( FDKaacEnc_CheckBandEnergyOptim(const FIXP_DBL *const RESTRICT mdctSpectrum,
const FIXP_DBL *mdctSpectrum, const INT *const RESTRICT sfbMaxScaleSpec,
INT *sfbMaxScaleSpec, const INT *const RESTRICT bandOffset,
const INT *bandOffset,
const INT numBands, const INT numBands,
FIXP_DBL *RESTRICT bandEnergy,
FIXP_DBL *RESTRICT bandEnergyLdData,
const INT minSpecShift);
INT FDKaacEnc_CalcBandEnergyOptimLong(const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset, const INT numBands,
FIXP_DBL *bandEnergy, FIXP_DBL *bandEnergy,
FIXP_DBL *bandEnergyLdData, FIXP_DBL *bandEnergyLdData);
INT minSpecShift
);
INT void FDKaacEnc_CalcBandEnergyOptimShort(const FIXP_DBL *mdctSpectrum,
FDKaacEnc_CalcBandEnergyOptimLong(
const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec, INT *sfbMaxScaleSpec,
const INT *bandOffset, const INT *bandOffset,
const INT numBands, const INT numBands,
FIXP_DBL *bandEnergy, FIXP_DBL *bandEnergy);
FIXP_DBL *bandEnergyLdData
);
void
FDKaacEnc_CalcBandEnergyOptimShort(
const FIXP_DBL *mdctSpectrum,
INT *sfbMaxScaleSpec,
const INT *bandOffset,
const INT numBands,
FIXP_DBL *bandEnergy
);
void FDKaacEnc_CalcBandNrgMSOpt( void FDKaacEnc_CalcBandNrgMSOpt(
const FIXP_DBL *RESTRICT mdctSpectrumLeft, const FIXP_DBL *RESTRICT mdctSpectrumLeft,
const FIXP_DBL *RESTRICT mdctSpectrumRight, const FIXP_DBL *RESTRICT mdctSpectrumRight,
INT *RESTRICT sfbMaxScaleSpecLeft, INT *RESTRICT sfbMaxScaleSpecLeft, INT *RESTRICT sfbMaxScaleSpecRight,
INT *RESTRICT sfbMaxScaleSpecRight, const INT *RESTRICT bandOffset, const INT numBands,
const INT *RESTRICT bandOffset, FIXP_DBL *RESTRICT bandEnergyMid, FIXP_DBL *RESTRICT bandEnergySide,
const INT numBands, INT calcLdData, FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergyMid,
FIXP_DBL *RESTRICT bandEnergySide,
INT calcLdData,
FIXP_DBL *RESTRICT bandEnergyMidLdData,
FIXP_DBL *RESTRICT bandEnergySideLdData); FIXP_DBL *RESTRICT bandEnergySideLdData);
#endif #endif

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android Software License for The Fraunhofer FDK AAC Codec Library for Android
<EFBFBD> Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur F<EFBFBD>rderung der angewandten Forschung e.V. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder ********************** /**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel Author(s): M. Schug / A. Groeschel
contents/description: bandwidth expert
******************************************************************************/ Description: bandwidth expert
*******************************************************************************/
#include "channel_map.h" #include "channel_map.h"
#include "bandwidth.h" #include "bandwidth.h"
@ -100,80 +112,36 @@ typedef struct{
} BANDWIDTH_TAB; } BANDWIDTH_TAB;
static const BANDWIDTH_TAB bandWidthTable[] = { static const BANDWIDTH_TAB bandWidthTable[] = {
{0, 3700, 5000}, {0, 3700, 5000}, {12000, 5000, 6400}, {20000, 6900, 9640},
{12000, 5000, 6400}, {28000, 9600, 13050}, {40000, 12060, 14260}, {56000, 13950, 15500},
{20000, 6900, 9640}, {72000, 14200, 16120}, {96000, 17000, 17000}, {576001, 17000, 17000}};
{28000, 9600, 13050},
{40000, 12060, 14260},
{56000, 13950, 15500},
{72000, 14200, 16120},
{96000, 17000, 17000},
{576001,17000, 17000}
};
static const BANDWIDTH_TAB bandWidthTable_LD_22050[] = { static const BANDWIDTH_TAB bandWidthTable_LD_22050[] = {
{ 8000, 2000, 2400}, {8000, 2000, 2400}, {12000, 2500, 2700}, {16000, 3300, 3100},
{12000, 2500, 2700}, {24000, 6250, 7200}, {32000, 9200, 10500}, {40000, 16000, 16000},
{16000, 3300, 3100}, {48000, 16000, 16000}, {282241, 16000, 16000}};
{24000, 6250, 7200},
{32000, 9200, 10500},
{40000, 16000, 16000},
{48000, 16000, 16000},
{360001, 16000, 16000}
};
static const BANDWIDTH_TAB bandWidthTable_LD_24000[] = { static const BANDWIDTH_TAB bandWidthTable_LD_24000[] = {
{ 8000, 2000, 2000}, {8000, 2000, 2000}, {12000, 2000, 2300}, {16000, 2200, 2500},
{12000, 2000, 2300}, {24000, 5650, 7200}, {32000, 11600, 12000}, {40000, 12000, 16000},
{16000, 2200, 2500}, {48000, 16000, 16000}, {64000, 16000, 16000}, {307201, 16000, 16000}};
{24000, 5650, 7200},
{32000, 11600, 12000},
{40000, 12000, 16000},
{48000, 16000, 16000},
{64000, 16000, 16000},
{360001, 16000, 16000}
};
static const BANDWIDTH_TAB bandWidthTable_LD_32000[] = { static const BANDWIDTH_TAB bandWidthTable_LD_32000[] = {
{ 8000, 2000, 2000}, {8000, 2000, 2000}, {12000, 2000, 2000}, {24000, 4250, 7200},
{12000, 2000, 2000}, {32000, 8400, 9000}, {40000, 9400, 11300}, {48000, 11900, 14700},
{24000, 4250, 7200}, {64000, 14800, 16000}, {76000, 16000, 16000}, {409601, 16000, 16000}};
{32000, 8400, 9000},
{40000, 9400, 11300},
{48000, 11900, 14700},
{64000, 14800, 16000},
{76000, 16000, 16000},
{360001, 16000, 16000}
};
static const BANDWIDTH_TAB bandWidthTable_LD_44100[] = { static const BANDWIDTH_TAB bandWidthTable_LD_44100[] = {
{ 8000, 2000, 2000}, {8000, 2000, 2000}, {24000, 2000, 2000}, {32000, 4400, 5700},
{24000, 2000, 2000}, {40000, 7400, 8800}, {48000, 9000, 10700}, {56000, 11000, 12900},
{32000, 4400, 5700}, {64000, 14400, 15500}, {80000, 16000, 16200}, {96000, 16500, 16000},
{40000, 7400, 8800}, {128000, 16000, 16000}, {564481, 16000, 16000}};
{48000, 9000, 10700},
{56000, 11000, 12900},
{64000, 14400, 15500},
{80000, 16000, 16200},
{96000, 16500, 16000},
{128000, 16000, 16000},
{360001, 16000, 16000}
};
static const BANDWIDTH_TAB bandWidthTable_LD_48000[] = { static const BANDWIDTH_TAB bandWidthTable_LD_48000[] = {
{ 8000, 2000, 2000}, {8000, 2000, 2000}, {24000, 2000, 2000}, {32000, 4400, 5700},
{24000, 2000, 2000}, {40000, 7400, 8800}, {48000, 9000, 10700}, {56000, 11000, 12800},
{32000, 4400, 5700}, {64000, 14300, 15400}, {80000, 16000, 16200}, {96000, 16500, 16000},
{40000, 7400, 8800}, {128000, 16000, 16000}, {614401, 16000, 16000}};
{48000, 9000, 10700},
{56000, 11000, 12800},
{64000, 14300, 15400},
{80000, 16000, 16200},
{96000, 16500, 16000},
{128000, 16000, 16000},
{360001, 16000, 16000}
};
typedef struct { typedef struct {
AACENC_BITRATE_MODE bitrateMode; AACENC_BITRATE_MODE bitrateMode;
@ -193,21 +161,22 @@ static const BANDWIDTH_TAB_VBR bandWidthTableVBR[]= {
}; };
static INT GetBandwidthEntry( static INT GetBandwidthEntry(const INT frameLength, const INT sampleRate,
const INT frameLength, const INT chanBitRate, const INT entryNo) {
const INT sampleRate,
const INT chanBitRate,
const INT entryNo)
{
INT bandwidth = -1; INT bandwidth = -1;
const BANDWIDTH_TAB *pBwTab = NULL; const BANDWIDTH_TAB *pBwTab = NULL;
INT bwTabSize = 0; INT bwTabSize = 0;
switch (frameLength) { switch (frameLength) {
case 960:
case 1024: case 1024:
pBwTab = bandWidthTable; pBwTab = bandWidthTable;
bwTabSize = sizeof(bandWidthTable) / sizeof(BANDWIDTH_TAB); bwTabSize = sizeof(bandWidthTable) / sizeof(BANDWIDTH_TAB);
break; break;
case 120:
case 128:
case 240:
case 256:
case 480: case 480:
case 512: case 512:
switch (sampleRate) { switch (sampleRate) {
@ -227,7 +196,7 @@ static INT GetBandwidthEntry(
pBwTab = bandWidthTable_LD_32000; pBwTab = bandWidthTable_LD_32000;
bwTabSize = sizeof(bandWidthTable_LD_32000) / sizeof(BANDWIDTH_TAB); bwTabSize = sizeof(bandWidthTable_LD_32000) / sizeof(BANDWIDTH_TAB);
break; break;
case (44100): case 44100:
pBwTab = bandWidthTable_LD_44100; pBwTab = bandWidthTable_LD_44100;
bwTabSize = sizeof(bandWidthTable_LD_44100) / sizeof(BANDWIDTH_TAB); bwTabSize = sizeof(bandWidthTable_LD_44100) / sizeof(BANDWIDTH_TAB);
break; break;
@ -249,27 +218,34 @@ static INT GetBandwidthEntry(
int i; int i;
for (i = 0; i < bwTabSize - 1; i++) { for (i = 0; i < bwTabSize - 1; i++) {
if (chanBitRate >= pBwTab[i].chanBitRate && if (chanBitRate >= pBwTab[i].chanBitRate &&
chanBitRate < pBwTab[i+1].chanBitRate) chanBitRate < pBwTab[i + 1].chanBitRate) {
{
switch (frameLength) { switch (frameLength) {
case 960:
case 1024: case 1024:
bandwidth = (entryNo==0) bandwidth = (entryNo == 0) ? pBwTab[i].bandWidthMono
? pBwTab[i].bandWidthMono
: pBwTab[i].bandWidth2AndMoreChan; : pBwTab[i].bandWidth2AndMoreChan;
break; break;
case 120:
case 128:
case 240:
case 256:
case 480: case 480:
case 512: case 512: {
{
INT q_res = 0; INT q_res = 0;
INT startBw = (entryNo==0) ? pBwTab[i ].bandWidthMono : pBwTab[i ].bandWidth2AndMoreChan; INT startBw = (entryNo == 0) ? pBwTab[i].bandWidthMono
INT endBw = (entryNo==0) ? pBwTab[i+1].bandWidthMono : pBwTab[i+1].bandWidth2AndMoreChan; : pBwTab[i].bandWidth2AndMoreChan;
INT endBw = (entryNo == 0) ? pBwTab[i + 1].bandWidthMono
: pBwTab[i + 1].bandWidth2AndMoreChan;
INT startBr = pBwTab[i].chanBitRate; INT startBr = pBwTab[i].chanBitRate;
INT endBr = pBwTab[i + 1].chanBitRate; INT endBr = pBwTab[i + 1].chanBitRate;
FIXP_DBL bwFac_fix = fDivNorm(chanBitRate-startBr, endBr-startBr, &q_res); FIXP_DBL bwFac_fix =
bandwidth = (INT)scaleValue(fMult(bwFac_fix, (FIXP_DBL)(endBw-startBw)),q_res) + startBw; fDivNorm(chanBitRate - startBr, endBr - startBr, &q_res);
} bandwidth =
break; (INT)scaleValue(fMult(bwFac_fix, (FIXP_DBL)(endBw - startBw)),
q_res) +
startBw;
} break;
default: default:
bandwidth = -1; bandwidth = -1;
} }
@ -281,20 +257,14 @@ static INT GetBandwidthEntry(
return bandwidth; return bandwidth;
} }
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth, const INT proposedBandWidth, const INT bitrate,
INT proposedBandWidth, const AACENC_BITRATE_MODE bitrateMode, const INT sampleRate,
INT bitrate, const INT frameLength, const CHANNEL_MAPPING *const cm,
AACENC_BITRATE_MODE bitrateMode, const CHANNEL_MODE encoderMode, INT *const bandWidth) {
INT sampleRate,
INT frameLength,
CHANNEL_MAPPING* cm,
CHANNEL_MODE encoderMode)
{
AAC_ENCODER_ERROR ErrorStatus = AAC_ENC_OK; AAC_ENCODER_ERROR ErrorStatus = AAC_ENC_OK;
INT chanBitRate = bitrate/cm->nChannels; INT chanBitRate = bitrate / cm->nChannelsEff;
/* vbr */
switch (bitrateMode) { switch (bitrateMode) {
case AACENC_BR_MODE_VBR_1: case AACENC_BR_MODE_VBR_1:
case AACENC_BR_MODE_VBR_2: case AACENC_BR_MODE_VBR_2:
@ -315,9 +285,12 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
case MODE_1_2_1: case MODE_1_2_1:
case MODE_1_2_2: case MODE_1_2_2:
case MODE_1_2_2_1: case MODE_1_2_2_1:
case MODE_6_1:
case MODE_1_2_2_2_1: case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND: case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER: case MODE_7_1_FRONT_CENTER:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
*bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan; *bandWidth = bandWidthTableVBR[bitrateMode].bandWidth2AndMoreChan;
break; break;
default: default:
@ -331,15 +304,14 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
/* bandwidth limiting */ /* bandwidth limiting */
if (proposedBandWidth != 0) { if (proposedBandWidth != 0) {
*bandWidth = FDKmin(proposedBandWidth, FDKmin(20000, sampleRate>>1)); *bandWidth = fMin(proposedBandWidth, fMin(20000, sampleRate >> 1));
} } else { /* search reasonable bandwidth */
else { /* search reasonable bandwidth */
int entryNo = 0; int entryNo = 0;
switch (encoderMode) { switch (encoderMode) {
case MODE_1: /* mono */ case MODE_1: /* mono */
entryNo = 0; /* use mono bandwith settings */ entryNo = 0; /* use mono bandwidth settings */
break; break;
case MODE_2: /* stereo */ case MODE_2: /* stereo */
@ -347,33 +319,42 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth,
case MODE_1_2_1: /* sce + cpe + sce */ case MODE_1_2_1: /* sce + cpe + sce */
case MODE_1_2_2: /* sce + cpe + cpe */ case MODE_1_2_2: /* sce + cpe + cpe */
case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */ case MODE_1_2_2_1: /* (5.1) sce + cpe + cpe + lfe */
case MODE_1_2_2_2_1: /* (7.1) sce + cpe + cpe + cpe + lfe */ case MODE_6_1:
case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND: case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER: case MODE_7_1_FRONT_CENTER:
entryNo = 1; /* use stereo bandwith settings */ case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
entryNo = 1; /* use stereo bandwidth settings */
break; break;
default: default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG; return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
} }
*bandWidth = GetBandwidthEntry( *bandWidth =
frameLength, GetBandwidthEntry(frameLength, sampleRate, chanBitRate, entryNo);
sampleRate,
chanBitRate,
entryNo);
if (*bandWidth == -1) { if (*bandWidth == -1) {
switch (frameLength) {
case 120:
case 128:
case 240:
case 256:
*bandWidth = 16000;
break;
default:
ErrorStatus = AAC_ENC_INVALID_CHANNEL_BITRATE; ErrorStatus = AAC_ENC_INVALID_CHANNEL_BITRATE;
} }
} }
}
break; break;
default: default:
*bandWidth = 0; *bandWidth = 0;
return AAC_ENC_UNSUPPORTED_BITRATE_MODE; return AAC_ENC_UNSUPPORTED_BITRATE_MODE;
} }
*bandWidth = FDKmin(*bandWidth, sampleRate/2); *bandWidth = fMin(*bandWidth, sampleRate / 2);
return ErrorStatus;; return ErrorStatus;
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,28 +90,25 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder ********************** /**************************** AAC encoder library ******************************
Initial author: M. Schug / A. Groeschel Author(s): M. Schug / A. Groeschel
contents/description: bandwidth expert
******************************************************************************/ Description: bandwidth expert
#ifndef _BANDWIDTH_H *******************************************************************************/
#define _BANDWIDTH_H
#ifndef BANDWIDTH_H
#define BANDWIDTH_H
#include "qc_data.h" #include "qc_data.h"
AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(INT* bandWidth, AAC_ENCODER_ERROR FDKaacEnc_DetermineBandWidth(
INT proposedBandwidth, const INT proposedBandWidth, const INT bitrate,
INT bitrate, const AACENC_BITRATE_MODE bitrateMode, const INT sampleRate,
AACENC_BITRATE_MODE bitrateMode, const INT frameLength, const CHANNEL_MAPPING *const cm,
INT sampleRate, const CHANNEL_MODE encoderMode, INT *const bandWidth);
INT frameLength,
CHANNEL_MAPPING* cm,
CHANNEL_MODE encoderMode);
#endif /* BANDWIDTH_H */ #endif /* BANDWIDTH_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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,18 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M.Werner Author(s): M.Werner
contents/description: Huffman Bitcounter & coder
******************************************************************************/ Description: Huffman Bitcounter & coder
#ifndef __BITCOUNT_H *******************************************************************************/
#define __BITCOUNT_H
#ifndef BIT_CNT_H
#define BIT_CNT_H
#include "common_fix.h" #include "common_fix.h"
#include "FDK_bitstream.h" #include "FDK_bitstream.h"
@ -167,20 +178,22 @@ enum codeBookLav{
CODE_BOOK_PNS_LAV = 60 CODE_BOOK_PNS_LAV = 60
}; };
INT FDKaacEnc_bitCount(const SHORT *aQuantSpectrum, INT FDKaacEnc_bitCount(const SHORT *aQuantSpectrum, const INT noOfSpecLines,
const INT noOfSpecLines, INT maxVal, INT *bitCountLut);
INT maxVal,
INT *bitCountLut);
INT FDKaacEnc_countValues(SHORT *values, INT width, INT codeBook); INT FDKaacEnc_countValues(SHORT *values, INT width, INT codeBook);
INT FDKaacEnc_codeValues(SHORT *values, INT width, INT codeBook, HANDLE_FDK_BITSTREAM hBitstream); INT FDKaacEnc_codeValues(SHORT *values, INT width, INT codeBook,
HANDLE_FDK_BITSTREAM hBitstream);
INT FDKaacEnc_codeScalefactorDelta(INT scalefactor, HANDLE_FDK_BITSTREAM hBitstream); INT FDKaacEnc_codeScalefactorDelta(INT scalefactor,
HANDLE_FDK_BITSTREAM hBitstream);
inline INT FDKaacEnc_bitCountScalefactorDelta(const INT delta) inline INT FDKaacEnc_bitCountScalefactorDelta(const INT delta) {
{ FDK_ASSERT((0 <= (delta + CODE_BOOK_SCF_LAV)) &&
FDK_ASSERT( (0 <= (delta+CODE_BOOK_SCF_LAV)) && ((delta+CODE_BOOK_SCF_LAV)<(int)(sizeof(FDKaacEnc_huff_ltabscf)/sizeof((FDKaacEnc_huff_ltabscf[0])))) ); ((delta + CODE_BOOK_SCF_LAV) <
(int)(sizeof(FDKaacEnc_huff_ltabscf) /
sizeof((FDKaacEnc_huff_ltabscf[0])))));
return ((INT)FDKaacEnc_huff_ltabscf[delta + CODE_BOOK_SCF_LAV]); return ((INT)FDKaacEnc_huff_ltabscf[delta + CODE_BOOK_SCF_LAV]);
} }

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 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,18 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Werner Author(s): M. Werner
contents/description: Bitstream encoder
******************************************************************************/ Description: Bitstream encoder
#ifndef _BITENC_H *******************************************************************************/
#define _BITENC_H
#ifndef BITENC_H
#define BITENC_H
#include "qc_data.h" #include "qc_data.h"
#include "aacenc_tns.h" #include "aacenc_tns.h"
@ -109,44 +120,40 @@ typedef enum{
FIRST_LAY = 1 /* default layer number for AAC nonscalable */ FIRST_LAY = 1 /* default layer number for AAC nonscalable */
} _MAX_CONST; } _MAX_CONST;
#define BUFFER_MX_HUFFCB_SIZE (32*sizeof(INT)) /* our FDK_bitbuffer needs size of power 2 */ #define BUFFER_MX_HUFFCB_SIZE \
(32 * sizeof(INT)) /* our FDK_bitbuffer needs size of power 2 */
#define EL_ID_BITS (3) #define EL_ID_BITS (3)
/** /**
* \brief Arbitrary order bitstream writer. This function can either assemble a bit stream * \brief Arbitrary order bitstream writer. This function can either assemble a
* and write into the bit buffer of hTpEnc or calculate the number of static bits (signal independent) * bit stream and write into the bit buffer of hTpEnc or calculate the number of
* TpEnc handle must be NULL in this case. Or also Calculate the minimum possible number of * static bits (signal independent) TpEnc handle must be NULL in this
* static bits which by disabling all tools e.g. MS, TNS and sbfCnt=0. The minCnt parameter * case. Or also Calculate the minimum possible number of static bits
* has to be 1 in this latter case. * which by disabling all tools e.g. MS, TNS and sbfCnt=0. The minCnt
* \param hTpEnc Transport encoder handle. If NULL, the number of static bits will be returned into * parameter has to be 1 in this latter case.
* *pBitDemand. * \param hTpEnc Transport encoder handle. If NULL, the number of static bits
* will be returned into *pBitDemand.
* \param pElInfo * \param pElInfo
* \param qcOutChannel * \param qcOutChannel
* \param hReorderInfo * \param hReorderInfo
* \param psyOutElement * \param psyOutElement
* \param psyOutChannel * \param psyOutChannel
* \param syntaxFlags Bit stream syntax flags as defined in FDK_audio.h (Audio Codec flags). * \param syntaxFlags Bit stream syntax flags as defined in FDK_audio.h (Audio
* Codec flags).
* \param aot * \param aot
* \param epConfig * \param epConfig
* \param pBitDemand Pointer to an int where the amount of bits is returned into. The returned value * \param pBitDemand Pointer to an int where the amount of bits is returned
* depends on if hTpEnc is NULL and minCnt. * into. The returned value depends on if hTpEnc is NULL and minCnt.
* \param minCnt If non-zero the value returned into *pBitDemand is the absolute minimum required amount of * \param minCnt If non-zero the value returned into *pBitDemand is the absolute
* static bits in order to write a valid bit stream. * minimum required amount of static bits in order to write a valid bit stream.
* \return AAC_ENCODER_ERROR error code * \return AAC_ENCODER_ERROR error code
*/ */
AAC_ENCODER_ERROR FDKaacEnc_ChannelElementWrite( HANDLE_TRANSPORTENC hTpEnc, AAC_ENCODER_ERROR FDKaacEnc_ChannelElementWrite(
ELEMENT_INFO *pElInfo, HANDLE_TRANSPORTENC hTpEnc, ELEMENT_INFO *pElInfo,
QC_OUT_CHANNEL *qcOutChannel[(2)], QC_OUT_CHANNEL *qcOutChannel[(2)], PSY_OUT_ELEMENT *psyOutElement,
PSY_OUT_ELEMENT *psyOutElement, PSY_OUT_CHANNEL *psyOutChannel[(2)], UINT syntaxFlags,
PSY_OUT_CHANNEL *psyOutChannel[(2)], AUDIO_OBJECT_TYPE aot, SCHAR epConfig, INT *pBitDemand, UCHAR minCnt);
UINT syntaxFlags,
AUDIO_OBJECT_TYPE aot,
SCHAR epConfig,
INT *pBitDemand,
UCHAR minCnt
);
/** /**
* \brief Write bit stream or account static bits * \brief Write bit stream or account static bits
* \param hTpEnc transport encoder handle. If NULL, the function will * \param hTpEnc transport encoder handle. If NULL, the function will
@ -163,21 +170,15 @@ AAC_ENCODER_ERROR FDKaacEnc_ChannelElementWrite( HANDLE_TRANSPORTENC hTpEnc,
*/ */
AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream(HANDLE_TRANSPORTENC hTpEnc, AAC_ENCODER_ERROR FDKaacEnc_WriteBitstream(HANDLE_TRANSPORTENC hTpEnc,
CHANNEL_MAPPING *channelMapping, CHANNEL_MAPPING *channelMapping,
QC_OUT* qcOut, QC_OUT *qcOut, PSY_OUT *psyOut,
PSY_OUT* psyOut,
QC_STATE *qcKernel, QC_STATE *qcKernel,
AUDIO_OBJECT_TYPE aot, AUDIO_OBJECT_TYPE aot,
UINT syntaxFlags, UINT syntaxFlags, SCHAR epConfig);
SCHAR epConfig
);
INT FDKaacEnc_writeExtensionData(HANDLE_TRANSPORTENC hTpEnc, INT FDKaacEnc_writeExtensionData(HANDLE_TRANSPORTENC hTpEnc,
QC_OUT_EXTENSION *pExtension, QC_OUT_EXTENSION *pExtension,
INT elInstanceTag, INT elInstanceTag, UINT alignAnchor,
UINT alignAnchor, UINT syntaxFlags, AUDIO_OBJECT_TYPE aot,
UINT syntaxFlags, SCHAR epConfig);
AUDIO_OBJECT_TYPE aot,
SCHAR epConfig
);
#endif /* _BITENC_H */ #endif /* BITENC_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,87 +90,90 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder ************************** /**************************** AAC encoder library ******************************
Author(s): M. Werner, Tobias Chalupka Author(s): M. Werner, Tobias Chalupka
Description: Block switching Description: Block switching
******************************************************************************/ *******************************************************************************/
/****************** Includes *****************************/ /****************** Includes *****************************/
#include "block_switch.h" #include "block_switch.h"
#include "genericStds.h" #include "genericStds.h"
#define LOWOV_WINDOW _LOWOV_WINDOW #define LOWOV_WINDOW _LOWOV_WINDOW
/**************** internal function prototypes ***********/ /**************** internal function prototypes ***********/
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx); static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[],
const INT blSwWndIdx);
static void FDKaacEnc_CalcWindowEnergy( static void FDKaacEnc_CalcWindowEnergy(
BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen,
INT windowLen, const INT_PCM *pTimeSignal);
const INT_PCM *pTimeSignal
);
/****************** Constants *****************************/ /****************** Constants *****************************/
/* LONG START SHORT STOP LOWOV */ /* LONG START
static const INT blockType2windowShape[2][5] = { {SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW, SINE_WINDOW, KBD_WINDOW}, /* LD */ * SHORT STOP LOWOV */
static const INT blockType2windowShape[2][5] = {
{SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW, SINE_WINDOW, KBD_WINDOW}, /* LD */
{KBD_WINDOW, SINE_WINDOW, SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW}}; /* LC */ {KBD_WINDOW, SINE_WINDOW, SINE_WINDOW, KBD_WINDOW, WRONG_WINDOW}}; /* LC */
/* IIR high pass coeffs */ /* IIR high pass coeffs */
#ifndef SINETABLE_16BIT #ifndef SINETABLE_16BIT
static const FIXP_DBL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN]= static const FIXP_DBL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
{ FL2FXCONST_DBL(-0.5095), FL2FXCONST_DBL(0.7548)};
FL2FXCONST_DBL(-0.5095),FL2FXCONST_DBL(0.7548)
};
static const FIXP_DBL accWindowNrgFac = FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */ static const FIXP_DBL accWindowNrgFac =
FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */
static const FIXP_DBL oneMinusAccWindowNrgFac = FL2FXCONST_DBL(0.7f); static const FIXP_DBL oneMinusAccWindowNrgFac = FL2FXCONST_DBL(0.7f);
/* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */ /* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
static const FIXP_DBL invAttackRatio = FL2FXCONST_DBL(0.1f); /* inverted lower ratio limit for attacks */ static const FIXP_DBL invAttackRatio =
FL2FXCONST_DBL(0.1f); /* inverted lower ratio limit for attacks */
/* The next constants are scaled, because they are used for comparison with scaled values*/ /* The next constants are scaled, because they are used for comparison with
* scaled values*/
/* minimum energy for attacks */ /* minimum energy for attacks */
static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */ static const FIXP_DBL minAttackNrg =
(FL2FXCONST_DBL(1e+6f * NORM_PCM_ENERGY) >>
BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */
#else #else
static const FIXP_SGL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN]= static const FIXP_SGL hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
{ FL2FXCONST_SGL(-0.5095), FL2FXCONST_SGL(0.7548)};
FL2FXCONST_SGL(-0.5095),FL2FXCONST_SGL(0.7548)
};
static const FIXP_DBL accWindowNrgFac = FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */ static const FIXP_DBL accWindowNrgFac =
FL2FXCONST_DBL(0.3f); /* factor for accumulating filtered window energies */
static const FIXP_SGL oneMinusAccWindowNrgFac = FL2FXCONST_SGL(0.7f); static const FIXP_SGL oneMinusAccWindowNrgFac = FL2FXCONST_SGL(0.7f);
/* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */ /* static const float attackRatio = 10.0; */ /* lower ratio limit for attacks */
static const FIXP_SGL invAttackRatio = FL2FXCONST_SGL(0.1f); /* inverted lower ratio limit for attacks */ static const FIXP_SGL invAttackRatio =
FL2FXCONST_SGL(0.1f); /* inverted lower ratio limit for attacks */
/* minimum energy for attacks */ /* minimum energy for attacks */
static const FIXP_DBL minAttackNrg = (FL2FXCONST_DBL(1e+6f*NORM_PCM_ENERGY)>>BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */ static const FIXP_DBL minAttackNrg =
(FL2FXCONST_DBL(1e+6f * NORM_PCM_ENERGY) >>
BLOCK_SWITCH_ENERGY_SHIFT); /* minimum energy for attacks */
#endif #endif
/**************** internal function prototypes ***********/ /**************** internal function prototypes ***********/
/****************** Routines ****************************/ /****************** Routines ****************************/
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay) void FDKaacEnc_InitBlockSwitching(
{ BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay) {
FDKmemclear(blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL)); FDKmemclear(blockSwitchingControl, sizeof(BLOCK_SWITCHING_CONTROL));
if (isLowDelay) if (isLowDelay) {
{
blockSwitchingControl->nBlockSwitchWindows = 4; blockSwitchingControl->nBlockSwitchWindows = 4;
blockSwitchingControl->allowShortFrames = 0; blockSwitchingControl->allowShortFrames = 0;
blockSwitchingControl->allowLookAhead = 0; blockSwitchingControl->allowLookAhead = 0;
} } else {
else
{
blockSwitchingControl->nBlockSwitchWindows = 8; blockSwitchingControl->nBlockSwitchWindows = 8;
blockSwitchingControl->allowShortFrames = 1; blockSwitchingControl->allowShortFrames = 1;
blockSwitchingControl->allowLookAhead = 1; blockSwitchingControl->allowLookAhead = 1;
@ -169,12 +183,12 @@ void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl
/* Initialize startvalue for blocktype */ /* Initialize startvalue for blocktype */
blockSwitchingControl->lastWindowSequence = LONG_WINDOW; blockSwitchingControl->lastWindowSequence = LONG_WINDOW;
blockSwitchingControl->windowShape = blockType2windowShape[blockSwitchingControl->allowShortFrames][blockSwitchingControl->lastWindowSequence]; blockSwitchingControl->windowShape =
blockType2windowShape[blockSwitchingControl->allowShortFrames]
[blockSwitchingControl->lastWindowSequence];
} }
static const INT suggestedGroupingTable[TRANS_FAC][MAX_NO_OF_GROUPS] = static const INT suggestedGroupingTable[TRANS_FAC][MAX_NO_OF_GROUPS] = {
{
/* Attack in Window 0 */ {1, 3, 3, 1}, /* Attack in Window 0 */ {1, 3, 3, 1},
/* Attack in Window 1 */ {1, 1, 3, 3}, /* Attack in Window 1 */ {1, 1, 3, 3},
/* Attack in Window 2 */ {2, 1, 3, 2}, /* Attack in Window 2 */ {2, 1, 3, 2},
@ -182,31 +196,39 @@ static const INT suggestedGroupingTable[TRANS_FAC][MAX_NO_OF_GROUPS] =
/* Attack in Window 4 */ {3, 1, 1, 3}, /* Attack in Window 4 */ {3, 1, 1, 3},
/* Attack in Window 5 */ {3, 2, 1, 2}, /* Attack in Window 5 */ {3, 2, 1, 2},
/* Attack in Window 6 */ {3, 3, 1, 1}, /* Attack in Window 6 */ {3, 3, 1, 1},
/* Attack in Window 7 */ {3, 3, 1, 1} /* Attack in Window 7 */ {3, 3, 1, 1}};
};
/* change block type depending on current blocktype and whether there's an attack */ /* change block type depending on current blocktype and whether there's an
* attack */
/* assume no look-ahead */ /* assume no look-ahead */
static const INT chgWndSq[2][N_BLOCKTYPES] = static const INT chgWndSq[2][N_BLOCKTYPES] = {
{ /* LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW,
/* LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW, LOWOV_WINDOW, WRONG_WINDOW */ LOWOV_WINDOW, WRONG_WINDOW */
/*no attack*/ {LONG_WINDOW, STOP_WINDOW, WRONG_WINDOW, LONG_WINDOW, STOP_WINDOW , WRONG_WINDOW }, /*no attack*/ {LONG_WINDOW, STOP_WINDOW, WRONG_WINDOW, LONG_WINDOW,
/*attack */ {START_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, START_WINDOW, LOWOV_WINDOW, WRONG_WINDOW } STOP_WINDOW, WRONG_WINDOW},
}; /*attack */ {START_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, START_WINDOW,
LOWOV_WINDOW, WRONG_WINDOW}};
/* change block type depending on current blocktype and whether there's an attack */ /* change block type depending on current blocktype and whether there's an
* attack */
/* assume look-ahead */ /* assume look-ahead */
static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] = static const INT chgWndSqLkAhd[2][2][N_BLOCKTYPES] = {
{
/*attack LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW, WRONG_WINDOW */ /* last attack */ /*attack LONG WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW, WRONG_WINDOW */ /* last attack */
/*no attack*/ { {LONG_WINDOW, SHORT_WINDOW, STOP_WINDOW, LONG_WINDOW, WRONG_WINDOW, WRONG_WINDOW}, /* no attack */ /*no attack*/ {
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} }, /* no attack */ {LONG_WINDOW, SHORT_WINDOW, STOP_WINDOW, LONG_WINDOW, WRONG_WINDOW,
/*no attack*/ { {LONG_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LONG_WINDOW, WRONG_WINDOW, WRONG_WINDOW}, /* attack */ WRONG_WINDOW}, /* no attack */
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW, WRONG_WINDOW, WRONG_WINDOW} } /* attack */ /*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, START_WINDOW,
WRONG_WINDOW, WRONG_WINDOW}}, /* no attack */
/*no attack*/ {{LONG_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LONG_WINDOW,
WRONG_WINDOW, WRONG_WINDOW}, /* attack */
/*attack */ {START_WINDOW, SHORT_WINDOW, SHORT_WINDOW,
START_WINDOW, WRONG_WINDOW,
WRONG_WINDOW}} /* attack */
}; };
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal) int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
{ const INT granuleLength, const int isLFE,
const INT_PCM *pTimeSignal) {
UINT i; UINT i;
FIXP_DBL enM1, enMax; FIXP_DBL enM1, enMax;
@ -214,7 +236,6 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con
/* for LFE : only LONG window allowed */ /* for LFE : only LONG window allowed */
if (isLFE) { if (isLFE) {
/* case LFE: */ /* case LFE: */
/* only long blocks, always use sine windows (MPEG2 AAC, MPEG4 AAC) */ /* only long blocks, always use sine windows (MPEG2 AAC, MPEG4 AAC) */
blockSwitchingControl->lastWindowSequence = LONG_WINDOW; blockSwitchingControl->lastWindowSequence = LONG_WINDOW;
@ -230,31 +251,40 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con
blockSwitchingControl->lastAttackIndex = blockSwitchingControl->attackIndex; blockSwitchingControl->lastAttackIndex = blockSwitchingControl->attackIndex;
/* Save current window energy as last window energy */ /* Save current window energy as last window energy */
FDKmemcpy(blockSwitchingControl->windowNrg[0], blockSwitchingControl->windowNrg[1], sizeof(blockSwitchingControl->windowNrg[0])); FDKmemcpy(blockSwitchingControl->windowNrg[0],
FDKmemcpy(blockSwitchingControl->windowNrgF[0], blockSwitchingControl->windowNrgF[1], sizeof(blockSwitchingControl->windowNrgF[0])); blockSwitchingControl->windowNrg[1],
sizeof(blockSwitchingControl->windowNrg[0]));
FDKmemcpy(blockSwitchingControl->windowNrgF[0],
blockSwitchingControl->windowNrgF[1],
sizeof(blockSwitchingControl->windowNrgF[0]));
if (blockSwitchingControl->allowShortFrames) if (blockSwitchingControl->allowShortFrames) {
{
/* Calculate suggested grouping info for the last frame */ /* Calculate suggested grouping info for the last frame */
/* Reset grouping info */ /* Reset grouping info */
FDKmemclear (blockSwitchingControl->groupLen, sizeof(blockSwitchingControl->groupLen)); FDKmemclear(blockSwitchingControl->groupLen,
sizeof(blockSwitchingControl->groupLen));
/* Set grouping info */ /* Set grouping info */
blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS; blockSwitchingControl->noOfGroups = MAX_NO_OF_GROUPS;
FDKmemcpy(blockSwitchingControl->groupLen, suggestedGroupingTable[blockSwitchingControl->lastAttackIndex], sizeof(blockSwitchingControl->groupLen)); FDKmemcpy(blockSwitchingControl->groupLen,
suggestedGroupingTable[blockSwitchingControl->lastAttackIndex],
sizeof(blockSwitchingControl->groupLen));
if (blockSwitchingControl->attack == TRUE) if (blockSwitchingControl->attack == TRUE)
blockSwitchingControl->maxWindowNrg = FDKaacEnc_GetWindowEnergy(blockSwitchingControl->windowNrg[0], blockSwitchingControl->lastAttackIndex); blockSwitchingControl->maxWindowNrg =
FDKaacEnc_GetWindowEnergy(blockSwitchingControl->windowNrg[0],
blockSwitchingControl->lastAttackIndex);
else else
blockSwitchingControl->maxWindowNrg = FL2FXCONST_DBL(0.0); blockSwitchingControl->maxWindowNrg = FL2FXCONST_DBL(0.0);
} }
/* Calculate unfiltered and filtered energies in subwindows and combine to
/* Calculate unfiltered and filtered energies in subwindows and combine to segments */ * segments */
FDKaacEnc_CalcWindowEnergy(blockSwitchingControl, granuleLength>>(nBlockSwitchWindows==4? 2:3 ), pTimeSignal); FDKaacEnc_CalcWindowEnergy(
blockSwitchingControl,
granuleLength >> (nBlockSwitchWindows == 4 ? 2 : 3), pTimeSignal);
/* now calculate if there is an attack */ /* now calculate if there is an attack */
@ -266,10 +296,12 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con
enM1 = blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows - 1]; enM1 = blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows - 1];
for (i = 0; i < nBlockSwitchWindows; i++) { for (i = 0; i < nBlockSwitchWindows; i++) {
FIXP_DBL tmp = fMultDiv2(oneMinusAccWindowNrgFac, blockSwitchingControl->accWindowNrg); FIXP_DBL tmp =
fMultDiv2(oneMinusAccWindowNrgFac, blockSwitchingControl->accWindowNrg);
blockSwitchingControl->accWindowNrg = fMultAdd(tmp, accWindowNrgFac, enM1); blockSwitchingControl->accWindowNrg = fMultAdd(tmp, accWindowNrgFac, enM1);
if (fMult(blockSwitchingControl->windowNrgF[1][i],invAttackRatio) > blockSwitchingControl->accWindowNrg ) { if (fMult(blockSwitchingControl->windowNrgF[1][i], invAttackRatio) >
blockSwitchingControl->accWindowNrg) {
blockSwitchingControl->attack = TRUE; blockSwitchingControl->attack = TRUE;
blockSwitchingControl->attackIndex = i; blockSwitchingControl->attackIndex = i;
} }
@ -277,153 +309,161 @@ int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, con
enMax = fixMax(enMax, enM1); enMax = fixMax(enMax, enM1);
} }
if (enMax < minAttackNrg) blockSwitchingControl->attack = FALSE; if (enMax < minAttackNrg) blockSwitchingControl->attack = FALSE;
/* Check if attack spreads over frame border */ /* Check if attack spreads over frame border */
if((blockSwitchingControl->attack == FALSE) && (blockSwitchingControl->lastattack == TRUE)) { if ((blockSwitchingControl->attack == FALSE) &&
(blockSwitchingControl->lastattack == TRUE)) {
/* if attack is in last window repeat SHORT_WINDOW */ /* if attack is in last window repeat SHORT_WINDOW */
if ( ((blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows-1]>>4) > fMult((FIXP_DBL)(10<<(DFRACT_BITS-1-4)), blockSwitchingControl->windowNrgF[1][1])) if (((blockSwitchingControl->windowNrgF[0][nBlockSwitchWindows - 1] >> 4) >
&& (blockSwitchingControl->lastAttackIndex == (INT)nBlockSwitchWindows-1) fMult((FIXP_DBL)(10 << (DFRACT_BITS - 1 - 4)),
) blockSwitchingControl->windowNrgF[1][1])) &&
{ (blockSwitchingControl->lastAttackIndex ==
(INT)nBlockSwitchWindows - 1)) {
blockSwitchingControl->attack = TRUE; blockSwitchingControl->attack = TRUE;
blockSwitchingControl->attackIndex = 0; blockSwitchingControl->attackIndex = 0;
} }
} }
if (blockSwitchingControl->allowLookAhead) {
if(blockSwitchingControl->allowLookAhead)
{
blockSwitchingControl->lastWindowSequence = blockSwitchingControl->lastWindowSequence =
chgWndSqLkAhd[blockSwitchingControl->lastattack][blockSwitchingControl->attack][blockSwitchingControl->lastWindowSequence]; chgWndSqLkAhd[blockSwitchingControl->lastattack]
} [blockSwitchingControl->attack]
else [blockSwitchingControl->lastWindowSequence];
{ } else {
/* Low Delay */ /* Low Delay */
blockSwitchingControl->lastWindowSequence = blockSwitchingControl->lastWindowSequence =
chgWndSq[blockSwitchingControl->attack][blockSwitchingControl->lastWindowSequence]; chgWndSq[blockSwitchingControl->attack]
[blockSwitchingControl->lastWindowSequence];
} }
/* update window shape */ /* update window shape */
blockSwitchingControl->windowShape = blockType2windowShape[blockSwitchingControl->allowShortFrames][blockSwitchingControl->lastWindowSequence]; blockSwitchingControl->windowShape =
blockType2windowShape[blockSwitchingControl->allowShortFrames]
[blockSwitchingControl->lastWindowSequence];
return (0); return (0);
} }
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[],
const INT blSwWndIdx) {
static FIXP_DBL FDKaacEnc_GetWindowEnergy(const FIXP_DBL in[], const INT blSwWndIdx) /* For coherency, change FDKaacEnc_GetWindowEnergy() to calcluate the energy
{ for a block switching analysis windows, not for a short block. The same is
/* For coherency, change FDKaacEnc_GetWindowEnergy() to calcluate the energy for a block switching analysis windows, done FDKaacEnc_CalcWindowEnergy(). The result of
not for a short block. The same is done FDKaacEnc_CalcWindowEnergy(). The result of FDKaacEnc_GetWindowEnergy() FDKaacEnc_GetWindowEnergy() is used for a comparision of the max energy of
is used for a comparision of the max energy of left/right channel. */ left/right channel. */
return in[blSwWndIdx]; return in[blSwWndIdx];
} }
static void FDKaacEnc_CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen, const INT_PCM *pTimeSignal) static void FDKaacEnc_CalcWindowEnergy(
{ BLOCK_SWITCHING_CONTROL *RESTRICT blockSwitchingControl, INT windowLen,
const INT_PCM *pTimeSignal) {
INT i; INT i;
UINT w; UINT w;
FIXP_SGL hiPassCoeff0 = hiPassCoeff[0]; #ifndef SINETABLE_16BIT
FIXP_SGL hiPassCoeff1 = hiPassCoeff[1]; const FIXP_DBL hiPassCoeff0 = hiPassCoeff[0];
const FIXP_DBL hiPassCoeff1 = hiPassCoeff[1];
#else
const FIXP_SGL hiPassCoeff0 = hiPassCoeff[0];
const FIXP_SGL hiPassCoeff1 = hiPassCoeff[1];
#endif
/* sum up scalarproduct of timesignal as windowed Energies */
for (w=0; w < blockSwitchingControl->nBlockSwitchWindows; w++) {
FIXP_DBL temp_windowNrg = FL2FXCONST_DBL(0.0f);
FIXP_DBL temp_windowNrgF = FL2FXCONST_DBL(0.0f);
FIXP_DBL temp_iirState0 = blockSwitchingControl->iirStates[0]; FIXP_DBL temp_iirState0 = blockSwitchingControl->iirStates[0];
FIXP_DBL temp_iirState1 = blockSwitchingControl->iirStates[1]; FIXP_DBL temp_iirState1 = blockSwitchingControl->iirStates[1];
/* windowNrg = sum(timesample^2) */ /* sum up scalarproduct of timesignal as windowed Energies */
for(i=0;i<windowLen;i++) for (w = 0; w < blockSwitchingControl->nBlockSwitchWindows; w++) {
{ ULONG temp_windowNrg = 0x0;
ULONG temp_windowNrgF = 0x0;
FIXP_DBL tempUnfiltered, tempFiltred, t1, t2; /* windowNrg = sum(timesample^2) */
/* tempUnfiltered is scaled with 1 to prevent overflows during calculation of tempFiltred */ for (i = 0; i < windowLen; i++) {
FIXP_DBL tempUnfiltered, t1, t2;
/* tempUnfiltered is scaled with 1 to prevent overflows during calculation
* of tempFiltred */
#if SAMPLE_BITS == DFRACT_BITS #if SAMPLE_BITS == DFRACT_BITS
tempUnfiltered = (FIXP_DBL)*pTimeSignal++ >> 1; tempUnfiltered = (FIXP_DBL)*pTimeSignal++ >> 1;
#else #else
tempUnfiltered = (FIXP_DBL) *pTimeSignal++ << (DFRACT_BITS-SAMPLE_BITS-1); tempUnfiltered = (FIXP_DBL)*pTimeSignal++
<< (DFRACT_BITS - SAMPLE_BITS - 1);
#endif #endif
t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered - temp_iirState0); t1 = fMultDiv2(hiPassCoeff1, tempUnfiltered - temp_iirState0);
t2 = fMultDiv2(hiPassCoeff0, temp_iirState1); t2 = fMultDiv2(hiPassCoeff0, temp_iirState1);
tempFiltred = (t1 - t2) << 1;
temp_iirState0 = tempUnfiltered; temp_iirState0 = tempUnfiltered;
temp_iirState1 = tempFiltred; temp_iirState1 = (t1 - t2) << 1;
/* subtract 2 from overallscaling (BLOCK_SWITCH_ENERGY_SHIFT) temp_windowNrg += (LONG)fPow2Div2(temp_iirState0) >>
* because tempUnfiltered was already scaled with 1 (is 2 after squaring) (BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2);
* subtract 1 from overallscaling (BLOCK_SWITCH_ENERGY_SHIFT) temp_windowNrgF += (LONG)fPow2Div2(temp_iirState1) >>
* because of fMultDiv2 is doing a scaling by one */ (BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2);
temp_windowNrg += fPow2Div2(tempUnfiltered) >> (BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2); }
temp_windowNrgF += fPow2Div2(tempFiltred) >> (BLOCK_SWITCH_ENERGY_SHIFT - 1 - 2); blockSwitchingControl->windowNrg[1][w] =
(LONG)fMin(temp_windowNrg, (UINT)MAXVAL_DBL);
blockSwitchingControl->windowNrgF[1][w] =
(LONG)fMin(temp_windowNrgF, (UINT)MAXVAL_DBL);
} }
blockSwitchingControl->windowNrg[1][w] = temp_windowNrg;
blockSwitchingControl->windowNrgF[1][w] = temp_windowNrgF;
blockSwitchingControl->iirStates[0] = temp_iirState0; blockSwitchingControl->iirStates[0] = temp_iirState0;
blockSwitchingControl->iirStates[1] = temp_iirState1; blockSwitchingControl->iirStates[1] = temp_iirState1;
} }
}
static const UCHAR synchronizedBlockTypeTable[5][5] = {
static const UCHAR synchronizedBlockTypeTable[5][5] = /* LONG_WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW
{ LOWOV_WINDOW*/
/* LONG_WINDOW START_WINDOW SHORT_WINDOW STOP_WINDOW LOWOV_WINDOW*/ /* LONG_WINDOW */ {LONG_WINDOW, START_WINDOW, SHORT_WINDOW, STOP_WINDOW,
/* LONG_WINDOW */ {LONG_WINDOW, START_WINDOW, SHORT_WINDOW, STOP_WINDOW, LOWOV_WINDOW}, LOWOV_WINDOW},
/* START_WINDOW */ {START_WINDOW, START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LOWOV_WINDOW}, /* START_WINDOW */
/* SHORT_WINDOW */ {SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, WRONG_WINDOW}, {START_WINDOW, START_WINDOW, SHORT_WINDOW, SHORT_WINDOW, LOWOV_WINDOW},
/* STOP_WINDOW */ {STOP_WINDOW, SHORT_WINDOW, SHORT_WINDOW, STOP_WINDOW, LOWOV_WINDOW}, /* SHORT_WINDOW */
/* LOWOV_WINDOW */ {LOWOV_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, LOWOV_WINDOW, LOWOV_WINDOW}, {SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, SHORT_WINDOW, WRONG_WINDOW},
/* STOP_WINDOW */
{STOP_WINDOW, SHORT_WINDOW, SHORT_WINDOW, STOP_WINDOW, LOWOV_WINDOW},
/* LOWOV_WINDOW */
{LOWOV_WINDOW, LOWOV_WINDOW, WRONG_WINDOW, LOWOV_WINDOW, LOWOV_WINDOW},
}; };
int FDKaacEnc_SyncBlockSwitching( int FDKaacEnc_SyncBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft, BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, const INT nChannels,
const INT nChannels, const INT commonWindow) {
const INT commonWindow )
{
UCHAR patchType = LONG_WINDOW; UCHAR patchType = LONG_WINDOW;
if( nChannels == 2 && commonWindow == TRUE) if (nChannels == 2 && commonWindow == TRUE) {
{
/* could be better with a channel loop (need a handle to psy_data) */ /* could be better with a channel loop (need a handle to psy_data) */
/* get suggested Block Types and synchronize */ /* get suggested Block Types and synchronize */
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft->lastWindowSequence]; patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlLeft
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight->lastWindowSequence]; ->lastWindowSequence];
patchType = synchronizedBlockTypeTable[patchType][blockSwitchingControlRight
->lastWindowSequence];
/* sanity check (no change from low overlap window to short winow and vice versa) */ /* sanity check (no change from low overlap window to short winow and vice
if (patchType == WRONG_WINDOW) * versa) */
return -1; /* mixed up AAC-LC and AAC-LD */ if (patchType == WRONG_WINDOW) return -1; /* mixed up AAC-LC and AAC-LD */
/* Set synchronized Blocktype */ /* Set synchronized Blocktype */
blockSwitchingControlLeft->lastWindowSequence = patchType; blockSwitchingControlLeft->lastWindowSequence = patchType;
blockSwitchingControlRight->lastWindowSequence = patchType; blockSwitchingControlRight->lastWindowSequence = patchType;
/* update window shape */ /* update window shape */
blockSwitchingControlLeft->windowShape = blockType2windowShape[blockSwitchingControlLeft->allowShortFrames][blockSwitchingControlLeft->lastWindowSequence]; blockSwitchingControlLeft->windowShape =
blockSwitchingControlRight->windowShape = blockType2windowShape[blockSwitchingControlLeft->allowShortFrames][blockSwitchingControlRight->lastWindowSequence]; blockType2windowShape[blockSwitchingControlLeft->allowShortFrames]
[blockSwitchingControlLeft->lastWindowSequence];
blockSwitchingControlRight->windowShape =
blockType2windowShape[blockSwitchingControlLeft->allowShortFrames]
[blockSwitchingControlRight->lastWindowSequence];
} }
if (blockSwitchingControlLeft->allowShortFrames) if (blockSwitchingControlLeft->allowShortFrames) {
{
int i; int i;
if( nChannels == 2 ) if (nChannels == 2) {
{ if (commonWindow == TRUE) {
if (commonWindow == TRUE)
{
/* Synchronize grouping info */ /* Synchronize grouping info */
int windowSequenceLeftOld = blockSwitchingControlLeft->lastWindowSequence; int windowSequenceLeftOld =
int windowSequenceRightOld = blockSwitchingControlRight->lastWindowSequence; blockSwitchingControlLeft->lastWindowSequence;
int windowSequenceRightOld =
blockSwitchingControlRight->lastWindowSequence;
/* Long Blocks */ /* Long Blocks */
if (patchType != SHORT_WINDOW) { if (patchType != SHORT_WINDOW) {
@ -433,8 +473,7 @@ int FDKaacEnc_SyncBlockSwitching (
blockSwitchingControlLeft->groupLen[0] = 1; blockSwitchingControlLeft->groupLen[0] = 1;
blockSwitchingControlRight->groupLen[0] = 1; blockSwitchingControlRight->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++) for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
{
blockSwitchingControlLeft->groupLen[i] = 0; blockSwitchingControlLeft->groupLen[i] = 0;
blockSwitchingControlRight->groupLen[i] = 0; blockSwitchingControlRight->groupLen[i] = 0;
} }
@ -442,64 +481,68 @@ int FDKaacEnc_SyncBlockSwitching (
/* Short Blocks */ /* Short Blocks */
else { else {
/* in case all two channels were detected as short-blocks before syncing, use the grouping of channel with higher maxWindowNrg */ /* in case all two channels were detected as short-blocks before
* syncing, use the grouping of channel with higher maxWindowNrg */
if ((windowSequenceLeftOld == SHORT_WINDOW) && if ((windowSequenceLeftOld == SHORT_WINDOW) &&
(windowSequenceRightOld == SHORT_WINDOW) ) (windowSequenceRightOld == SHORT_WINDOW)) {
{ if (blockSwitchingControlLeft->maxWindowNrg >
if(blockSwitchingControlLeft->maxWindowNrg > blockSwitchingControlRight->maxWindowNrg) { blockSwitchingControlRight->maxWindowNrg) {
/* Left Channel wins */ /* Left Channel wins */
blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups; blockSwitchingControlRight->noOfGroups =
blockSwitchingControlLeft->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) { for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlRight->groupLen[i] = blockSwitchingControlLeft->groupLen[i]; blockSwitchingControlRight->groupLen[i] =
blockSwitchingControlLeft->groupLen[i];
} }
} } else {
else {
/* Right Channel wins */ /* Right Channel wins */
blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups; blockSwitchingControlLeft->noOfGroups =
blockSwitchingControlRight->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) { for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] = blockSwitchingControlRight->groupLen[i]; blockSwitchingControlLeft->groupLen[i] =
blockSwitchingControlRight->groupLen[i];
} }
} }
} } else if ((windowSequenceLeftOld == SHORT_WINDOW) &&
else if ( (windowSequenceLeftOld == SHORT_WINDOW) && (windowSequenceRightOld != SHORT_WINDOW)) {
(windowSequenceRightOld != SHORT_WINDOW) )
{
/* else use grouping of short-block channel */ /* else use grouping of short-block channel */
blockSwitchingControlRight->noOfGroups = blockSwitchingControlLeft->noOfGroups; blockSwitchingControlRight->noOfGroups =
blockSwitchingControlLeft->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) { for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlRight->groupLen[i] = blockSwitchingControlLeft->groupLen[i]; blockSwitchingControlRight->groupLen[i] =
blockSwitchingControlLeft->groupLen[i];
} }
} } else if ((windowSequenceRightOld == SHORT_WINDOW) &&
else if ( (windowSequenceRightOld == SHORT_WINDOW) && (windowSequenceLeftOld != SHORT_WINDOW)) {
(windowSequenceLeftOld != SHORT_WINDOW) ) blockSwitchingControlLeft->noOfGroups =
{ blockSwitchingControlRight->noOfGroups;
blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups;
for (i = 0; i < MAX_NO_OF_GROUPS; i++) { for (i = 0; i < MAX_NO_OF_GROUPS; i++) {
blockSwitchingControlLeft->groupLen[i] = blockSwitchingControlRight->groupLen[i]; blockSwitchingControlLeft->groupLen[i] =
blockSwitchingControlRight->groupLen[i];
} }
} else { } else {
/* syncing a start and stop window ... */ /* syncing a start and stop window ... */
blockSwitchingControlLeft->noOfGroups = blockSwitchingControlRight->noOfGroups = 2; blockSwitchingControlLeft->noOfGroups =
blockSwitchingControlLeft->groupLen[0] = blockSwitchingControlRight->groupLen[0] = 4; blockSwitchingControlRight->noOfGroups = 2;
blockSwitchingControlLeft->groupLen[1] = blockSwitchingControlRight->groupLen[1] = 4; blockSwitchingControlLeft->groupLen[0] =
blockSwitchingControlRight->groupLen[0] = 4;
blockSwitchingControlLeft->groupLen[1] =
blockSwitchingControlRight->groupLen[1] = 4;
} }
} /* Short Blocks */ } /* Short Blocks */
} } else {
else {
/* stereo, no common window */ /* stereo, no common window */
if (blockSwitchingControlLeft->lastWindowSequence != SHORT_WINDOW) { if (blockSwitchingControlLeft->lastWindowSequence != SHORT_WINDOW) {
blockSwitchingControlLeft->noOfGroups = 1; blockSwitchingControlLeft->noOfGroups = 1;
blockSwitchingControlLeft->groupLen[0] = 1; blockSwitchingControlLeft->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++) for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
{
blockSwitchingControlLeft->groupLen[i] = 0; blockSwitchingControlLeft->groupLen[i] = 0;
} }
} }
if (blockSwitchingControlRight->lastWindowSequence != SHORT_WINDOW) { if (blockSwitchingControlRight->lastWindowSequence != SHORT_WINDOW) {
blockSwitchingControlRight->noOfGroups = 1; blockSwitchingControlRight->noOfGroups = 1;
blockSwitchingControlRight->groupLen[0] = 1; blockSwitchingControlRight->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++) for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
{
blockSwitchingControlRight->groupLen[i] = 0; blockSwitchingControlRight->groupLen[i] = 0;
} }
} }
@ -510,29 +553,25 @@ int FDKaacEnc_SyncBlockSwitching (
blockSwitchingControlLeft->noOfGroups = 1; blockSwitchingControlLeft->noOfGroups = 1;
blockSwitchingControlLeft->groupLen[0] = 1; blockSwitchingControlLeft->groupLen[0] = 1;
for (i = 1; i < MAX_NO_OF_GROUPS; i++) for (i = 1; i < MAX_NO_OF_GROUPS; i++) {
{
blockSwitchingControlLeft->groupLen[i] = 0; blockSwitchingControlLeft->groupLen[i] = 0;
} }
} }
} }
} /* allowShortFrames */ } /* allowShortFrames */
/* Translate LOWOV_WINDOW block type to a meaningful window shape. */ /* Translate LOWOV_WINDOW block type to a meaningful window shape. */
if (!blockSwitchingControlLeft->allowShortFrames) { if (!blockSwitchingControlLeft->allowShortFrames) {
if ( blockSwitchingControlLeft->lastWindowSequence != LONG_WINDOW if (blockSwitchingControlLeft->lastWindowSequence != LONG_WINDOW &&
&& blockSwitchingControlLeft->lastWindowSequence != STOP_WINDOW ) blockSwitchingControlLeft->lastWindowSequence != STOP_WINDOW) {
{
blockSwitchingControlLeft->lastWindowSequence = LONG_WINDOW; blockSwitchingControlLeft->lastWindowSequence = LONG_WINDOW;
blockSwitchingControlLeft->windowShape = LOL_WINDOW; blockSwitchingControlLeft->windowShape = LOL_WINDOW;
} }
} }
if (nChannels == 2) { if (nChannels == 2) {
if (!blockSwitchingControlRight->allowShortFrames) { if (!blockSwitchingControlRight->allowShortFrames) {
if ( blockSwitchingControlRight->lastWindowSequence != LONG_WINDOW if (blockSwitchingControlRight->lastWindowSequence != LONG_WINDOW &&
&& blockSwitchingControlRight->lastWindowSequence != STOP_WINDOW ) blockSwitchingControlRight->lastWindowSequence != STOP_WINDOW) {
{
blockSwitchingControlRight->lastWindowSequence = LONG_WINDOW; blockSwitchingControlRight->lastWindowSequence = LONG_WINDOW;
blockSwitchingControlRight->windowShape = LOL_WINDOW; blockSwitchingControlRight->windowShape = LOL_WINDOW;
} }
@ -541,5 +580,3 @@ int FDKaacEnc_SyncBlockSwitching (
return 0; return 0;
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/***************************** MPEG-4 AAC Encoder ************************** /**************************** AAC encoder library ******************************
Author(s): M. Werner Author(s): M. Werner
Description: Block switching Description: Block switching
******************************************************************************/ *******************************************************************************/
#ifndef _BLOCK_SWITCH_H #ifndef BLOCK_SWITCH_H
#define _BLOCK_SWITCH_H #define BLOCK_SWITCH_H
#include "common_fix.h" #include "common_fix.h"
@ -98,13 +110,15 @@ amm-info@iis.fraunhofer.de
/****************** Defines ******************************/ /****************** Defines ******************************/
#define BLOCK_SWITCH_WINDOWS 8 /* number of windows for energy calculation */ #define BLOCK_SWITCH_WINDOWS 8 /* number of windows for energy calculation */
#define BLOCK_SWITCHING_IIR_LEN 2 /* Length of HighPass-IIR-Filter for Attack-Detection */ #define BLOCK_SWITCHING_IIR_LEN \
#define BLOCK_SWITCH_ENERGY_SHIFT 7 /* should be logDualis(BLOCK_SWITCH_WINDOW_LEN) to avoid overflow in windowNrgs. */ 2 /* Length of HighPass-IIR-Filter for Attack-Detection */
#define BLOCK_SWITCH_ENERGY_SHIFT \
7 /* should be logDualis(BLOCK_SWITCH_WINDOW_LEN) to avoid overflow in \
windowNrgs. */
#define LAST_WINDOW 0 #define LAST_WINDOW 0
#define THIS_WINDOW 1 #define THIS_WINDOW 1
/****************** Structures ***************************/ /****************** Structures ***************************/
typedef struct { typedef struct {
INT lastWindowSequence; INT lastWindowSequence;
@ -121,26 +135,28 @@ typedef struct{
INT groupLen[MAX_NO_OF_GROUPS]; INT groupLen[MAX_NO_OF_GROUPS];
FIXP_DBL maxWindowNrg; /* max energy in subwindows */ FIXP_DBL maxWindowNrg; /* max energy in subwindows */
FIXP_DBL windowNrg[2][BLOCK_SWITCH_WINDOWS]; /* time signal energy in Subwindows (last and current) */ FIXP_DBL
FIXP_DBL windowNrgF[2][BLOCK_SWITCH_WINDOWS]; /* filtered time signal energy in segments (last and current) */ windowNrg[2][BLOCK_SWITCH_WINDOWS]; /* time signal energy in Subwindows
(last and current) */
FIXP_DBL windowNrgF[2][BLOCK_SWITCH_WINDOWS]; /* filtered time signal energy
in segments (last and
current) */
FIXP_DBL accWindowNrg; /* recursively accumulated windowNrgF */ FIXP_DBL accWindowNrg; /* recursively accumulated windowNrgF */
FIXP_DBL iirStates[BLOCK_SWITCHING_IIR_LEN]; /* filter delay-line */ FIXP_DBL iirStates[BLOCK_SWITCHING_IIR_LEN]; /* filter delay-line */
} BLOCK_SWITCHING_CONTROL; } BLOCK_SWITCHING_CONTROL;
void FDKaacEnc_InitBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay);
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
const INT granuleLength, const int isLFE,
const INT_PCM *pTimeSignal);
void FDKaacEnc_InitBlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, INT isLowDelay);
int FDKaacEnc_BlockSwitching(BLOCK_SWITCHING_CONTROL *blockSwitchingControl, const INT granuleLength, const int isLFE, const INT_PCM *pTimeSignal);
int FDKaacEnc_SyncBlockSwitching( int FDKaacEnc_SyncBlockSwitching(
BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft, BLOCK_SWITCHING_CONTROL *blockSwitchingControlLeft,
BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, BLOCK_SWITCHING_CONTROL *blockSwitchingControlRight, const INT noOfChannels,
const INT noOfChannels,
const INT commonWindow); const INT commonWindow);
#endif /* #ifndef _BLOCK_SWITCH_H */ #endif /* #ifndef BLOCK_SWITCH_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,21 +90,22 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder ********************** /**************************** AAC encoder library ******************************
Initial author: A. Groeschel Author(s): A. Groeschel
contents/description: channel mapping functionality
******************************************************************************/ Description: channel mapping functionality
*******************************************************************************/
#include "channel_map.h" #include "channel_map.h"
#include "bitenc.h" #include "bitenc.h"
#include "psy_const.h" #include "psy_const.h"
#include "qc_data.h" #include "qc_data.h"
#include "aacEnc_ram.h" #include "aacEnc_ram.h"
#include "FDK_tools_rom.h"
/* channel_assignment treats the relationship of Input file channels /* channel_assignment treats the relationship of Input file channels
to the encoder channels. to the encoder channels.
@ -121,93 +133,43 @@ amm-info@iis.fraunhofer.de
LFE 3 5 (LFE) LFE 3 5 (LFE)
*/ */
typedef struct {
CHANNEL_MODE encoderMode;
INT channel_assignment[/*(8)*/12];
} CHANNEL_ASSIGNMENT_INFO_TAB;
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabMpeg[] =
{
{ MODE_INVALID, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* invalid */
{ MODE_1, { 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* mono */
{ MODE_2, { 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* stereo */
{ MODE_1_2, { 0, 1, 2,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 3ch */
{ MODE_1_2_1, { 0, 1, 2, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */
{ MODE_1_2_2, { 0, 1, 2, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 0, 1, 2, 3, 4, 5,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_REAR_SURROUND, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_FRONT_CENTER, { 0, 1, 2, 3, 4, 5, 6, 7,-1,-1,-1,-1} } /* 7.1ch */
};
static const CHANNEL_ASSIGNMENT_INFO_TAB assignmentInfoTabWav[] =
{
{ MODE_INVALID, {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* invalid */
{ MODE_1, { 0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* mono */
{ MODE_2, { 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* stereo */
{ MODE_1_2, { 2, 0, 1,-1,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 3ch */
{ MODE_1_2_1, { 2, 0, 1, 3,-1,-1,-1,-1,-1,-1,-1,-1} }, /* 4ch */
{ MODE_1_2_2, { 2, 0, 1, 3, 4,-1,-1,-1,-1,-1,-1,-1} }, /* 5ch */
{ MODE_1_2_2_1, { 2, 0, 1, 4, 5, 3,-1,-1,-1,-1,-1,-1} }, /* 5.1ch */
{ MODE_1_2_2_2_1, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_REAR_SURROUND, { 2, 0, 1, 6, 7, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
{ MODE_7_1_FRONT_CENTER, { 2, 6, 7, 0, 1, 4, 5, 3,-1,-1,-1,-1} }, /* 7.1ch */
};
/* Channel mode configuration tab provides, /* Channel mode configuration tab provides,
corresponding number of channels and elements corresponding number of channels and elements
*/ */
static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] = static const CHANNEL_MODE_CONFIG_TAB channelModeConfig[] = {
{ {MODE_1, 1, 1, 1}, /* chCfg 1, SCE */
{ MODE_1, 1, 1, 1 }, /* SCE */ {MODE_2, 2, 2, 1}, /* chCfg 2, CPE */
{ MODE_2, 2, 2, 1 }, /* CPE */ {MODE_1_2, 3, 3, 2}, /* chCfg 3, SCE,CPE */
{ MODE_1_2, 3, 3, 2 }, /* SCE,CPE */ {MODE_1_2_1, 4, 4, 3}, /* chCfg 4, SCE,CPE,SCE */
{ MODE_1_2_1, 4, 4, 3 }, /* SCE,CPE,SCE */ {MODE_1_2_2, 5, 5, 3}, /* chCfg 5, SCE,CPE,CPE */
{ MODE_1_2_2, 5, 5, 3 }, /* SCE,CPE,CPE */ {MODE_1_2_2_1, 6, 5, 4}, /* chCfg 6, SCE,CPE,CPE,LFE */
{ MODE_1_2_2_1, 6, 5, 4 }, /* SCE,CPE,CPE,LFE */ {MODE_1_2_2_2_1, 8, 7, 5}, /* chCfg 7, SCE,CPE,CPE,CPE,LFE */
{ MODE_1_2_2_2_1, 8, 7, 5 }, /* SCE,CPE,CPE,CPE,LFE */ {MODE_6_1, 7, 6, 5}, /* chCfg 11, SCE,CPE,CPE,SCE,LFE */
{ MODE_7_1_REAR_SURROUND, 8, 7, 5 }, {MODE_7_1_BACK, 8, 7, 5}, /* chCfg 12, SCE,CPE,CPE,CPE,LFE */
{ MODE_7_1_FRONT_CENTER, 8, 7, 5 }, {MODE_7_1_TOP_FRONT, 8, 7, 5}, /* chCfg 14, SCE,CPE,CPE,LFE,CPE */
{MODE_7_1_REAR_SURROUND, 8, 7,
5}, /* same as MODE_7_1_BACK, SCE,CPE,CPE,CPE,LFE */
{MODE_7_1_FRONT_CENTER, 8, 7,
5}, /* same as MODE_1_2_2_2_1, SCE,CPE,CPE,CPE,LFE */
}; };
#define MAX_MODES (sizeof(assignmentInfoTabWav)/sizeof(CHANNEL_ASSIGNMENT_INFO_TAB)) AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode,
INT nChannels) {
const INT* FDKaacEnc_getChannelAssignment(CHANNEL_MODE encMode, CHANNEL_ORDER co)
{
const CHANNEL_ASSIGNMENT_INFO_TAB *pTab;
int i;
if (co == CH_ORDER_MPEG)
pTab = assignmentInfoTabMpeg;
else
pTab = assignmentInfoTabWav;
for(i=MAX_MODES-1; i>0; i--) {
if (encMode== pTab[i].encoderMode) {
break;
}
}
return (pTab[i].channel_assignment);
}
AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode, INT nChannels)
{
INT i; INT i;
CHANNEL_MODE encMode = MODE_INVALID; CHANNEL_MODE encMode = MODE_INVALID;
if (*mode == MODE_UNKNOWN) { if (*mode == MODE_UNKNOWN) {
for (i=0; i<(INT)sizeof(channelModeConfig)/(INT)sizeof(CHANNEL_MODE_CONFIG_TAB); i++) { for (i = 0; i < (INT)sizeof(channelModeConfig) /
(INT)sizeof(CHANNEL_MODE_CONFIG_TAB);
i++) {
if (channelModeConfig[i].nChannels == nChannels) { if (channelModeConfig[i].nChannels == nChannels) {
encMode = channelModeConfig[i].encMode; encMode = channelModeConfig[i].encMode;
break; break;
} }
} }
*mode = encMode; *mode = encMode;
} } else {
else {
/* check if valid channel configuration */ /* check if valid channel configuration */
if (FDKaacEnc_GetChannelModeConfiguration(*mode)->nChannels == nChannels) { if (FDKaacEnc_GetChannelModeConfiguration(*mode)->nChannels == nChannels) {
encMode = *mode; encMode = *mode;
@ -221,27 +183,31 @@ AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode, INT nChanne
return AAC_ENC_OK; return AAC_ENC_OK;
} }
static INT FDKaacEnc_initElement (ELEMENT_INFO* elInfo, MP4_ELEMENT_ID elType, INT* cnt, CHANNEL_MODE mode, CHANNEL_ORDER co, INT* it_cnt, const FIXP_DBL relBits) { static INT FDKaacEnc_initElement(ELEMENT_INFO* elInfo, MP4_ELEMENT_ID elType,
INT* cnt, FDK_channelMapDescr* mapDescr,
UINT mapIdx, INT* it_cnt,
const FIXP_DBL relBits) {
INT error = 0; INT error = 0;
INT counter = *cnt; INT counter = *cnt;
const INT *assign = FDKaacEnc_getChannelAssignment(mode, co);
elInfo->elType = elType; elInfo->elType = elType;
elInfo->relativeBits = relBits; elInfo->relativeBits = relBits;
switch (elInfo->elType) { switch (elInfo->elType) {
case ID_SCE: case ID_LFE: case ID_CCE: case ID_SCE:
case ID_LFE:
case ID_CCE:
elInfo->nChannelsInEl = 1; elInfo->nChannelsInEl = 1;
elInfo->ChannelIndex[0]=assign[counter++]; elInfo->ChannelIndex[0] =
FDK_chMapDescr_getMapValue(mapDescr, counter++, mapIdx);
elInfo->instanceTag = it_cnt[elType]++; elInfo->instanceTag = it_cnt[elType]++;
break; break;
case ID_CPE: case ID_CPE:
elInfo->nChannelsInEl = 2; elInfo->nChannelsInEl = 2;
elInfo->ChannelIndex[0]=assign[counter++]; elInfo->ChannelIndex[0] =
elInfo->ChannelIndex[1]=assign[counter++]; FDK_chMapDescr_getMapValue(mapDescr, counter++, mapIdx);
elInfo->ChannelIndex[1] =
FDK_chMapDescr_getMapValue(mapDescr, counter++, mapIdx);
elInfo->instanceTag = it_cnt[elType]++; elInfo->instanceTag = it_cnt[elType]++;
break; break;
case ID_DSE: case ID_DSE:
@ -250,28 +216,31 @@ static INT FDKaacEnc_initElement (ELEMENT_INFO* elInfo, MP4_ELEMENT_ID elType, I
elInfo->ChannelIndex[1] = 0; elInfo->ChannelIndex[1] = 0;
elInfo->instanceTag = it_cnt[elType]++; elInfo->instanceTag = it_cnt[elType]++;
break; break;
default: error=1; default:
error = 1;
}; };
*cnt = counter; *cnt = counter;
return error; return error;
} }
AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER co, CHANNEL_MAPPING* cm) AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode,
{ CHANNEL_ORDER co,
CHANNEL_MAPPING* cm) {
INT count = 0; /* count through coder channels */ INT count = 0; /* count through coder channels */
INT it_cnt[ID_END + 1]; INT it_cnt[ID_END + 1];
INT i; INT i;
UINT mapIdx;
FDK_channelMapDescr mapDescr;
for (i=0; i<ID_END; i++) for (i = 0; i < ID_END; i++) it_cnt[i] = 0;
it_cnt[i]=0;
FDKmemclear(cm, sizeof(CHANNEL_MAPPING)); FDKmemclear(cm, sizeof(CHANNEL_MAPPING));
/* init channel mapping*/ /* init channel mapping*/
for (i=0; i<(INT)sizeof(channelModeConfig)/(INT)sizeof(CHANNEL_MODE_CONFIG_TAB); i++) { for (i = 0; i < (INT)sizeof(channelModeConfig) /
if (channelModeConfig[i].encMode==mode) (INT)sizeof(CHANNEL_MODE_CONFIG_TAB);
{ i++) {
if (channelModeConfig[i].encMode == mode) {
cm->encMode = channelModeConfig[i].encMode; cm->encMode = channelModeConfig[i].encMode;
cm->nChannels = channelModeConfig[i].nChannels; cm->nChannels = channelModeConfig[i].nChannels;
cm->nChannelsEff = channelModeConfig[i].nChannelsEff; cm->nChannelsEff = channelModeConfig[i].nChannelsEff;
@ -281,73 +250,133 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode, CHANNEL_ORDER
} }
} }
/* init map descriptor */
FDK_chMapDescr_init(&mapDescr, NULL, 0, (co == CH_ORDER_MPEG) ? 1 : 0);
switch (mode) {
case MODE_7_1_REAR_SURROUND: /* MODE_7_1_REAR_SURROUND is equivalent to
MODE_7_1_BACK */
mapIdx = (INT)MODE_7_1_BACK;
break;
case MODE_7_1_FRONT_CENTER: /* MODE_7_1_FRONT_CENTER is equivalent to
MODE_1_2_2_2_1 */
mapIdx = (INT)MODE_1_2_2_2_1;
break;
default:
mapIdx =
(INT)mode > 14
? 0
: (INT)
mode; /* if channel config > 14 MPEG mapping will be used */
}
/* init element info struct */ /* init element info struct */
switch (mode) { switch (mode) {
case MODE_1: case MODE_1:
/* (mono) sce */ /* (mono) sce */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, (FIXP_DBL)MAXVAL_DBL); FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, (FIXP_DBL)MAXVAL_DBL);
break; break;
case MODE_2: case MODE_2:
/* (stereo) cpe */ /* (stereo) cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_CPE, &count, mode, co, it_cnt, (FIXP_DBL)MAXVAL_DBL); FDKaacEnc_initElement(&cm->elInfo[0], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, (FIXP_DBL)MAXVAL_DBL);
break; break;
case MODE_1_2: case MODE_1_2:
/* sce + cpe */ /* sce + cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.4f)); FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.6f)); it_cnt, FL2FXCONST_DBL(0.4f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.6f));
break; break;
case MODE_1_2_1: case MODE_1_2_1:
/* sce + cpe + sce */ /* sce + cpe + sce */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.3f)); FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.4f)); it_cnt, FL2FXCONST_DBL(0.3f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.3f)); FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.4f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.3f));
break; break;
case MODE_1_2_2: case MODE_1_2_2:
/* sce + cpe + cpe */ /* sce + cpe + cpe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f)); FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.37f)); it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.37f)); FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.37f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.37f));
break; break;
case MODE_1_2_2_1: case MODE_1_2_2_1:
/* (5.1) sce + cpe + cpe + lfe */ /* (5.1) sce + cpe + cpe + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.24f)); FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.35f)); it_cnt, FL2FXCONST_DBL(0.24f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.35f)); FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
FDKaacEnc_initElement(&cm->elInfo[3], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.06f)); it_cnt, FL2FXCONST_DBL(0.35f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.35f));
FDKaacEnc_initElement(&cm->elInfo[3], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.06f));
break;
case MODE_6_1:
/* (6.1) sce + cpe + cpe + sce + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.2f));
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.275f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.275f));
FDKaacEnc_initElement(&cm->elInfo[3], ID_SCE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.2f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.05f));
break; break;
case MODE_1_2_2_2_1: case MODE_1_2_2_2_1:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
case MODE_7_1_REAR_SURROUND: case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER: case MODE_7_1_FRONT_CENTER: {
/* (7.1) sce + cpe + cpe + cpe + lfe */ /* (7.1) sce + cpe + cpe + cpe + lfe */
FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.18f)); /* (7.1 top) sce + cpe + cpe + lfe + cpe */
FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f)); FDKaacEnc_initElement(&cm->elInfo[0], ID_SCE, &count, &mapDescr, mapIdx,
FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.26f)); it_cnt, FL2FXCONST_DBL(0.18f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, mode, co, it_cnt, FL2FXCONST_DBL(0.04f)); FDKaacEnc_initElement(&cm->elInfo[1], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[2], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
if (mode != MODE_7_1_TOP_FRONT) {
FDKaacEnc_initElement(&cm->elInfo[3], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.04f));
} else {
FDKaacEnc_initElement(&cm->elInfo[3], ID_LFE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.04f));
FDKaacEnc_initElement(&cm->elInfo[4], ID_CPE, &count, &mapDescr, mapIdx,
it_cnt, FL2FXCONST_DBL(0.26f));
}
break; break;
}
default: default:
//*chMap=0; //*chMap=0;
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG; return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
}; };
FDK_ASSERT(cm->nElements <= ((8)));
FDK_ASSERT(cm->nElements<=(8));
return AAC_ENC_OK; return AAC_ENC_OK;
} }
AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC, AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE* hQC, CHANNEL_MAPPING* cm,
CHANNEL_MAPPING *cm, INT bitrateTot, INT averageBitsTot,
INT bitrateTot, INT maxChannelBits) {
INT averageBitsTot,
INT maxChannelBits)
{
int sc_brTot = CountLeadingBits(bitrateTot); int sc_brTot = CountLeadingBits(bitrateTot);
switch (cm->encMode) { switch (cm->encMode) {
@ -372,8 +401,10 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
FIXP_DBL sceRate = cm->elInfo[0].relativeBits; FIXP_DBL sceRate = cm->elInfo[0].relativeBits;
FIXP_DBL cpeRate = cm->elInfo[1].relativeBits; FIXP_DBL cpeRate = cm->elInfo[1].relativeBits;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[0]->chBitrateEl =
hQC->elementBits[1]->chBitrateEl = fMult(cpeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[0]->maxBitsEl = maxChannelBits; hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits; hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
@ -388,9 +419,12 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
FIXP_DBL cpeRate = cm->elInfo[1].relativeBits; FIXP_DBL cpeRate = cm->elInfo[1].relativeBits;
FIXP_DBL sce2Rate = cm->elInfo[2].relativeBits; FIXP_DBL sce2Rate = cm->elInfo[2].relativeBits;
hQC->elementBits[0]->chBitrateEl = fMult(sce1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[0]->chBitrateEl =
hQC->elementBits[1]->chBitrateEl = fMult(cpeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); fMult(sce1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[2]->chBitrateEl = fMult(sce2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[1]->chBitrateEl =
fMult(cpeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(sce2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits; hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits; hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
@ -406,16 +440,18 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits; FIXP_DBL cpe1Rate = cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits; FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[0]->chBitrateEl =
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); hQC->elementBits[1]->chBitrateEl =
fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[0]->maxBitsEl = maxChannelBits; hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits; hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits; hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits;
break; break;
} }
case MODE_1_2_2_1: { case MODE_1_2_2_1: {
/* (5.1) sce + cpe + cpe + lfe */ /* (5.1) sce + cpe + cpe + lfe */
hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits; hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits;
@ -427,20 +463,30 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits; FIXP_DBL cpe2Rate = cm->elInfo[2].relativeBits;
FIXP_DBL lfeRate = cm->elInfo[3].relativeBits; FIXP_DBL lfeRate = cm->elInfo[3].relativeBits;
int maxBitsTot = maxChannelBits * 5; /* LFE does not add to bit reservoir */ int maxBitsTot =
maxChannelBits * 5; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot)); int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot));
int maxLfeBits = (int) FDKmax ( (INT)((fMult(lfeRate,(FIXP_DBL)(maxChannelBits<<sc))>>sc)<<1), int maxLfeBits = (int)fMax(
(INT)((fMult(FL2FXCONST_DBL(1.1f/2.f),fMult(lfeRate,(FIXP_DBL)(averageBitsTot<<sc)))<<1)>>sc) ); (INT)((fMult(lfeRate, (FIXP_DBL)(maxChannelBits << sc)) >> sc) << 1),
(INT)((fMult(FL2FXCONST_DBL(1.1f / 2.f),
fMult(lfeRate, (FIXP_DBL)(averageBitsTot << sc)))
<< 1) >>
sc));
maxChannelBits = (maxBitsTot - maxLfeBits); maxChannelBits = (maxBitsTot - maxLfeBits);
sc = CountLeadingBits(maxChannelBits); sc = CountLeadingBits(maxChannelBits);
maxChannelBits = fMult((FIXP_DBL)maxChannelBits<<sc,GetInvInt(5))>>sc; maxChannelBits =
fMult((FIXP_DBL)maxChannelBits << sc, GetInvInt(5)) >> sc;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[0]->chBitrateEl =
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); hQC->elementBits[1]->chBitrateEl =
hQC->elementBits[3]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[3]->chBitrateEl =
fMult(lfeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits; hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits; hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
@ -449,31 +495,91 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
break; break;
} }
case MODE_6_1: {
/* (6.1) sce + cpe + cpe + sce + lfe */
FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl =
cm->elInfo[0].relativeBits;
FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl =
cm->elInfo[1].relativeBits;
FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl =
cm->elInfo[2].relativeBits;
FIXP_DBL sce2Rate = hQC->elementBits[3]->relativeBitsEl =
cm->elInfo[3].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[4]->relativeBitsEl =
cm->elInfo[4].relativeBits;
int maxBitsTot =
maxChannelBits * 6; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot));
int maxLfeBits = (int)fMax(
(INT)((fMult(lfeRate, (FIXP_DBL)(maxChannelBits << sc)) >> sc) << 1),
(INT)((fMult(FL2FXCONST_DBL(1.1f / 2.f),
fMult(lfeRate, (FIXP_DBL)(averageBitsTot << sc)))
<< 1) >>
sc));
maxChannelBits = (maxBitsTot - maxLfeBits) / 6;
hQC->elementBits[0]->chBitrateEl =
fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[1]->chBitrateEl =
fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[3]->chBitrateEl =
fMult(sce2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[4]->chBitrateEl =
fMult(lfeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[2]->maxBitsEl = 2 * maxChannelBits;
hQC->elementBits[3]->maxBitsEl = maxChannelBits;
hQC->elementBits[4]->maxBitsEl = maxLfeBits;
break;
}
case MODE_7_1_TOP_FRONT:
case MODE_7_1_BACK:
case MODE_7_1_REAR_SURROUND: case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER: case MODE_7_1_FRONT_CENTER:
case MODE_1_2_2_2_1: { case MODE_1_2_2_2_1: {
int cpe3Idx = 3; int cpe3Idx = (cm->encMode != MODE_7_1_TOP_FRONT) ? 3 : 4;
int lfeIdx = 4; int lfeIdx = (cm->encMode != MODE_7_1_TOP_FRONT) ? 4 : 3;
/* (7.1) sce + cpe + cpe + cpe + lfe */ /* (7.1) sce + cpe + cpe + cpe + lfe */
FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl = cm->elInfo[0].relativeBits; FIXP_DBL sceRate = hQC->elementBits[0]->relativeBitsEl =
FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl = cm->elInfo[1].relativeBits; cm->elInfo[0].relativeBits;
FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl = cm->elInfo[2].relativeBits; FIXP_DBL cpe1Rate = hQC->elementBits[1]->relativeBitsEl =
FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl = cm->elInfo[cpe3Idx].relativeBits; cm->elInfo[1].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl = cm->elInfo[lfeIdx].relativeBits; FIXP_DBL cpe2Rate = hQC->elementBits[2]->relativeBitsEl =
cm->elInfo[2].relativeBits;
FIXP_DBL cpe3Rate = hQC->elementBits[cpe3Idx]->relativeBitsEl =
cm->elInfo[cpe3Idx].relativeBits;
FIXP_DBL lfeRate = hQC->elementBits[lfeIdx]->relativeBitsEl =
cm->elInfo[lfeIdx].relativeBits;
int maxBitsTot = maxChannelBits * 7; /* LFE does not add to bit reservoir */ int maxBitsTot =
maxChannelBits * 7; /* LFE does not add to bit reservoir */
int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot)); int sc = CountLeadingBits(fixMax(maxChannelBits, averageBitsTot));
int maxLfeBits = (int) FDKmax ( (INT)((fMult(lfeRate,(FIXP_DBL)(maxChannelBits<<sc))>>sc)<<1), int maxLfeBits = (int)fMax(
(INT)((fMult(FL2FXCONST_DBL(1.1f/2.f),fMult(lfeRate,(FIXP_DBL)(averageBitsTot<<sc)))<<1)>>sc) ); (INT)((fMult(lfeRate, (FIXP_DBL)(maxChannelBits << sc)) >> sc) << 1),
(INT)((fMult(FL2FXCONST_DBL(1.1f / 2.f),
fMult(lfeRate, (FIXP_DBL)(averageBitsTot << sc)))
<< 1) >>
sc));
maxChannelBits = (maxBitsTot - maxLfeBits) / 7; maxChannelBits = (maxBitsTot - maxLfeBits) / 7;
hQC->elementBits[0]->chBitrateEl = fMult(sceRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[0]->chBitrateEl =
hQC->elementBits[1]->chBitrateEl = fMult(cpe1Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); fMult(sceRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[2]->chBitrateEl = fMult(cpe2Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); hQC->elementBits[1]->chBitrateEl =
hQC->elementBits[cpe3Idx]->chBitrateEl = fMult(cpe3Rate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>(sc_brTot+1); fMult(cpe1Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[lfeIdx]->chBitrateEl = fMult(lfeRate, (FIXP_DBL)(bitrateTot<<sc_brTot))>>sc_brTot; hQC->elementBits[2]->chBitrateEl =
fMult(cpe2Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[cpe3Idx]->chBitrateEl =
fMult(cpe3Rate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> (sc_brTot + 1);
hQC->elementBits[lfeIdx]->chBitrateEl =
fMult(lfeRate, (FIXP_DBL)(bitrateTot << sc_brTot)) >> sc_brTot;
hQC->elementBits[0]->maxBitsEl = maxChannelBits; hQC->elementBits[0]->maxBitsEl = maxChannelBits;
hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits; hQC->elementBits[1]->maxBitsEl = 2 * maxChannelBits;
@ -482,6 +588,7 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits; hQC->elementBits[lfeIdx]->maxBitsEl = maxLfeBits;
break; break;
} }
default: default:
return AAC_ENC_UNSUPPORTED_CHANNELCONFIG; return AAC_ENC_UNSUPPORTED_CHANNELCONFIG;
} }
@ -510,23 +617,27 @@ AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC,
/********************************************************************************/ /********************************************************************************/
ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode) { ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode) {
ELEMENT_MODE monoStereoSetting = EL_MODE_INVALID; ELEMENT_MODE monoStereoSetting = EL_MODE_INVALID;
switch (mode) { switch (mode) {
case MODE_1: /* mono setups */ case MODE_1: /* mono setups */
monoStereoSetting = EL_MODE_MONO; monoStereoSetting = EL_MODE_MONO;
break; break;
case MODE_2: /* stereo setups */ case MODE_2: /* stereo setups */
case MODE_1_2: case MODE_1_2:
case MODE_1_2_1: case MODE_1_2_1:
case MODE_1_2_2: case MODE_1_2_2:
case MODE_1_2_2_1: case MODE_1_2_2_1:
case MODE_6_1:
case MODE_1_2_2_2_1: case MODE_1_2_2_2_1:
case MODE_7_1_REAR_SURROUND: case MODE_7_1_REAR_SURROUND:
case MODE_7_1_FRONT_CENTER: case MODE_7_1_FRONT_CENTER:
case MODE_7_1_BACK:
case MODE_7_1_TOP_FRONT:
monoStereoSetting = EL_MODE_STEREO; monoStereoSetting = EL_MODE_STEREO;
break; break;
default: /* error */ default: /* error */
monoStereoSetting = EL_MODE_INVALID; monoStereoSetting = EL_MODE_INVALID;
break; break;
@ -535,15 +646,16 @@ ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode){
return monoStereoSetting; return monoStereoSetting;
} }
const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(const CHANNEL_MODE mode) const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(
{ const CHANNEL_MODE mode) {
INT i; INT i;
const CHANNEL_MODE_CONFIG_TAB* cm_config = NULL; const CHANNEL_MODE_CONFIG_TAB* cm_config = NULL;
/* get channel mode config */ /* get channel mode config */
for (i=0; i<(INT)sizeof(channelModeConfig)/(INT)sizeof(CHANNEL_MODE_CONFIG_TAB); i++) { for (i = 0; i < (INT)sizeof(channelModeConfig) /
if (channelModeConfig[i].encMode==mode) (INT)sizeof(CHANNEL_MODE_CONFIG_TAB);
{ i++) {
if (channelModeConfig[i].encMode == mode) {
cm_config = &channelModeConfig[i]; cm_config = &channelModeConfig[i];
break; break;
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,18 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/************************* Fast MPEG AAC Audio Encoder ********************** /**************************** AAC encoder library ******************************
Initial author: A. Groeschel Author(s): A. Groeschel
contents/description: channel mapping functionality
******************************************************************************/ Description: channel mapping functionality
#ifndef _CHANNEL_MAP_H *******************************************************************************/
#define _CHANNEL_MAP_H
#ifndef CHANNEL_MAP_H
#define CHANNEL_MAP_H
#include "aacenc.h" #include "aacenc.h"
#include "psy_const.h" #include "psy_const.h"
@ -103,14 +114,8 @@ typedef struct {
INT nElements; INT nElements;
} CHANNEL_MODE_CONFIG_TAB; } CHANNEL_MODE_CONFIG_TAB;
/* Element mode */ /* Element mode */
typedef enum { typedef enum { EL_MODE_INVALID = 0, EL_MODE_MONO, EL_MODE_STEREO } ELEMENT_MODE;
EL_MODE_INVALID = 0,
EL_MODE_MONO,
EL_MODE_STEREO
} ELEMENT_MODE;
AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode, AAC_ENCODER_ERROR FDKaacEnc_DetermineEncoderMode(CHANNEL_MODE* mode,
INT nChannels); INT nChannels);
@ -119,14 +124,13 @@ AAC_ENCODER_ERROR FDKaacEnc_InitChannelMapping(CHANNEL_MODE mode,
CHANNEL_ORDER co, CHANNEL_ORDER co,
CHANNEL_MAPPING* chMap); CHANNEL_MAPPING* chMap);
AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE *hQC, AAC_ENCODER_ERROR FDKaacEnc_InitElementBits(QC_STATE* hQC, CHANNEL_MAPPING* cm,
CHANNEL_MAPPING *cm, INT bitrateTot, INT averageBitsTot,
INT bitrateTot,
INT averageBitsTot,
INT maxChannelBits); INT maxChannelBits);
ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode); ELEMENT_MODE FDKaacEnc_GetMonoStereoMode(const CHANNEL_MODE mode);
const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(const CHANNEL_MODE mode); const CHANNEL_MODE_CONFIG_TAB* FDKaacEnc_GetChannelModeConfiguration(
const CHANNEL_MODE mode);
#endif /* CHANNEL_MAP_H */ #endif /* CHANNEL_MAP_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Werner Author(s): M. Werner
contents/description: Chaos measure calculation
******************************************************************************/ Description: Chaos measure calculation
*******************************************************************************/
#include "chaosmeasure.h" #include "chaosmeasure.h"
@ -94,40 +106,63 @@ amm-info@iis.fraunhofer.de
functionname: FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast functionname: FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast
description: Eberlein method of chaos measure calculation by high-pass description: Eberlein method of chaos measure calculation by high-pass
filtering amplitude spectrum filtering amplitude spectrum
A special case of FDKaacEnc_CalculateChaosMeasureTonalGeneric -- A special case of FDKaacEnc_CalculateChaosMeasureTonalGeneric
highly optimized -- highly optimized
*****************************************************************************/ *****************************************************************************/
static void static void FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast(
FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( FIXP_DBL *RESTRICT paMDCTDataNM0, FIXP_DBL *RESTRICT paMDCTDataNM0, INT numberOfLines,
INT numberOfLines, FIXP_DBL *RESTRICT chaosMeasure) {
FIXP_DBL *RESTRICT chaosMeasure )
{
INT i, j; INT i, j;
/* calculate chaos measure by "peak filter" */ /* calculate chaos measure by "peak filter" */
for (i=0; i<2; i++) {
/* make even and odd pass through data */ /* make even and odd pass through data */
FIXP_DBL left,center; /* left, center tap of filter */ FIXP_DBL left_0_div2,
center_0; /* left, center tap of filter, even numbered */
FIXP_DBL left_1_div2, center_1; /* left, center tap of filter, odd numbered */
left = (FIXP_DBL)((LONG)paMDCTDataNM0[i]^((LONG)paMDCTDataNM0[i]>>(DFRACT_BITS-1))); left_0_div2 = (FIXP_DBL)(((LONG)paMDCTDataNM0[0] ^
center = (FIXP_DBL)((LONG)paMDCTDataNM0[i+2]^((LONG)paMDCTDataNM0[i+2]>>(DFRACT_BITS-1))); ((LONG)paMDCTDataNM0[0] >> (DFRACT_BITS - 1))) >>
1);
left_1_div2 = (FIXP_DBL)(((LONG)paMDCTDataNM0[1] ^
((LONG)paMDCTDataNM0[1] >> (DFRACT_BITS - 1))) >>
1);
center_0 = (FIXP_DBL)((LONG)paMDCTDataNM0[2] ^
((LONG)paMDCTDataNM0[2] >> (DFRACT_BITS - 1)));
center_1 = (FIXP_DBL)((LONG)paMDCTDataNM0[3] ^
((LONG)paMDCTDataNM0[3] >> (DFRACT_BITS - 1)));
for (j = i+2; j < numberOfLines - 2; j+=2) { for (j = 2; j < numberOfLines - 2; j += 2) {
FIXP_DBL right = (FIXP_DBL)((LONG)paMDCTDataNM0[j+2]^((LONG)paMDCTDataNM0[j+2]>>(DFRACT_BITS-1))); FIXP_DBL right_0 =
FIXP_DBL tmp = (left>>1)+(right>>1); (FIXP_DBL)((LONG)paMDCTDataNM0[j + 2] ^
((LONG)paMDCTDataNM0[j + 2] >> (DFRACT_BITS - 1)));
FIXP_DBL tmp_0 = left_0_div2 + (right_0 >> 1);
FIXP_DBL right_1 =
(FIXP_DBL)((LONG)paMDCTDataNM0[j + 3] ^
((LONG)paMDCTDataNM0[j + 3] >> (DFRACT_BITS - 1)));
FIXP_DBL tmp_1 = left_1_div2 + (right_1 >> 1);
if (tmp < center ) { if (tmp_0 < center_0) {
INT leadingBits = CntLeadingZeros(center)-1; INT leadingBits = CntLeadingZeros(center_0) - 1;
tmp = schur_div(tmp<<leadingBits, center<<leadingBits, 8); tmp_0 = schur_div(tmp_0 << leadingBits, center_0 << leadingBits, 8);
chaosMeasure[j] = fMult(tmp,tmp); tmp_0 = fMult(tmp_0, tmp_0);
} else {
tmp_0 = (FIXP_DBL)MAXVAL_DBL;
} }
else { chaosMeasure[j + 0] = tmp_0;
chaosMeasure[j] = (FIXP_DBL)MAXVAL_DBL; left_0_div2 = center_0 >> 1;
center_0 = right_0;
if (tmp_1 < center_1) {
INT leadingBits = CntLeadingZeros(center_1) - 1;
tmp_1 = schur_div(tmp_1 << leadingBits, center_1 << leadingBits, 8);
tmp_1 = fMult(tmp_1, tmp_1);
} else {
tmp_1 = (FIXP_DBL)MAXVAL_DBL;
} }
left = center; left_1_div2 = center_1 >> 1;
center = right; center_1 = right_1;
} chaosMeasure[j + 1] = tmp_1;
} }
/* provide chaos measure for first few lines */ /* provide chaos measure for first few lines */
@ -139,7 +174,6 @@ FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( FIXP_DBL *RESTRICT paMDCTDat
chaosMeasure[i] = FL2FXCONST_DBL(0.5); chaosMeasure[i] = FL2FXCONST_DBL(0.5);
} }
/***************************************************************************** /*****************************************************************************
functionname: FDKaacEnc_CalculateChaosMeasure functionname: FDKaacEnc_CalculateChaosMeasure
description: calculates a chaosmeasure for every line, different methods description: calculates a chaosmeasure for every line, different methods
@ -148,14 +182,10 @@ FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( FIXP_DBL *RESTRICT paMDCTDat
input: MDCT data, number of lines input: MDCT data, number of lines
output: chaosMeasure output: chaosMeasure
*****************************************************************************/ *****************************************************************************/
void void FDKaacEnc_CalculateChaosMeasure(FIXP_DBL *paMDCTDataNM0, INT numberOfLines,
FDKaacEnc_CalculateChaosMeasure( FIXP_DBL *paMDCTDataNM0,
INT numberOfLines,
FIXP_DBL *chaosMeasure) FIXP_DBL *chaosMeasure)
{ {
FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast( paMDCTDataNM0, FDKaacEnc_FDKaacEnc_CalculateChaosMeasurePeakFast(
numberOfLines, paMDCTDataNM0, numberOfLines, chaosMeasure);
chaosMeasure );
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,25 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M. Werner Author(s): M. Werner
contents/description: Chaos measure calculation
******************************************************************************/ Description: Chaos measure calculation
#ifndef __CHAOSMEASURE_H *******************************************************************************/
#define __CHAOSMEASURE_H
#ifndef CHAOSMEASURE_H
#define CHAOSMEASURE_H
#include "common_fix.h" #include "common_fix.h"
#include "psy_const.h" #include "psy_const.h"
void void FDKaacEnc_CalculateChaosMeasure(FIXP_DBL *paMDCTDataNM0, INT numberOfLines,
FDKaacEnc_CalculateChaosMeasure( FIXP_DBL *paMDCTDataNM0,
INT numberOfLines,
FIXP_DBL *chaosMeasure); FIXP_DBL *chaosMeasure);
#endif #endif /* CHAOSMEASURE_H */

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M.Werner Author(s): M.Werner
contents/description: Noiseless coder module
******************************************************************************/ Description: Noiseless coder module
*******************************************************************************/
#include "dyn_bits.h" #include "dyn_bits.h"
#include "bit_cnt.h" #include "bit_cnt.h"
@ -97,18 +109,15 @@ amm-info@iis.fraunhofer.de
typedef INT (*lookUpTable)[CODE_BOOK_ESC_NDX + 1]; typedef INT (*lookUpTable)[CODE_BOOK_ESC_NDX + 1];
static INT FDKaacEnc_getSideInfoBits( static INT FDKaacEnc_getSideInfoBits(const SECTION_INFO* const huffsection,
const SECTION_INFO* const huffsection,
const SHORT* const sideInfoTab, const SHORT* const sideInfoTab,
const INT useHCR const INT useHCR) {
)
{
INT sideInfoBits; INT sideInfoBits;
if ( useHCR && ((huffsection->codeBook == 11) || (huffsection->codeBook >= 16)) ) { if (useHCR &&
((huffsection->codeBook == 11) || (huffsection->codeBook >= 16))) {
sideInfoBits = 5; sideInfoBits = 5;
} } else {
else {
sideInfoBits = sideInfoTab[huffsection->sfbCnt]; sideInfoBits = sideInfoTab[huffsection->sfbCnt];
} }
@ -117,43 +126,32 @@ static INT FDKaacEnc_getSideInfoBits(
/* count bits using all possible tables */ /* count bits using all possible tables */
static void FDKaacEnc_buildBitLookUp( static void FDKaacEnc_buildBitLookUp(
const SHORT* const quantSpectrum, const SHORT* const quantSpectrum, const INT maxSfb,
const INT maxSfb, const INT* const sfbOffset, const UINT* const sfbMax,
const INT* const sfbOffset,
const UINT* const sfbMax,
INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
SECTION_INFO* const huffsection SECTION_INFO* const huffsection) {
)
{
INT i, sfbWidth; INT i, sfbWidth;
for (i = 0; i < maxSfb; i++) for (i = 0; i < maxSfb; i++) {
{
huffsection[i].sfbCnt = 1; huffsection[i].sfbCnt = 1;
huffsection[i].sfbStart = i; huffsection[i].sfbStart = i;
huffsection[i].sectionBits = INVALID_BITCOUNT; huffsection[i].sectionBits = INVALID_BITCOUNT;
huffsection[i].codeBook = -1; huffsection[i].codeBook = -1;
sfbWidth = sfbOffset[i + 1] - sfbOffset[i]; sfbWidth = sfbOffset[i + 1] - sfbOffset[i];
FDKaacEnc_bitCount(quantSpectrum + sfbOffset[i], sfbWidth, sfbMax[i], bitLookUp[i]); FDKaacEnc_bitCount(quantSpectrum + sfbOffset[i], sfbWidth, sfbMax[i],
bitLookUp[i]);
} }
} }
/* essential helper functions */ /* essential helper functions */
static INT FDKaacEnc_findBestBook( static inline INT FDKaacEnc_findBestBook(const INT* const bc, INT* const book,
const INT* const bc, const INT useVCB11) {
INT* const book,
const INT useVCB11
)
{
INT minBits = INVALID_BITCOUNT, j; INT minBits = INVALID_BITCOUNT, j;
int end = CODE_BOOK_ESC_NDX; int end = CODE_BOOK_ESC_NDX;
for (j = 0; j <= end; j++) {
for (j = 0; j <= end; j++) if (bc[j] < minBits) {
{
if (bc[j] < minBits)
{
minBits = bc[j]; minBits = bc[j];
*book = j; *book = j;
} }
@ -161,114 +159,94 @@ static INT FDKaacEnc_findBestBook(
return (minBits); return (minBits);
} }
static INT FDKaacEnc_findMinMergeBits( static inline INT FDKaacEnc_findMinMergeBits(const INT* const bc1,
const INT* const bc1,
const INT* const bc2, const INT* const bc2,
const INT useVCB11 const INT useVCB11) {
)
{
INT minBits = INVALID_BITCOUNT, j; INT minBits = INVALID_BITCOUNT, j;
int end = CODE_BOOK_ESC_NDX; DWORD_ALIGNED(bc1);
DWORD_ALIGNED(bc2);
for (j = 0; j <= CODE_BOOK_ESC_NDX; j++) {
for (j = 0; j <= end; j++) minBits = fixMin(minBits, bc1[j] + bc2[j]);
{
if (bc1[j] + bc2[j] < minBits)
{
minBits = bc1[j] + bc2[j];
}
} }
return (minBits); return (minBits);
} }
static void FDKaacEnc_mergeBitLookUp( static inline void FDKaacEnc_mergeBitLookUp(INT* const RESTRICT bc1,
INT* const bc1, const INT* const RESTRICT bc2) {
const INT* const bc2
)
{
int j; int j;
for (j = 0; j <= CODE_BOOK_ESC_NDX; j++) for (j = 0; j <= CODE_BOOK_ESC_NDX; j++) {
{ FDK_ASSERT(INVALID_BITCOUNT == 0x1FFFFFFF);
bc1[j] = fixMin(bc1[j] + bc2[j], INVALID_BITCOUNT); bc1[j] = fixMin(bc1[j] + bc2[j], INVALID_BITCOUNT);
} }
} }
static INT FDKaacEnc_findMaxMerge( static inline INT FDKaacEnc_findMaxMerge(const INT* const mergeGainLookUp,
const INT* const mergeGainLookUp,
const SECTION_INFO* const huffsection, const SECTION_INFO* const huffsection,
const INT maxSfb, const INT maxSfb, INT* const maxNdx) {
INT* const maxNdx
)
{
INT i, maxMergeGain = 0; INT i, maxMergeGain = 0;
int lastMaxNdx = 0;
for (i = 0; i + huffsection[i].sfbCnt < maxSfb; i += huffsection[i].sfbCnt) for (i = 0; i + huffsection[i].sfbCnt < maxSfb; i += huffsection[i].sfbCnt) {
{ if (mergeGainLookUp[i] > maxMergeGain) {
if (mergeGainLookUp[i] > maxMergeGain)
{
maxMergeGain = mergeGainLookUp[i]; maxMergeGain = mergeGainLookUp[i];
*maxNdx = i; lastMaxNdx = i;
} }
} }
*maxNdx = lastMaxNdx;
return (maxMergeGain); return (maxMergeGain);
} }
static INT FDKaacEnc_CalcMergeGain( static inline INT FDKaacEnc_CalcMergeGain(
const SECTION_INFO* const huffsection, const SECTION_INFO* const huffsection,
const INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
const SHORT* const sideInfoTab, const SHORT* const sideInfoTab, const INT ndx1, const INT ndx2,
const INT ndx1, const INT useVCB11) {
const INT ndx2,
const INT useVCB11
)
{
INT MergeGain, MergeBits, SplitBits; INT MergeGain, MergeBits, SplitBits;
MergeBits = sideInfoTab[huffsection[ndx1].sfbCnt + huffsection[ndx2].sfbCnt] + FDKaacEnc_findMinMergeBits(bitLookUp[ndx1], bitLookUp[ndx2], useVCB11); MergeBits =
SplitBits = huffsection[ndx1].sectionBits + huffsection[ndx2].sectionBits; /* Bit amount for splitted huffsections */ sideInfoTab[huffsection[ndx1].sfbCnt + huffsection[ndx2].sfbCnt] +
FDKaacEnc_findMinMergeBits(bitLookUp[ndx1], bitLookUp[ndx2], useVCB11);
SplitBits =
huffsection[ndx1].sectionBits +
huffsection[ndx2].sectionBits; /* Bit amount for splitted huffsections */
MergeGain = SplitBits - MergeBits; MergeGain = SplitBits - MergeBits;
if ( (huffsection[ndx1].codeBook==CODE_BOOK_PNS_NO)||(huffsection[ndx2].codeBook==CODE_BOOK_PNS_NO) if ((huffsection[ndx1].codeBook == CODE_BOOK_PNS_NO) ||
|| (huffsection[ndx1].codeBook==CODE_BOOK_IS_OUT_OF_PHASE_NO)||(huffsection[ndx2].codeBook==CODE_BOOK_IS_OUT_OF_PHASE_NO) (huffsection[ndx2].codeBook == CODE_BOOK_PNS_NO) ||
|| (huffsection[ndx1].codeBook==CODE_BOOK_IS_IN_PHASE_NO)||(huffsection[ndx2].codeBook==CODE_BOOK_IS_IN_PHASE_NO) (huffsection[ndx1].codeBook == CODE_BOOK_IS_OUT_OF_PHASE_NO) ||
) (huffsection[ndx2].codeBook == CODE_BOOK_IS_OUT_OF_PHASE_NO) ||
{ (huffsection[ndx1].codeBook == CODE_BOOK_IS_IN_PHASE_NO) ||
(huffsection[ndx2].codeBook == CODE_BOOK_IS_IN_PHASE_NO)) {
MergeGain = -1; MergeGain = -1;
} }
return (MergeGain); return (MergeGain);
} }
/* sectioning Stage 0:find minimum codbooks */ /* sectioning Stage 0:find minimum codbooks */
static void FDKaacEnc_gmStage0( static void FDKaacEnc_gmStage0(
SECTION_INFO* const RESTRICT huffsection, SECTION_INFO* const RESTRICT huffsection,
const INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const INT maxSfb,
const INT maxSfb, const INT* const noiseNrg, const INT* const isBook) {
const INT* const noiseNrg,
const INT* const isBook
)
{
INT i; INT i;
for (i = 0; i < maxSfb; i++) for (i = 0; i < maxSfb; i++) {
{
/* Side-Info bits will be calculated in Stage 1! */ /* Side-Info bits will be calculated in Stage 1! */
if (huffsection[i].sectionBits == INVALID_BITCOUNT) if (huffsection[i].sectionBits == INVALID_BITCOUNT) {
{
/* intensity and pns codebooks are already allocated in bitcount.c */ /* intensity and pns codebooks are already allocated in bitcount.c */
if (noiseNrg[i] != NO_NOISE_PNS) { if (noiseNrg[i] != NO_NOISE_PNS) {
huffsection[i].codeBook = CODE_BOOK_PNS_NO; huffsection[i].codeBook = CODE_BOOK_PNS_NO;
huffsection[i].sectionBits = 0; huffsection[i].sectionBits = 0;
} } else if (isBook[i]) {
else if( isBook[i] ) {
huffsection[i].codeBook = isBook[i]; huffsection[i].codeBook = isBook[i];
huffsection[i].sectionBits = 0; huffsection[i].sectionBits = 0;
} } else {
else { huffsection[i].sectionBits =
huffsection[i].sectionBits = FDKaacEnc_findBestBook(bitLookUp[i], &(huffsection[i].codeBook), 0); /* useVCB11 must be 0!!! */ FDKaacEnc_findBestBook(bitLookUp[i], &(huffsection[i].codeBook),
0); /* useVCB11 must be 0!!! */
} }
} }
} }
@ -280,23 +258,17 @@ static void FDKaacEnc_gmStage0(
*/ */
static void FDKaacEnc_gmStage1( static void FDKaacEnc_gmStage1(
SECTION_INFO* const RESTRICT huffsection, SECTION_INFO* const RESTRICT huffsection,
INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const INT maxSfb,
const INT maxSfb, const SHORT* const sideInfoTab, const INT useVCB11) {
const SHORT* const sideInfoTab,
const INT useVCB11
)
{
INT mergeStart = 0, mergeEnd; INT mergeStart = 0, mergeEnd;
do do {
{ for (mergeEnd = mergeStart + 1; mergeEnd < maxSfb; mergeEnd++) {
for (mergeEnd = mergeStart + 1; mergeEnd < maxSfb; mergeEnd++)
{
if (huffsection[mergeStart].codeBook != huffsection[mergeEnd].codeBook) if (huffsection[mergeStart].codeBook != huffsection[mergeEnd].codeBook)
break; break;
/* we can merge. update tables, side info bits will be updated outside of
/* we can merge. update tables, side info bits will be updated outside of this loop */ * this loop */
huffsection[mergeStart].sfbCnt++; huffsection[mergeStart].sfbCnt++;
huffsection[mergeStart].sectionBits += huffsection[mergeEnd].sectionBits; huffsection[mergeStart].sectionBits += huffsection[mergeEnd].sectionBits;
@ -305,8 +277,10 @@ static void FDKaacEnc_gmStage1(
} }
/* add side info info bits */ /* add side info info bits */
huffsection[mergeStart].sectionBits += FDKaacEnc_getSideInfoBits(&huffsection[mergeStart], sideInfoTab, useVCB11); huffsection[mergeStart].sectionBits += FDKaacEnc_getSideInfoBits(
huffsection[mergeEnd - 1].sfbStart = huffsection[mergeStart].sfbStart; /* speed up prev search */ &huffsection[mergeStart], sideInfoTab, useVCB11);
huffsection[mergeEnd - 1].sfbStart =
huffsection[mergeStart].sfbStart; /* speed up prev search */
mergeStart = mergeEnd; mergeStart = mergeEnd;
@ -317,98 +291,71 @@ static void FDKaacEnc_gmStage1(
sectioning Stage 2:greedy merge algorithm, merge connected sections with sectioning Stage 2:greedy merge algorithm, merge connected sections with
maximum bit gain until no more gain is possible maximum bit gain until no more gain is possible
*/ */
static void static inline void FDKaacEnc_gmStage2(
FDKaacEnc_gmStage2(
SECTION_INFO* const RESTRICT huffsection, SECTION_INFO* const RESTRICT huffsection,
INT* const RESTRICT mergeGainLookUp, INT* const RESTRICT mergeGainLookUp,
INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const INT maxSfb,
const INT maxSfb, const SHORT* const sideInfoTab, const INT useVCB11) {
const SHORT* const sideInfoTab,
const INT useVCB11
)
{
INT i; INT i;
for (i = 0; i + huffsection[i].sfbCnt < maxSfb; i += huffsection[i].sfbCnt) for (i = 0; i + huffsection[i].sfbCnt < maxSfb; i += huffsection[i].sfbCnt) {
{ mergeGainLookUp[i] =
mergeGainLookUp[i] = FDKaacEnc_CalcMergeGain(huffsection, FDKaacEnc_CalcMergeGain(huffsection, bitLookUp, sideInfoTab, i,
bitLookUp, i + huffsection[i].sfbCnt, useVCB11);
sideInfoTab,
i,
i + huffsection[i].sfbCnt,
useVCB11);
} }
while (TRUE) while (TRUE) {
{ INT maxMergeGain, maxNdx, maxNdxNext, maxNdxLast;
INT maxMergeGain, maxNdx = 0, maxNdxNext, maxNdxLast;
maxMergeGain = FDKaacEnc_findMaxMerge(mergeGainLookUp, huffsection, maxSfb, &maxNdx); maxMergeGain =
FDKaacEnc_findMaxMerge(mergeGainLookUp, huffsection, maxSfb, &maxNdx);
/* exit while loop if no more gain is possible */ /* exit while loop if no more gain is possible */
if (maxMergeGain <= 0) if (maxMergeGain <= 0) break;
break;
maxNdxNext = maxNdx + huffsection[maxNdx].sfbCnt; maxNdxNext = maxNdx + huffsection[maxNdx].sfbCnt;
/* merge sections with maximum bit gain */ /* merge sections with maximum bit gain */
huffsection[maxNdx].sfbCnt += huffsection[maxNdxNext].sfbCnt; huffsection[maxNdx].sfbCnt += huffsection[maxNdxNext].sfbCnt;
huffsection[maxNdx].sectionBits += huffsection[maxNdxNext].sectionBits - maxMergeGain; huffsection[maxNdx].sectionBits +=
huffsection[maxNdxNext].sectionBits - maxMergeGain;
/* update bit look up table for merged huffsection */ /* update bit look up table for merged huffsection */
FDKaacEnc_mergeBitLookUp(bitLookUp[maxNdx], bitLookUp[maxNdxNext]); FDKaacEnc_mergeBitLookUp(bitLookUp[maxNdx], bitLookUp[maxNdxNext]);
/* update mergeLookUpTable */ /* update mergeLookUpTable */
if (maxNdx != 0) if (maxNdx != 0) {
{
maxNdxLast = huffsection[maxNdx - 1].sfbStart; maxNdxLast = huffsection[maxNdx - 1].sfbStart;
mergeGainLookUp[maxNdxLast] = FDKaacEnc_CalcMergeGain(huffsection, mergeGainLookUp[maxNdxLast] = FDKaacEnc_CalcMergeGain(
bitLookUp, huffsection, bitLookUp, sideInfoTab, maxNdxLast, maxNdx, useVCB11);
sideInfoTab,
maxNdxLast,
maxNdx,
useVCB11);
} }
maxNdxNext = maxNdx + huffsection[maxNdx].sfbCnt; maxNdxNext = maxNdx + huffsection[maxNdx].sfbCnt;
huffsection[maxNdxNext - 1].sfbStart = huffsection[maxNdx].sfbStart; huffsection[maxNdxNext - 1].sfbStart = huffsection[maxNdx].sfbStart;
if (maxNdxNext < maxSfb) if (maxNdxNext < maxSfb)
mergeGainLookUp[maxNdx] = FDKaacEnc_CalcMergeGain(huffsection, mergeGainLookUp[maxNdx] = FDKaacEnc_CalcMergeGain(
bitLookUp, huffsection, bitLookUp, sideInfoTab, maxNdx, maxNdxNext, useVCB11);
sideInfoTab,
maxNdx,
maxNdxNext,
useVCB11);
} }
} }
/* count bits used by the noiseless coder */ /* count bits used by the noiseless coder */
static void FDKaacEnc_noiselessCounter( static void FDKaacEnc_noiselessCounter(
SECTION_DATA* const RESTRICT sectionData, SECTION_DATA* const RESTRICT sectionData, INT mergeGainLookUp[MAX_SFB_LONG],
INT mergeGainLookUp[MAX_SFB_LONG],
INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], INT bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
const SHORT* const quantSpectrum, const SHORT* const quantSpectrum, const UINT* const maxValueInSfb,
const UINT* const maxValueInSfb, const INT* const sfbOffset, const INT blockType, const INT* const noiseNrg,
const INT* const sfbOffset, const INT* const isBook, const INT useVCB11) {
const INT blockType,
const INT* const noiseNrg,
const INT* const isBook,
const INT useVCB11
)
{
INT grpNdx, i; INT grpNdx, i;
const SHORT* sideInfoTab = NULL; const SHORT* sideInfoTab = NULL;
SECTION_INFO* huffsection; SECTION_INFO* huffsection;
/* use appropriate side info table */ /* use appropriate side info table */
switch (blockType) switch (blockType) {
{
case LONG_WINDOW: case LONG_WINDOW:
case START_WINDOW: case START_WINDOW:
case STOP_WINDOW: case STOP_WINDOW:
default:
sideInfoTab = FDKaacEnc_sideInfoTabLong; sideInfoTab = FDKaacEnc_sideInfoTabLong;
break; break;
case SHORT_WINDOW: case SHORT_WINDOW:
@ -420,29 +367,25 @@ static void FDKaacEnc_noiselessCounter(
sectionData->huffmanBits = 0; sectionData->huffmanBits = 0;
sectionData->sideInfoBits = 0; sectionData->sideInfoBits = 0;
if (sectionData->maxSfbPerGroup == 0) return;
if (sectionData->maxSfbPerGroup == 0)
return;
/* loop trough groups */ /* loop trough groups */
for (grpNdx = 0; grpNdx < sectionData->sfbCnt; grpNdx += sectionData->sfbPerGroup) for (grpNdx = 0; grpNdx < sectionData->sfbCnt;
{ grpNdx += sectionData->sfbPerGroup) {
huffsection = sectionData->huffsection + sectionData->noOfSections; huffsection = sectionData->huffsection + sectionData->noOfSections;
/* count bits in this group */ /* count bits in this group */
FDKaacEnc_buildBitLookUp(quantSpectrum, FDKaacEnc_buildBitLookUp(quantSpectrum, sectionData->maxSfbPerGroup,
sectionData->maxSfbPerGroup, sfbOffset + grpNdx, maxValueInSfb + grpNdx,
sfbOffset + grpNdx, bitLookUp, huffsection);
maxValueInSfb + grpNdx,
bitLookUp,
huffsection);
/* 0.Stage :Find minimum Codebooks */ /* 0.Stage :Find minimum Codebooks */
FDKaacEnc_gmStage0(huffsection, bitLookUp, sectionData->maxSfbPerGroup, noiseNrg+grpNdx, isBook+grpNdx); FDKaacEnc_gmStage0(huffsection, bitLookUp, sectionData->maxSfbPerGroup,
noiseNrg + grpNdx, isBook + grpNdx);
/* 1.Stage :Merge all connected regions with the same code book */ /* 1.Stage :Merge all connected regions with the same code book */
FDKaacEnc_gmStage1(huffsection, bitLookUp, sectionData->maxSfbPerGroup, sideInfoTab, useVCB11); FDKaacEnc_gmStage1(huffsection, bitLookUp, sectionData->maxSfbPerGroup,
sideInfoTab, useVCB11);
/* /*
2.Stage 2.Stage
@ -450,14 +393,8 @@ static void FDKaacEnc_noiselessCounter(
gain until no more gain is possible gain until no more gain is possible
*/ */
FDKaacEnc_gmStage2(huffsection, FDKaacEnc_gmStage2(huffsection, mergeGainLookUp, bitLookUp,
mergeGainLookUp, sectionData->maxSfbPerGroup, sideInfoTab, useVCB11);
bitLookUp,
sectionData->maxSfbPerGroup,
sideInfoTab,
useVCB11);
/* /*
compress output, calculate total huff and side bits compress output, calculate total huff and side bits
@ -465,31 +402,33 @@ static void FDKaacEnc_noiselessCounter(
to save time, we must set it here for later use in bitenc to save time, we must set it here for later use in bitenc
*/ */
for (i = 0; i < sectionData->maxSfbPerGroup; i += huffsection[i].sfbCnt) for (i = 0; i < sectionData->maxSfbPerGroup; i += huffsection[i].sfbCnt) {
{
if ((huffsection[i].codeBook == CODE_BOOK_PNS_NO) || if ((huffsection[i].codeBook == CODE_BOOK_PNS_NO) ||
(huffsection[i].codeBook == CODE_BOOK_IS_OUT_OF_PHASE_NO) || (huffsection[i].codeBook == CODE_BOOK_IS_OUT_OF_PHASE_NO) ||
(huffsection[i].codeBook==CODE_BOOK_IS_IN_PHASE_NO)) (huffsection[i].codeBook == CODE_BOOK_IS_IN_PHASE_NO)) {
{
huffsection[i].sectionBits = 0; huffsection[i].sectionBits = 0;
} else { } else {
/* the sections in the sectionData are now marked with the optimal code book */ /* the sections in the sectionData are now marked with the optimal code
* book */
FDKaacEnc_findBestBook(bitLookUp[i], &(huffsection[i].codeBook), useVCB11); FDKaacEnc_findBestBook(bitLookUp[i], &(huffsection[i].codeBook),
useVCB11);
sectionData->huffmanBits += huffsection[i].sectionBits - FDKaacEnc_getSideInfoBits(&huffsection[i], sideInfoTab, useVCB11); sectionData->huffmanBits +=
huffsection[i].sectionBits -
FDKaacEnc_getSideInfoBits(&huffsection[i], sideInfoTab, useVCB11);
} }
huffsection[i].sfbStart += grpNdx; huffsection[i].sfbStart += grpNdx;
/* sum up side info bits (section data bits) */ /* sum up side info bits (section data bits) */
sectionData->sideInfoBits += FDKaacEnc_getSideInfoBits(&huffsection[i], sideInfoTab, useVCB11); sectionData->sideInfoBits +=
FDKaacEnc_getSideInfoBits(&huffsection[i], sideInfoTab, useVCB11);
sectionData->huffsection[sectionData->noOfSections++] = huffsection[i]; sectionData->huffsection[sectionData->noOfSections++] = huffsection[i];
} }
} }
} }
/******************************************************************************* /*******************************************************************************
functionname: FDKaacEnc_scfCount functionname: FDKaacEnc_scfCount
@ -525,13 +464,10 @@ static void FDKaacEnc_noiselessCounter(
scalfacGain (75) and the future scalefacGain (5) is 70. scalfacGain (75) and the future scalefacGain (5) is 70.
********************************************************************************/ ********************************************************************************/
static void FDKaacEnc_scfCount( static void FDKaacEnc_scfCount(const INT* const scalefacGain,
const INT* const scalefacGain,
const UINT* const maxValueInSfb, const UINT* const maxValueInSfb,
SECTION_DATA* const RESTRICT sectionData, SECTION_DATA* const RESTRICT sectionData,
const INT* const isScale const INT* const isScale) {
)
{
INT i, j, k, m, n; INT i, j, k, m, n;
INT lastValScf = 0; INT lastValScf = 0;
@ -542,63 +478,54 @@ static void FDKaacEnc_scfCount(
sectionData->scalefacBits = 0; sectionData->scalefacBits = 0;
if (scalefacGain == NULL) if (scalefacGain == NULL) return;
return;
sectionData->firstScf = 0; sectionData->firstScf = 0;
for (i=0; i<sectionData->noOfSections; i++) for (i = 0; i < sectionData->noOfSections; i++) {
{ if (sectionData->huffsection[i].codeBook != CODE_BOOK_ZERO_NO) {
if (sectionData->huffsection[i].codeBook != CODE_BOOK_ZERO_NO)
{
sectionData->firstScf = sectionData->huffsection[i].sfbStart; sectionData->firstScf = sectionData->huffsection[i].sfbStart;
lastValScf = scalefacGain[sectionData->firstScf]; lastValScf = scalefacGain[sectionData->firstScf];
break; break;
} }
} }
for (i=0; i<sectionData->noOfSections; i++) for (i = 0; i < sectionData->noOfSections; i++) {
{ if ((sectionData->huffsection[i].codeBook ==
if ((sectionData->huffsection[i].codeBook == CODE_BOOK_IS_OUT_OF_PHASE_NO) || CODE_BOOK_IS_OUT_OF_PHASE_NO) ||
(sectionData->huffsection[i].codeBook == CODE_BOOK_IS_IN_PHASE_NO)) (sectionData->huffsection[i].codeBook == CODE_BOOK_IS_IN_PHASE_NO)) {
{
for (j = sectionData->huffsection[i].sfbStart; for (j = sectionData->huffsection[i].sfbStart;
j < sectionData->huffsection[i].sfbStart + sectionData->huffsection[i].sfbCnt; j < sectionData->huffsection[i].sfbStart +
j++) sectionData->huffsection[i].sfbCnt;
{ j++) {
INT deltaIs = isScale[j] - lastValIs; INT deltaIs = isScale[j] - lastValIs;
lastValIs = isScale[j]; lastValIs = isScale[j];
sectionData->scalefacBits+=FDKaacEnc_bitCountScalefactorDelta(deltaIs); sectionData->scalefacBits +=
FDKaacEnc_bitCountScalefactorDelta(deltaIs);
} }
} /* Intensity */ } /* Intensity */
else if ((sectionData->huffsection[i].codeBook != CODE_BOOK_ZERO_NO) && else if ((sectionData->huffsection[i].codeBook != CODE_BOOK_ZERO_NO) &&
(sectionData->huffsection[i].codeBook != CODE_BOOK_PNS_NO)) (sectionData->huffsection[i].codeBook != CODE_BOOK_PNS_NO)) {
{ INT tmp = sectionData->huffsection[i].sfbStart +
INT tmp = sectionData->huffsection[i].sfbStart + sectionData->huffsection[i].sfbCnt; sectionData->huffsection[i].sfbCnt;
for (j = sectionData->huffsection[i].sfbStart; j<tmp; j++) for (j = sectionData->huffsection[i].sfbStart; j < tmp; j++) {
{
/* check if we can repeat the last value to save bits */ /* check if we can repeat the last value to save bits */
if (maxValueInSfb[j] == 0) if (maxValueInSfb[j] == 0) {
{
found = 0; found = 0;
/* are scalefactors skipped? */ /* are scalefactors skipped? */
if (scfSkipCounter == 0) if (scfSkipCounter == 0) {
{
/* end of section */ /* end of section */
if (j == (tmp - 1)) if (j == (tmp - 1))
found = 0; /* search in other sections for maxValueInSfb != 0 */ found = 0; /* search in other sections for maxValueInSfb != 0 */
else else {
{
/* search in this section for the next maxValueInSfb[] != 0 */ /* search in this section for the next maxValueInSfb[] != 0 */
for (k = (j+1); k < tmp; k++) for (k = (j + 1); k < tmp; k++) {
{ if (maxValueInSfb[k] != 0) {
if (maxValueInSfb[k] != 0)
{
found = 1; found = 1;
if ( (fixp_abs(scalefacGain[k] - lastValScf)) <= CODE_BOOK_SCF_LAV) if ((fixp_abs(scalefacGain[k] - lastValScf)) <=
CODE_BOOK_SCF_LAV)
deltaScf = 0; /* save bits */ deltaScf = 0; /* save bits */
else else {
{
/* do not save bits */ /* do not save bits */
deltaScf = lastValScf - scalefacGain[j]; deltaScf = lastValScf - scalefacGain[j];
lastValScf = scalefacGain[j]; lastValScf = scalefacGain[j];
@ -612,20 +539,19 @@ static void FDKaacEnc_scfCount(
} }
/* search for the next maxValueInSfb[] != 0 in all other sections */ /* search for the next maxValueInSfb[] != 0 in all other sections */
for (m=(i+1); (m < sectionData->noOfSections) && (found == 0); m++) for (m = (i + 1); (m < sectionData->noOfSections) && (found == 0);
{ m++) {
if ((sectionData->huffsection[m].codeBook != CODE_BOOK_ZERO_NO) && (sectionData->huffsection[m].codeBook != CODE_BOOK_PNS_NO)) if ((sectionData->huffsection[m].codeBook != CODE_BOOK_ZERO_NO) &&
{ (sectionData->huffsection[m].codeBook != CODE_BOOK_PNS_NO)) {
INT end = sectionData->huffsection[m].sfbStart + sectionData->huffsection[m].sfbCnt; INT end = sectionData->huffsection[m].sfbStart +
for (n = sectionData->huffsection[m].sfbStart; n<end; n++) sectionData->huffsection[m].sfbCnt;
{ for (n = sectionData->huffsection[m].sfbStart; n < end; n++) {
if (maxValueInSfb[n] != 0) if (maxValueInSfb[n] != 0) {
{
found = 1; found = 1;
if (fixp_abs(scalefacGain[n] - lastValScf) <= CODE_BOOK_SCF_LAV) if (fixp_abs(scalefacGain[n] - lastValScf) <=
CODE_BOOK_SCF_LAV)
deltaScf = 0; /* save bits */ deltaScf = 0; /* save bits */
else else {
{
/* do not save bits */ /* do not save bits */
deltaScf = lastValScf - scalefacGain[j]; deltaScf = lastValScf - scalefacGain[j];
lastValScf = scalefacGain[j]; lastValScf = scalefacGain[j];
@ -639,64 +565,29 @@ static void FDKaacEnc_scfCount(
} }
} }
/* no maxValueInSfb[] != 0 found */ /* no maxValueInSfb[] != 0 found */
if (found == 0) if (found == 0) {
{
deltaScf = 0; deltaScf = 0;
scfSkipCounter = 0; scfSkipCounter = 0;
} }
} } else {
else {
/* consider skipped scalefactors */ /* consider skipped scalefactors */
deltaScf = 0; deltaScf = 0;
scfSkipCounter--; scfSkipCounter--;
} }
} } else {
else {
deltaScf = lastValScf - scalefacGain[j]; deltaScf = lastValScf - scalefacGain[j];
lastValScf = scalefacGain[j]; lastValScf = scalefacGain[j];
} }
sectionData->scalefacBits += FDKaacEnc_bitCountScalefactorDelta(deltaScf); sectionData->scalefacBits +=
FDKaacEnc_bitCountScalefactorDelta(deltaScf);
} }
} }
} /* for (i=0; i<sectionData->noOfSections; i++) */ } /* for (i=0; i<sectionData->noOfSections; i++) */
} }
#ifdef PNS_PRECOUNT_ENABLE
/*
preCount bits used pns
*/
/* estimate bits used by pns for correction of static bits */
/* no codebook switch estimation, see AAC LD FASTENC */
INT noisePreCount(const INT *noiseNrg, INT maxSfb)
{
INT noisePCMFlag = TRUE;
INT lastValPns = 0, deltaPns;
int i, bits=0;
for (i = 0; i < maxSfb; i++) {
if (noiseNrg[i] != NO_NOISE_PNS) {
if (noisePCMFlag) {
bits+=PNS_PCM_BITS;
lastValPns = noiseNrg[i];
noisePCMFlag = FALSE;
}else {
deltaPns = noiseNrg[i]-lastValPns;
lastValPns = noiseNrg[i];
bits+=FDKaacEnc_bitCountScalefactorDelta(deltaPns);
}
}
}
return ( bits );
}
#endif /* PNS_PRECOUNT_ENABLE */
/* count bits used by pns */ /* count bits used by pns */
static void FDKaacEnc_noiseCount( static void FDKaacEnc_noiseCount(SECTION_DATA* const RESTRICT sectionData,
SECTION_DATA* const RESTRICT sectionData, const INT* const noiseNrg) {
const INT* const noiseNrg
)
{
INT noisePCMFlag = TRUE; INT noisePCMFlag = TRUE;
INT lastValPns = 0, deltaPns; INT lastValPns = 0, deltaPns;
int i, j; int i, j;
@ -708,7 +599,6 @@ static void FDKaacEnc_noiseCount(
int sfbStart = sectionData->huffsection[i].sfbStart; int sfbStart = sectionData->huffsection[i].sfbStart;
int sfbEnd = sfbStart + sectionData->huffsection[i].sfbCnt; int sfbEnd = sfbStart + sectionData->huffsection[i].sfbCnt;
for (j = sfbStart; j < sfbEnd; j++) { for (j = sfbStart; j < sfbEnd; j++) {
if (noisePCMFlag) { if (noisePCMFlag) {
sectionData->noiseNrgBits += PNS_PCM_BITS; sectionData->noiseNrgBits += PNS_PCM_BITS;
lastValPns = noiseNrg[j]; lastValPns = noiseNrg[j];
@ -716,90 +606,58 @@ static void FDKaacEnc_noiseCount(
} else { } else {
deltaPns = noiseNrg[j] - lastValPns; deltaPns = noiseNrg[j] - lastValPns;
lastValPns = noiseNrg[j]; lastValPns = noiseNrg[j];
sectionData->noiseNrgBits+=FDKaacEnc_bitCountScalefactorDelta(deltaPns); sectionData->noiseNrgBits +=
FDKaacEnc_bitCountScalefactorDelta(deltaPns);
} }
} }
} }
} }
} }
INT FDKaacEnc_dynBitCount( INT FDKaacEnc_dynBitCount(BITCNTR_STATE* const hBC,
BITCNTR_STATE* const hBC,
const SHORT* const quantSpectrum, const SHORT* const quantSpectrum,
const UINT* const maxValueInSfb, const UINT* const maxValueInSfb,
const INT* const scalefac, const INT* const scalefac, const INT blockType,
const INT blockType, const INT sfbCnt, const INT maxSfbPerGroup,
const INT sfbCnt, const INT sfbPerGroup, const INT* const sfbOffset,
const INT maxSfbPerGroup,
const INT sfbPerGroup,
const INT* const sfbOffset,
SECTION_DATA* const RESTRICT sectionData, SECTION_DATA* const RESTRICT sectionData,
const INT* const noiseNrg, const INT* const noiseNrg, const INT* const isBook,
const INT* const isBook, const INT* const isScale, const UINT syntaxFlags) {
const INT* const isScale,
const UINT syntaxFlags
)
{
sectionData->blockType = blockType; sectionData->blockType = blockType;
sectionData->sfbCnt = sfbCnt; sectionData->sfbCnt = sfbCnt;
sectionData->sfbPerGroup = sfbPerGroup; sectionData->sfbPerGroup = sfbPerGroup;
sectionData->noOfGroups = sfbCnt / sfbPerGroup; sectionData->noOfGroups = sfbCnt / sfbPerGroup;
sectionData->maxSfbPerGroup = maxSfbPerGroup; sectionData->maxSfbPerGroup = maxSfbPerGroup;
FDKaacEnc_noiselessCounter( FDKaacEnc_noiselessCounter(sectionData, hBC->mergeGainLookUp,
sectionData, (lookUpTable)hBC->bitLookUp, quantSpectrum,
hBC->mergeGainLookUp, maxValueInSfb, sfbOffset, blockType, noiseNrg,
(lookUpTable)hBC->bitLookUp, isBook, (syntaxFlags & AC_ER_VCB11) ? 1 : 0);
quantSpectrum,
maxValueInSfb,
sfbOffset,
blockType,
noiseNrg,
isBook,
(syntaxFlags & AC_ER_VCB11)?1:0);
FDKaacEnc_scfCount( FDKaacEnc_scfCount(scalefac, maxValueInSfb, sectionData, isScale);
scalefac,
maxValueInSfb,
sectionData,
isScale);
FDKaacEnc_noiseCount(sectionData, FDKaacEnc_noiseCount(sectionData, noiseNrg);
noiseNrg);
return (sectionData->huffmanBits + return (sectionData->huffmanBits + sectionData->sideInfoBits +
sectionData->sideInfoBits + sectionData->scalefacBits + sectionData->noiseNrgBits);
sectionData->scalefacBits +
sectionData->noiseNrgBits);
} }
INT FDKaacEnc_BCNew(BITCNTR_STATE **phBC INT FDKaacEnc_BCNew(BITCNTR_STATE** phBC, UCHAR* dynamic_RAM) {
,UCHAR* dynamic_RAM
)
{
BITCNTR_STATE* hBC = GetRam_aacEnc_BitCntrState(); BITCNTR_STATE* hBC = GetRam_aacEnc_BitCntrState();
if (hBC) if (hBC) {
{
*phBC = hBC; *phBC = hBC;
hBC->bitLookUp = GetRam_aacEnc_BitLookUp(0, dynamic_RAM); hBC->bitLookUp = GetRam_aacEnc_BitLookUp(0, dynamic_RAM);
hBC->mergeGainLookUp = GetRam_aacEnc_MergeGainLookUp(0, dynamic_RAM); hBC->mergeGainLookUp = GetRam_aacEnc_MergeGainLookUp(0, dynamic_RAM);
if (hBC->bitLookUp == 0 || if (hBC->bitLookUp == 0 || hBC->mergeGainLookUp == 0) {
hBC->mergeGainLookUp == 0)
{
return 1; return 1;
} }
} }
return (hBC == 0) ? 1 : 0; return (hBC == 0) ? 1 : 0;
} }
void FDKaacEnc_BCClose(BITCNTR_STATE **phBC) void FDKaacEnc_BCClose(BITCNTR_STATE** phBC) {
{
if (*phBC != NULL) { if (*phBC != NULL) {
FreeRam_aacEnc_BitCntrState(phBC); FreeRam_aacEnc_BitCntrState(phBC);
} }
} }

View File

@ -1,74 +1,85 @@
/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. © Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
All rights reserved. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software
the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio. that implements the MPEG Advanced Audio Coding ("AAC") encoding and decoding
This FDK AAC Codec software is intended to be used on a wide variety of Android devices. 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 AAC's HE-AAC and HE-AAC v2 versions are regarded as today's most efficient
audio codecs. AAC-ELD is considered the best-performing full-bandwidth communications codec by general perceptual audio codecs. AAC-ELD is considered the best-performing
independent studies and is widely deployed. AAC has been standardized by ISO and IEC as part full-bandwidth communications codec by independent studies and is widely
of the MPEG specifications. 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) Patent licenses for necessary patent claims for the FDK AAC Codec (including
may be obtained through Via Licensing (www.vialicensing.com) or through the respective patent owners those of Fraunhofer) may be obtained through Via Licensing
individually for the purpose of encoding or decoding bit streams in products that are compliant with (www.vialicensing.com) or through the respective patent owners individually for
the ISO/IEC MPEG audio standards. Please note that most manufacturers of Android devices already license the purpose of encoding or decoding bit streams in products that are compliant
these patent claims through Via Licensing or directly from the patent owners, and therefore FDK AAC Codec with the ISO/IEC MPEG audio standards. Please note that most manufacturers of
software may already be covered under those patent licenses when it is used for those licensed purposes only. 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, Commercially-licensed AAC software libraries, including floating-point versions
are also available from Fraunhofer. Users are encouraged to check the Fraunhofer website for additional with enhanced sound quality, are also available from Fraunhofer. Users are
applications information and documentation. encouraged to check the Fraunhofer website for additional applications
information and documentation.
2. COPYRIGHT LICENSE 2. COPYRIGHT LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted without Redistribution and use in source and binary forms, with or without modification,
payment of copyright license fees provided that you satisfy the following conditions: 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 You must retain the complete text of this software license in redistributions of
your modifications thereto in source code form. 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 You must retain the complete text of this software license in the documentation
provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form. and/or other materials provided with redistributions of the FDK AAC Codec or
You must make available free of charge copies of the complete source code of the FDK AAC Codec and your 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. 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 The name of Fraunhofer may not be used to endorse or promote products derived
prior written permission. 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 You may not charge copyright license fees for anyone to use, copy or distribute
software or your modifications thereto. 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 Your modified versions of the FDK AAC Codec must carry prominent notices stating
and the date of any change. For modified versions of the FDK AAC Codec, the term that you changed the software and the date of any change. For modified versions
"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
"Third-Party Modified Version of the 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 3. NO PATENT LICENSE
NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer, NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
respect to this software. 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 You may use this FDK AAC Codec software or modifications thereto only for
by appropriate patent licenses. purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER 4. DISCLAIMER
This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR including but not limited to the implied warranties of merchantability and
CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages, fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
including but not limited to procurement of substitute goods or services; loss of use, data, or profits, CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
or business interruption, however caused and on any theory of liability, whether in contract, strict or consequential damages, including but not limited to procurement of substitute
liability, or tort (including negligence), arising in any way out of the use of this software, even if goods or services; loss of use, data, or profits, or business interruption,
advised of the possibility of such damage. 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 5. CONTACT INFORMATION
@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de amm-info@iis.fraunhofer.de
----------------------------------------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */
/******************************** MPEG Audio Encoder ************************** /**************************** AAC encoder library ******************************
Initial author: M.Werner Author(s): M.Werner
contents/description: Noiseless coder module
******************************************************************************/ Description: Noiseless coder module
#ifndef __DYN_BITS_H *******************************************************************************/
#define __DYN_BITS_H
#ifndef DYN_BITS_H
#define DYN_BITS_H
#include "common_fix.h" #include "common_fix.h"
@ -104,17 +116,14 @@ amm-info@iis.fraunhofer.de
#define SECT_BITS_SHORT 3 #define SECT_BITS_SHORT 3
#define PNS_PCM_BITS 9 #define PNS_PCM_BITS 9
typedef struct typedef struct {
{
INT codeBook; INT codeBook;
INT sfbStart; INT sfbStart;
INT sfbCnt; INT sfbCnt;
INT sectionBits; /* huff + si ! */ INT sectionBits; /* huff + si ! */
} SECTION_INFO; } SECTION_INFO;
typedef struct {
typedef struct
{
INT blockType; INT blockType;
INT noOfGroups; INT noOfGroups;
INT sfbCnt; INT sfbCnt;
@ -129,39 +138,23 @@ typedef struct
INT firstScf; /* first scf to be coded */ INT firstScf; /* first scf to be coded */
} SECTION_DATA; } SECTION_DATA;
struct BITCNTR_STATE {
struct BITCNTR_STATE
{
INT* bitLookUp; INT* bitLookUp;
INT* mergeGainLookUp; INT* mergeGainLookUp;
}; };
INT FDKaacEnc_BCNew(BITCNTR_STATE** phBC, UCHAR* dynamic_RAM);
INT FDKaacEnc_BCNew(BITCNTR_STATE **phBC
,UCHAR* dynamic_RAM
);
void FDKaacEnc_BCClose(BITCNTR_STATE** phBC); void FDKaacEnc_BCClose(BITCNTR_STATE** phBC);
#if defined(PNS_PRECOUNT_ENABLE) INT FDKaacEnc_dynBitCount(BITCNTR_STATE* const hBC,
INT noisePreCount(const INT *noiseNrg, INT maxSfb);
#endif
INT FDKaacEnc_dynBitCount(
BITCNTR_STATE* const hBC,
const SHORT* const quantSpectrum, const SHORT* const quantSpectrum,
const UINT* const maxValueInSfb, const UINT* const maxValueInSfb,
const INT* const scalefac, const INT* const scalefac, const INT blockType,
const INT blockType, const INT sfbCnt, const INT maxSfbPerGroup,
const INT sfbCnt, const INT sfbPerGroup, const INT* const sfbOffset,
const INT maxSfbPerGroup,
const INT sfbPerGroup,
const INT* const sfbOffset,
SECTION_DATA* const RESTRICT sectionData, SECTION_DATA* const RESTRICT sectionData,
const INT* const noiseNrg, const INT* const noiseNrg, const INT* const isBook,
const INT* const isBook, const INT* const isScale, const UINT syntaxFlags);
const INT* const isScale,
const UINT syntaxFlags
);
#endif #endif

Some files were not shown because too many files have changed in this diff Show More