aboutsummaryrefslogtreecommitdiffstats
path: root/libFDK/include
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2018-02-26 20:17:00 +0100
committerJean-Michel Trivi <jmtrivi@google.com>2018-04-19 11:21:15 -0700
commit6cfabd35363c3ef5e3b209b867169a500b3ccc3c (patch)
tree01c0a19f2735e8b5d2407555fe992d4230d089eb /libFDK/include
parent6288a1e34c4dede4c2806beb1736ece6580558c7 (diff)
downloadfdk-aac-6cfabd35363c3ef5e3b209b867169a500b3ccc3c.tar.gz
fdk-aac-6cfabd35363c3ef5e3b209b867169a500b3ccc3c.tar.bz2
fdk-aac-6cfabd35363c3ef5e3b209b867169a500b3ccc3c.zip
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
Diffstat (limited to 'libFDK/include')
-rw-r--r--libFDK/include/FDK_archdef.h232
-rw-r--r--libFDK/include/FDK_bitbuffer.h191
-rw-r--r--libFDK/include/FDK_bitstream.h720
-rw-r--r--libFDK/include/FDK_core.h123
-rw-r--r--libFDK/include/FDK_crc.h226
-rw-r--r--libFDK/include/FDK_decorrelate.h314
-rw-r--r--libFDK/include/FDK_hybrid.h260
-rw-r--r--libFDK/include/FDK_lpc.h218
-rw-r--r--libFDK/include/FDK_matrixCalloc.h230
-rw-r--r--libFDK/include/FDK_qmf_domain.h416
-rw-r--r--libFDK/include/FDK_tools_rom.h358
-rw-r--r--libFDK/include/FDK_trigFcts.h309
-rw-r--r--libFDK/include/abs.h141
-rw-r--r--libFDK/include/arm/clz_arm.h200
-rw-r--r--libFDK/include/arm/cplx_mul.h214
-rw-r--r--libFDK/include/arm/cplx_mul_arm.h201
-rw-r--r--libFDK/include/arm/fixmadd_arm.h298
-rw-r--r--libFDK/include/arm/fixmul_arm.h222
-rw-r--r--libFDK/include/arm/scale.h152
-rw-r--r--libFDK/include/arm/scale_arm.h163
-rw-r--r--libFDK/include/arm/scramble.h158
-rw-r--r--libFDK/include/arm/scramble_arm.h174
-rw-r--r--libFDK/include/autocorr2nd.h171
-rw-r--r--libFDK/include/clz.h224
-rw-r--r--libFDK/include/common_fix.h583
-rw-r--r--libFDK/include/cplx_mul.h325
-rw-r--r--libFDK/include/dct.h148
-rw-r--r--libFDK/include/fft.h376
-rw-r--r--libFDK/include/fft_rad2.h163
-rw-r--r--libFDK/include/fixmadd.h233
-rw-r--r--libFDK/include/fixminmax.h157
-rw-r--r--libFDK/include/fixmul.h267
-rw-r--r--libFDK/include/fixpoint_math.h902
-rw-r--r--libFDK/include/huff_nodes.h258
-rw-r--r--libFDK/include/mdct.h289
-rw-r--r--libFDK/include/mips/abs_mips.h142
-rw-r--r--libFDK/include/mips/clz_mips.h156
-rw-r--r--libFDK/include/mips/cplx_mul.h162
-rw-r--r--libFDK/include/mips/cplx_mul_mips.h170
-rw-r--r--libFDK/include/mips/fixmadd_mips.h95
-rw-r--r--libFDK/include/mips/fixmul_mips.h139
-rw-r--r--libFDK/include/mips/scale.h110
-rw-r--r--libFDK/include/mips/scale_mips.h122
-rw-r--r--libFDK/include/mips/scramble.h121
-rw-r--r--libFDK/include/mips/scramble_mips.h133
-rw-r--r--libFDK/include/nlc_dec.h187
-rw-r--r--libFDK/include/qmf.h419
-rw-r--r--libFDK/include/qmf_pcm.h405
-rw-r--r--libFDK/include/scale.h294
-rw-r--r--libFDK/include/scramble.h182
-rw-r--r--libFDK/include/x86/abs_x86.h141
-rw-r--r--libFDK/include/x86/clz_x86.h219
-rw-r--r--libFDK/include/x86/fixmul_x86.h175
-rw-r--r--libFDK/include/x86/fixpoint_math_x86.h208
54 files changed, 8297 insertions, 4899 deletions
diff --git a/libFDK/include/FDK_archdef.h b/libFDK/include/FDK_archdef.h
index 5dbc138..95601bb 100644
--- a/libFDK/include/FDK_archdef.h
+++ b/libFDK/include/FDK_archdef.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,74 +90,76 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s):
- Description:
-
-******************************************************************************/
-#ifndef __ARCH_H__
-#define __ARCH_H__
+ Description:
-/* Performance / Quality profile selector */
- #define FDK_HIGH_PERFORMANCE
+*******************************************************************************/
-/* Unify some few toolchain specific defines to avoid having large "or" macro contraptions all over the source code. */
+#ifndef FDK_ARCHDEF_H
+#define FDK_ARCHDEF_H
-/* Take action against VisualStudio 2005 crosscompile problems. */
+/* Unify some few toolchain specific defines to avoid having large "or" macro
+ * contraptions all over the source code. */
-/* Use single macro (the GCC built in macro) for architecture identification independent of the particular toolchain */
-#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || (defined(_MSC_VER) && defined(_M_IX86)) || defined (__x86_64__)
+/* Use single macro (the GCC built in macro) for architecture identification
+ * independent of the particular toolchain */
+#if defined(__i386__) || defined(__i486__) || defined(__i586__) || \
+ defined(__i686__) || (defined(_MSC_VER) && defined(_M_IX86)) || \
+ (defined(_MSC_VER) && defined(_M_X64)) || defined(__x86_64__)
#define __x86__
#endif
-#if (defined(_M_ARM) || defined(__CC_ARM)) && !defined(__arm__) || defined(__TI_TMS470_V5__) && !defined(__arm__)
+#if defined(_M_ARM) && !defined(__arm__) || defined(__aarch64__)
#define __arm__
#endif
-
-
+#if (__TARGET_ARCH_ARM == 5) || defined(__TARGET_FEATURE_DSPMUL) || \
+ (_M_ARM == 5) || defined(__ARM_ARCH_5TEJ__) || defined(__ARM_ARCH_7EM__)
/* Define __ARM_ARCH_5TE__ if armv5te features are supported */
-#if (__TARGET_ARCH_ARM == 5) || defined(__TARGET_FEATURE_DSPMUL) || (_M_ARM == 5) || defined(__ARM_ARCH_5TEJ__) || defined(__TI_TMS470_V5__) || defined(__ARM_ARCH_7EM__)
#define __ARM_ARCH_5TE__
#endif
+#if (__TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6J__) || \
+ defined(__ARM_ARCH_6ZK__)
/* Define __ARM_ARCH_6__ if the armv6 intructions are being supported. */
-#if (__TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6ZK__)
#define __ARM_ARCH_5TE__
#define __ARM_ARCH_6__
#endif
-/* Define __ARM_ARCH_7_A__ if the armv7 intructions are being supported. */
#if defined(__TARGET_ARCH_7_R) || defined(__ARM_ARCH_7R__)
+/* Define __ARM_ARCH_7_A__ if the armv7 intructions are being supported. */
#define __ARM_ARCH_5TE__
#define __ARM_ARCH_6__
#define __ARM_ARCH_7_R__
#endif
+#if defined(__TARGET_ARCH_7_A) || defined(__ARM_ARCH_7A__) || \
+ ((__ARM_ARCH == 8) && (__ARM_32BIT_STATE == 1))
/* Define __ARM_ARCH_7_A__ if the armv7 intructions are being supported. */
-#if defined(__TARGET_ARCH_7_A) || defined(__ARM_ARCH_7A__)
#define __ARM_ARCH_5TE__
#define __ARM_ARCH_6__
#define __ARM_ARCH_7_A__
#endif
-/* Define __ARM_ARCH_7M__ if the ARMv7-M instructions are being supported, e.g. Cortex-M3. */
#if defined(__TARGET_ARCH_7_M) || defined(__ARM_ARCH_7_M__)
+/* Define __ARM_ARCH_7M__ if the ARMv7-M instructions are being supported, e.g.
+ * Cortex-M3. */
#define __ARM_ARCH_7M__
#endif
-/* Define __ARM_ARCH_7EM__ if the ARMv7-ME instructions are being supported, e.g. Cortex-M4. */
#if defined(__TARGET_ARCH_7E_M) || defined(__ARM_ARCH_7E_M__)
+/* Define __ARM_ARCH_7EM__ if the ARMv7-ME instructions are being supported,
+ * e.g. Cortex-M4. */
#define __ARM_ARCH_7EM__
#endif
-/* Detect and unify macros for neon feature. */
-#if defined(__TARGET_FEATURE_NEON) && !defined(__ARM_NEON__)
-#define __ARM_NEON__
+#if defined(__aarch64__)
+#define __ARM_ARCH_8__
#endif
#ifdef _M_ARM
@@ -154,18 +167,23 @@ amm-info@iis.fraunhofer.de
#include "armintr.h"
#endif
-
/* Define preferred Multiplication type */
-#if defined(FDK_HIGH_PERFORMANCE) && !defined(FDK_HIGH_QUALITY) /* FDK_HIGH_PERFORMANCE */
-#if defined(__mips__) || defined(__powerpc__) || defined(__sh__)
+#if defined(__mips__)
#define ARCH_PREFER_MULT_16x16
#undef SINETABLE_16BIT
#undef POW2COEFF_16BIT
#undef LDCOEFF_16BIT
#undef WINDOWTABLE_16BIT
-#elif defined(__arm__) && defined(__ARM_ARCH_5TE__) /* cppp replaced: elif */ /* cppp replaced: elif */
+#elif defined(__arm__) && defined(__ARM_ARCH_8__)
+#define ARCH_PREFER_MULT_32x16
+#define SINETABLE_16BIT
+#define POW2COEFF_16BIT
+#define LDCOEFF_16BIT
+#define WINDOWTABLE_16BIT
+
+#elif defined(__arm__) && defined(__ARM_ARCH_5TE__)
#define ARCH_PREFER_MULT_32x16
#define SINETABLE_16BIT
#define POW2COEFF_16BIT
@@ -194,7 +212,7 @@ amm-info@iis.fraunhofer.de
#undef POW2COEFF_16BIT
#undef LDCOEFF_16BIT
-#elif defined(__x86__) /* cppp replaced: elif */
+#elif defined(__x86__)
#define ARCH_PREFER_MULT_32x16
#define SINETABLE_16BIT
#define WINDOWTABLE_16BIT
@@ -202,44 +220,40 @@ amm-info@iis.fraunhofer.de
#define LDCOEFF_16BIT
#else
-
- #warning >>>> Please set architecture characterization defines for your platform (FDK_HIGH_PERFORMANCE)! <<<<
+#warning >>>> Please set architecture characterization defines for your platform (FDK_HIGH_PERFORMANCE)! <<<<
#endif /* Architecture switches */
-#else /* neither FDK_HIGH_QUALITY or FDK_HIGH_PERFORMANCE */
-
-#error Either set FDK_HIGH_QUALITY or FDK_HIGH_PERFORMANCE, but not both nor none of them.
-
-#endif /* End of quality/complexity tradeoff */
-
-#define FDKTOOLS_PACKED_TABLES
-
-
#ifdef SINETABLE_16BIT
- #define FIXP_STB FIXP_SGL /* STB sinus Tab used in transformation */
- #define FIXP_STP FIXP_SPK
- #define STC(a) (FX_DBL2FXCONST_SGL(a))
+#define FIXP_STB FIXP_SGL /* STB sinus Tab used in transformation */
+#define FIXP_STP FIXP_SPK
+#define STC(a) (FX_DBL2FXCONST_SGL(a))
#else
- #define FIXP_STB FIXP_DBL
- #define FIXP_STP FIXP_DPK
- #define STC(a) ((FIXP_DBL)(LONG)(a))
+#define FIXP_STB FIXP_DBL
+#define FIXP_STP FIXP_DPK
+#define STC(a) ((FIXP_DBL)(LONG)(a))
#endif /* defined(SINETABLE_16BIT) */
-#define STCP(cos,sin) { { STC(cos), STC(sin) } }
-
+#define STCP(cos, sin) \
+ { \
+ { STC(cos), STC(sin) } \
+ }
#ifdef WINDOWTABLE_16BIT
- #define FIXP_WTB FIXP_SGL /* single FIXP_SGL values */
- #define FIXP_WTP FIXP_SPK /* packed FIXP_SGL values */
- #define WTC(a) FX_DBL2FXCONST_SGL(a)
+#define FIXP_WTB FIXP_SGL /* single FIXP_SGL values */
+#define FX_DBL2FX_WTB(x) FX_DBL2FX_SGL(x)
+#define FIXP_WTP FIXP_SPK /* packed FIXP_SGL values */
+#define WTC(a) FX_DBL2FXCONST_SGL(a)
#else /* SINETABLE_16BIT */
- #define FIXP_WTB FIXP_DBL
- #define FIXP_WTP FIXP_DPK
- #define WTC(a) (FIXP_DBL)(a)
+#define FIXP_WTB FIXP_DBL
+#define FX_DBL2FX_WTB(x) (x)
+#define FIXP_WTP FIXP_DPK
+#define WTC(a) (FIXP_DBL)(a)
#endif /* SINETABLE_16BIT */
-#define WTCP(a,b) { { WTC(a), WTC(b) } }
-
+#define WTCP(a, b) \
+ { \
+ { WTC(a), WTC(b) } \
+ }
-#endif /* __ARCH_H__ */
+#endif /* FDK_ARCHDEF_H */
diff --git a/libFDK/include/FDK_bitbuffer.h b/libFDK/include/FDK_bitbuffer.h
index 65fa04b..ed0b2f6 100644
--- a/libFDK/include/FDK_bitbuffer.h
+++ b/libFDK/include/FDK_bitbuffer.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,24 +90,26 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser
- Description: common bitbuffer read/write routines
-******************************************************************************/
-
-#ifndef __FDK_BITBUFFER_H__
-#define __FDK_BITBUFFER_H__
+ Description: common bitbuffer read/write routines
+*******************************************************************************/
+#ifndef FDK_BITBUFFER_H
+#define FDK_BITBUFFER_H
+#include "FDK_archdef.h"
#include "machine_type.h"
-typedef struct
-{
+/* leave 3 bits headroom so MAX_BUFSIZE can be represented in bits as well. */
+#define MAX_BUFSIZE_BYTES (0x10000000)
+
+typedef struct {
UINT ValidBits;
UINT ReadOffset;
UINT WriteOffset;
@@ -104,63 +117,67 @@ typedef struct
UINT BitNdx;
UCHAR *Buffer;
- UINT bufSize;
- UINT bufBits;
+ UINT bufSize;
+ UINT bufBits;
} FDK_BITBUF;
typedef FDK_BITBUF *HANDLE_FDK_BITBUF;
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
-extern const UINT BitMask [32+1];
+extern const UINT BitMask[32 + 1];
/** The BitBuffer Functions are called straight from FDK_bitstream Interface.
For Functions functional survey look there.
*/
-void FDK_CreateBitBuffer (HANDLE_FDK_BITBUF *hBitBuffer, UCHAR *pBuffer, UINT bufSize) ;
+void FDK_CreateBitBuffer(HANDLE_FDK_BITBUF *hBitBuffer, UCHAR *pBuffer,
+ UINT bufSize);
+
+void FDK_InitBitBuffer(HANDLE_FDK_BITBUF hBitBuffer, UCHAR *pBuffer,
+ UINT bufSize, UINT validBits);
-void FDK_InitBitBuffer (HANDLE_FDK_BITBUF hBitBuffer, UCHAR *pBuffer,
- UINT bufSize, UINT validBits) ;
+void FDK_ResetBitBuffer(HANDLE_FDK_BITBUF hBitBuffer);
-void FDK_ResetBitBuffer (HANDLE_FDK_BITBUF hBitBuffer) ;
+void FDK_DeleteBitBuffer(HANDLE_FDK_BITBUF hBitBuffer);
-void FDK_DeleteBitBuffer (HANDLE_FDK_BITBUF hBitBuffer) ;
+INT FDK_get(HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits);
-INT FDK_get (HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits) ;
+INT FDK_get32(HANDLE_FDK_BITBUF hBitBuf);
-INT FDK_get32 (HANDLE_FDK_BITBUF hBitBuffer) ;
+void FDK_put(HANDLE_FDK_BITBUF hBitBuffer, UINT value, const UINT numberOfBits);
-void FDK_put (HANDLE_FDK_BITBUF hBitBuffer, UINT value, const UINT numberOfBits) ;
+INT FDK_getBwd(HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits);
+void FDK_putBwd(HANDLE_FDK_BITBUF hBitBuffer, UINT value,
+ const UINT numberOfBits);
-INT FDK_getBwd (HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits);
-void FDK_putBwd (HANDLE_FDK_BITBUF hBitBuffer, UINT value, const UINT numberOfBits) ;
+void FDK_pushBack(HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits,
+ UCHAR config);
-void FDK_pushBack (HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits, UCHAR config) ;
-void FDK_pushForward (HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits, UCHAR config) ;
+void FDK_pushForward(HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits,
+ UCHAR config);
-void FDK_byteAlign (HANDLE_FDK_BITBUF hBitBuffer, UCHAR config) ;
+void FDK_byteAlign(HANDLE_FDK_BITBUF hBitBuffer, UCHAR config);
-UINT FDK_getValidBits (HANDLE_FDK_BITBUF hBitBuffer) ;
-INT FDK_getFreeBits (HANDLE_FDK_BITBUF hBitBuffer) ;
+UINT FDK_getValidBits(HANDLE_FDK_BITBUF hBitBuffer);
-void FDK_setBitCnt (HANDLE_FDK_BITBUF hBitBuffer, const UINT value) ;
-INT FDK_getBitCnt (HANDLE_FDK_BITBUF hBitBuffer) ;
+INT FDK_getFreeBits(HANDLE_FDK_BITBUF hBitBuffer);
-void FDK_Feed (HANDLE_FDK_BITBUF hBitBuffer, UCHAR inputBuffer [],
- const UINT bufferSize, UINT *bytesValid) ;
+void FDK_setBitCnt(HANDLE_FDK_BITBUF hBitBuffer, const UINT value);
+INT FDK_getBitCnt(HANDLE_FDK_BITBUF hBitBuffer);
-void FDK_Copy (HANDLE_FDK_BITBUF hBitBufDst, HANDLE_FDK_BITBUF hBitBufSrc, UINT *bytesValid) ;
+void FDK_Feed(HANDLE_FDK_BITBUF hBitBuffer, const UCHAR inputBuffer[],
+ const UINT bufferSize, UINT *bytesValid);
-void FDK_Fetch (HANDLE_FDK_BITBUF hBitBuffer, UCHAR outBuf[], UINT *writeBytes);
+void FDK_Copy(HANDLE_FDK_BITBUF hBitBufDst, HANDLE_FDK_BITBUF hBitBufSrc,
+ UINT *bytesValid);
+void FDK_Fetch(HANDLE_FDK_BITBUF hBitBuffer, UCHAR outBuf[], UINT *writeBytes);
#ifdef __cplusplus
}
#endif
-
#endif
diff --git a/libFDK/include/FDK_bitstream.h b/libFDK/include/FDK_bitstream.h
index fc8d7de..49eeeaf 100644
--- a/libFDK/include/FDK_bitstream.h
+++ b/libFDK/include/FDK_bitstream.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,19 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser
- Description: bitstream interface to bitbuffer routines
-******************************************************************************/
-
-#ifndef __FDK_BITSTREAM_H__
-#define __FDK_BITSTREAM_H__
+ Description: bitstream interface to bitbuffer routines
+*******************************************************************************/
+#ifndef FDK_BITSTREAM_H
+#define FDK_BITSTREAM_H
#include "FDK_bitbuffer.h"
#include "machine_type.h"
@@ -100,21 +110,18 @@ amm-info@iis.fraunhofer.de
#define CACHE_BITS 32
-typedef enum {
- BS_READER,
- BS_WRITER
-} FDK_BS_CFG;
+#define BUFSIZE_DUMMY_VALUE MAX_BUFSIZE_BYTES
+typedef enum { BS_READER, BS_WRITER } FDK_BS_CFG;
-typedef struct
-{
- UINT CacheWord ;
- UINT BitsInCache ;
+typedef struct {
+ UINT CacheWord;
+ UINT BitsInCache;
FDK_BITBUF hBitBuf;
- UINT ConfigCache ;
+ UINT ConfigCache;
} FDK_BITSTREAM;
-typedef FDK_BITSTREAM* HANDLE_FDK_BITSTREAM;
+typedef FDK_BITSTREAM *HANDLE_FDK_BITSTREAM;
/**
* \brief CreateBitStream Function.
@@ -122,50 +129,48 @@ typedef FDK_BITSTREAM* HANDLE_FDK_BITSTREAM;
* Create and initialize bitstream with extern allocated buffer.
*
* \param pBuffer Pointer to BitBuffer array.
- * \param bufSize Length of BitBuffer array. (awaits size 2^n)
+ * \param bufSize Length of BitBuffer array. (awaits size 2^n and <=
+ * MAX_BUFSIZE_BYTES)
* \param config Initialize BitStream as Reader or Writer.
*/
FDK_INLINE
-HANDLE_FDK_BITSTREAM FDKcreateBitStream (UCHAR *pBuffer,
- UINT bufSize,
- FDK_BS_CFG config = BS_READER)
-{
- HANDLE_FDK_BITSTREAM hBitStream = (HANDLE_FDK_BITSTREAM) FDKcalloc(1, sizeof(FDK_BITSTREAM));
- FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, 0) ;
+HANDLE_FDK_BITSTREAM FDKcreateBitStream(UCHAR *pBuffer, UINT bufSize,
+ FDK_BS_CFG config = BS_READER) {
+ HANDLE_FDK_BITSTREAM hBitStream =
+ (HANDLE_FDK_BITSTREAM)FDKcalloc(1, sizeof(FDK_BITSTREAM));
+ if (hBitStream == NULL) return NULL;
+ FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, 0);
/* init cache */
- hBitStream->CacheWord = hBitStream->BitsInCache = 0 ;
- hBitStream->ConfigCache = config ;
+ hBitStream->CacheWord = hBitStream->BitsInCache = 0;
+ hBitStream->ConfigCache = config;
- return hBitStream ;
+ return hBitStream;
}
-
/**
- * \brief Initialize BistreamBuffer. BitBuffer can point to filled BitBuffer array .
+ * \brief Initialize BistreamBuffer. BitBuffer can point to filled BitBuffer
+ * array .
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param pBuffer Pointer to BitBuffer array.
- * \param bufSize Length of BitBuffer array. (awaits size 2^n)
+ * \param bufSize Length of BitBuffer array in bytes. (awaits size 2^n and <=
+ * MAX_BUFSIZE_BYTES)
* \param validBits Number of valid BitBuffer filled Bits.
* \param config Initialize BitStream as Reader or Writer.
* \return void
*/
FDK_INLINE
-void FDKinitBitStream (HANDLE_FDK_BITSTREAM hBitStream,
- UCHAR *pBuffer,
- UINT bufSize,
- UINT validBits,
- FDK_BS_CFG config = BS_READER)
-{
- FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, validBits) ;
+void FDKinitBitStream(HANDLE_FDK_BITSTREAM hBitStream, UCHAR *pBuffer,
+ UINT bufSize, UINT validBits,
+ FDK_BS_CFG config = BS_READER) {
+ FDK_InitBitBuffer(&hBitStream->hBitBuf, pBuffer, bufSize, validBits);
/* init cache */
- hBitStream->CacheWord = hBitStream->BitsInCache = 0 ;
- hBitStream->ConfigCache = config ;
+ hBitStream->CacheWord = hBitStream->BitsInCache = 0;
+ hBitStream->ConfigCache = config;
}
-
/**
* \brief ResetBitbuffer Function. Reset states in BitBuffer and Cache.
*
@@ -173,183 +178,206 @@ void FDKinitBitStream (HANDLE_FDK_BITSTREAM hBitStream,
* \param config Initialize BitStream as Reader or Writer.
* \return void
*/
-FDK_INLINE void FDKresetBitbuffer( HANDLE_FDK_BITSTREAM hBitStream, FDK_BS_CFG config = BS_READER)
-{
- FDK_ResetBitBuffer( &hBitStream->hBitBuf ) ;
+FDK_INLINE void FDKresetBitbuffer(HANDLE_FDK_BITSTREAM hBitStream,
+ FDK_BS_CFG config = BS_READER) {
+ FDK_ResetBitBuffer(&hBitStream->hBitBuf);
/* init cache */
- hBitStream->CacheWord = hBitStream->BitsInCache = 0 ;
- hBitStream->ConfigCache = config ;
+ hBitStream->CacheWord = hBitStream->BitsInCache = 0;
+ hBitStream->ConfigCache = config;
}
-
/** DeleteBitStream.
Deletes the in Create Bitstream allocated BitStream and BitBuffer.
*/
-FDK_INLINE void FDKdeleteBitStream (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDK_DeleteBitBuffer(&hBitStream->hBitBuf) ;
- FDKfree(hBitStream) ;
+FDK_INLINE void FDKdeleteBitStream(HANDLE_FDK_BITSTREAM hBitStream) {
+ FDK_DeleteBitBuffer(&hBitStream->hBitBuf);
+ FDKfree(hBitStream);
}
-
/**
- * \brief ReadBits Function (forward). This function returns a number of sequential
- * bits from the input bitstream.
+ * \brief ReadBits Function (forward). This function returns a number of
+ * sequential bits from the input bitstream.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \param numberOfBits The number of bits to be retrieved.
+ * \param numberOfBits The number of bits to be retrieved. ( (0),1 <=
+ * numberOfBits <= 32)
* \return the requested bits, right aligned
* \return
*/
-#define OPTIMIZE_FDKREADBITS
FDK_INLINE UINT FDKreadBits(HANDLE_FDK_BITSTREAM hBitStream,
- const UINT numberOfBits)
-{
-#ifdef noOPTIMIZE_FDKREADBITS
- INT missingBits = numberOfBits - hBitStream->BitsInCache;
- if (missingBits > 0)
- {
- UINT bits = hBitStream->CacheWord << missingBits;
- hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf) ;
- hBitStream->BitsInCache = CACHE_BITS - missingBits;
- return ( bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) & BitMask[numberOfBits];
+ const UINT numberOfBits) {
+ UINT bits = 0;
+ INT missingBits = (INT)numberOfBits - (INT)hBitStream->BitsInCache;
+
+ FDK_ASSERT(numberOfBits <= 32);
+ if (missingBits > 0) {
+ if (missingBits != 32) bits = hBitStream->CacheWord << missingBits;
+ hBitStream->CacheWord = FDK_get32(&hBitStream->hBitBuf);
+ hBitStream->BitsInCache += CACHE_BITS;
}
hBitStream->BitsInCache -= numberOfBits;
- return ( hBitStream->CacheWord >> hBitStream->BitsInCache) & BitMask[numberOfBits];
-
-#else
- const UINT validMask = BitMask [numberOfBits] ;
-
- if (hBitStream->BitsInCache <= numberOfBits)
- {
- const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ;
-
- hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_get (&hBitStream->hBitBuf,freeBits) ;
- hBitStream->BitsInCache += freeBits ;
- }
-
- hBitStream->BitsInCache -= numberOfBits ;
- return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask ;
-#endif
+ return (bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) &
+ BitMask[numberOfBits];
}
-FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream)
-{
-#ifdef OPTIMIZE_FDKREADBITS
- if (!hBitStream->BitsInCache)
- {
- hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf);
- hBitStream->BitsInCache = CACHE_BITS;
+FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream) {
+ if (!hBitStream->BitsInCache) {
+ hBitStream->CacheWord = FDK_get32(&hBitStream->hBitBuf);
+ hBitStream->BitsInCache = CACHE_BITS - 1;
+ return hBitStream->CacheWord >> 31;
}
hBitStream->BitsInCache--;
return (hBitStream->CacheWord >> hBitStream->BitsInCache) & 1;
-#else
- return FDKreadBits(hBitStream,1);
-#endif
}
/**
- * \brief Read2Bits Function (forward). This function 2 sequential
+ * \brief Read2Bits Function (forward). This function reads 2 sequential
* bits from the input bitstream. It is the optimized version
- of FDKreadBits() for readign 2 bits.
+ of FDKreadBits() for reading 2 bits.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return the requested bits, right aligned
* \return
*/
-inline UINT FDKread2Bits(HANDLE_FDK_BITSTREAM hBitStream)
-{
- UINT BitsInCache = hBitStream->BitsInCache;
- if (BitsInCache < 2) /* Comparison changed from 'less-equal' to 'less' */
- {
- const INT freeBits = (CACHE_BITS-1) - BitsInCache ;
-
- hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_get (&hBitStream->hBitBuf,freeBits) ;
- BitsInCache += freeBits;
+FDK_INLINE UINT FDKread2Bits(HANDLE_FDK_BITSTREAM hBitStream) {
+ /*
+ ** Version corresponds to optimized FDKreadBits implementation
+ ** calling FDK_get32, that keeps read pointer aligned.
+ */
+ UINT bits = 0;
+ INT missingBits = 2 - (INT)hBitStream->BitsInCache;
+ if (missingBits > 0) {
+ bits = hBitStream->CacheWord << missingBits;
+ hBitStream->CacheWord = FDK_get32(&hBitStream->hBitBuf);
+ hBitStream->BitsInCache += CACHE_BITS;
}
- hBitStream->BitsInCache = BitsInCache - 2;
- return (hBitStream->CacheWord >> hBitStream->BitsInCache) & 0x3;
+
+ hBitStream->BitsInCache -= 2;
+
+ return (bits | (hBitStream->CacheWord >> hBitStream->BitsInCache)) & 0x3;
}
/**
- * \brief ReadBits Function (backward). This function returns a number of sequential bits
- * from the input bitstream.
+ * \brief ReadBits Function (backward). This function returns a number of
+ * sequential bits from the input bitstream.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param numberOfBits The number of bits to be retrieved.
* \return the requested bits, right aligned
*/
FDK_INLINE UINT FDKreadBitsBwd(HANDLE_FDK_BITSTREAM hBitStream,
- const UINT numberOfBits)
-{
- const UINT validMask = BitMask [numberOfBits] ;
+ const UINT numberOfBits) {
+ const UINT validMask = BitMask[numberOfBits];
- if (hBitStream->BitsInCache <= numberOfBits)
- {
- const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ;
+ if (hBitStream->BitsInCache <= numberOfBits) {
+ const INT freeBits = (CACHE_BITS - 1) - hBitStream->BitsInCache;
- hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) | FDK_getBwd (&hBitStream->hBitBuf,freeBits) ;
- hBitStream->BitsInCache += freeBits ;
+ hBitStream->CacheWord = (hBitStream->CacheWord << freeBits) |
+ FDK_getBwd(&hBitStream->hBitBuf, freeBits);
+ hBitStream->BitsInCache += freeBits;
}
- hBitStream->BitsInCache -= numberOfBits ;
+ hBitStream->BitsInCache -= numberOfBits;
- return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask ;
+ return (hBitStream->CacheWord >> hBitStream->BitsInCache) & validMask;
}
+/**
+ * \brief read an integer value using a varying number of bits from the
+ * bitstream
+ *
+ * q.v. ISO/IEC FDIS 23003-3 Table 16
+ *
+ * \param hBitStream HANDLE_FDK_BITSTREAM handle
+ * \param nBits1 number of bits to read for a small integer value or escape
+ * value
+ * \param nBits2 number of bits to read for a medium sized integer value or
+ * escape value
+ * \param nBits3 number of bits to read for a large integer value
+ * \return integer value read from bitstream
+ */
+FDK_INLINE UINT escapedValue(HANDLE_FDK_BITSTREAM hBitStream, int nBits1,
+ int nBits2, int nBits3) {
+ UINT value = FDKreadBits(hBitStream, nBits1);
+
+ if (value == (UINT)(1 << nBits1) - 1) {
+ UINT valueAdd = FDKreadBits(hBitStream, nBits2);
+ value += valueAdd;
+ if (valueAdd == (UINT)(1 << nBits2) - 1) {
+ value += FDKreadBits(hBitStream, nBits3);
+ }
+ }
+
+ return value;
+}
/**
* \brief return a number of bits from the bitBuffer.
- * You have to know what you do! Cache has to be synchronized before using this
- * function.
+ * You have to know what you do! Cache has to be synchronized before
+ * using this function.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param numBits The number of bits to be retrieved.
* \return the requested bits, right aligned
*/
-FDK_INLINE UINT FDKgetBits (HANDLE_FDK_BITSTREAM hBitStream, UINT numBits)
-{
- return FDK_get (&hBitStream->hBitBuf, numBits) ;
+FDK_INLINE UINT FDKgetBits(HANDLE_FDK_BITSTREAM hBitStream, UINT numBits) {
+ return FDK_get(&hBitStream->hBitBuf, numBits);
}
-
/**
- * \brief WriteBits Function. This function writes numberOfBits of value into bitstream.
+ * \brief WriteBits Function. This function writes numberOfBits of value into
+ * bitstream.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \param value Variable holds data to be written.
- * \param numberOfBits The number of bits to be written.
- * \return number of bits written
+ * \param value The data to be written
+ * \param numberOfBits The number of bits to be written
+ * \return Number of bits written
*/
FDK_INLINE UCHAR FDKwriteBits(HANDLE_FDK_BITSTREAM hBitStream, UINT value,
- const UINT numberOfBits)
-{
- const UINT validMask = BitMask [numberOfBits] ;
-
- if ((hBitStream->BitsInCache+numberOfBits) < CACHE_BITS)
- {
- hBitStream->BitsInCache += numberOfBits ;
- hBitStream->CacheWord = (hBitStream->CacheWord << numberOfBits) | (value & validMask);
+ const UINT numberOfBits) {
+ const UINT validMask = BitMask[numberOfBits];
+
+ if (hBitStream == NULL) {
+ return numberOfBits;
}
- else
- {
- FDK_put(&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ;
- hBitStream->BitsInCache = numberOfBits ;
- hBitStream->CacheWord = (value & validMask) ;
+
+ if ((hBitStream->BitsInCache + numberOfBits) < CACHE_BITS) {
+ hBitStream->BitsInCache += numberOfBits;
+ hBitStream->CacheWord =
+ (hBitStream->CacheWord << numberOfBits) | (value & validMask);
+ } else {
+ /* Put always 32 bits into memory */
+ /* - fill cache's LSBits with MSBits of value */
+ /* - store 32 bits in memory using subroutine */
+ /* - fill remaining bits into cache's LSBits */
+ /* - upper bits in cache are don't care */
+
+ /* Compute number of bits to be filled into cache */
+ int missing_bits = CACHE_BITS - hBitStream->BitsInCache;
+ int remaining_bits = numberOfBits - missing_bits;
+ value = value & validMask;
+ /* Avoid shift left by 32 positions */
+ UINT CacheWord =
+ (missing_bits == 32) ? 0 : (hBitStream->CacheWord << missing_bits);
+ CacheWord |= (value >> (remaining_bits));
+ FDK_put(&hBitStream->hBitBuf, CacheWord, 32);
+
+ hBitStream->CacheWord = value;
+ hBitStream->BitsInCache = remaining_bits;
}
- return numberOfBits;
+ return numberOfBits;
}
-
/**
- * \brief WriteBits Function (backward). This function writes numberOfBits of value into bitstream.
+ * \brief WriteBits Function (backward). This function writes numberOfBits of
+ * value into bitstream.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param value Variable holds data to be written.
@@ -357,25 +385,63 @@ FDK_INLINE UCHAR FDKwriteBits(HANDLE_FDK_BITSTREAM hBitStream, UINT value,
* \return number of bits written
*/
FDK_INLINE UCHAR FDKwriteBitsBwd(HANDLE_FDK_BITSTREAM hBitStream, UINT value,
- const UINT numberOfBits)
-{
- const UINT validMask = BitMask [numberOfBits] ;
-
- if ((hBitStream->BitsInCache+numberOfBits) <= CACHE_BITS)
- {
- hBitStream->BitsInCache += numberOfBits ;
- hBitStream->CacheWord = (hBitStream->CacheWord << numberOfBits) | (value & validMask);
- }
- else
- {
- FDK_putBwd(&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ;
- hBitStream->BitsInCache = numberOfBits ;
- hBitStream->CacheWord = (value & validMask) ;
+ const UINT numberOfBits) {
+ const UINT validMask = BitMask[numberOfBits];
+
+ if ((hBitStream->BitsInCache + numberOfBits) <= CACHE_BITS) {
+ hBitStream->BitsInCache += numberOfBits;
+ hBitStream->CacheWord =
+ (hBitStream->CacheWord << numberOfBits) | (value & validMask);
+ } else {
+ FDK_putBwd(&hBitStream->hBitBuf, hBitStream->CacheWord,
+ hBitStream->BitsInCache);
+ hBitStream->BitsInCache = numberOfBits;
+ hBitStream->CacheWord = (value & validMask);
}
- return numberOfBits;
+ return numberOfBits;
}
+/**
+ * \brief write an integer value using a varying number of bits from the
+ * bitstream
+ *
+ * q.v. ISO/IEC FDIS 23003-3 Table 16
+ *
+ * \param hBitStream HANDLE_FDK_BITSTREAM handle
+ * \param value the data to be written
+ * \param nBits1 number of bits to write for a small integer value or escape
+ * value
+ * \param nBits2 number of bits to write for a medium sized integer value or
+ * escape value
+ * \param nBits3 number of bits to write for a large integer value
+ * \return number of bits written
+ */
+FDK_INLINE UCHAR FDKwriteEscapedValue(HANDLE_FDK_BITSTREAM hBitStream,
+ UINT value, UINT nBits1, UINT nBits2,
+ UINT nBits3) {
+ UCHAR nbits = 0;
+ UINT tmp = (1 << nBits1) - 1;
+
+ if (value < tmp) {
+ nbits += FDKwriteBits(hBitStream, value, nBits1);
+ } else {
+ nbits += FDKwriteBits(hBitStream, tmp, nBits1);
+ value -= tmp;
+ tmp = (1 << nBits2) - 1;
+
+ if (value < tmp) {
+ nbits += FDKwriteBits(hBitStream, value, nBits2);
+ } else {
+ nbits += FDKwriteBits(hBitStream, tmp, nBits2);
+ value -= tmp;
+
+ nbits += FDKwriteBits(hBitStream, value, nBits3);
+ }
+ }
+
+ return nbits;
+}
/**
* \brief SyncCache Function. Clear cache after read forward.
@@ -383,152 +449,158 @@ FDK_INLINE UCHAR FDKwriteBitsBwd(HANDLE_FDK_BITSTREAM hBitStream, UINT value,
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return void
*/
-FDK_INLINE void FDKsyncCache (HANDLE_FDK_BITSTREAM hBitStream)
-{
+FDK_INLINE void FDKsyncCache(HANDLE_FDK_BITSTREAM hBitStream) {
if (hBitStream->ConfigCache == BS_READER)
- FDK_pushBack (&hBitStream->hBitBuf,hBitStream->BitsInCache,hBitStream->ConfigCache) ;
- else /* BS_WRITER */
- FDK_put(&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ;
-
- hBitStream->BitsInCache = 0 ;
- hBitStream->CacheWord = 0 ;
+ FDK_pushBack(&hBitStream->hBitBuf, hBitStream->BitsInCache,
+ hBitStream->ConfigCache);
+ else if (hBitStream->BitsInCache) /* BS_WRITER */
+ FDK_put(&hBitStream->hBitBuf, hBitStream->CacheWord,
+ hBitStream->BitsInCache);
+
+ hBitStream->BitsInCache = 0;
+ hBitStream->CacheWord = 0;
}
-
/**
* \brief SyncCache Function. Clear cache after read backwards.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return void
*/
-FDK_INLINE void FDKsyncCacheBwd (HANDLE_FDK_BITSTREAM hBitStream)
-{
+FDK_INLINE void FDKsyncCacheBwd(HANDLE_FDK_BITSTREAM hBitStream) {
if (hBitStream->ConfigCache == BS_READER) {
- FDK_pushForward (&hBitStream->hBitBuf,hBitStream->BitsInCache,hBitStream->ConfigCache) ;
- } else { /* BS_WRITER */
- FDK_putBwd (&hBitStream->hBitBuf, hBitStream->CacheWord, hBitStream->BitsInCache) ;
+ FDK_pushForward(&hBitStream->hBitBuf, hBitStream->BitsInCache,
+ hBitStream->ConfigCache);
+ } else { /* BS_WRITER */
+ FDK_putBwd(&hBitStream->hBitBuf, hBitStream->CacheWord,
+ hBitStream->BitsInCache);
}
- hBitStream->BitsInCache = 0 ;
- hBitStream->CacheWord = 0 ;
+ hBitStream->BitsInCache = 0;
+ hBitStream->CacheWord = 0;
}
-
/**
* \brief Byte Alignment Function.
- * This function performs the byte_alignment() syntactic function on the input stream,
- * i.e. some bits will be discarded/padded so that the next bits to be read/written will
- * be aligned on a byte boundary with respect to the bit position 0.
+ * This function performs the byte_alignment() syntactic function on the
+ * input stream, i.e. some bits will be discarded/padded so that the next bits
+ * to be read/written will be aligned on a byte boundary with respect to
+ * the bit position 0.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return void
*/
-FDK_INLINE void FDKbyteAlign (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache (hBitStream) ;
- FDK_byteAlign (&hBitStream->hBitBuf, (UCHAR)hBitStream->ConfigCache) ;
+FDK_INLINE void FDKbyteAlign(HANDLE_FDK_BITSTREAM hBitStream) {
+ FDKsyncCache(hBitStream);
+ FDK_byteAlign(&hBitStream->hBitBuf, (UCHAR)hBitStream->ConfigCache);
}
-
/**
* \brief Byte Alignment Function with anchor
- * This function performs the byte_alignment() syntactic function on the input stream,
- * i.e. some bits will be discarded so that the next bits to be read/written would be aligned
- * on a byte boundary with respect to the given alignment anchor.
+ * This function performs the byte_alignment() syntactic function on the
+ * input stream, i.e. some bits will be discarded so that the next bits to be
+ * read/written would be aligned on a byte boundary with respect to the
+ * given alignment anchor.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \param alignmentAnchor bit position to be considered as origin for byte alignment
+ * \param alignmentAnchor bit position to be considered as origin for byte
+ * alignment
* \return void
*/
-FDK_INLINE void FDKbyteAlign (HANDLE_FDK_BITSTREAM hBitStream, UINT alignmentAnchor)
-{
- FDKsyncCache (hBitStream) ;
+FDK_INLINE void FDKbyteAlign(HANDLE_FDK_BITSTREAM hBitStream,
+ UINT alignmentAnchor) {
+ FDKsyncCache(hBitStream);
if (hBitStream->ConfigCache == BS_READER) {
- FDK_pushForward (&hBitStream->hBitBuf,
- (8 - ((alignmentAnchor - FDK_getValidBits(&hBitStream->hBitBuf)) & 0x07)) & 0x07,
- hBitStream->ConfigCache) ;
- }
- else {
- FDK_put (&hBitStream->hBitBuf,
- 0,
- (8 - ((FDK_getValidBits(&hBitStream->hBitBuf)-alignmentAnchor) & 0x07)) & 0x07 );
+ FDK_pushForward(
+ &hBitStream->hBitBuf,
+ (UINT)((INT)8 - (((INT)alignmentAnchor -
+ (INT)FDK_getValidBits(&hBitStream->hBitBuf)) &
+ 0x07)) &
+ 0x07,
+ hBitStream->ConfigCache);
+ } else {
+ FDK_put(&hBitStream->hBitBuf, 0,
+ (8 - ((FDK_getValidBits(&hBitStream->hBitBuf) - alignmentAnchor) &
+ 0x07)) &
+ 0x07);
}
}
-
/**
* \brief Push Back(Cache) / For / BiDirectional Function.
- * PushBackCache function ungets a number of bits erroneously read/written by the last Get() call.
- * NB: The number of bits to be stuffed back into the stream may never exceed the
- * number of bits returned by the immediately preceding Get() call.
+ * PushBackCache function ungets a number of bits erroneously
+ * read/written by the last Get() call. NB: The number of bits to be stuffed
+ * back into the stream may never exceed the number of bits returned by
+ * the immediately preceding Get() call.
*
- * PushBack function ungets a number of bits (combines cache and bitbuffer indices)
- * PushFor function gets a number of bits (combines cache and bitbuffer indices)
- * PushBiDirectional gets/ungets number of bits as defined in PusBack/For function
- * NB: The sign of bits is not known, so the function checks direction and calls
- * appropriate function. (positive sign pushFor, negative sign pushBack )
+ * PushBack function ungets a number of bits (combines cache and bitbuffer
+ * indices) PushFor function gets a number of bits (combines cache and
+ * bitbuffer indices) PushBiDirectional gets/ungets number of bits as
+ * defined in PusBack/For function NB: The sign of bits is not known, so
+ * the function checks direction and calls appropriate function. (positive
+ * sign pushFor, negative sign pushBack )
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param numberOfBits The number of bits to be pushed back/for.
* \return void
*/
-FDK_INLINE void FDKpushBackCache (HANDLE_FDK_BITSTREAM hBitStream, const UINT numberOfBits)
-{
- FDK_ASSERT ((hBitStream->BitsInCache+numberOfBits)<=CACHE_BITS);
- hBitStream->BitsInCache += numberOfBits ;
+FDK_INLINE void FDKpushBackCache(HANDLE_FDK_BITSTREAM hBitStream,
+ const UINT numberOfBits) {
+ FDK_ASSERT((hBitStream->BitsInCache + numberOfBits) <= CACHE_BITS);
+ hBitStream->BitsInCache += numberOfBits;
}
-FDK_INLINE void FDKpushBack (HANDLE_FDK_BITSTREAM hBitStream, const UINT numberOfBits)
-{
- if ((hBitStream->BitsInCache+numberOfBits)<CACHE_BITS && (hBitStream->ConfigCache == BS_READER) ) {
- hBitStream->BitsInCache += numberOfBits ;
- FDKsyncCache(hBitStream) ; /* sync cache to avoid invalid cache */
- }
- else {
- FDKsyncCache(hBitStream) ;
- FDK_pushBack(&hBitStream->hBitBuf,numberOfBits,hBitStream->ConfigCache);
+FDK_INLINE void FDKpushBack(HANDLE_FDK_BITSTREAM hBitStream,
+ const UINT numberOfBits) {
+ if ((hBitStream->BitsInCache + numberOfBits) < CACHE_BITS &&
+ (hBitStream->ConfigCache == BS_READER)) {
+ hBitStream->BitsInCache += numberOfBits;
+ FDKsyncCache(hBitStream); /* sync cache to avoid invalid cache */
+ } else {
+ FDKsyncCache(hBitStream);
+ FDK_pushBack(&hBitStream->hBitBuf, numberOfBits, hBitStream->ConfigCache);
}
}
-FDK_INLINE void FDKpushFor (HANDLE_FDK_BITSTREAM hBitStream, const UINT numberOfBits)
-{
- if ( (hBitStream->BitsInCache>numberOfBits) && (hBitStream->ConfigCache == BS_READER) ) {
+FDK_INLINE void FDKpushFor(HANDLE_FDK_BITSTREAM hBitStream,
+ const UINT numberOfBits) {
+ if ((hBitStream->BitsInCache > numberOfBits) &&
+ (hBitStream->ConfigCache == BS_READER)) {
hBitStream->BitsInCache -= numberOfBits;
- }
- else {
- FDKsyncCache(hBitStream) ;
- FDK_pushForward(&hBitStream->hBitBuf,numberOfBits,hBitStream->ConfigCache);
+ } else {
+ FDKsyncCache(hBitStream);
+ FDK_pushForward(&hBitStream->hBitBuf, numberOfBits,
+ hBitStream->ConfigCache);
}
}
-FDK_INLINE void FDKpushBiDirectional (HANDLE_FDK_BITSTREAM hBitStream, const INT numberOfBits)
-{
- if(numberOfBits>=0) FDKpushFor(hBitStream, numberOfBits) ;
- else FDKpushBack(hBitStream, -numberOfBits) ;
+FDK_INLINE void FDKpushBiDirectional(HANDLE_FDK_BITSTREAM hBitStream,
+ const INT numberOfBits) {
+ if (numberOfBits >= 0)
+ FDKpushFor(hBitStream, numberOfBits);
+ else
+ FDKpushBack(hBitStream, -numberOfBits);
}
-
/**
- * \brief GetValidBits Function. Clear cache and return valid Bits from Bitbuffer.
+ * \brief GetValidBits Function. Clear cache and return valid Bits from
+ * Bitbuffer.
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return amount of valid bits that still can be read or were already written.
*
*/
-FDK_INLINE UINT FDKgetValidBits (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache(hBitStream) ;
- return FDK_getValidBits(&hBitStream->hBitBuf) ;
+FDK_INLINE UINT FDKgetValidBits(HANDLE_FDK_BITSTREAM hBitStream) {
+ FDKsyncCache(hBitStream);
+ return FDK_getValidBits(&hBitStream->hBitBuf);
}
-
/**
* \brief return amount of unused Bits from Bitbuffer.
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return amount of free bits that still can be written into the bitstream
*/
-FDK_INLINE INT FDKgetFreeBits (HANDLE_FDK_BITSTREAM hBitStream)
-{
- return FDK_getFreeBits (&hBitStream->hBitBuf) ;
+FDK_INLINE INT FDKgetFreeBits(HANDLE_FDK_BITSTREAM hBitStream) {
+ return FDK_getFreeBits(&hBitStream->hBitBuf);
}
/**
@@ -536,10 +608,9 @@ FDK_INLINE INT FDKgetFreeBits (HANDLE_FDK_BITSTREAM hBitStream)
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return void
*/
-FDK_INLINE void FDKresetBitCnt (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache (hBitStream) ;
- FDK_setBitCnt (&hBitStream->hBitBuf, 0) ;
+FDK_INLINE void FDKresetBitCnt(HANDLE_FDK_BITSTREAM hBitStream) {
+ FDKsyncCache(hBitStream);
+ FDK_setBitCnt(&hBitStream->hBitBuf, 0);
}
/**
@@ -548,10 +619,9 @@ FDK_INLINE void FDKresetBitCnt (HANDLE_FDK_BITSTREAM hBitStream)
* \param value new value to be assigned to the bit counter
* \return void
*/
-FDK_INLINE void FDKsetBitCnt (HANDLE_FDK_BITSTREAM hBitStream, UINT value)
-{
- FDKsyncCache (hBitStream) ;
- FDK_setBitCnt (&hBitStream->hBitBuf, value) ;
+FDK_INLINE void FDKsetBitCnt(HANDLE_FDK_BITSTREAM hBitStream, UINT value) {
+ FDKsyncCache(hBitStream);
+ FDK_setBitCnt(&hBitStream->hBitBuf, value);
}
/**
@@ -559,60 +629,60 @@ FDK_INLINE void FDKsetBitCnt (HANDLE_FDK_BITSTREAM hBitStream, UINT value)
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \return current bit counter value
*/
-FDK_INLINE INT FDKgetBitCnt (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache(hBitStream) ;
- return FDK_getBitCnt(&hBitStream->hBitBuf) ;
+FDK_INLINE INT FDKgetBitCnt(HANDLE_FDK_BITSTREAM hBitStream) {
+ FDKsyncCache(hBitStream);
+ return FDK_getBitCnt(&hBitStream->hBitBuf);
}
-
/**
* \brief Fill the BitBuffer with a number of input bytes from external source.
- * The bytesValid variable returns the number of ramaining valid bytes in extern inputBuffer.
+ * The bytesValid variable returns the number of ramaining valid bytes in
+ * extern inputBuffer.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param inputBuffer Pointer to input buffer with bitstream data.
* \param bufferSize Total size of inputBuffer array.
- * \param bytesValid Input: number of valid bytes in inputBuffer. Output: bytes still left unread in inputBuffer.
+ * \param bytesValid Input: number of valid bytes in inputBuffer. Output: bytes
+ * still left unread in inputBuffer.
* \return void
*/
-FDK_INLINE void FDKfeedBuffer (HANDLE_FDK_BITSTREAM hBitStream, const UCHAR inputBuffer [], const UINT bufferSize, UINT *bytesValid)
-{
- FDKsyncCache (hBitStream) ;
- FDK_Feed(&hBitStream->hBitBuf, (UCHAR*)inputBuffer, bufferSize, bytesValid ) ;
+FDK_INLINE void FDKfeedBuffer(HANDLE_FDK_BITSTREAM hBitStream,
+ const UCHAR inputBuffer[], const UINT bufferSize,
+ UINT *bytesValid) {
+ FDKsyncCache(hBitStream);
+ FDK_Feed(&hBitStream->hBitBuf, inputBuffer, bufferSize, bytesValid);
}
-
/**
- * \brief fill destination BitBuffer with a number of bytes from source BitBuffer. The
- * bytesValid variable returns the number of ramaining valid bytes in source BitBuffer.
+ * \brief fill destination BitBuffer with a number of bytes from source
+ * BitBuffer. The bytesValid variable returns the number of ramaining valid
+ * bytes in source BitBuffer.
*
* \param hBSDst HANDLE_FDK_BITSTREAM handle to write data into
* \param hBSSrc HANDLE_FDK_BITSTREAM handle to read data from
- * \param bytesValid Input: number of valid bytes in inputBuffer. Output: bytes still left unread in inputBuffer.
+ * \param bytesValid Input: number of valid bytes in inputBuffer. Output:
+ * bytes still left unread in inputBuffer.
* \return void
*/
-FDK_INLINE void FDKcopyBuffer (HANDLE_FDK_BITSTREAM hBSDst, HANDLE_FDK_BITSTREAM hBSSrc, UINT *bytesValid)
-{
- FDKsyncCache (hBSSrc) ;
- FDK_Copy (&hBSDst->hBitBuf, &hBSSrc->hBitBuf, bytesValid) ;
+FDK_INLINE void FDKcopyBuffer(HANDLE_FDK_BITSTREAM hBSDst,
+ HANDLE_FDK_BITSTREAM hBSSrc, UINT *bytesValid) {
+ FDKsyncCache(hBSSrc);
+ FDK_Copy(&hBSDst->hBitBuf, &hBSSrc->hBitBuf, bytesValid);
}
-
/**
- * \brief fill the outputBuffer with all valid bytes hold in BitBuffer. The WriteBytes
- * variable returns the number of written Bytes.
+ * \brief fill the outputBuffer with all valid bytes hold in BitBuffer. The
+ * WriteBytes variable returns the number of written Bytes.
*
* \param hBitStream HANDLE_FDK_BITSTREAM handle
* \param outputBuffer Pointer to output buffer.
* \param writeBytes Number of bytes write to output buffer.
* \return void
*/
-FDK_INLINE void FDKfetchBuffer(HANDLE_FDK_BITSTREAM hBitStream, UCHAR *outputBuffer, UINT *writeBytes)
-{
- FDKsyncCache (hBitStream) ;
+FDK_INLINE void FDKfetchBuffer(HANDLE_FDK_BITSTREAM hBitStream,
+ UCHAR *outputBuffer, UINT *writeBytes) {
+ FDKsyncCache(hBitStream);
FDK_Fetch(&hBitStream->hBitBuf, outputBuffer, writeBytes);
}
-
#endif
diff --git a/libFDK/include/FDK_core.h b/libFDK/include/FDK_core.h
index 10a6a8e..9543522 100644
--- a/libFDK/include/FDK_core.h
+++ b/libFDK/include/FDK_core.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s): Manuel Jander
+
Description: FDK tools versioning support
-******************************************************************************/
+*******************************************************************************/
#ifndef FDK_CORE_H
#define FDK_CORE_H
@@ -98,7 +110,8 @@ extern "C" {
#endif
/** @brief Get FDK_tools library information.
- * @return Return 0 on success and a negative errorcode on failure (see errorcodes.h).
+ * @return Return 0 on success and a negative errorcode on failure (see
+ * errorcodes.h).
*/
int FDK_toolsGetLibInfo(LIB_INFO *info);
diff --git a/libFDK/include/FDK_crc.h b/libFDK/include/FDK_crc.h
index b1fed88..17439ab 100644
--- a/libFDK/include/FDK_crc.h
+++ b/libFDK/include/FDK_crc.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,55 +90,53 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
-/******************************** MPEG Audio Encoder **************************
+ Author(s):
- Initial author:
- contents/description: CRC calculation
+ Description: CRC calculation
-******************************************************************************/
+*******************************************************************************/
#ifndef FDK_CRC_H
#define FDK_CRC_H
-
-
#include "FDK_bitstream.h"
-
-#define MAX_CRC_REGS 3 /*!< Maximal number of overlapping crc region in ADTS channel pair element is two.
- Select three independent regions preventively. */
+#define MAX_CRC_REGS \
+ 3 /*!< Maximal number of overlapping crc region in ADTS channel pair element \
+ is two. Select three independent regions preventively. */
/**
* This structure describes single crc region used for crc calculation.
*/
-typedef struct
-{
+typedef struct {
UCHAR isActive;
- INT maxBits;
- UINT bitBufCntBits;
- UINT validBits;
+ INT maxBits;
+ UINT bitBufCntBits;
+ UINT validBits;
} CCrcRegData;
/**
* CRC info structure.
*/
-typedef struct
-{
- CCrcRegData crcRegData[MAX_CRC_REGS]; /*!< Multiple crc region description. */
- const USHORT *pCrcLookup; /*!< Pointer to lookup table filled in FDK_crcInit(). */
+typedef struct {
+ CCrcRegData crcRegData[MAX_CRC_REGS]; /*!< Multiple crc region description. */
+ const USHORT*
+ pCrcLookup; /*!< Pointer to lookup table filled in FDK_crcInit(). */
- USHORT crcPoly; /*!< CRC generator polynom. */
- USHORT crcMask; /*!< CRC mask. */
- USHORT startValue; /*!< CRC start value. */
- UCHAR crcLen; /*!< CRC length. */
+ USHORT crcPoly; /*!< CRC generator polynom. */
+ USHORT crcMask; /*!< CRC mask. */
+ USHORT startValue; /*!< CRC start value. */
+ UCHAR crcLen; /*!< CRC length. */
- UINT regStart; /*!< Start region marker for synchronization. */
- UINT regStop; /*!< Stop region marker for synchronization. */
+ UINT regStart; /*!< Start region marker for synchronization. */
+ UINT regStop; /*!< Stop region marker for synchronization. */
- USHORT crcValue; /*!< Crc value to be calculated. */
+ USHORT crcValue; /*!< Crc value to be calculated. */
} FDK_CRCINFO;
@@ -136,25 +145,22 @@ typedef struct
*/
typedef FDK_CRCINFO* HANDLE_FDK_CRCINFO;
-
/**
* \brief Initialize CRC structure.
*
- * The function initializes existing crc info structure with denoted configuration.
+ * The function initializes existing crc info structure with denoted
+ * configuration.
*
- * \param hCrcInfo Pointer to an outlying allocated crc info structure.
+ * \param hCrcInfo Pointer to an outlying allocated crc info
+ * structure.
* \param crcPoly Configure crc polynom.
* \param crcStartValue Configure crc start value.
* \param crcLen Configure crc length.
*
* \return none
*/
-void FDKcrcInit(
- HANDLE_FDK_CRCINFO hCrcInfo,
- const UINT crcPoly,
- const UINT crcStartValue,
- const UINT crcLen
- );
+void FDKcrcInit(HANDLE_FDK_CRCINFO hCrcInfo, const UINT crcPoly,
+ const UINT crcStartValue, const UINT crcLen);
/**
* \brief Reset CRC info structure.
@@ -165,42 +171,37 @@ void FDKcrcInit(
*
* \return none
*/
-void FDKcrcReset(
- HANDLE_FDK_CRCINFO hCrcInfo
- );
-
+void FDKcrcReset(HANDLE_FDK_CRCINFO hCrcInfo);
/**
* \brief Start CRC region with maximum number of bits.
*
- * This function marks position in bitstream to be used as start point for crc calculation.
- * Bitstream range for crc calculation can be limited or kept dynamic depending on mBits parameter.
- * The crc region has to be terminated with FDKcrcEndReg() in each case.
+ * This function marks position in bitstream to be used as start point for crc
+ * calculation. Bitstream range for crc calculation can be limited or kept
+ * dynamic depending on mBits parameter. The crc region has to be terminated
+ * with FDKcrcEndReg() in each case.
*
* \param hCrcInfo Pointer to crc info stucture.
* \param hBs Pointer to current bit buffer structure.
* \param mBits Number of bits in crc region to be calculated.
- * - mBits > 0: Zero padding will be used for CRC calculation, if there
- * are less than mBits bits available.
+ * - mBits > 0: Zero padding will be used for CRC
+ * calculation, if there are less than mBits bits available.
* - mBits < 0: No zero padding is done.
- * - mBits = 0: The number of bits used in crc calculation is dynamically,
- * depending on bitstream position between FDKcrcStartReg() and
- * FDKcrcEndReg() call.
+ * - mBits = 0: The number of bits used in crc
+ * calculation is dynamically, depending on bitstream position between
+ * FDKcrcStartReg() and FDKcrcEndReg()
+ * call.
*
* \return ID for the created region, -1 in case of an error
*/
-INT FDKcrcStartReg(
- HANDLE_FDK_CRCINFO hCrcInfo,
- const HANDLE_FDK_BITSTREAM hBs,
- const INT mBits
- );
-
+INT FDKcrcStartReg(HANDLE_FDK_CRCINFO hCrcInfo, const HANDLE_FDK_BITSTREAM hBs,
+ const INT mBits);
/**
* \brief Ends CRC region.
*
- * This function terminates crc region specified with FDKcrcStartReg(). The number of bits in crc region depends
- * on mBits parameter of FDKcrcStartReg().
+ * This function terminates crc region specified with FDKcrcStartReg(). The
+ * number of bits in crc region depends on mBits parameter of FDKcrcStartReg().
* This function calculates and updates crc in info structure.
*
* \param hCrcInfo Pointer to crc info stucture.
@@ -209,12 +210,8 @@ INT FDKcrcStartReg(
*
* \return 0 on success
*/
-INT FDKcrcEndReg(
- HANDLE_FDK_CRCINFO hCrcInfo,
- const HANDLE_FDK_BITSTREAM hBs,
- const INT reg
- );
-
+INT FDKcrcEndReg(HANDLE_FDK_CRCINFO hCrcInfo, const HANDLE_FDK_BITSTREAM hBs,
+ const INT reg);
/**
* \brief This function returns crc value from info struct.
@@ -223,9 +220,6 @@ INT FDKcrcEndReg(
*
* \return CRC value masked with crc length.
*/
-USHORT FDKcrcGetCRC(
- const HANDLE_FDK_CRCINFO hCrcInfo
- );
-
+USHORT FDKcrcGetCRC(const HANDLE_FDK_CRCINFO hCrcInfo);
#endif /* FDK_CRC_H */
diff --git a/libFDK/include/FDK_decorrelate.h b/libFDK/include/FDK_decorrelate.h
new file mode 100644
index 0000000..733aaae
--- /dev/null
+++ b/libFDK/include/FDK_decorrelate.h
@@ -0,0 +1,314 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Markus Lohwasser
+
+ Description: FDK Tools Decorrelator
+
+*******************************************************************************/
+
+#ifndef FDK_DECORRELATE_H
+#define FDK_DECORRELATE_H
+
+#include "common_fix.h"
+
+#define FIXP_MPS FIXP_DBL
+
+#ifndef ARCH_PREFER_MULT_32x32
+#define FIXP_DECORR FIXP_SGL
+#define FX_DECORR2FX_DBL FX_SGL2FX_DBL
+#define FX_DECORR2FX_SGL
+#define FX_DBL2FX_DECORR FX_DBL2FX_SGL
+#define FX_SGL2FX_DECORR
+#define DECORR(a) (FX_DBL2FXCONST_SGL(a))
+#define FL2FXCONST_DECORR FL2FXCONST_SGL
+#else
+#define FIXP_DECORR FIXP_DBL
+#define FX_DECORR2FX_DBL
+#define FX_DECORR2FX_SGL FX_DBL2FX_SGL
+#define FX_DBL2FX_DECORR
+#define FX_SGL2FX_DECORR FX_SGL2FX_DBL
+#define DECORR(a) FIXP_DBL(a)
+#define FL2FXCONST_DECORR FL2FXCONST_DBL
+#endif
+
+/*--------------- enums -------------------------------*/
+
+/**
+ * Decorrelator types.
+ */
+typedef enum {
+ DECORR_MPS, /**< Decorrelator type used by MPS LP/HQ */
+ DECORR_PS, /**< Decorrelator type used by HEAACv2 and MPS LP */
+ DECORR_USAC, /**< Decorrelator type used by USAC */
+ DECORR_LD /**< Decorrelator type used by MPS Low Delay */
+} FDK_DECORR_TYPE;
+
+/**
+ * Ducker types.
+ */
+typedef enum {
+ DUCKER_AUTOMATIC, /**< FDKdecorrelateInit() chooses correct ducker type
+ depending on provided parameters. */
+ DUCKER_MPS, /**< Force ducker type to MPS. */
+ DUCKER_PS /**< Force ducker type to PS. */
+} FDK_DUCKER_TYPE;
+
+/**
+ * Reverb band types.
+ */
+typedef enum {
+ NOT_EXIST, /**< Mark reverb band as non-existing (number of bands = 0). */
+ DELAY, /**< Reverb bands just contains delay elements and no allpass filters.
+ */
+ COMMON_REAL, /**< Real filter coeffs, common filter coeffs within one reverb
+ band */
+ COMMON_CPLX, /**< Complex filter coeffs, common filter coeffs within one
+ reverb band */
+ INDEP_CPLX, /**< Complex filter coeffs, independent filter coeffs for each
+ hybrid band */
+ INDEP_CPLX_PS /**< PS optimized implementation of general INDEP_CPLX type */
+} REVBAND_FILT_TYPE;
+
+typedef struct DECORR_DEC *HANDLE_DECORR_DEC;
+
+typedef struct DUCKER_INSTANCE {
+ int hybridBands;
+ int parameterBands;
+ int partiallyComplex;
+ FDK_DUCKER_TYPE duckerType;
+
+ const UCHAR *qs_next;
+ const UCHAR *mapProcBands2HybBands;
+ const UCHAR *mapHybBands2ProcBands;
+ /* interleaved SmoothDirectNrg[] and SmoothReverbNrg[],
+ non-interleaved SmoothDirectNrg[] in case of parametric stereo */
+ FIXP_MPS SmoothDirRevNrg[2 * (28)];
+
+ /*
+ parametric stereo
+ */
+ FIXP_MPS peakDecay[(28)];
+ FIXP_MPS peakDiff[(28)];
+ FIXP_DBL maxValDirectData;
+ FIXP_DBL maxValReverbData;
+ SCHAR scaleDirectNrg;
+ SCHAR scaleReverbNrg;
+ SCHAR scaleSmoothDirRevNrg;
+ SCHAR headroomSmoothDirRevNrg;
+
+} DUCKER_INSTANCE;
+
+typedef struct DECORR_FILTER_INSTANCE {
+ FIXP_MPS *stateCplx;
+ FIXP_DBL *DelayBufferCplx;
+
+ const FIXP_DECORR *numeratorReal;
+ const FIXP_STP *coeffsPacked;
+ const FIXP_DECORR *denominatorReal;
+} DECORR_FILTER_INSTANCE;
+
+typedef struct DECORR_DEC {
+ INT L_stateBufferCplx;
+ FIXP_DBL *stateBufferCplx;
+ INT L_delayBufferCplx;
+ FIXP_DBL *delayBufferCplx;
+
+ const REVBAND_FILT_TYPE *REV_filtType;
+ const UCHAR *REV_bandOffset;
+ const UCHAR *REV_delay;
+ const SCHAR *REV_filterOrder;
+ INT reverbBandDelayBufferIndex[(4)];
+ UCHAR stateBufferOffset[(3)];
+
+ DECORR_FILTER_INSTANCE Filter[(71)];
+ DUCKER_INSTANCE ducker;
+
+ int numbins;
+ int partiallyComplex;
+} DECORR_DEC;
+
+/**
+ * \brief Create one instance of Decorrelator.
+ *
+ * \param hDecorrDec A pointer to a decorrelator instance which was
+ * allocated externally.
+ * \param bufferCplx Externally allocated buffer (allocate (2*( ( 825 )
+ * + ( 373 ) )) FIXP_DBL values).
+ * \param bufLen Length of bufferCplx. Must be >= (2*( ( 825 ) + (
+ * 373 ) )).
+ *
+ * \return 0 on success.
+ */
+INT FDKdecorrelateOpen(HANDLE_DECORR_DEC hDecorrDec, FIXP_DBL *bufferCplx,
+ const INT bufLen);
+
+/**
+ * \brief Initialize and configure Decorrelator instance.
+ *
+ * \param hDecorrDec A Decorrelator handle.
+ * \param nrHybBands Number of (hybrid) bands.
+ * \param decorrType Decorrelator type to use.
+ * \param duckerType Ducker type to use (in general use
+ * DUCKER_AUTOMATIC).
+ * \param decorrConfig Depending on decorrType values of 0,1,2 are
+ * allowed.
+ * \param seed Seed of decorrelator instance. Allowed maximum
+ * valued depends on decorrType.
+ * \param partiallyComplex Low power or high quality processing 0: HQ, 1: LQ
+ * (only allowed for DECORR_MPS | DECORR_PS).
+ * \param useFractDelay Indicate usage of fractional delay 0: off, 1: on
+ * (currently not supported).
+ * \param isLegacyPS Indicate if DECORR_PS is used for HEAACv2 (for all
+ * other cases: isLegacyPS = 0). The purpose of this parameter is to select the
+ * correct number of param bands for the ducker.
+ * \param initStatesFlag Indicates whether the states buffer has to be
+ * cleared.
+ *
+ * \return 0 on success.
+ */
+INT FDKdecorrelateInit(HANDLE_DECORR_DEC hDecorrDec, const INT nrHybBands,
+ const FDK_DECORR_TYPE decorrType,
+ const FDK_DUCKER_TYPE duckerType, const INT decorrConfig,
+ const INT seed, const INT partiallyComplex,
+ const INT useFractDelay, const INT isLegacyPS,
+ const INT initStatesFlag);
+
+/**
+ * \brief Apply Decorrelator on input data.
+ *
+ * Function applies decorrelator and ducker inplace on hybrid input data.
+ * Modified hybrid data will be returned inplace.
+ *
+ * \param hDecorrDec A decorrelator handle.
+ * \param dataRealIn In (hybrid) data.
+ * \param dataImagIn In (hybrid) data.
+ * \param dataRealOut Out (hybrid) data (can be same as dataRealIn for
+ * in-place calculation).
+ * \param dataImagOut Out (hybrid) data (can be same as dataImagIn for
+ * in-place calculation).
+ * \param startHybBand Hybrid band to start with decorrelation.
+ *
+ * \return 0 on success.
+ */
+INT FDKdecorrelateApply(HANDLE_DECORR_DEC hDecorrDec, FIXP_DBL *dataRealIn,
+ FIXP_DBL *dataImagIn, FIXP_DBL *dataRealOut,
+ FIXP_DBL *dataImagOut, const INT startHybBand);
+
+/**
+ * \brief Destroy a Decorrelator instance.
+ *
+ * Deallocate whole memory of decorraltor and inside ducker.
+ *
+ * \param hDecorrDec Pointer to a decoderrolator handle. Null initialized on
+ * return.
+ *
+ * \return 0 on success.
+ */
+INT FDKdecorrelateClose(HANDLE_DECORR_DEC hDecorrDec);
+
+/**
+ * \brief Get max value address of direct signal.
+ *
+ * Get max value address of direct signal needed for ducker energy calculation.
+ *
+ * \param hDecorrDec Pointer to a decoderrolator handle.
+ *
+ * \return address of max value
+ */
+FIXP_DBL *getAddrDirectSignalMaxVal(HANDLE_DECORR_DEC hDecorrDec);
+
+#endif /* FDK_DECORRELATE_H */
diff --git a/libFDK/include/FDK_hybrid.h b/libFDK/include/FDK_hybrid.h
index 63f2d70..583f299 100644
--- a/libFDK/include/FDK_hybrid.h
+++ b/libFDK/include/FDK_hybrid.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,19 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
+----------------------------------------------------------------------------- */
- Author(s): Markus Lohwasser
- Description: FDK Tools Hybrid Filterbank
+/******************* Library for basic calculation routines ********************
-******************************************************************************/
+ Author(s): Markus Lohwasser
-#ifndef __FDK_HYBRID_H
-#define __FDK_HYBRID_H
+ Description: FDK Tools Hybrid Filterbank
+*******************************************************************************/
+#ifndef FDK_HYBRID_H
+#define FDK_HYBRID_H
#include "common_fix.h"
@@ -101,57 +111,53 @@ amm-info@iis.fraunhofer.de
* Hybrid Filterband modes.
*/
typedef enum {
- THREE_TO_TEN,
- THREE_TO_TWELVE,
- THREE_TO_SIXTEEN
+ THREE_TO_TEN,
+ THREE_TO_TWELVE,
+ THREE_TO_SIXTEEN
} FDK_HYBRID_MODE;
-
/*--------------- structure definitions ---------------*/
-typedef struct FDK_HYBRID_SETUP *HANDLE_FDK_HYBRID_SETUP;
+typedef const struct FDK_HYBRID_SETUP *HANDLE_FDK_HYBRID_SETUP;
-typedef struct
-{
- FIXP_DBL *bufferLFReal[3]; /*!< LF real filter states. */
- FIXP_DBL *bufferLFImag[3]; /*!< LF imag filter states. */
- FIXP_DBL *bufferHFReal[13]; /*!< HF real delay lines. */
- FIXP_DBL *bufferHFImag[13]; /*!< HF imag delay lines. */
+typedef struct {
+ FIXP_DBL *bufferLFReal[3]; /*!< LF real filter states. */
+ FIXP_DBL *bufferLFImag[3]; /*!< LF imag filter states. */
+ FIXP_DBL *bufferHFReal[13]; /*!< HF real delay lines. */
+ FIXP_DBL *bufferHFImag[13]; /*!< HF imag delay lines. */
- INT bufferLFpos; /*!< Position to write incoming data into ringbuffer. */
- INT bufferHFpos; /*!< Delay line positioning. */
- INT nrBands; /*!< Number of QMF bands. */
- INT cplxBands; /*!< Number of complex QMF bands.*/
- UCHAR hfMode; /*!< Flag signalizes treatment of HF bands. */
+ INT bufferLFpos; /*!< Position to write incoming data into ringbuffer. */
+ INT bufferHFpos; /*!< Delay line positioning. */
+ INT nrBands; /*!< Number of QMF bands. */
+ INT cplxBands; /*!< Number of complex QMF bands.*/
+ UCHAR hfMode; /*!< Flag signalizes treatment of HF bands. */
- FIXP_DBL *pLFmemory; /*!< Pointer to LF states buffer. */
- FIXP_DBL *pHFmemory; /*!< Pointer to HF states buffer. */
+ FIXP_DBL *pLFmemory; /*!< Pointer to LF states buffer. */
+ FIXP_DBL *pHFmemory; /*!< Pointer to HF states buffer. */
- UINT LFmemorySize; /*!< Size of LF states buffer. */
- UINT HFmemorySize; /*!< Size of HF states buffer. */
+ UINT LFmemorySize; /*!< Size of LF states buffer. */
+ UINT HFmemorySize; /*!< Size of HF states buffer. */
- HANDLE_FDK_HYBRID_SETUP pSetup; /*!< Pointer to filter setup. */
+ HANDLE_FDK_HYBRID_SETUP pSetup; /*!< Pointer to filter setup. */
} FDK_ANA_HYB_FILTER;
+typedef struct {
+ INT nrBands; /*!< Number of QMF bands. */
+ INT cplxBands; /*!< Number of complex QMF bands.*/
-typedef struct
-{
- INT nrBands; /*!< Number of QMF bands. */
- INT cplxBands; /*!< Number of complex QMF bands.*/
-
- HANDLE_FDK_HYBRID_SETUP pSetup; /*!< Pointer to filter setup. */
+ HANDLE_FDK_HYBRID_SETUP pSetup; /*!< Pointer to filter setup. */
} FDK_SYN_HYB_FILTER;
typedef FDK_ANA_HYB_FILTER *HANDLE_FDK_ANA_HYB_FILTER;
typedef FDK_SYN_HYB_FILTER *HANDLE_FDK_SYN_HYB_FILTER;
-
/**
* \brief Create one instance of Hybrid Analyis Filterbank.
*
- * \param hAnalysisHybFilter Pointer to an outlying allocated Hybrid Analysis Filterbank structure.
+ * \param hAnalysisHybFilter Pointer to an outlying allocated Hybrid Analysis
+ * Filterbank structure.
* \param pLFmemory Pointer to outlying buffer used LF filtering.
* \param LFmemorySize Size of pLFmemory in bytes.
* \param pHFmemory Pointer to outlying buffer used HF delay line.
@@ -159,48 +165,36 @@ typedef FDK_SYN_HYB_FILTER *HANDLE_FDK_SYN_HYB_FILTER;
*
* \return 0 on success.
*/
-INT FDKhybridAnalysisOpen(
- HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
- FIXP_DBL *const pLFmemory,
- const UINT LFmemorySize,
- FIXP_DBL *const pHFmemory,
- const UINT HFmemorySize
- );
-
+INT FDKhybridAnalysisOpen(HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
+ FIXP_DBL *const pLFmemory, const UINT LFmemorySize,
+ FIXP_DBL *const pHFmemory, const UINT HFmemorySize);
/**
- * \brief Initialize and configure Hybrdid Analysis Filterbank instance.
+ * \brief Initialize and configure Hybrid Analysis Filterbank instance.
*
* \param hAnalysisHybFilter A Hybrid Analysis Filterbank handle.
* \param mode Select hybrid filter configuration.
* \param qmfBands Number of qmf bands to be processed.
* \param cplxBands Number of complex qmf bands to be processed.
- * \param initStatesFlag Indicates whether the states buffer has to be cleared.
+ * \param initStatesFlag Indicates whether the states buffer has to be
+ * cleared.
*
* \return 0 on success.
*/
-INT FDKhybridAnalysisInit(
- HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
- const FDK_HYBRID_MODE mode,
- const INT qmfBands,
- const INT cplxBands,
- const INT initStatesFlag
- );
-
+INT FDKhybridAnalysisInit(HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
+ const FDK_HYBRID_MODE mode, const INT qmfBands,
+ const INT cplxBands, const INT initStatesFlag);
/**
- * \brief Adjust Hybrdid Analysis Filterbank states.
+ * \brief Adjust Hybrid Analysis Filterbank states.
*
* \param hAnalysisHybFilter A Hybrid Analysis Filterbank handle.
* \param scalingValue Scaling value to be applied on filter states.
*
* \return 0 on success.
*/
-INT FDKhybridAnalysisScaleStates(
- HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
- const INT scalingValue
- );
-
+INT FDKhybridAnalysisScaleStates(HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
+ const INT scalingValue);
/**
* \brief Apply Hybrid Analysis Filterbank on Qmf input data.
@@ -213,14 +207,11 @@ INT FDKhybridAnalysisScaleStates(
*
* \return 0 on success.
*/
-INT FDKhybridAnalysisApply(
- HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
- const FIXP_DBL *const pQmfReal,
- const FIXP_DBL *const pQmfImag,
- FIXP_DBL *const pHybridReal,
- FIXP_DBL *const pHybridImag
- );
-
+INT FDKhybridAnalysisApply(HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter,
+ const FIXP_DBL *const pQmfReal,
+ const FIXP_DBL *const pQmfImag,
+ FIXP_DBL *const pHybridReal,
+ FIXP_DBL *const pHybridImag);
/**
* \brief Close a Hybrid Analysis Filterbank instance.
@@ -229,9 +220,7 @@ INT FDKhybridAnalysisApply(
*
* \return 0 on success.
*/
-INT FDKhybridAnalysisClose(
- HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter
- );
+INT FDKhybridAnalysisClose(HANDLE_FDK_ANA_HYB_FILTER hAnalysisHybFilter);
/**
* \brief Initialize and configure Hybrdid Synthesis Filterbank instance.
@@ -243,12 +232,9 @@ INT FDKhybridAnalysisClose(
*
* \return 0 on success.
*/
-INT FDKhybridSynthesisInit(
- HANDLE_FDK_SYN_HYB_FILTER hSynthesisHybFilter,
- const FDK_HYBRID_MODE mode,
- const INT qmfBands,
- const INT cplxBands
- );
+INT FDKhybridSynthesisInit(HANDLE_FDK_SYN_HYB_FILTER hSynthesisHybFilter,
+ const FDK_HYBRID_MODE mode, const INT qmfBands,
+ const INT cplxBands);
/**
* \brief Apply Hybrid Analysis Filterbank on Hybrid data.
@@ -259,15 +245,11 @@ INT FDKhybridSynthesisInit(
* \param pQmfReal Qmf output data.
* \param pQmfImag Qmf output data.
*
- * \return 0 on success.
*/
-INT FDKhybridSynthesisApply(
- HANDLE_FDK_SYN_HYB_FILTER hSynthesisHybFilter,
- const FIXP_DBL *const pHybridReal,
- const FIXP_DBL *const pHybridImag,
- FIXP_DBL *const pQmfReal,
- FIXP_DBL *const pQmfImag
- );
-
+void FDKhybridSynthesisApply(HANDLE_FDK_SYN_HYB_FILTER hSynthesisHybFilter,
+ const FIXP_DBL *const pHybridReal,
+ const FIXP_DBL *const pHybridImag,
+ FIXP_DBL *const pQmfReal,
+ FIXP_DBL *const pQmfImag);
-#endif /* __FDK_HYBRID_H */
+#endif /* FDK_HYBRID_H */
diff --git a/libFDK/include/FDK_lpc.h b/libFDK/include/FDK_lpc.h
new file mode 100644
index 0000000..851dd1f
--- /dev/null
+++ b/libFDK/include/FDK_lpc.h
@@ -0,0 +1,218 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Manuel Jander
+
+ Description: LPC related functions
+
+*******************************************************************************/
+
+#ifndef FDK_LPC_H
+#define FDK_LPC_H
+
+#include "common_fix.h"
+
+#define LPC_MAX_ORDER 24
+
+/*
+ * Experimental solution for lattice filter substitution.
+ * LPC_SYNTHESIS_IIR macro must be activated in aacdec_tns.cpp.
+ * When LPC_SYNTHESIS_IIR enabled, there will be a substitution of the default
+ * lpc synthesis lattice filter by an IIR synthesis filter (with a conversionof
+ * the filter coefs). LPC_TNS related macros are intended to implement the data
+ * types used by the CLpc_Synthesis variant which is used for this solution.
+ * */
+
+/* #define LPC_TNS_LOWER_PRECISION */
+
+typedef FIXP_DBL FIXP_LPC_TNS;
+#define FX_DBL2FX_LPC_TNS(x) (x)
+#define FX_DBL2FXCONST_LPC_TNS(x) (x)
+#define FX_LPC_TNS2FX_DBL(x) (x)
+#define FL2FXCONST_LPC_TNS(val) FL2FXCONST_DBL(val)
+#define MAXVAL_LPC_TNS MAXVAL_DBL
+
+typedef FIXP_SGL FIXP_LPC;
+#define FX_DBL2FX_LPC(x) FX_DBL2FX_SGL((FIXP_DBL)(x))
+#define FX_DBL2FXCONST_LPC(x) FX_DBL2FXCONST_SGL(x)
+#define FX_LPC2FX_DBL(x) FX_SGL2FX_DBL(x)
+#define FL2FXCONST_LPC(val) FL2FXCONST_SGL(val)
+#define MAXVAL_LPC MAXVAL_SGL
+
+/**
+ * \brief Obtain residual signal through LPC analysis.
+ * \param signal pointer to buffer holding signal to be analysed. Residual is
+ * returned there (in place)
+ * \param signal_size the size of the input data in pData
+ * \param lpcCoeff_m the LPC filter coefficient mantissas
+ * \param lpcCoeff_e the LPC filter coefficient exponent
+ * \param order the LPC filter order (size of coeff)
+ * \param filtState Pointer to state buffer of size order
+ * \param filtStateIndex pointer to state index storage
+ */
+void CLpc_Analysis(FIXP_DBL signal[], const int signal_size,
+ const FIXP_LPC lpcCoeff_m[], const int lpcCoeff_e,
+ const int order, FIXP_DBL *filtState, int *filtStateIndex);
+
+/**
+ * \brief Synthesize signal fom residual through LPC synthesis, using LP
+ * coefficients.
+ * \param signal pointer to buffer holding the residual signal. The synthesis is
+ * returned there (in place)
+ * \param signal_size the size of the input data in pData
+ * \param inc buffer traversal increment for signal
+ * \param coeff the LPC filter coefficients
+ * \param coeff_e exponent of coeff
+ * \param order the LPC filter order (size of coeff)
+ * \param state state buffer of size LPC_MAX_ORDER
+ * \param pStateIndex pointer to state index storage
+ */
+void CLpc_Synthesis(FIXP_DBL *signal, const int signal_size, const int signal_e,
+ const int inc, const FIXP_LPC_TNS *lpcCoeff_m,
+ const int lpcCoeff_e, const int order, FIXP_DBL *state,
+ int *pStateIndex);
+void CLpc_Synthesis(FIXP_DBL *signal, const int signal_size, const int signal_e,
+ const int inc, const FIXP_LPC coeff[], const int coeff_e,
+ const int order, FIXP_DBL *filtState, int *pStateIndex);
+
+/**
+ * \brief Synthesize signal fom residual through LPC synthesis, using ParCor
+ * coefficients. The algorithm assumes a filter gain of max 1.0. If the filter
+ * gain is higher, this must be accounted into the values of signal_e
+ * and/or signal_e_out to avoid overflows.
+ * \param signal pointer to buffer holding the residual signal. The synthesis is
+ * returned there (in place)
+ * \param signal_size the size of the input data in pData
+ * \param inc buffer traversal increment for signal
+ * \param coeff the LPC filter coefficients
+ * \param coeff_e exponent of coeff
+ * \param order the LPC filter order (size of coeff)
+ * \param state state buffer of size LPC_MAX_ORDER
+ */
+void CLpc_SynthesisLattice(FIXP_DBL *signal, const int signal_size,
+ const int signal_e, const int signal_e_out,
+ const int inc, const FIXP_SGL *coeff,
+ const int order, FIXP_DBL *state);
+
+void CLpc_SynthesisLattice(FIXP_DBL *RESTRICT signal, const int signal_size,
+ const int signal_e, const int signal_e_out,
+ const int inc, const FIXP_DBL *RESTRICT coeff,
+ const int order, FIXP_DBL *RESTRICT state);
+
+/**
+ * \brief
+ */
+INT CLpc_ParcorToLpc(const FIXP_LPC_TNS reflCoeff[], FIXP_LPC_TNS LpcCoeff[],
+ INT numOfCoeff, FIXP_DBL workBuffer[]);
+INT CLpc_ParcorToLpc(const FIXP_LPC reflCoeff[], FIXP_LPC LpcCoeff[],
+ const int numOfCoeff, FIXP_DBL workBuffer[]);
+
+/**
+ * \brief Calculate ParCor (Partial autoCorrelation, reflection) coefficients
+ * from autocorrelation coefficients using the Schur algorithm (instead of
+ * Levinson Durbin).
+ * \param acorr order+1 autocorrelation coefficients
+ * \param reflCoeff output reflection /ParCor coefficients. The first
+ * coefficient which is always 1.0 is ommitted.
+ * \param order number of acorr / reflCoeff coefficients.
+ * \param pPredictionGain_m prediction gain mantissa
+ * \param pPredictionGain_e prediction gain exponent
+ */
+void CLpc_AutoToParcor(FIXP_DBL acorr[], const int acorr_e,
+ FIXP_LPC reflCoeff[], const int order,
+ FIXP_DBL *pPredictionGain_m, INT *pPredictionGain_e);
+
+#endif /* FDK_LPC_H */
diff --git a/libFDK/include/FDK_matrixCalloc.h b/libFDK/include/FDK_matrixCalloc.h
new file mode 100644
index 0000000..ffb54fe
--- /dev/null
+++ b/libFDK/include/FDK_matrixCalloc.h
@@ -0,0 +1,230 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description: matrix memory allocation
+
+*******************************************************************************/
+
+#ifndef FDK_MATRIXCALLOC_H
+#define FDK_MATRIXCALLOC_H
+
+#include "machine_type.h"
+#include "genericStds.h"
+
+/* It is recommended to use FDK_ALLOCATE_MEMORY_1D instead of fdkCallocMatrix1D
+ */
+void* fdkCallocMatrix1D(UINT dim1, UINT size);
+void* fdkCallocMatrix1D_aligned(UINT dim1, UINT size);
+/* It is recommended to use FDK_ALLOCATE_MEMORY_1D_INT instead of
+ * fdkCallocMatrix1D_int */
+void* fdkCallocMatrix1D_int(UINT dim1, UINT size, MEMORY_SECTION s);
+void* fdkCallocMatrix1D_int_aligned(UINT dim1, UINT size, MEMORY_SECTION s);
+/* It is recommended to use FDK_FREE_MEMORY_1D instead of fdkFreeMatrix1D */
+void fdkFreeMatrix1D(void* p);
+void fdkFreeMatrix1D_aligned(void* p);
+
+/* It is recommended to use FDK_ALLOCATE_MEMORY_2D instead of fdkCallocMatrix2D
+ */
+void** fdkCallocMatrix2D(UINT dim1, UINT dim2, UINT size);
+void** fdkCallocMatrix2D_aligned(UINT dim1, UINT dim2, UINT size);
+/* It is recommended to use FDK_ALLOCATE_MEMORY_2D_INT instead of
+ * fdkCallocMatrix2D_int */
+void** fdkCallocMatrix2D_int(UINT dim1, UINT dim2, UINT size, MEMORY_SECTION s);
+/* It is recommended to use FDK_ALLOCATE_MEMORY_2D_INT_ALIGNED instead of
+ * fdkCallocMatrix2D_int_aligned */
+void** fdkCallocMatrix2D_int_aligned(UINT dim1, UINT dim2, UINT size,
+ MEMORY_SECTION s);
+/* It is recommended to use FDK_FREE_MEMORY_2D instead of fdkFreeMatrix2D */
+void fdkFreeMatrix2D(void** p);
+/* It is recommended to use FDK_FREE_MEMORY_2D_ALIGNED instead of
+ * fdkFreeMatrix2D_aligned */
+void fdkFreeMatrix2D_aligned(void** p);
+
+/* It is recommended to use FDK_ALLOCATE_MEMORY_3D instead of fdkCallocMatrix3D
+ */
+void*** fdkCallocMatrix3D(UINT dim1, UINT dim2, UINT dim3, UINT size);
+/* It is recommended to use FDK_ALLOCATE_MEMORY_3D_INT instead of
+ * fdkCallocMatrix3D_int */
+void*** fdkCallocMatrix3D_int(UINT dim1, UINT dim2, UINT dim3, UINT size,
+ MEMORY_SECTION s);
+/* It is recommended to use FDK_FREE_MEMORY_3D instead of fdkFreeMatrix3D */
+void fdkFreeMatrix3D(void*** p);
+
+#define FDK_ALLOCATE_MEMORY_1D(a, dim1, type) \
+ if (((a) = (type*)fdkCallocMatrix1D((dim1), sizeof(type))) == NULL) { \
+ goto bail; \
+ }
+
+#define FDK_ALLOCATE_MEMORY_1D_ALIGNED(a, dim1, type) \
+ if (((a) = (type*)fdkCallocMatrix1D_aligned((dim1), sizeof(type))) == \
+ NULL) { \
+ goto bail; \
+ }
+
+#define FDK_ALLOCATE_MEMORY_1D_P(a, dim1, type, ptype) \
+ if (((a) = (ptype)fdkCallocMatrix1D((dim1), sizeof(type))) == NULL) { \
+ goto bail; \
+ }
+
+#define FDK_ALLOCATE_MEMORY_1D_INT(a, dim1, type, s) \
+ if (((a) = (type*)fdkCallocMatrix1D_int((dim1), sizeof(type), (s))) == \
+ NULL) { \
+ goto bail; \
+ }
+
+#define FDK_FREE_MEMORY_1D(a) \
+ do { \
+ fdkFreeMatrix1D((void*)(a)); \
+ (a) = NULL; \
+ } while (0)
+
+#define FDK_FREE_MEMORY_1D_ALIGNED(a) \
+ do { \
+ fdkFreeMatrix1D_aligned((void*)(a)); \
+ (a) = NULL; \
+ } while (0)
+
+#define FDK_ALLOCATE_MEMORY_2D(a, dim1, dim2, type) \
+ if (((a) = (type**)fdkCallocMatrix2D((dim1), (dim2), sizeof(type))) == \
+ NULL) { \
+ goto bail; \
+ }
+
+#define FDK_ALLOCATE_MEMORY_2D_INT(a, dim1, dim2, type, s) \
+ if (((a) = (type**)fdkCallocMatrix2D_int((dim1), (dim2), sizeof(type), \
+ (s))) == NULL) { \
+ goto bail; \
+ }
+
+#define FDK_ALLOCATE_MEMORY_2D_INT_ALIGNED(a, dim1, dim2, type, s) \
+ if (((a) = (type**)fdkCallocMatrix2D_int_aligned( \
+ (dim1), (dim2), sizeof(type), (s))) == NULL) { \
+ goto bail; \
+ }
+
+#define FDK_FREE_MEMORY_2D(a) \
+ do { \
+ fdkFreeMatrix2D((void**)(a)); \
+ (a) = NULL; \
+ } while (0)
+
+#define FDK_FREE_MEMORY_2D_ALIGNED(a) \
+ do { \
+ fdkFreeMatrix2D_aligned((void**)(a)); \
+ (a) = NULL; \
+ } while (0)
+
+#define FDK_ALLOCATE_MEMORY_3D(a, dim1, dim2, dim3, type) \
+ if (((a) = (type***)fdkCallocMatrix3D((dim1), (dim2), (dim3), \
+ sizeof(type))) == NULL) { \
+ goto bail; \
+ }
+
+#define FDK_ALLOCATE_MEMORY_3D_INT(a, dim1, dim2, dim3, type, s) \
+ if (((a) = (type***)fdkCallocMatrix3D_int((dim1), (dim2), (dim3), \
+ sizeof(type), (s))) == NULL) { \
+ goto bail; \
+ }
+
+#define FDK_FREE_MEMORY_3D(a) \
+ do { \
+ fdkFreeMatrix3D((void***)(a)); \
+ (a) = NULL; \
+ } while (0)
+
+#endif /* FDK_MATRIXCALLOC_H */
diff --git a/libFDK/include/FDK_qmf_domain.h b/libFDK/include/FDK_qmf_domain.h
new file mode 100644
index 0000000..5c12682
--- /dev/null
+++ b/libFDK/include/FDK_qmf_domain.h
@@ -0,0 +1,416 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Matthias Hildenbrand
+
+ Description: Module to efficiently handle QMF data for multiple channels and
+ to share the data between e.g. SBR and MPS
+
+*******************************************************************************/
+
+#ifndef FDK_QMF_DOMAIN_H
+#define FDK_QMF_DOMAIN_H
+
+#include "qmf.h"
+
+typedef enum {
+ QMF_DOMAIN_OK = 0x0, /*!< No error occurred. */
+ QMF_DOMAIN_OUT_OF_MEMORY =
+ 0x1, /*!< QMF-Configuration demands for more memory than allocated on
+ heap. */
+ QMF_DOMAIN_INIT_ERROR =
+ 0x2, /*!< An error during filterbank-setup occurred. */
+ QMF_DOMAIN_RESAMPLER_INIT_ERROR =
+ 0x3 /*!< An error during QMF-resampler-setup occurred. */
+} QMF_DOMAIN_ERROR;
+
+#define CMPLX_MOD (2)
+
+#define QMF_MAX_WB_SECTIONS (5) /* maximum number of workbuffer sections */
+#define QMF_WB_SECTION_SIZE (1024 * 2)
+
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore1, FIXP_DBL)
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore2, FIXP_DBL)
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore3, FIXP_DBL)
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore4, FIXP_DBL)
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore5, FIXP_DBL)
+H_ALLOC_MEM_OVERLAY(QmfWorkBufferCore6, FIXP_DBL)
+
+#define QMF_DOMAIN_MAX_ANALYSIS_QMF_BANDS (64)
+#define QMF_DOMAIN_MAX_SYNTHESIS_QMF_BANDS (QMF_MAX_SYNTHESIS_BANDS)
+#define QMF_DOMAIN_MAX_QMF_PROC_BANDS (64)
+#define QMF_DOMAIN_MAX_TIMESLOTS (64)
+#define QMF_DOMAIN_MAX_OV_TIMESLOTS (12)
+
+#define QMF_DOMAIN_ANALYSIS_QMF_BANDS_16 (16)
+#define QMF_DOMAIN_ANALYSIS_QMF_BANDS_24 (24)
+#define QMF_DOMAIN_ANALYSIS_QMF_BANDS_32 (32)
+
+#define QMF_DOMAIN_TIMESLOTS_16 (16)
+#define QMF_DOMAIN_TIMESLOTS_32 (32)
+
+#define QMF_DOMAIN_OV_TIMESLOTS_16 (3)
+#define QMF_DOMAIN_OV_TIMESLOTS_32 (6)
+
+H_ALLOC_MEM(AnaQmfStates, FIXP_QAS)
+H_ALLOC_MEM(SynQmfStates, FIXP_QSS)
+H_ALLOC_MEM(QmfSlotsReal, FIXP_DBL *)
+H_ALLOC_MEM(QmfSlotsImag, FIXP_DBL *)
+H_ALLOC_MEM(QmfOverlapBuffer, FIXP_DBL)
+
+H_ALLOC_MEM(AnaQmfStates16, FIXP_QAS)
+H_ALLOC_MEM(AnaQmfStates24, FIXP_QAS)
+H_ALLOC_MEM(AnaQmfStates32, FIXP_QAS)
+H_ALLOC_MEM(QmfSlotsReal16, FIXP_DBL *)
+H_ALLOC_MEM(QmfSlotsReal32, FIXP_DBL *)
+H_ALLOC_MEM(QmfSlotsImag16, FIXP_DBL *)
+H_ALLOC_MEM(QmfSlotsImag32, FIXP_DBL *)
+H_ALLOC_MEM(QmfOverlapBuffer16, FIXP_DBL)
+H_ALLOC_MEM(QmfOverlapBuffer32, FIXP_DBL)
+
+#define QDOM_PCM INT_PCM
+
+/**
+ * Structure to hold the configuration data which is global whithin a QMF domain
+ * instance.
+ */
+typedef struct {
+ UCHAR qmfDomainExplicitConfig; /*!< Flag to signal that QMF domain is set
+ explicitly instead of SBR and MPS init
+ routines. */
+ UCHAR nInputChannels; /*!< Number of QMF input channels. */
+ UCHAR nInputChannels_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR nOutputChannels; /*!< Number of QMF output channels. */
+ UCHAR nOutputChannels_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR
+ parkChannel; /*!< signal to automatically allocate additional memory to
+ park a channel if only one processing channel is
+ available. */
+ UCHAR parkChannel_requested;
+ QDOM_PCM
+ *TDinput; /*!< Pointer to time domain data used as input for the QMF
+ analysis. */
+ FIXP_DBL *
+ pWorkBuffer[QMF_MAX_WB_SECTIONS]; /*!< Pointerarray to volatile memory. */
+ UINT flags; /*!< Flags to be set on all QMF analysis/synthesis filter
+ instances. */
+ UINT flags_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR nBandsAnalysis; /*!< Number of QMF analysis bands for all input
+ channels. */
+ UCHAR nBandsAnalysis_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ USHORT nBandsSynthesis; /*!< Number of QMF synthesis bands for all output
+ channels. */
+ USHORT
+ nBandsSynthesis_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR nQmfTimeSlots; /*!< Number of QMF time slots (stored in work buffer
+ memory). */
+ UCHAR nQmfTimeSlots_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR
+ nQmfOvTimeSlots; /*!< Number of QMF overlap/delay time slots (stored in
+ persistent memory). */
+ UCHAR nQmfOvTimeSlots_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR nQmfProcBands; /*!< Number of QMF bands which are processed by the
+ decoder. Typically this is equal to nBandsSynthesis
+ but it may differ if the QMF based resampler is being
+ used. */
+ UCHAR nQmfProcBands_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+ UCHAR
+ nQmfProcChannels; /*!< Number of complete QMF channels which need to
+ coexist in memory at the same time. For most cases
+ this is 1 which means the work buffer can be shared
+ between audio channels. */
+ UCHAR
+ nQmfProcChannels_requested; /*!< Corresponding requested not yet active
+ configuration parameter. */
+} FDK_QMF_DOMAIN_GC;
+typedef FDK_QMF_DOMAIN_GC *HANDLE_FDK_QMF_DOMAIN_GC;
+
+/**
+ * Structure representing one QMF input channel. This includes the QMF analysis
+ * and the QMF domain data representation needed by the codec. Work buffer data
+ * may be shared between channels if the codec processes all QMF channels in a
+ * consecutive order.
+ */
+typedef struct {
+ HANDLE_FDK_QMF_DOMAIN_GC
+ pGlobalConf; /*!< Pointer to global configuration structure. */
+ QMF_FILTER_BANK fb; /*!< QMF (analysis) filter bank structure. */
+ QMF_SCALE_FACTOR scaling; /*!< Structure with scaling information. */
+ UCHAR workBuf_nTimeSlots; /*!< Work buffer dimension for this channel is
+ (workBuf_nTimeSlots * workBuf_nBands *
+ CMPLX_MOD). */
+ UCHAR workBuf_nBands; /*!< Work buffer dimension for this channel is
+ (workBuf_nTimeSlots * workBuf_nBands * CMPLX_MOD). */
+ USHORT workBufferOffset; /*!< Offset within work buffer. */
+ USHORT workBufferSectSize; /*!< Size of work buffer section. */
+ FIXP_QAS *
+ pAnaQmfStates; /*!< Pointer to QMF analysis states (persistent memory). */
+ FIXP_DBL
+ *pOverlapBuffer; /*!< Pointer to QMF overlap/delay memory (persistent
+ memory). */
+ FIXP_DBL **pWorkBuffer; /*!< Pointer array to available work buffers. */
+ FIXP_DBL *
+ *hQmfSlotsReal; /*!< Handle for QMF real data time slot pointer array. */
+ FIXP_DBL **hQmfSlotsImag; /*!< Handle for QMF imaginary data time slot pointer
+ array. */
+} FDK_QMF_DOMAIN_IN;
+typedef FDK_QMF_DOMAIN_IN *HANDLE_FDK_QMF_DOMAIN_IN;
+
+/**
+ * Structure representing one QMF output channel.
+ */
+typedef struct {
+ QMF_FILTER_BANK fb; /*!< QMF (synthesis) filter bank structure. */
+ FIXP_QSS *pSynQmfStates; /*!< Pointer to QMF synthesis states (persistent
+ memory). */
+} FDK_QMF_DOMAIN_OUT;
+typedef FDK_QMF_DOMAIN_OUT *HANDLE_FDK_QMF_DOMAIN_OUT;
+
+/**
+ * Structure representing the QMF domain for multiple channels.
+ */
+typedef struct {
+ FDK_QMF_DOMAIN_GC globalConf; /*!< Global configuration structure. */
+ FDK_QMF_DOMAIN_IN
+ QmfDomainIn[((8) + (1))]; /*!< Array of QMF domain input structures */
+ FDK_QMF_DOMAIN_OUT
+ QmfDomainOut[((8) + (1))]; /*!< Array of QMF domain output structures */
+} FDK_QMF_DOMAIN;
+typedef FDK_QMF_DOMAIN *HANDLE_FDK_QMF_DOMAIN;
+
+/**
+ * \brief Check whether analysis- and synthesis-filterbank-states have been
+ * initialized.
+ *
+ * \param qd Pointer to QMF domain structure.
+ *
+ * \return 1 if initialized, 0 else
+ */
+int FDK_QmfDomain_IsInitialized(const HANDLE_FDK_QMF_DOMAIN qd);
+
+/**
+ * \brief Initialize QMF analysis and synthesis filter banks and set up QMF data
+ * representation.
+ *
+ * \param qd Pointer to QMF domain structure.
+ * \param extra_flags Initialize filter banks with extra flags which were not
+ * set in the global config flags field.
+ *
+ * \return 0 on success.
+ */
+int FDK_QmfDomain_InitFilterBank(HANDLE_FDK_QMF_DOMAIN qd, UINT extra_flags);
+
+/**
+ * \brief When QMF processing of one channel is finished copy the overlap/delay
+ * part into the persistent memory to be used in the next frame.
+ *
+ * \param qd_ch Pointer to a QMF domain input channel.
+ * \param offset
+ *
+ * \return void
+ */
+void FDK_QmfDomain_SaveOverlap(HANDLE_FDK_QMF_DOMAIN_IN qd_ch, int offset);
+
+/**
+ * \brief Get one slot of QMF data and adapt the scaling.
+ *
+ * \param qd_ch Pointer to a QMF domain input channel.
+ * \param ts Time slot number to be obtained.
+ * \param start_band Start index of QMF bands to be obtained.
+ * \param stop_band Stop index of QMF band to be obtained.
+ * \param pQmfOutReal Output buffer (real QMF data).
+ * \param pQmfOutImag Output buffer (imag QMF data).
+ * \param exp_out Target exponent (scaling) of data.
+ *
+ * \return void
+ */
+void FDK_QmfDomain_GetSlot(const HANDLE_FDK_QMF_DOMAIN_IN qd_ch, const int ts,
+ const int start_band, const int stop_band,
+ FIXP_DBL *pQmfOutReal, FIXP_DBL *pQmfOutImag,
+ const int exp_out);
+
+/**
+ * \brief Direct access to the work buffer associated with a certain channel (no
+ * time slot pointer array is used).
+ *
+ * \param qd_ch Pointer to a QMF domain input channel.
+ * \param ts Time slot number to be obtained.
+ * \param ppQmfReal Returns the pointer to the requested part of the work buffer
+ * (real time slot).
+ * \param ppQmfImag Returns the pointer to the requested part of the work buffer
+ * (imag time slot).
+ *
+ * \return void
+ */
+void FDK_QmfDomain_GetWorkBuffer(const HANDLE_FDK_QMF_DOMAIN_IN qd_ch,
+ const int ts, FIXP_DBL **ppQmfReal,
+ FIXP_DBL **ppQmfImag);
+
+/**
+ * \brief For the case that the work buffer associated to this channel is not
+ * identical to the processing channel work buffer copy the data into the
+ * processing channel.
+ *
+ * \param qd_ch Pointer to a QMF domain input channel.
+ * \return void
+ */
+void FDK_QmfDomain_WorkBuffer2ProcChannel(const HANDLE_FDK_QMF_DOMAIN_IN qd_ch);
+
+/**
+ * \brief For the case of stereoCfgIndex3 with HBE the HBE buffer is copied into
+ * the processing channel work buffer and the processing channel work buffer is
+ * copied into the HBE buffer.
+ *
+ * \param qd_ch Pointer to a QMF domain input channel.
+ * \param ppQmfReal Pointer to a HBE QMF data buffer (real).
+ * \param ppQmfImag Pointer to a HBE QMF data buffer (imag).
+ *
+ * \return void
+ */
+void FDK_QmfDomain_QmfData2HBE(HANDLE_FDK_QMF_DOMAIN_IN qd_ch,
+ FIXP_DBL **ppQmfReal, FIXP_DBL **ppQmfImag);
+
+/**
+ * \brief Set all fields for requested parametervalues in global config struct
+ * FDK_QMF_DOMAIN_GC to 0.
+ *
+ * \param hgc Pointer to a QMF domain global config struct.
+ */
+void FDK_QmfDomain_ClearRequested(HANDLE_FDK_QMF_DOMAIN_GC hgc);
+
+/**
+ * \brief Check for parameter-change requests in global config and
+ * (re-)configure QMF domain accordingly.
+ *
+ * \param hqd Pointer to QMF domain
+ *
+ * \return errorcode
+ */
+QMF_DOMAIN_ERROR FDK_QmfDomain_Configure(HANDLE_FDK_QMF_DOMAIN hqd);
+
+/**
+ * \brief Free QMF workbuffer, QMF persistent memory and configuration
+ * variables.
+ *
+ * \param hqd Pointer to QMF domain
+ */
+void FDK_QmfDomain_FreeMem(HANDLE_FDK_QMF_DOMAIN hqd);
+
+/**
+ * \brief Clear QMF overlap buffers and QMF filter bank states.
+ *
+ * \param hqd Pointer to QMF domain
+ */
+QMF_DOMAIN_ERROR FDK_QmfDomain_ClearPersistentMemory(HANDLE_FDK_QMF_DOMAIN hqd);
+
+/**
+ * \brief Free QMF workbuffer and QMF persistent memory.
+ *
+ * \param hqd Pointer to QMF domain
+ *
+ * \param dmx_lp_mode downmix low power mode flag
+ */
+void FDK_QmfDomain_Close(HANDLE_FDK_QMF_DOMAIN hqd);
+
+#endif /* FDK_QMF_DOMAIN_H */
diff --git a/libFDK/include/FDK_tools_rom.h b/libFDK/include/FDK_tools_rom.h
index 9361c81..d1cb980 100644
--- a/libFDK/include/FDK_tools_rom.h
+++ b/libFDK/include/FDK_tools_rom.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,72 +90,114 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s): Oliver Moser
+
Description: ROM tables used by FDK tools
-******************************************************************************/
+*******************************************************************************/
-#ifndef __FDK_TOOLS_ROM_H__
-#define __FDK_TOOLS_ROM_H__
+#ifndef FDK_TOOLS_ROM_H
+#define FDK_TOOLS_ROM_H
#include "common_fix.h"
#include "FDK_audio.h"
+/* sinetables */
/* None radix2 rotation vectors */
-extern const FIXP_STB RotVectorReal60[60];
-extern const FIXP_STB RotVectorImag60[60];
-extern const FIXP_STB RotVectorReal240[240];
-extern const FIXP_STB RotVectorImag240[240];
-extern const FIXP_STB RotVectorReal480[480];
-extern const FIXP_STB RotVectorImag480[480];
-
+extern RAM_ALIGN const FIXP_STB RotVectorReal60[60];
+extern RAM_ALIGN const FIXP_STB RotVectorImag60[60];
+extern RAM_ALIGN const FIXP_STB RotVectorReal192[192];
+extern RAM_ALIGN const FIXP_STB RotVectorImag192[192];
+extern RAM_ALIGN const FIXP_STB RotVectorReal240[210];
+extern RAM_ALIGN const FIXP_STB RotVectorImag240[210];
+extern RAM_ALIGN const FIXP_STB RotVectorReal480[480];
+extern RAM_ALIGN const FIXP_STB RotVectorImag480[480];
+extern RAM_ALIGN const FIXP_STB RotVectorReal6[6];
+extern RAM_ALIGN const FIXP_STB RotVectorImag6[6];
+extern RAM_ALIGN const FIXP_STB RotVectorReal12[12];
+extern RAM_ALIGN const FIXP_STB RotVectorImag12[12];
+extern RAM_ALIGN const FIXP_STB RotVectorReal24[24];
+extern RAM_ALIGN const FIXP_STB RotVectorImag24[24];
+extern RAM_ALIGN const FIXP_STB RotVectorReal48[48];
+extern RAM_ALIGN const FIXP_STB RotVectorImag48[48];
+extern RAM_ALIGN const FIXP_STB RotVectorReal80[80];
+extern RAM_ALIGN const FIXP_STB RotVectorImag80[80];
+extern RAM_ALIGN const FIXP_STB RotVectorReal96[96];
+extern RAM_ALIGN const FIXP_STB RotVectorImag96[96];
+extern RAM_ALIGN const FIXP_STB RotVectorReal384[384];
+extern RAM_ALIGN const FIXP_STB RotVectorImag384[384];
+extern RAM_ALIGN const FIXP_STB RotVectorReal20[20];
+extern RAM_ALIGN const FIXP_STB RotVectorImag20[20];
+extern RAM_ALIGN const FIXP_STB RotVectorReal120[120];
+extern RAM_ALIGN const FIXP_STB RotVectorImag120[120];
/* Regular sine tables */
-extern const FIXP_STP SineTable512[];
-extern const FIXP_STP SineTable480[];
+extern RAM_ALIGN const FIXP_STP SineTable1024[];
+extern RAM_ALIGN const FIXP_STP SineTable512[];
+extern RAM_ALIGN const FIXP_STP SineTable480[];
+extern RAM_ALIGN const FIXP_STP SineTable384[];
+extern RAM_ALIGN const FIXP_STP SineTable80[];
+#ifdef INCLUDE_SineTable10
+extern RAM_ALIGN const FIXP_STP SineTable10[];
+#endif
/* AAC-LC windows */
-extern const FIXP_WTP SineWindow1024[];
-extern const FIXP_WTP KBDWindow1024[];
-extern const FIXP_WTP SineWindow128[];
-extern const FIXP_WTP KBDWindow128[];
+extern RAM_ALIGN const FIXP_WTP SineWindow1024[];
+extern RAM_ALIGN const FIXP_WTP KBDWindow1024[];
+extern RAM_ALIGN const FIXP_WTP SineWindow128[];
+extern RAM_ALIGN const FIXP_WTP KBDWindow128[];
-extern const FIXP_WTP SineWindow960[];
-extern const FIXP_WTP KBDWindow960[];
-extern const FIXP_WTP SineWindow120[];
-extern const FIXP_WTP KBDWindow120[];
+extern RAM_ALIGN const FIXP_WTP SineWindow960[];
+extern RAM_ALIGN const FIXP_WTP KBDWindow960[];
+extern RAM_ALIGN const FIXP_WTP SineWindow120[];
+extern RAM_ALIGN const FIXP_WTP KBDWindow120[];
/* AAC-LD windows */
-extern const FIXP_WTP SineWindow512[];
+extern RAM_ALIGN const FIXP_WTP SineWindow512[];
#define LowOverlapWindow512 SineWindow128
-extern const FIXP_WTP SineWindow480[];
+extern RAM_ALIGN const FIXP_WTP SineWindow480[];
#define LowOverlapWindow480 SineWindow120
+/* USAC TCX Window */
+extern RAM_ALIGN const FIXP_WTP SineWindow256[256];
+extern RAM_ALIGN const FIXP_WTP SineWindow192[];
+/* USAC 8/3 windows */
+extern RAM_ALIGN const FIXP_WTP SineWindow768[];
+extern RAM_ALIGN const FIXP_WTP KBDWindow768[];
+extern RAM_ALIGN const FIXP_WTP SineWindow96[];
+extern RAM_ALIGN const FIXP_WTP KBDWindow96[];
-extern const FIXP_WTP SineWindow64[];
-extern const FIXP_WTP SineWindow32[];
+/* DCT and others */
+extern RAM_ALIGN const FIXP_WTP SineWindow64[];
+extern RAM_ALIGN const FIXP_WTP SineWindow48[];
+extern RAM_ALIGN const FIXP_WTP SineWindow32[];
+extern RAM_ALIGN const FIXP_WTP SineWindow24[];
+extern RAM_ALIGN const FIXP_WTP SineWindow16[];
+extern RAM_ALIGN const FIXP_WTP SineWindow8[];
/**
- * \brief Helper table for window slope mapping. You should prefer the usage of the
- * function FDKgetWindowSlope(), this table is only made public for some optimized
- * access inside dct.cpp.
+ * \brief Helper table for window slope mapping. You should prefer the usage of
+ * the function FDKgetWindowSlope(), this table is only made public for some
+ * optimized access inside dct.cpp.
*/
-extern const FIXP_WTP *const windowSlopes[2][3][9];
+extern const FIXP_WTP *const windowSlopes[2][4][9];
/**
* \brief Window slope access helper. Obtain a window of given length and shape.
* \param length Length of the window slope.
- * \param shape Shape index of the window slope. 0: sine window, 1: Kaiser-Bessel. Any other
- * value is applied a mask of 1 to, mapping it to either 0 or 1.
- * \param Pointer to window slope or NULL if the requested window slope is not available.
+ * \param shape Shape index of the window slope. 0: sine window, 1:
+ * Kaiser-Bessel. Any other value is applied a mask of 1 to, mapping it to
+ * either 0 or 1.
+ * \param Pointer to window slope or NULL if the requested window slope is not
+ * available.
*/
-const FIXP_WTP * FDKgetWindowSlope(int length, int shape);
+const FIXP_WTP *FDKgetWindowSlope(int length, int shape);
extern const FIXP_WTP sin_twiddle_L64[];
@@ -153,62 +206,103 @@ extern const FIXP_WTP sin_twiddle_L64[];
*/
#if defined(ARCH_PREFER_MULT_16x16) || defined(ARCH_PREFER_MULT_32x16)
- #define QMF_COEFF_16BIT
+#define QMF_COEFF_16BIT
#endif
-#define QMF_FILTER_PROTOTYPE_SIZE 640
-#define QMF_NO_POLY 5
+#define QMF_FILTER_PROTOTYPE_SIZE 640
+#define QMF_NO_POLY 5
#ifdef QMF_COEFF_16BIT
- #define FIXP_PFT FIXP_SGL
- #define FIXP_QTW FIXP_SGL
+#define FIXP_PFT FIXP_SGL
+#define FIXP_QTW FIXP_SGL
+#define FX_DBL2FX_QTW(x) FX_DBL2FX_SGL(x)
#else
- #define FIXP_PFT FIXP_DBL
- #define FIXP_QTW FIXP_DBL
-#endif
+#define FIXP_PFT FIXP_DBL
+#define FIXP_QTW FIXP_DBL
-#define QMF640_PFT_TABLE_SIZE (640/2 + QMF_NO_POLY)
-
-extern const FIXP_QTW qmf_phaseshift_cos32[32];
-extern const FIXP_QTW qmf_phaseshift_sin32[32];
-/* Adapted analysis post-twiddles for down-sampled HQ SBR */
-extern const FIXP_QTW qmf_phaseshift_cos_downsamp32[32];
-extern const FIXP_QTW qmf_phaseshift_sin_downsamp32[32];
-extern const FIXP_QTW qmf_phaseshift_cos64[64];
-extern const FIXP_QTW qmf_phaseshift_sin64[64];
-
-extern const FIXP_PFT qmf_64[QMF640_PFT_TABLE_SIZE+QMF_NO_POLY];
+#define FX_DBL2FX_QTW(x) (x)
+#endif
+#define QMF640_PFT_TABLE_SIZE (640 / 2 + QMF_NO_POLY)
+/* Resampling twiddles for QMF */
+/* Not resampling twiddles */
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos32[32];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin32[32];
+/* Adapted analysis post-twiddles for down-sampled HQ SBR */
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos_downsamp32[32];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin_downsamp32[32];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos64[64];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin64[64];
+extern RAM_ALIGN const FIXP_PFT
+ qmf_pfilt640[QMF640_PFT_TABLE_SIZE + QMF_NO_POLY];
+extern RAM_ALIGN const FIXP_PFT qmf_pfilt640_vector[640];
+
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos40[40];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin40[40];
+extern RAM_ALIGN const FIXP_PFT qmf_pfilt400[];
+extern RAM_ALIGN const FIXP_PFT qmf_pfilt200[];
+extern RAM_ALIGN const FIXP_PFT qmf_pfilt120[];
+
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos24[24];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin24[24];
+extern RAM_ALIGN const FIXP_PFT qmf_pfilt240[];
+
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_cos16[16];
+extern RAM_ALIGN const FIXP_QTW qmf_phaseshift_sin16[16];
#define QMF640_CLDFB_PFT_TABLE_SIZE (640)
#define QMF320_CLDFB_PFT_TABLE_SIZE (320)
#define QMF_CLDFB_PFT_SCALE 1
-extern const FIXP_QTW qmf_phaseshift_cos32_cldfb[32];
+extern const FIXP_QTW qmf_phaseshift_cos32_cldfb_ana[32];
+extern const FIXP_QTW qmf_phaseshift_cos32_cldfb_syn[32];
extern const FIXP_QTW qmf_phaseshift_sin32_cldfb[32];
+
+extern const FIXP_QTW qmf_phaseshift_cos16_cldfb_ana[16];
+extern const FIXP_QTW qmf_phaseshift_cos16_cldfb_syn[16];
+extern const FIXP_QTW qmf_phaseshift_sin16_cldfb[16];
+
+extern const FIXP_QTW qmf_phaseshift_cos8_cldfb_ana[8];
+extern const FIXP_QTW qmf_phaseshift_cos8_cldfb_syn[8];
+extern const FIXP_QTW qmf_phaseshift_sin8_cldfb[8];
+
extern const FIXP_QTW qmf_phaseshift_cos64_cldfb[64];
extern const FIXP_QTW qmf_phaseshift_sin64_cldfb[64];
-extern const FIXP_PFT qmf_cldfb_640[QMF640_CLDFB_PFT_TABLE_SIZE];
-extern const FIXP_PFT qmf_cldfb_320[QMF320_CLDFB_PFT_TABLE_SIZE];
-
+extern RAM_ALIGN const FIXP_PFT qmf_cldfb_640[QMF640_CLDFB_PFT_TABLE_SIZE];
+extern RAM_ALIGN const FIXP_PFT qmf_cldfb_320[QMF320_CLDFB_PFT_TABLE_SIZE];
+#define QMF160_CLDFB_PFT_TABLE_SIZE (160)
+extern RAM_ALIGN const FIXP_PFT qmf_cldfb_160[QMF160_CLDFB_PFT_TABLE_SIZE];
+#define QMF80_CLDFB_PFT_TABLE_SIZE (80)
+extern RAM_ALIGN const FIXP_PFT qmf_cldfb_80[QMF80_CLDFB_PFT_TABLE_SIZE];
+#define QMF320_MPSLDFB_PFT_TABLE_SIZE (320)
+#define QMF640_MPSLDFB_PFT_TABLE_SIZE (640)
+#define QMF_MPSLDFB_PFT_SCALE 1
+extern const FIXP_PFT qmf_mpsldfb_320[QMF320_MPSLDFB_PFT_TABLE_SIZE];
+extern RAM_ALIGN const FIXP_PFT qmf_mpsldfb_640[QMF640_MPSLDFB_PFT_TABLE_SIZE];
+/**
+ * Audio bitstream element specific syntax flags:
+ */
+#define AC_EL_GA_CCE 0x00000001 /*!< GA AAC coupling channel element (CCE) */
/*
- * Raw Data Block list stuff.
+ * Raw Data Block list items.
*/
typedef enum {
element_instance_tag,
- common_window,
+ common_window, /* -> decision for link_sequence */
global_gain,
- ics_info, /* ics_reserved_bit, window_sequence, window_shape, max_sfb, scale_factor_grouping, predictor_data_present, ltp_data_present, ltp_data */
+ ics_info, /* ics_reserved_bit, window_sequence, window_shape, max_sfb,
+ scale_factor_grouping, predictor_data_present, ltp_data_present,
+ ltp_data */
max_sfb,
- ms, /* ms_mask_present, ms_used */
+ ms, /* ms_mask_present, ms_used */
/*predictor_data_present,*/ /* part of ics_info */
ltp_data_present,
ltp_data,
@@ -224,7 +318,7 @@ typedef enum {
spectral_data,
scale_factor_data_usac,
- core_mode,
+ core_mode, /* -> decision for link_sequence */
common_tw,
lpd_channel_stream,
tw_data,
@@ -235,6 +329,8 @@ typedef enum {
tns_data_present_usac,
common_max_sfb,
+ coupled_elements, /* only for CCE parsing */
+ gain_element_lists, /* only for CCE parsing */
/* Non data list items */
adtscrc_start_reg1,
@@ -261,10 +357,42 @@ typedef struct element_list element_list_t;
* \param epConfig the epConfig value from the current Audio Specific Config
* \param nChannels amount of channels contained in the current element.
* \param layer the layer of the current element.
+ * \param elFlags element specific flags.
* \return element_list_t parser guidance structure.
*/
-const element_list_t * getBitstreamElementList(AUDIO_OBJECT_TYPE aot, SCHAR epConfig, UCHAR nChannels, UCHAR layer);
+const element_list_t *getBitstreamElementList(AUDIO_OBJECT_TYPE aot,
+ SCHAR epConfig, UCHAR nChannels,
+ UCHAR layer, UINT elFlags);
+typedef enum {
+ /* n.a. */
+ FDK_FORMAT_1_0 = 1, /* mono */
+ FDK_FORMAT_2_0 = 2, /* stereo */
+ FDK_FORMAT_3_0_FC = 3, /* 3/0.0 */
+ FDK_FORMAT_3_1_0 = 4, /* 3/1.0 */
+ FDK_FORMAT_5_0 = 5, /* 3/2.0 */
+ FDK_FORMAT_5_1 = 6, /* 5.1 */
+ FDK_FORMAT_7_1_ALT = 7, /* 5/2.1 ALT */
+ /* 8 n.a.*/
+ FDK_FORMAT_3_0_RC = 9, /* 2/1.0 */
+ FDK_FORMAT_2_2_0 = 10, /* 2/2.0 */
+ FDK_FORMAT_6_1 = 11, /* 3/3.1 */
+ FDK_FORMAT_7_1 = 12, /* 3/4.1 */
+ FDK_FORMAT_22_2 = 13, /* 22.2 */
+ FDK_FORMAT_5_2_1 = 14, /* 5/2.1*/
+ FDK_FORMAT_5_5_2 = 15, /* 5/5.2 */
+ FDK_FORMAT_9_1 = 16, /* 5/4.1 */
+ FDK_FORMAT_6_5_1 = 17, /* 6/5.1 */
+ FDK_FORMAT_6_7_1 = 18, /* 6/7.1 */
+ FDK_FORMAT_5_6_1 = 19, /* 5/6.1 */
+ FDK_FORMAT_7_6_1 = 20, /* 7/6.1 */
+ FDK_FORMAT_IN_LISTOFCHANNELS = 21,
+ FDK_FORMAT_OUT_LISTOFCHANNELS = 22,
+ /* 20 formats + In & Out list of channels */
+ FDK_NFORMATS = 23,
+ FDK_FORMAT_FAIL = -1
+} FDK_converter_formatid_t;
+
+extern const INT format_nchan[FDK_NFORMATS + 9 - 2];
#endif
-
diff --git a/libFDK/include/FDK_trigFcts.h b/libFDK/include/FDK_trigFcts.h
index c32c0f2..153ca4c 100644
--- a/libFDK/include/FDK_trigFcts.h
+++ b/libFDK/include/FDK_trigFcts.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,43 +90,45 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): Haricharan Lakshman, Manuel Jander
- Description: Trigonometric functions fixed point fractional implementation.
-******************************************************************************/
+ Description: Trigonometric functions fixed point fractional implementation.
+*******************************************************************************/
+#if !defined(FDK_TRIGFCTS_H)
+#define FDK_TRIGFCTS_H
#include "common_fix.h"
#include "FDK_tools_rom.h"
/* Fixed point precision definitions */
-#define Q(format) ((FIXP_DBL)(((LONG)1) << (format)))
+#define Q(format) ((FIXP_DBL)(((LONG)1) << (format)))
#ifndef M_PI
-#define M_PI (3.14159265358979323846f)
+#define M_PI (3.14159265358979323846f)
#endif
/*!
* Inverse tangent function.
*/
-// --- fixp_atan() ----
-#define Q_ATANINP (25) // Input in q25, Output in q30
-#define Q_ATANOUT (30)
-#define ATI_SF ((DFRACT_BITS-1)-Q_ATANINP) // 6
-#define ATI_SCALE ((float)(1<<ATI_SF)) //
-#define ATO_SF ((DFRACT_BITS-1)-Q_ATANOUT) // 1 ] -pi/2 .. pi/2 [
-#define ATO_SCALE ((float)(1<<ATO_SF)) //
-// --- fixp_atan2() ---
-#define Q_ATAN2OUT (29)
-#define AT2O_SF ((DFRACT_BITS-1)-Q_ATAN2OUT) // 2 ] -pi .. pi ]
-#define AT2O_SCALE ((float)(1<<AT2O_SF)) //
+/* --- fixp_atan() ---- */
+#define Q_ATANINP (25) // Input in q25, Output in q30
+#define Q_ATANOUT (30)
+#define ATI_SF ((DFRACT_BITS - 1) - Q_ATANINP) /* 6 */
+#define ATI_SCALE ((float)(1 << ATI_SF))
+#define ATO_SF ((DFRACT_BITS - 1) - Q_ATANOUT) /* 1 ] -pi/2 .. pi/2 [ */
+#define ATO_SCALE ((float)(1 << ATO_SF))
+/* --- fixp_atan2() --- */
+#define Q_ATAN2OUT (29)
+#define AT2O_SF ((DFRACT_BITS - 1) - Q_ATAN2OUT) /* 2 ] -pi .. pi ] */
+#define AT2O_SCALE ((float)(1 << AT2O_SF))
// --------------------
FIXP_DBL fixp_atan(FIXP_DBL x);
@@ -126,13 +139,11 @@ FIXP_DBL fixp_sin(FIXP_DBL x, int scale);
#define FIXP_COS_SIN
-
#include "FDK_tools_rom.h"
#define SINETAB SineTable512
#define LD 9
-
#ifndef FUNCTION_inline_fixp_cos_sin
#define FUNCTION_inline_fixp_cos_sin
@@ -141,89 +152,107 @@ FIXP_DBL fixp_sin(FIXP_DBL x, int scale);
* Calculates coarse lookup index and sign for sine.
* Returns delta x residual.
*/
-static inline FIXP_DBL fixp_sin_cos_residual_inline(FIXP_DBL x, int scale, FIXP_DBL *sine, FIXP_DBL *cosine)
-{
- FIXP_DBL residual;
- int s;
- int shift = (31-scale-LD-1);
- int ssign = 1;
- int csign = 1;
-
- residual = fMult(x, FL2FXCONST_DBL(1.0/M_PI));
- s = ((LONG)residual) >> shift;
-
- residual &= ( (1<<shift) - 1 );
- residual = fMult(residual, FL2FXCONST_DBL(M_PI/4.0)) << 2;
- residual <<= scale;
-
- /* Sine sign symmetry */
- if (s & ((1<<LD)<<1) ) {
- ssign = -ssign;
- }
- /* Cosine sign symmetry */
- if ( (s + (1<<LD)) & ((1<<LD)<<1) ) {
- csign = -csign;
+static inline FIXP_DBL fixp_sin_cos_residual_inline(FIXP_DBL x, int scale,
+ FIXP_DBL *sine,
+ FIXP_DBL *cosine) {
+ FIXP_DBL residual;
+ int s;
+ int shift = (31 - scale - LD - 1);
+ int ssign = 1;
+ int csign = 1;
+
+ residual = fMult(x, FL2FXCONST_DBL(1.0 / M_PI));
+ s = ((LONG)residual) >> shift;
+
+ residual &= ((1 << shift) - 1);
+ residual = fMult(residual, FL2FXCONST_DBL(M_PI / 4.0)) << 2;
+ residual <<= scale;
+
+ /* Sine sign symmetry */
+ if (s & ((1 << LD) << 1)) {
+ ssign = -ssign;
+ }
+ /* Cosine sign symmetry */
+ if ((s + (1 << LD)) & ((1 << LD) << 1)) {
+ csign = -csign;
+ }
+
+ s = fAbs(s);
+
+ s &= (((1 << LD) << 1) - 1); /* Modulo PI */
+
+ if (s > (1 << LD)) {
+ s = ((1 << LD) << 1) - s;
+ }
+
+ {
+ LONG sl, cl;
+ /* Because of packed table */
+ if (s > (1 << (LD - 1))) {
+ FIXP_STP tmp;
+ /* Cosine/Sine simetry for angles greater than PI/4 */
+ s = (1 << LD) - s;
+ tmp = SINETAB[s];
+ sl = (LONG)tmp.v.re;
+ cl = (LONG)tmp.v.im;
+ } else {
+ FIXP_STP tmp;
+ tmp = SINETAB[s];
+ sl = (LONG)tmp.v.im;
+ cl = (LONG)tmp.v.re;
}
- s = fAbs(s);
-
- s &= (((1<<LD)<<1)-1); /* Modulo PI */
-
- if (s > (1<<LD)) {
- s = ((1<<LD)<<1) - s;
- }
-
- {
- LONG sl, cl;
- /* Because of packed table */
- if (s > (1<<(LD-1))) {
- FIXP_STP tmp;
- /* Cosine/Sine simetry for angles greater than PI/4 */
- s = (1<<LD)-s;
- tmp = SINETAB[s];
- sl = (LONG)tmp.v.re;
- cl = (LONG)tmp.v.im;
- } else {
- FIXP_STP tmp;
- tmp = SINETAB[s];
- sl = (LONG)tmp.v.im;
- cl = (LONG)tmp.v.re;
- }
-
#ifdef SINETABLE_16BIT
- *sine = (FIXP_DBL)((sl * ssign) << (DFRACT_BITS-FRACT_BITS));
- *cosine = (FIXP_DBL)((cl * csign) << (DFRACT_BITS-FRACT_BITS));
+ *sine = (FIXP_DBL)((sl * ssign) << (DFRACT_BITS - FRACT_BITS));
+ *cosine = (FIXP_DBL)((cl * csign) << (DFRACT_BITS - FRACT_BITS));
#else
- *sine = (FIXP_DBL)(sl * ssign);
- *cosine = (FIXP_DBL)(cl * csign);
+ /* scale down by 1 for overflow prevention. This is undone at the calling
+ * function. */
+ *sine = (FIXP_DBL)(sl * ssign) >> 1;
+ *cosine = (FIXP_DBL)(cl * csign) >> 1;
#endif
- }
+ }
- return residual;
+ return residual;
}
/**
- * \brief Calculate cosine and sine value each of 2 angles different angle values.
+ * \brief Calculate cosine and sine value each of 2 angles different angle
+ * values.
* \param x1 first angle value
* \param x2 second angle value
* \param scale exponent of x1 and x2
- * \param out pointer to 4 FIXP_DBL locations, were the values cos(x1), sin(x1), cos(x2), sin(x2)
- * will be stored into.
+ * \param out pointer to 4 FIXP_DBL locations, were the values cos(x1), sin(x1),
+ * cos(x2), sin(x2) will be stored into.
*/
-static inline void inline_fixp_cos_sin (FIXP_DBL x1, FIXP_DBL x2, const int scale, FIXP_DBL *out)
-{
- FIXP_DBL residual, error0, error1, sine, cosine;
- residual = fixp_sin_cos_residual_inline(x1, scale, &sine, &cosine);
- error0 = fMultDiv2(sine, residual);
- error1 = fMultDiv2(cosine, residual);
- *out++ = cosine - (error0<<1);
- *out++ = sine + (error1<<1);
-
- residual = fixp_sin_cos_residual_inline(x2, scale, &sine, &cosine);
- error0 = fMultDiv2(sine, residual);
- error1 = fMultDiv2(cosine, residual);
- *out++ = cosine - (error0<<1);
- *out++ = sine + (error1<<1);
+static inline void inline_fixp_cos_sin(FIXP_DBL x1, FIXP_DBL x2,
+ const int scale, FIXP_DBL *out) {
+ FIXP_DBL residual, error0, error1, sine, cosine;
+ residual = fixp_sin_cos_residual_inline(x1, scale, &sine, &cosine);
+ error0 = fMultDiv2(sine, residual);
+ error1 = fMultDiv2(cosine, residual);
+
+#ifdef SINETABLE_16BIT
+ *out++ = cosine - (error0 << 1);
+ *out++ = sine + (error1 << 1);
+#else
+ /* Undo downscaling by 1 which was done at fixp_sin_cos_residual_inline */
+ *out++ = SATURATE_LEFT_SHIFT(cosine - (error0 << 1), 1, DFRACT_BITS);
+ *out++ = SATURATE_LEFT_SHIFT(sine + (error1 << 1), 1, DFRACT_BITS);
+#endif
+
+ residual = fixp_sin_cos_residual_inline(x2, scale, &sine, &cosine);
+ error0 = fMultDiv2(sine, residual);
+ error1 = fMultDiv2(cosine, residual);
+
+#ifdef SINETABLE_16BIT
+ *out++ = cosine - (error0 << 1);
+ *out++ = sine + (error1 << 1);
+#else
+ *out++ = SATURATE_LEFT_SHIFT(cosine - (error0 << 1), 1, DFRACT_BITS);
+ *out++ = SATURATE_LEFT_SHIFT(sine + (error1 << 1), 1, DFRACT_BITS);
+#endif
}
#endif
+#endif /* !defined(FDK_TRIGFCTS_H) */
diff --git a/libFDK/include/abs.h b/libFDK/include/abs.h
index 0837e3c..0846c96 100644
--- a/libFDK/include/abs.h
+++ b/libFDK/include/abs.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,23 +90,23 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser
- Description: fixed point abs definitions
-******************************************************************************/
+ Description: fixed point abs definitions
-#if !defined(__ABS_H__)
-#define __ABS_H__
+*******************************************************************************/
+#if !defined(ABS_H)
+#define ABS_H
-#if defined(__mips__) /* cppp replaced: elif */
+#if defined(__mips__)
#include "mips/abs_mips.h"
-#elif defined(__x86__) /* cppp replaced: elif */
+#elif defined(__x86__)
#include "x86/abs_x86.h"
#endif /* all cores */
@@ -107,15 +118,19 @@ amm-info@iis.fraunhofer.de
**************************************************************************/
#if !defined(FUNCTION_fixabs_D)
-inline FIXP_DBL fixabs_D(FIXP_DBL x) { return ((x) > (FIXP_DBL)(0)) ? (x) : -(x) ; }
+inline FIXP_DBL fixabs_D(FIXP_DBL x) {
+ return ((x) > (FIXP_DBL)(0)) ? (x) : -(x);
+}
#endif
#if !defined(FUNCTION_fixabs_I)
-inline INT fixabs_I(INT x) { return ((x) > (INT)(0)) ? (x) : -(x) ; }
+inline INT fixabs_I(INT x) { return ((x) > (INT)(0)) ? (x) : -(x); }
#endif
#if !defined(FUNCTION_fixabs_S)
-inline FIXP_SGL fixabs_S(FIXP_SGL x) { return ((x) > (FIXP_SGL)(0)) ? (x) : -(x) ; }
+inline FIXP_SGL fixabs_S(FIXP_SGL x) {
+ return ((x) > (FIXP_SGL)(0)) ? (x) : -(x);
+}
#endif
-#endif /* __ABS_H__ */
+#endif /* ABS_H */
diff --git a/libFDK/include/arm/clz_arm.h b/libFDK/include/arm/clz_arm.h
index f43a7b1..1c3e1fb 100644
--- a/libFDK/include/arm/clz_arm.h
+++ b/libFDK/include/arm/clz_arm.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,44 +90,75 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(CLZ_ARM_H)
+#define CLZ_ARM_H
#if defined(__arm__)
-#if defined(__GNUC__) && defined(__ARM_ARCH_5TE__) /* cppp replaced: elif */
- /* ARM gcc*/
-
- #define FUNCTION_fixnormz_D
- #define FUNCTION_fixnorm_D
-
- inline INT fixnormz_D(LONG value)
- {
- INT result;
- asm("clz %0, %1 ": "=r"(result) : "r"(value) );
- return result;
- }
-
- inline INT fixnorm_D(LONG value)
- {
- INT result;
- if (value == 0) {
- return 0;
- }
- if (value < 0) {
- value = ~value;
- }
- result = fixnormz_D(value);
- return result - 1;
- }
+#if defined(__GNUC__)
+/* ARM gcc*/
+
+#if defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_8__)
+#define FUNCTION_fixnormz_D
+#define FUNCTION_fixnorm_D
+#define FUNCTION_fixnormz_S
+#define FUNCTION_fixnorm_S
+
+#ifdef FUNCTION_fixnormz_D
+inline INT fixnormz_D(LONG value) {
+ INT result;
+#if defined(__ARM_ARCH_8__)
+ asm("clz %w0, %w1 " : "=r"(result) : "r"(value));
+#else
+ asm("clz %0, %1 " : "=r"(result) : "r"(value));
+#endif
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixnormz_D */
+
+#ifdef FUNCTION_fixnorm_D
+inline INT fixnorm_D(LONG value) {
+ if (!value) return 0;
+ if (value < 0) value = ~value;
+ return fixnormz_D(value) - 1;
+}
+#endif /* #ifdef FUNCTION_fixnorm_D */
+
+#ifdef FUNCTION_fixnormz_S
+inline INT fixnormz_S(SHORT value) {
+ INT result;
+ result = (LONG)(value << 16);
+ if (result == 0)
+ result = 16;
+ else
+ result = fixnormz_D(result);
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixnormz_S */
+
+#ifdef FUNCTION_fixnorm_S
+inline INT fixnorm_S(SHORT value) {
+ LONG lvalue = (LONG)(value << 16);
+ if (!lvalue) return 0;
+ if (lvalue < 0) lvalue = ~lvalue;
+ return fixnormz_D(lvalue) - 1;
+}
+#endif /* #ifdef FUNCTION_fixnorm_S */
+
+#endif
#endif /* arm toolchain */
#endif /* __arm__ */
+#endif /* !defined(CLZ_ARM_H) */
diff --git a/libFDK/include/arm/cplx_mul.h b/libFDK/include/arm/cplx_mul.h
deleted file mode 100644
index 8b48031..0000000
--- a/libFDK/include/arm/cplx_mul.h
+++ /dev/null
@@ -1,214 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
-
- Author(s):
- Description: fixed point intrinsics
-
-******************************************************************************/
-
-#if defined(__arm__) && defined(__GNUC__) /* cppp replaced: elif */
-
-#if defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__)
- #define FUNCTION_cplxMultDiv2_32x16
- #define FUNCTION_cplxMultDiv2_32x16X2
- //#define FUNCTION_cplxMult_32x16
- //#define FUNCTION_cplxMult_32x16X2
-#endif
-
-#define FUNCTION_cplxMultDiv2_32x32X2
-//#define FUNCTION_cplxMult_32x32X2
-
-#ifdef FUNCTION_cplxMultDiv2_32x16
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SPK wpk )
-{
- LONG tmp1,tmp2;
- const LONG w = wpk.w;
-
- asm("smulwt %0, %3, %4;\n"
- "rsb %1,%0,#0;\n"
- "smlawb %0, %2, %4, %1;\n"
- "smulwt %1, %2, %4;\n"
- "smlawb %1, %3, %4, %1;\n"
- : "=&r"(tmp1), "=&r"(tmp2)
- : "r"(a_Re), "r"(a_Im), "r"(w)
- );
-
- *c_Re = tmp1;
- *c_Im = tmp2;
-}
-#endif /* FUNCTION_cplxMultDiv2_32x16 */
-
-#ifdef FUNCTION_cplxMultDiv2_32x16X2
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SGL b_Re,
- const FIXP_SGL b_Im)
-{
- LONG tmp1, tmp2;
-
- asm("smulwb %0, %3, %5;\n" /* %7 = -a_Im * b_Im */
- "rsb %1,%0,#0;\n"
- "smlawb %0, %2, %4, %1;\n" /* tmp1 = a_Re * b_Re - a_Im * b_Im */
- "smulwb %1, %2, %5;\n" /* %7 = a_Re * b_Im */
- "smlawb %1, %3, %4, %1;\n" /* tmp2 = a_Im * b_Re + a_Re * b_Im */
- : "=&r"(tmp1), "=&r"(tmp2)
- : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im)
- );
-
- *c_Re = tmp1;
- *c_Im = tmp2;
-}
-#endif /* FUNCTION_cplxMultDiv2_32x16X2 */
-
-#ifdef FUNCTION_cplxMultAddDiv2_32x16X2
-inline void cplxMultAddDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SGL b_Re,
- const FIXP_SGL b_Im)
-{
- LONG tmp1, tmp2;
-
- asm("smulwb %0, %3, %5;\n"
- "rsb %1,%0,#0;\n"
- "smlawb %0, %2, %4, %1;\n"
- "smulwb %1, %2, %5;\n"
- "smlawb %1, %3, %4, %1;\n"
- : "=&r"(tmp1), "=&r"(tmp2)
- : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im)
- );
-
- *c_Re += tmp1;
- *c_Im += tmp2;
-}
-#endif /* FUNCTION_cplxMultAddDiv2_32x16X2 */
-
-
-#ifdef FUNCTION_cplxMultDiv2_32x32X2
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_DBL b_Re,
- const FIXP_DBL b_Im)
-{
- LONG tmp1, tmp2;
-
-#ifdef __ARM_ARCH_6__
- asm(
- "smmul %0, %2, %4;\n" /* tmp1 = a_Re * b_Re */
- "smmls %0, %3, %5, %0;\n" /* tmp1 -= a_Im * b_Im */
- "smmul %1, %2, %5;\n" /* tmp2 = a_Re * b_Im */
- "smmla %1, %3, %4, %1;\n" /* tmp2 += a_Im * b_Re */
- : "=&r"(tmp1), "=&r"(tmp2)
- : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im)
- : "r0"
- );
-#else
- LONG discard;
- asm(
- "smull %2, %0, %7, %6;\n" /* tmp1 = -a_Im * b_Im */
- "smlal %2, %0, %3, %5;\n" /* tmp1 += a_Re * b_Re */
- "smull %2, %1, %3, %6;\n" /* tmp2 = a_Re * b_Im */
- "smlal %2, %1, %4, %5;\n" /* tmp2 += a_Im * b_Re */
- : "=&r"(tmp1), "=&r"(tmp2), "=&r"(discard)
- : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im), "r"(-a_Im)
- );
- #endif
- *c_Re = tmp1;
- *c_Im = tmp2;
-}
-#endif /* FUNCTION_cplxMultDiv2_32x32X2 */
-
-
-#endif
-
diff --git a/libFDK/include/arm/cplx_mul_arm.h b/libFDK/include/arm/cplx_mul_arm.h
new file mode 100644
index 0000000..a448e33
--- /dev/null
+++ b/libFDK/include/arm/cplx_mul_arm.h
@@ -0,0 +1,201 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description: fixed point intrinsics
+
+*******************************************************************************/
+
+#if !defined(CPLX_MUL_ARM_H)
+#define CPLX_MUL_ARM_H
+
+#if defined(__arm__) && defined(__GNUC__)
+
+#if defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__) || \
+ defined(__ARM_ARCH_8__)
+#define FUNCTION_cplxMultDiv2_32x16
+#define FUNCTION_cplxMultDiv2_32x16X2
+#endif
+
+#define FUNCTION_cplxMultDiv2_32x32X2
+#ifdef FUNCTION_cplxMultDiv2_32x32X2
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DBL b_Re,
+ const FIXP_DBL b_Im) {
+ LONG tmp1, tmp2;
+
+#ifdef __ARM_ARCH_8__
+ asm("smull %x0, %w2, %w4; \n" /* tmp1 = a_Re * b_Re */
+ "smull %x1, %w2, %w5; \n" /* tmp2 = a_Re * b_Im */
+ "smsubl %x0, %w3, %w5, %x0; \n" /* tmp1 -= a_Im * b_Im */
+ "smaddl %x1, %w3, %w4, %x1; \n" /* tmp2 += a_Im * b_Re */
+ "asr %x0, %x0, #32 \n"
+ "asr %x1, %x1, #32 \n"
+ : "=&r"(tmp1), "=&r"(tmp2)
+ : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im));
+#elif defined(__ARM_ARCH_6__)
+ asm("smmul %0, %2, %4;\n" /* tmp1 = a_Re * b_Re */
+ "smmls %0, %3, %5, %0;\n" /* tmp1 -= a_Im * b_Im */
+ "smmul %1, %2, %5;\n" /* tmp2 = a_Re * b_Im */
+ "smmla %1, %3, %4, %1;\n" /* tmp2 += a_Im * b_Re */
+ : "=&r"(tmp1), "=&r"(tmp2)
+ : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im));
+#else
+ LONG discard;
+ asm("smull %2, %0, %7, %6;\n" /* tmp1 = -a_Im * b_Im */
+ "smlal %2, %0, %3, %5;\n" /* tmp1 += a_Re * b_Re */
+ "smull %2, %1, %3, %6;\n" /* tmp2 = a_Re * b_Im */
+ "smlal %2, %1, %4, %5;\n" /* tmp2 += a_Im * b_Re */
+ : "=&r"(tmp1), "=&r"(tmp2), "=&r"(discard)
+ : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im), "r"(-a_Im));
+#endif
+ *c_Re = tmp1;
+ *c_Im = tmp2;
+}
+#endif /* FUNCTION_cplxMultDiv2_32x32X2 */
+
+#if defined(FUNCTION_cplxMultDiv2_32x16)
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, FIXP_SPK wpk) {
+#ifdef __ARM_ARCH_8__
+ FIXP_DBL b_Im = FX_SGL2FX_DBL(wpk.v.im);
+ FIXP_DBL b_Re = FX_SGL2FX_DBL(wpk.v.re);
+ cplxMultDiv2(c_Re, c_Im, a_Re, a_Im, b_Re, b_Im);
+#else
+ LONG tmp1, tmp2;
+ const LONG w = wpk.w;
+ asm("smulwt %0, %3, %4;\n"
+ "rsb %1,%0,#0;\n"
+ "smlawb %0, %2, %4, %1;\n"
+ "smulwt %1, %2, %4;\n"
+ "smlawb %1, %3, %4, %1;\n"
+ : "=&r"(tmp1), "=&r"(tmp2)
+ : "r"(a_Re), "r"(a_Im), "r"(w));
+ *c_Re = tmp1;
+ *c_Im = tmp2;
+#endif
+}
+#endif /* FUNCTION_cplxMultDiv2_32x16 */
+
+#ifdef FUNCTION_cplxMultDiv2_32x16X2
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+#ifdef __ARM_ARCH_8__
+ FIXP_DBL b_re = FX_SGL2FX_DBL(b_Re);
+ FIXP_DBL b_im = FX_SGL2FX_DBL(b_Im);
+ cplxMultDiv2(c_Re, c_Im, a_Re, a_Im, b_re, b_im);
+#else
+ LONG tmp1, tmp2;
+
+ asm("smulwb %0, %3, %5;\n" /* %7 = -a_Im * b_Im */
+ "rsb %1,%0,#0;\n"
+ "smlawb %0, %2, %4, %1;\n" /* tmp1 = a_Re * b_Re - a_Im * b_Im */
+ "smulwb %1, %2, %5;\n" /* %7 = a_Re * b_Im */
+ "smlawb %1, %3, %4, %1;\n" /* tmp2 = a_Im * b_Re + a_Re * b_Im */
+ : "=&r"(tmp1), "=&r"(tmp2)
+ : "r"(a_Re), "r"(a_Im), "r"(b_Re), "r"(b_Im));
+
+ *c_Re = tmp1;
+ *c_Im = tmp2;
+#endif
+}
+#endif /* FUNCTION_cplxMultDiv2_32x16X2 */
+
+#endif
+
+#endif /* !defined(CPLX_MUL_ARM_H) */
diff --git a/libFDK/include/arm/fixmadd_arm.h b/libFDK/include/arm/fixmadd_arm.h
index 111147b..1378660 100644
--- a/libFDK/include/arm/fixmadd_arm.h
+++ b/libFDK/include/arm/fixmadd_arm.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,82 +90,131 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(FIXMADD_ARM_H)
+#define FIXMADD_ARM_H
#if defined(__arm__)
- /* ############################################################################# */
- #if defined(__GNUC__) && defined(__arm__) && !defined(__SYMBIAN32__) /* cppp replaced: elif */
- /* ############################################################################# */
- /* ARM GNU GCC */
-
- #define FUNCTION_fixmadddiv2_DD
-
- #ifdef __ARM_ARCH_6__
- inline FIXP_DBL fixmadddiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
- INT result;
- asm ("smmla %0, %1, %2, %3;\n"
- : "=r" (result)
- : "r" (a), "r" (b), "r"(x) );
- return result ;
- }
- #define FUNCTION_fixmsubdiv2_DD
- inline FIXP_DBL fixmsubdiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
- INT result;
- asm ("smmls %0, %1, %2, %3;\n"
- : "=r" (result)
- : "r" (a), "r" (b), "r"(x) );
- return result ;
- }
- #else /* __ARM_ARCH_6__ */
- inline FIXP_DBL fixmadddiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
- INT discard, result = x;
- asm ("smlal %0, %1, %2, %3;\n"
- : "=r" (discard), "+r" (result)
- : "r" (a), "r" (b) );
- return result ;
- }
- #endif /* __ARM_ARCH_6__ */
-
- #if defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__)
-
- #define FUNCTION_fixmadddiv2_DS
-
- inline FIXP_DBL fixmadddiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
- INT result;
- asm("smlawb %0, %1, %2, %3 "
- : "=r" (result)
- : "r" (a), "r" (b), "r" (x) );
- return result ;
- }
-
- #endif /* defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__) */
-
- #define FUNCTION_fixmadddiv2BitExact_DD
- #define fixmadddiv2BitExact_DD(a, b, c) fixmadddiv2_DD(a, b, c)
-
- #define FUNCTION_fixmsubdiv2BitExact_DD
- inline FIXP_DBL fixmsubdiv2BitExact_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
- return x - fixmuldiv2BitExact_DD(a, b);
- }
-
- #define FUNCTION_fixmadddiv2BitExact_DS
- #define fixmadddiv2BitExact_DS(a, b, c) fixmadddiv2_DS(a, b, c)
-
- #define FUNCTION_fixmsubdiv2BitExact_DS
- inline FIXP_DBL fixmsubdiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
- return x - fixmuldiv2BitExact_DS(a, b);
- }
- /* ############################################################################# */
- #endif /* toolchain */
- /* ############################################################################# */
+/* #############################################################################
+ */
+#if defined(__GNUC__) && defined(__arm__)
+/* #############################################################################
+ */
+/* ARM GNU GCC */
+
+#ifdef __ARM_ARCH_8__
+#define FUNCTION_fixmadddiv2_DD
+#ifdef FUNCTION_fixmadddiv2_DD
+inline FIXP_DBL fixmadddiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ INT64 result;
+ asm("smull %x0, %w1, %w2; \n"
+ "asr %x0, %x0, #32; \n"
+ "add %w0, %w3, %w0; \n"
+ : "=&r"(result)
+ : "r"(a), "r"(b), "r"(x));
+ return (INT)result;
+}
+#endif /* #ifdef FUNCTION_fixmadddiv2_DD */
+
+#define FUNCTION_fixmsubdiv2_DD
+#ifdef FUNCTION_fixmsubdiv2_DD
+inline FIXP_DBL fixmsubdiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ INT64 result;
+ asm("smull %x0, %w1, %w2; \n"
+ "asr %x0, %x0, #32; \n"
+ "sub %w0, %w3, %w0; \n"
+ : "=&r"(result)
+ : "r"(a), "r"(b), "r"(x));
+ return (INT)result;
+}
+#endif /* #ifdef FUNCTION_fixmsubdiv2_DD */
+
+#elif defined(__ARM_ARCH_6__)
+#define FUNCTION_fixmadddiv2_DD
+#ifdef FUNCTION_fixmadddiv2_DD
+inline FIXP_DBL fixmadddiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ INT result;
+ asm("smmla %0, %1, %2, %3;\n" : "=r"(result) : "r"(a), "r"(b), "r"(x));
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixmadddiv2_DD */
+
+#define FUNCTION_fixmsubdiv2_DD
+#ifdef FUNCTION_fixmsubdiv2_DD
+inline FIXP_DBL fixmsubdiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ INT result;
+ asm("smmls %0, %1, %2, %3;\n" : "=r"(result) : "r"(a), "r"(b), "r"(x));
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixmsubdiv2_DD */
+
+#else
+#define FUNCTION_fixmadddiv2_DD
+#ifdef FUNCTION_fixmadddiv2_DD
+inline FIXP_DBL fixmadddiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ INT discard = 0;
+ INT result = x;
+ asm("smlal %0, %1, %2, %3;\n" : "+r"(discard), "+r"(result) : "r"(a), "r"(b));
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixmadddiv2_DD */
+#endif
+
+#if defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__)
+
+#define FUNCTION_fixmadddiv2_DS
+#ifdef FUNCTION_fixmadddiv2_DS
+inline FIXP_DBL fixmadddiv2_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+ INT result;
+ asm("smlawb %0, %1, %2, %3 " : "=r"(result) : "r"(a), "r"(b), "r"(x));
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixmadddiv2_DS */
+
+#endif /* defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__) */
+
+#define FUNCTION_fixmadddiv2BitExact_DD
+#ifdef FUNCTION_fixmadddiv2BitExact_DD
+#define fixmadddiv2BitExact_DD(a, b, c) fixmadddiv2_DD(a, b, c)
+#endif /* #ifdef FUNCTION_fixmadddiv2BitExact_DD */
+
+#define FUNCTION_fixmsubdiv2BitExact_DD
+#ifdef FUNCTION_fixmsubdiv2BitExact_DD
+inline FIXP_DBL fixmsubdiv2BitExact_DD(FIXP_DBL x, const FIXP_DBL a,
+ const FIXP_DBL b) {
+ return x - fixmuldiv2BitExact_DD(a, b);
+}
+#endif /* #ifdef FUNCTION_fixmsubdiv2BitExact_DD */
+
+#define FUNCTION_fixmadddiv2BitExact_DS
+#ifdef FUNCTION_fixmadddiv2BitExact_DS
+#define fixmadddiv2BitExact_DS(a, b, c) fixmadddiv2_DS(a, b, c)
+#endif /* #ifdef FUNCTION_fixmadddiv2BitExact_DS */
+
+#define FUNCTION_fixmsubdiv2BitExact_DS
+#ifdef FUNCTION_fixmsubdiv2BitExact_DS
+inline FIXP_DBL fixmsubdiv2BitExact_DS(FIXP_DBL x, const FIXP_DBL a,
+ const FIXP_SGL b) {
+ return x - fixmuldiv2BitExact_DS(a, b);
+}
+#endif /* #ifdef FUNCTION_fixmsubdiv2BitExact_DS */
+
+/* #############################################################################
+ */
+#endif /* toolchain */
+ /* #############################################################################
+ */
#endif /* __arm__ */
+#endif /* !defined(FIXMADD_ARM_H) */
diff --git a/libFDK/include/arm/fixmul_arm.h b/libFDK/include/arm/fixmul_arm.h
index 2f04705..077e5c6 100644
--- a/libFDK/include/arm/fixmul_arm.h
+++ b/libFDK/include/arm/fixmul_arm.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,64 +90,109 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(FIXMUL_ARM_H)
+#define FIXMUL_ARM_H
#if defined(__arm__)
-#if defined(__GNUC__) && defined(__arm__) /* cppp replaced: elif */
+#if defined(__GNUC__) && defined(__arm__)
/* ARM with GNU compiler */
#define FUNCTION_fixmuldiv2_DD
#define FUNCTION_fixmuldiv2BitExact_DD
-#define fixmuldiv2BitExact_DD(a,b) fixmuldiv2_DD(a,b)
+#ifdef FUNCTION_fixmuldiv2BitExact_DD
+#define fixmuldiv2BitExact_DD(a, b) fixmuldiv2_DD(a, b)
+#endif /* #ifdef FUNCTION_fixmuldiv2BitExact_DD */
+
#define FUNCTION_fixmulBitExact_DD
-#define fixmulBitExact_DD(a,b) fixmul_DD(a,b)
+#ifdef FUNCTION_fixmulBitExact_DD
+#define fixmulBitExact_DD(a, b) (fixmuldiv2BitExact_DD(a, b) << 1)
+#endif /* #ifdef FUNCTION_fixmulBitExact_DD */
#define FUNCTION_fixmuldiv2BitExact_DS
-#define fixmuldiv2BitExact_DS(a,b) fixmuldiv2_DS(a,b)
+#ifdef FUNCTION_fixmuldiv2BitExact_DS
+#define fixmuldiv2BitExact_DS(a, b) fixmuldiv2_DS(a, b)
+#endif /* #ifdef FUNCTION_fixmuldiv2BitExact_DS */
#define FUNCTION_fixmulBitExact_DS
-#define fixmulBitExact_DS(a,b) fixmul_DS(a,b)
-
-#if defined(__ARM_ARCH_6__) || defined(__TARGET_ARCH_7E_M)
-inline INT fixmuldiv2_DD (const INT a, const INT b)
-{
- INT result ;
- __asm__ ("smmul %0, %1, %2" : "=r" (result)
- : "r" (a), "r" (b)) ;
- return result ;
-}
+#ifdef FUNCTION_fixmulBitExact_DS
+#define fixmulBitExact_DS(a, b) fixmul_DS(a, b)
+#endif /* #ifdef FUNCTION_fixmulBitExact_DS */
+
+#ifdef FUNCTION_fixmuldiv2_DD
+inline INT fixmuldiv2_DD(const INT a, const INT b) {
+ INT result;
+#if defined(__ARM_ARCH_8__)
+ INT64 result64;
+ __asm__(
+ "smull %x0, %w1, %w2;\n"
+ "asr %x0, %x0, #32; "
+ : "=r"(result64)
+ : "r"(a), "r"(b));
+ result = (INT)result64;
+#elif defined(__ARM_ARCH_6__) || defined(__TARGET_ARCH_7E_M)
+ __asm__("smmul %0, %1, %2" : "=r"(result) : "r"(a), "r"(b));
#else
-inline INT fixmuldiv2_DD (const INT a, const INT b)
-{
- INT discard, result ;
- __asm__ ("smull %0, %1, %2, %3" : "=&r" (discard), "=r" (result)
- : "r" (a), "r" (b)) ;
- return result ;
-}
+ INT discard;
+ __asm__("smull %0, %1, %2, %3"
+ : "=&r"(discard), "=r"(result)
+ : "r"(a), "r"(b));
#endif
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixmuldiv2_DD */
-#if defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__)
+#if defined(__ARM_ARCH_8__)
#define FUNCTION_fixmuldiv2_SD
-inline INT fixmuldiv2_SD (const SHORT a, const INT b)
-{
- INT result ;
- __asm__ ("smulwb %0, %1, %2"
- : "=r" (result)
- : "r" (b), "r" (a)) ;
- return result ;
+#ifdef FUNCTION_fixmuldiv2_SD
+inline INT fixmuldiv2_SD(const SHORT a, const INT b) {
+ return fixmuldiv2_DD((INT)(a << 16), b);
}
+#endif /* #ifdef FUNCTION_fixmuldiv2_SD */
+#elif defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_6__)
+#define FUNCTION_fixmuldiv2_SD
+#ifdef FUNCTION_fixmuldiv2_SD
+inline INT fixmuldiv2_SD(const SHORT a, const INT b) {
+ INT result;
+ __asm__("smulwb %0, %1, %2" : "=r"(result) : "r"(b), "r"(a));
+ return result;
+}
+#endif /* #ifdef FUNCTION_fixmuldiv2_SD */
#endif
+#define FUNCTION_fixmul_DD
+#ifdef FUNCTION_fixmul_DD
+#if defined(__ARM_ARCH_8__)
+inline INT fixmul_DD(const INT a, const INT b) {
+ INT64 result64;
+
+ __asm__(
+ "smull %x0, %w1, %w2;\n"
+ "asr %x0, %x0, #31; "
+ : "=r"(result64)
+ : "r"(a), "r"(b));
+ return (INT)result64;
+}
+#else
+inline INT fixmul_DD(const INT a, const INT b) {
+ return (fixmuldiv2_DD(a, b) << 1);
+}
+#endif /* __ARM_ARCH_8__ */
+#endif /* #ifdef FUNCTION_fixmul_DD */
+
#endif /* defined(__GNUC__) && defined(__arm__) */
#endif /* __arm__ */
+#endif /* !defined(FIXMUL_ARM_H) */
diff --git a/libFDK/include/arm/scale.h b/libFDK/include/arm/scale.h
deleted file mode 100644
index cbb81dc..0000000
--- a/libFDK/include/arm/scale.h
+++ /dev/null
@@ -1,152 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/******************************** Fraunhofer IIS ***************************
-
- Author(s):
- Description: ARM scaling operations
-
-******************************************************************************/
-
-#if defined(__GNUC__) /* GCC Compiler */ /* cppp replaced: elif */
-
-#if defined(__ARM_ARCH_6__)
-
-inline static INT shiftRightSat(INT src, int scale)
-{
- INT result;
- asm(
- "ssat %0,%2,%0;\n"
-
- : "=&r"(result)
- : "r"(src>>scale), "M"(SAMPLE_BITS)
- );
-
- return result;
-}
-
- #define SATURATE_INT_PCM_RIGHT_SHIFT(src, scale) shiftRightSat(src, scale)
-
-inline static INT shiftLeftSat(INT src, int scale)
-{
- INT result;
- asm(
- "ssat %0,%2,%0;\n"
-
- : "=&r"(result)
- : "r"(src<<scale), "M"(SAMPLE_BITS)
- );
-
- return result;
-}
-
- #define SATURATE_INT_PCM_LEFT_SHIFT(src, scale) shiftLeftSat(src, scale)
-
-#endif /* __ARM_ARCH_6__ */
-
-#endif /* compiler selection */
-
-#define FUNCTION_scaleValueInPlace
-inline
-void scaleValueInPlace(FIXP_DBL *value, /*!< Value */
- INT scalefactor /*!< Scalefactor */
- )
-{
- INT newscale;
- if ((newscale = scalefactor) >= 0)
- *value <<= newscale;
- else
- *value >>= -newscale;
-}
-
-
- #define SATURATE_RIGHT_SHIFT(src, scale, dBits) \
- ( (((LONG)(src) ^ ((LONG)(src) >> (DFRACT_BITS-1)))>>(scale)) > (LONG)(((1U)<<((dBits)-1))-1)) \
- ? ((LONG)(src) >> (DFRACT_BITS-1)) ^ (LONG)(((1U)<<((dBits)-1))-1) \
- : ((LONG)(src) >> (scale))
-
- #define SATURATE_LEFT_SHIFT(src, scale, dBits) \
- ( ((LONG)(src) ^ ((LONG)(src) >> (DFRACT_BITS-1))) > ((LONG)(((1U)<<((dBits)-1))-1) >> (scale)) ) \
- ? ((LONG)(src) >> (DFRACT_BITS-1)) ^ (LONG)(((1U)<<((dBits)-1))-1) \
- : ((LONG)(src) << (scale))
-
diff --git a/libFDK/include/arm/scale_arm.h b/libFDK/include/arm/scale_arm.h
new file mode 100644
index 0000000..0bf4f66
--- /dev/null
+++ b/libFDK/include/arm/scale_arm.h
@@ -0,0 +1,163 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description: ARM scaling operations
+
+*******************************************************************************/
+
+#if !defined(SCALE_ARM_H)
+#define SCALE_ARM_H
+
+#if defined(__GNUC__) /* GCC Compiler */
+
+#if defined(__ARM_ARCH_6__)
+
+inline static INT shiftRightSat(INT src, int scale) {
+ INT result;
+ asm("ssat %0,%2,%0;\n"
+
+ : "=&r"(result)
+ : "r"(src >> scale), "M"(SAMPLE_BITS));
+
+ return result;
+}
+
+#define SATURATE_INT_PCM_RIGHT_SHIFT(src, scale) shiftRightSat(src, scale)
+
+inline static INT shiftLeftSat(INT src, int scale) {
+ INT result;
+ asm("ssat %0,%2,%0;\n"
+
+ : "=&r"(result)
+ : "r"(src << scale), "M"(SAMPLE_BITS));
+
+ return result;
+}
+
+#define SATURATE_INT_PCM_LEFT_SHIFT(src, scale) shiftLeftSat(src, scale)
+
+#endif /* __ARM_ARCH_6__ */
+
+#endif /* compiler selection */
+
+#define FUNCTION_scaleValueInPlace
+#ifdef FUNCTION_scaleValueInPlace
+inline void scaleValueInPlace(FIXP_DBL *value, /*!< Value */
+ INT scalefactor /*!< Scalefactor */
+) {
+ INT newscale;
+ if ((newscale = scalefactor) >= 0)
+ *value <<= newscale;
+ else
+ *value >>= -newscale;
+}
+#endif /* #ifdef FUNCTION_scaleValueInPlace */
+
+#define SATURATE_RIGHT_SHIFT(src, scale, dBits) \
+ ((((LONG)(src) ^ ((LONG)(src) >> (DFRACT_BITS - 1))) >> (scale)) > \
+ (LONG)(((1U) << ((dBits)-1)) - 1)) \
+ ? ((LONG)(src) >> (DFRACT_BITS - 1)) ^ (LONG)(((1U) << ((dBits)-1)) - 1) \
+ : ((LONG)(src) >> (scale))
+
+#define SATURATE_LEFT_SHIFT(src, scale, dBits) \
+ (((LONG)(src) ^ ((LONG)(src) >> (DFRACT_BITS - 1))) > \
+ ((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \
+ ? ((LONG)(src) >> (DFRACT_BITS - 1)) ^ (LONG)(((1U) << ((dBits)-1)) - 1) \
+ : ((LONG)(src) << (scale))
+
+#endif /* !defined(SCALE_ARM_H) */
diff --git a/libFDK/include/arm/scramble.h b/libFDK/include/arm/scramble.h
deleted file mode 100644
index 82d0338..0000000
--- a/libFDK/include/arm/scramble.h
+++ /dev/null
@@ -1,158 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
-
- Author(s):
- Description: bitreversal of input data
-
-******************************************************************************/
-
-#if defined(FUNCTION_scramble)
-#if defined(__GNUC__) /* cppp replaced: elif */
-
-#define FUNCTION_scramble
-
-#if defined(__ARM_ARCH_5TE__)
-#define USE_LDRD_STRD /* LDRD requires 8 byte data alignment. */
-#endif
-
-inline void scramble(FIXP_DBL x [], INT n) {
- FDK_ASSERT(!(((INT)x)&(ALIGNMENT_DEFAULT-1)));
- asm("mov r2, #1;\n" /* r2(m) = 1; */
- "sub r3, %1, #1;\n" /* r3 = n-1; */
- "mov r4, #0;\n" /* r4(j) = 0; */
-
-"scramble_m_loop%=:\n" /* { */
- "mov r5, %1;\n" /* r5(k) = 1; */
-
-"scramble_k_loop%=:\n" /* { */
- "mov r5, r5, lsr #1;\n" /* k >>= 1; */
- "eor r4, r4, r5;\n" /* j ^=k; */
- "ands r10, r4, r5;\n" /* r10 = r4 & r5; */
- "beq scramble_k_loop%=;\n" /* } while (r10 == 0); */
-
- "cmp r4, r2;\n" /* if (r4 < r2) break; */
- "bcc scramble_m_loop_end%=;\n"
-
-#ifdef USE_LDRD_STRD
- "mov r5, r2, lsl #3;\n" /* m(r5) = r2*4*2 */
- "ldrd r10, [%0, r5];\n" /* r10 = x[r5], x7 = x[r5+1] */
- "mov r6, r4, lsl #3;\n" /* j(r6) = r4*4*2 */
- "ldrd r8, [%0, r6];\n" /* r8 = x[r6], r9 = x[r6+1]; */
- "strd r10, [%0, r6];\n" /* x[r6,r6+1] = r10,r11; */
- "strd r8, [%0, r5];\n" /* x[r5,r5+1] = r8,r9; */
-#else
- "mov r5, r2, lsl #3;\n" /* m(r5) = r2*4*2 */
- "ldr r10, [%0, r5];\n"
- "mov r6, r4, lsl #3;\n" /* j(r6) = r4*4*2 */
- "ldr r11, [%0, r6];\n"
-
- "str r10, [%0, r6];\n"
- "str r11, [%0, r5];\n"
-
- "add r5, r5, #4;"
- "ldr r10, [%0, r5];\n"
- "add r6, r6, #4;"
- "ldr r11, [%0, r6];\n"
- "str r10, [%0, r6];\n"
- "str r11, [%0, r5];\n"
-#endif
-"scramble_m_loop_end%=:\n"
- "add r2, r2, #1;\n" /* r2++; */
- "cmp r2, r3;\n"
- "bcc scramble_m_loop%=;\n" /* } while (r2(m) < r3(n-1)); */
- :
- : "r"(x), "r"(n)
-#ifdef USE_LDRD_STRD
- : "r2","r3", "r4","r5", "r10","r11", "r8","r9", "r6" );
-#else
- : "r2","r3", "r4","r5", "r10","r11", "r6" );
-#endif
-}
-#else
-/* Force C implementation if no assembler version available. */
-#undef FUNCTION_scramble
-#endif /* Toolchain selection. */
-
-#endif /* defined(FUNCTION_scramble) */
diff --git a/libFDK/include/arm/scramble_arm.h b/libFDK/include/arm/scramble_arm.h
new file mode 100644
index 0000000..a7cfe65
--- /dev/null
+++ b/libFDK/include/arm/scramble_arm.h
@@ -0,0 +1,174 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description: bitreversal of input data
+
+*******************************************************************************/
+
+#if !defined(SCRAMBLE_ARM_H)
+#define SCRAMBLE_ARM_H
+
+#if defined(FUNCTION_scramble)
+#if defined(__GNUC__)
+
+#define FUNCTION_scramble
+
+#if defined(__ARM_ARCH_5TE__)
+#define USE_LDRD_STRD /* LDRD requires 8 byte data alignment. */
+#endif
+
+inline void scramble(FIXP_DBL x[], INT n) {
+ FDK_ASSERT(!(((INT)x) & (ALIGNMENT_DEFAULT - 1)));
+ asm("mov r2, #1;\n" /* r2(m) = 1; */
+ "sub r3, %1, #1;\n" /* r3 = n-1; */
+ "mov r4, #0;\n" /* r4(j) = 0; */
+
+ "scramble_m_loop%=:\n" /* { */
+ "mov r5, %1;\n" /* r5(k) = 1; */
+
+ "scramble_k_loop%=:\n" /* { */
+ "mov r5, r5, lsr #1;\n" /* k >>= 1; */
+ "eor r4, r4, r5;\n" /* j ^=k; */
+ "ands r10, r4, r5;\n" /* r10 = r4 & r5; */
+ "beq scramble_k_loop%=;\n" /* } while (r10 == 0); */
+
+ "cmp r4, r2;\n" /* if (r4 < r2) break; */
+ "bcc scramble_m_loop_end%=;\n"
+
+#ifdef USE_LDRD_STRD
+ "mov r5, r2, lsl #3;\n" /* m(r5) = r2*4*2 */
+ "ldrd r10, [%0, r5];\n" /* r10 = x[r5], x7 = x[r5+1] */
+ "mov r6, r4, lsl #3;\n" /* j(r6) = r4*4*2 */
+ "ldrd r8, [%0, r6];\n" /* r8 = x[r6], r9 = x[r6+1]; */
+ "strd r10, [%0, r6];\n" /* x[r6,r6+1] = r10,r11; */
+ "strd r8, [%0, r5];\n" /* x[r5,r5+1] = r8,r9; */
+#else
+ "mov r5, r2, lsl #3;\n" /* m(r5) = r2*4*2 */
+ "ldr r10, [%0, r5];\n"
+ "mov r6, r4, lsl #3;\n" /* j(r6) = r4*4*2 */
+ "ldr r11, [%0, r6];\n"
+
+ "str r10, [%0, r6];\n"
+ "str r11, [%0, r5];\n"
+
+ "add r5, r5, #4;"
+ "ldr r10, [%0, r5];\n"
+ "add r6, r6, #4;"
+ "ldr r11, [%0, r6];\n"
+ "str r10, [%0, r6];\n"
+ "str r11, [%0, r5];\n"
+#endif
+ "scramble_m_loop_end%=:\n"
+ "add r2, r2, #1;\n" /* r2++; */
+ "cmp r2, r3;\n"
+ "bcc scramble_m_loop%=;\n" /* } while (r2(m) < r3(n-1)); */
+ :
+ : "r"(x), "r"(n)
+#ifdef USE_LDRD_STRD
+ : "r2", "r3", "r4", "r5", "r10", "r11", "r8", "r9", "r6");
+#else
+ : "r2", "r3", "r4", "r5", "r10", "r11", "r6");
+#endif
+}
+#else
+/* Force C implementation if no assembler version available. */
+#undef FUNCTION_scramble
+#endif /* Toolchain selection. */
+
+#endif /* defined(FUNCTION_scramble) */
+#endif /* !defined(SCRAMBLE_ARM_H) */
diff --git a/libFDK/include/autocorr2nd.h b/libFDK/include/autocorr2nd.h
index c2e9595..e01989b 100644
--- a/libFDK/include/autocorr2nd.h
+++ b/libFDK/include/autocorr2nd.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,50 +90,48 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools ***********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser
- Description: fixed point abs definitions
-
-******************************************************************************/
-#ifndef _AUTOCORR_2ND_H
-#define _AUTOCORR_2ND_H
+ Description: fixed point abs definitions
+*******************************************************************************/
+#ifndef AUTOCORR2ND_H
+#define AUTOCORR2ND_H
#include "common_fix.h"
typedef struct {
- FIXP_DBL r00r;
- FIXP_DBL r11r;
- FIXP_DBL r22r;
- FIXP_DBL r01r;
- FIXP_DBL r02r;
- FIXP_DBL r12r;
- FIXP_DBL r01i;
- FIXP_DBL r02i;
- FIXP_DBL r12i;
- FIXP_DBL det;
+ FIXP_DBL r00r;
+ FIXP_DBL r11r;
+ FIXP_DBL r22r;
+ FIXP_DBL r01r;
+ FIXP_DBL r02r;
+ FIXP_DBL r12r;
+ FIXP_DBL r01i;
+ FIXP_DBL r02i;
+ FIXP_DBL r12i;
+ FIXP_DBL det;
int det_scale;
} ACORR_COEFS;
#define LPC_ORDER 2
+INT autoCorr2nd_real(
+ ACORR_COEFS *ac, /*!< Pointer to autocorrelation coeffs */
+ const FIXP_DBL *reBuffer, /*!< Pointer to to real part of spectrum */
+ const int len /*!< Number of qmf slots */
+);
-INT
-autoCorr2nd_real (ACORR_COEFS *ac, /*!< Pointer to autocorrelation coeffs */
- const FIXP_DBL *reBuffer, /*!< Pointer to to real part of spectrum */
- const int len /*!< Number of qmf slots */
- );
-INT
-autoCorr2nd_cplx (ACORR_COEFS *ac, /*!< Pointer to autocorrelation coeffs */
- const FIXP_DBL *reBuffer, /*!< Pointer to to real part of spectrum */
- const FIXP_DBL *imBuffer, /*!< Pointer to imag part of spectrum */
- const int len /*!< Number of qmf slots */
- );
-
+INT autoCorr2nd_cplx(
+ ACORR_COEFS *ac, /*!< Pointer to autocorrelation coeffs */
+ const FIXP_DBL *reBuffer, /*!< Pointer to to real part of spectrum */
+ const FIXP_DBL *imBuffer, /*!< Pointer to imag part of spectrum */
+ const int len /*!< Number of qmf slots */
+);
-#endif /* _AUTOCORR_2ND_H */
+#endif /* AUTOCORR2ND_H */
diff --git a/libFDK/include/clz.h b/libFDK/include/clz.h
index fc612e1..6acdee6 100644
--- a/libFDK/include/clz.h
+++ b/libFDK/include/clz.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): Marc Gayer
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
-#if !defined(__CLZ_H__)
-#define __CLZ_H__
+#if !defined(CLZ_H)
+#define CLZ_H
#include "FDK_archdef.h"
#include "machine_type.h"
@@ -97,15 +109,14 @@ amm-info@iis.fraunhofer.de
#if defined(__arm__)
#include "arm/clz_arm.h"
-#elif defined(__mips__) /* cppp replaced: elif */
+#elif defined(__mips__)
#include "mips/clz_mips.h"
-#elif defined(__x86__) /* cppp replaced: elif */
+#elif defined(__x86__)
#include "x86/clz_x86.h"
#endif /* all cores */
-
/*************************************************************************
*************************************************************************
Software fallbacks for missing functions.
@@ -114,79 +125,78 @@ amm-info@iis.fraunhofer.de
#if !defined(FUNCTION_fixnormz_S)
#ifdef FUNCTION_fixnormz_D
-inline INT fixnormz_S (SHORT a)
-{
- return fixnormz_D((INT)(a));
+inline INT fixnormz_S(SHORT a) {
+ if (a < 0) {
+ return 0;
+ }
+ return fixnormz_D((INT)(a)) - 16;
}
#else
-inline INT fixnormz_S (SHORT a)
-{
- int leadingBits = 0;
- a = ~a;
- while(a & 0x8000) {
- leadingBits++;
- a <<= 1;
- }
-
- return (leadingBits);
+inline INT fixnormz_S(SHORT a) {
+ int leadingBits = 0;
+ a = ~a;
+ while (a & 0x8000) {
+ leadingBits++;
+ a <<= 1;
+ }
+
+ return (leadingBits);
}
#endif
#endif
#if !defined(FUNCTION_fixnormz_D)
-inline INT fixnormz_D (LONG a)
-{
- INT leadingBits = 0;
- a = ~a;
- while(a & 0x80000000) {
- leadingBits++;
- a <<= 1;
- }
-
- return (leadingBits);
+inline INT fixnormz_D(LONG a) {
+ INT leadingBits = 0;
+ a = ~a;
+ while (a & 0x80000000) {
+ leadingBits++;
+ a <<= 1;
+ }
+
+ return (leadingBits);
}
#endif
-
/*****************************************************************************
functionname: fixnorm_D
- description: Count leading ones or zeros of operand val for dfract/LONG INT values.
- Return this value minus 1. Return 0 if operand==0.
+ description: Count leading ones or zeros of operand val for dfract/LONG INT
+values. Return this value minus 1. Return 0 if operand==0.
*****************************************************************************/
#if !defined(FUNCTION_fixnorm_S)
#ifdef FUNCTION_fixnorm_D
-inline INT fixnorm_S(FIXP_SGL val)
-{
- return fixnorm_D((INT)(val));
+inline INT fixnorm_S(FIXP_SGL val) {
+ if (val == (FIXP_SGL)0) {
+ return 0;
+ }
+ return fixnorm_D((INT)(val)) - 16;
}
#else
-inline INT fixnorm_S(FIXP_SGL val)
-{
- INT leadingBits = 0;
- if ( val != (FIXP_SGL)0 ) {
- if ( val < (FIXP_SGL)0 ) {
- val = ~val;
- }
- leadingBits = fixnormz_S(val) - 1;
+inline INT fixnorm_S(FIXP_SGL val) {
+ INT leadingBits = 0;
+ if (val != (FIXP_SGL)0) {
+ if (val < (FIXP_SGL)0) {
+ val = ~val;
}
- return (leadingBits);
+ leadingBits = fixnormz_S(val) - 1;
+ }
+ return (leadingBits);
}
#endif
#endif
#if !defined(FUNCTION_fixnorm_D)
-inline INT fixnorm_D(FIXP_DBL val)
-{
- INT leadingBits = 0;
- if ( val != (FIXP_DBL)0 ) {
- if ( val < (FIXP_DBL)0 ) {
- val = ~val;
- }
- leadingBits = fixnormz_D(val) - 1;
+inline INT fixnorm_D(FIXP_DBL val) {
+ INT leadingBits = 0;
+ if (val != (FIXP_DBL)0) {
+ if (val < (FIXP_DBL)0) {
+ val = ~val;
}
- return (leadingBits);
+ leadingBits = fixnormz_D(val) - 1;
+ }
+ return (leadingBits);
}
#endif
-#endif /* __CLZ_H__ */
+#endif /* CLZ_H */
diff --git a/libFDK/include/common_fix.h b/libFDK/include/common_fix.h
index d2d11f4..8d0dfde 100644
--- a/libFDK/include/common_fix.h
+++ b/libFDK/include/common_fix.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,74 +90,85 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser, M. Gayer
+
Description: Flexible fixpoint library configuration
-******************************************************************************/
+*******************************************************************************/
-#ifndef _COMMON_FIX_H
-#define _COMMON_FIX_H
+#ifndef COMMON_FIX_H
+#define COMMON_FIX_H
#include "FDK_archdef.h"
#include "machine_type.h"
/* ***** Start of former fix.h ****** */
-/* Configure fractional or integer arithmetic */
- #define FIX_FRACT 0 /* Define this to "1" to use fractional arithmetic simulation in class fract instead of integer arithmetic */
- /* 1 for debug with extra runtime overflow checking. */
-
/* Define bit sizes of integer fixpoint fractional data types */
-#define FRACT_BITS 16 /* single precision */
-#define DFRACT_BITS 32 /* double precision */
-#define ACCU_BITS 40 /* double precision plus overflow */
+#define FRACT_BITS 16 /* single precision */
+#define DFRACT_BITS 32 /* double precision */
+#define ACCU_BITS 40 /* double precision plus overflow */
/* Fixpoint equivalent type fot PCM audio time domain data. */
#if defined(SAMPLE_BITS)
#if (SAMPLE_BITS == DFRACT_BITS)
- #define FIXP_PCM FIXP_DBL
- #define FX_PCM2FX_DBL(x) ((FIXP_DBL)(x))
- #define FX_DBL2FX_PCM(x) ((INT_PCM)(x))
+#define FIXP_PCM FIXP_DBL
+#define MAXVAL_FIXP_PCM MAXVAL_DBL
+#define MINVAL_FIXP_PCM MINVAL_DBL
+#define FX_PCM2FX_DBL(x) ((FIXP_DBL)(x))
+#define FX_DBL2FX_PCM(x) ((INT_PCM)(x))
#elif (SAMPLE_BITS == FRACT_BITS)
- #define FIXP_PCM FIXP_SGL
- #define FX_PCM2FX_DBL(x) FX_SGL2FX_DBL((FIXP_SGL)(x))
- #define FX_DBL2FX_PCM(x) FX_DBL2FX_SGL(x)
+#define FIXP_PCM FIXP_SGL
+#define MAXVAL_FIXP_PCM MAXVAL_SGL
+#define MINVAL_FIXP_PCM MINVAL_SGL
+#define FX_PCM2FX_DBL(x) FX_SGL2FX_DBL((FIXP_SGL)(x))
+#define FX_DBL2FX_PCM(x) FX_DBL2FX_SGL(x)
#else
- #error SAMPLE_BITS different from FRACT_BITS or DFRACT_BITS not implemented!
+#error SAMPLE_BITS different from FRACT_BITS or DFRACT_BITS not implemented!
#endif
#endif
/* ****** End of former fix.h ****** */
-#define SGL_MASK ((1UL<<FRACT_BITS)-1) /* 16bit: (2^16)-1 = 0xFFFF */
-
-#define MAX_SHIFT_SGL (FRACT_BITS-1) /* maximum possible shift for FIXP_SGL values */
-#define MAX_SHIFT_DBL (DFRACT_BITS-1) /* maximum possible shift for FIXP_DBL values */
-
-/* Scale factor from/to float/fixpoint values. DO NOT USE THESE VALUES AS SATURATION LIMITS !! */
-#define FRACT_FIX_SCALE ((INT64(1)<<(FRACT_BITS-1)))
-#define DFRACT_FIX_SCALE ((INT64(1)<<(DFRACT_BITS-1)))
-
-/* Max and Min values for saturation purposes. DO NOT USE THESE VALUES AS SCALE VALUES !! */
-#define MAXVAL_SGL ((signed)0x00007FFF) /* this has to be synchronized to FRACT_BITS */
-#define MINVAL_SGL ((signed)0xFFFF8000) /* this has to be synchronized to FRACT_BITS */
-#define MAXVAL_DBL ((signed)0x7FFFFFFF) /* this has to be synchronized to DFRACT_BITS */
-#define MINVAL_DBL ((signed)0x80000000) /* this has to be synchronized to DFRACT_BITS */
-
-
-#define FX_DBL2FXCONST_SGL(val) ( ( ((((val) >> (DFRACT_BITS-FRACT_BITS-1)) + 1) > (((LONG)1<<FRACT_BITS)-1)) && ((LONG)(val) > 0) ) ? \
- (FIXP_SGL)(SHORT)(((LONG)1<<(FRACT_BITS-1))-1):(FIXP_SGL)(SHORT)((((val) >> (DFRACT_BITS-FRACT_BITS-1)) + 1) >> 1) )
-
-
-
-#define shouldBeUnion union /* unions are possible */
-
- typedef SHORT FIXP_SGL;
- typedef LONG FIXP_DBL;
+#define SGL_MASK ((1UL << FRACT_BITS) - 1) /* 16bit: (2^16)-1 = 0xFFFF */
+
+#define MAX_SHIFT_SGL \
+ (FRACT_BITS - 1) /* maximum possible shift for FIXP_SGL values */
+#define MAX_SHIFT_DBL \
+ (DFRACT_BITS - 1) /* maximum possible shift for FIXP_DBL values */
+
+/* Scale factor from/to float/fixpoint values. DO NOT USE THESE VALUES AS
+ * SATURATION LIMITS !! */
+#define FRACT_FIX_SCALE ((INT64(1) << (FRACT_BITS - 1)))
+#define DFRACT_FIX_SCALE ((INT64(1) << (DFRACT_BITS - 1)))
+
+/* Max and Min values for saturation purposes. DO NOT USE THESE VALUES AS SCALE
+ * VALUES !! */
+#define MAXVAL_SGL \
+ ((signed)0x00007FFF) /* this has to be synchronized to FRACT_BITS */
+#define MINVAL_SGL \
+ ((signed)0xFFFF8000) /* this has to be synchronized to FRACT_BITS */
+#define MAXVAL_DBL \
+ ((signed)0x7FFFFFFF) /* this has to be synchronized to DFRACT_BITS */
+#define MINVAL_DBL \
+ ((signed)0x80000000) /* this has to be synchronized to DFRACT_BITS */
+
+#define FX_DBL2FXCONST_SGL(val) \
+ ((((((val) >> (DFRACT_BITS - FRACT_BITS - 1)) + 1) > \
+ (((LONG)1 << FRACT_BITS) - 1)) && \
+ ((LONG)(val) > 0)) \
+ ? (FIXP_SGL)(SHORT)(((LONG)1 << (FRACT_BITS - 1)) - 1) \
+ : (FIXP_SGL)(SHORT)((((val) >> (DFRACT_BITS - FRACT_BITS - 1)) + 1) >> \
+ 1))
+
+#define shouldBeUnion union /* unions are possible */
+
+typedef SHORT FIXP_SGL;
+typedef LONG FIXP_DBL;
/* macros for compile-time conversion of constant float values to fixedpoint */
#define FL2FXCONST_SPC FL2FXCONST_DBL
@@ -154,199 +176,251 @@ amm-info@iis.fraunhofer.de
#define MINVAL_DBL_CONST MINVAL_DBL
#define MINVAL_SGL_CONST MINVAL_SGL
-#define FL2FXCONST_SGL(val) \
-(FIXP_SGL)( ( (val) >= 0) ? \
-((( (double)(val) * (FRACT_FIX_SCALE) + 0.5 ) >= (double)(MAXVAL_SGL) ) ? (SHORT)(MAXVAL_SGL) : (SHORT)( (double)(val) * (double)(FRACT_FIX_SCALE) + 0.5)) : \
-((( (double)(val) * (FRACT_FIX_SCALE) - 0.5) <= (double)(MINVAL_SGL_CONST) ) ? (SHORT)(MINVAL_SGL_CONST) : (SHORT)( (double)(val) * (double)(FRACT_FIX_SCALE) - 0.5)) )
-
-#define FL2FXCONST_DBL(val) \
-(FIXP_DBL)( ( (val) >= 0) ? \
-((( (double)(val) * (DFRACT_FIX_SCALE) + 0.5 ) >= (double)(MAXVAL_DBL) ) ? (LONG)(MAXVAL_DBL) : (LONG)( (double)(val) * (double)(DFRACT_FIX_SCALE) + 0.5)) : \
-((( (double)(val) * (DFRACT_FIX_SCALE) - 0.5) <= (double)(MINVAL_DBL_CONST) ) ? (LONG)(MINVAL_DBL_CONST) : (LONG)( (double)(val) * (double)(DFRACT_FIX_SCALE) - 0.5)) )
-
-/* macros for runtime conversion of float values to integer fixedpoint. NO OVERFLOW CHECK!!! */
+#define FL2FXCONST_SGL(val) \
+ (FIXP_SGL)( \
+ ((val) >= 0) \
+ ? ((((double)(val) * (FRACT_FIX_SCALE) + 0.5) >= \
+ (double)(MAXVAL_SGL)) \
+ ? (SHORT)(MAXVAL_SGL) \
+ : (SHORT)((double)(val) * (double)(FRACT_FIX_SCALE) + 0.5)) \
+ : ((((double)(val) * (FRACT_FIX_SCALE)-0.5) <= \
+ (double)(MINVAL_SGL_CONST)) \
+ ? (SHORT)(MINVAL_SGL_CONST) \
+ : (SHORT)((double)(val) * (double)(FRACT_FIX_SCALE)-0.5)))
+
+#define FL2FXCONST_DBL(val) \
+ (FIXP_DBL)( \
+ ((val) >= 0) \
+ ? ((((double)(val) * (DFRACT_FIX_SCALE) + 0.5) >= \
+ (double)(MAXVAL_DBL)) \
+ ? (LONG)(MAXVAL_DBL) \
+ : (LONG)((double)(val) * (double)(DFRACT_FIX_SCALE) + 0.5)) \
+ : ((((double)(val) * (DFRACT_FIX_SCALE)-0.5) <= \
+ (double)(MINVAL_DBL_CONST)) \
+ ? (LONG)(MINVAL_DBL_CONST) \
+ : (LONG)((double)(val) * (double)(DFRACT_FIX_SCALE)-0.5)))
+
+/* macros for runtime conversion of float values to integer fixedpoint. NO
+ * OVERFLOW CHECK!!! */
#define FL2FX_SPC FL2FX_DBL
-#define FL2FX_SGL(val) ( (val)>0.0f ? (SHORT)( (val)*(float)(FRACT_FIX_SCALE)+0.5f ) : (SHORT)( (val)*(float)(FRACT_FIX_SCALE)-0.5f ) )
-#define FL2FX_DBL(val) ( (val)>0.0f ? (LONG)( (val)*(float)(DFRACT_FIX_SCALE)+0.5f ) : (LONG)( (val)*(float)(DFRACT_FIX_SCALE)-0.5f ) )
-
-/* macros for runtime conversion of fixedpoint values to other fixedpoint. NO ROUNDING!!! */
-#define FX_ACC2FX_SGL(val) ((FIXP_SGL)((val)>>(ACCU_BITS-FRACT_BITS)))
-#define FX_ACC2FX_DBL(val) ((FIXP_DBL)((val)>>(ACCU_BITS-DFRACT_BITS)))
-#define FX_SGL2FX_ACC(val) ((FIXP_ACC)((LONG)(val)<<(ACCU_BITS-FRACT_BITS)))
-#define FX_SGL2FX_DBL(val) ((FIXP_DBL)((LONG)(val)<<(DFRACT_BITS-FRACT_BITS)))
-#define FX_DBL2FX_SGL(val) ((FIXP_SGL)((val)>>(DFRACT_BITS-FRACT_BITS)))
+#define FL2FX_SGL(val) \
+ ((val) > 0.0f ? (SHORT)((val) * (float)(FRACT_FIX_SCALE) + 0.5f) \
+ : (SHORT)((val) * (float)(FRACT_FIX_SCALE)-0.5f))
+#define FL2FX_DBL(val) \
+ ((val) > 0.0f ? (LONG)((val) * (float)(DFRACT_FIX_SCALE) + 0.5f) \
+ : (LONG)((val) * (float)(DFRACT_FIX_SCALE)-0.5f))
+
+/* macros for runtime conversion of fixedpoint values to other fixedpoint. NO
+ * ROUNDING!!! */
+#define FX_ACC2FX_SGL(val) ((FIXP_SGL)((val) >> (ACCU_BITS - FRACT_BITS)))
+#define FX_ACC2FX_DBL(val) ((FIXP_DBL)((val) >> (ACCU_BITS - DFRACT_BITS)))
+#define FX_SGL2FX_ACC(val) ((FIXP_ACC)((LONG)(val) << (ACCU_BITS - FRACT_BITS)))
+#define FX_SGL2FX_DBL(val) \
+ ((FIXP_DBL)((LONG)(val) << (DFRACT_BITS - FRACT_BITS)))
+#define FX_DBL2FX_SGL(val) ((FIXP_SGL)((val) >> (DFRACT_BITS - FRACT_BITS)))
/* ############################################################# */
/* macros for runtime conversion of integer fixedpoint values to float. */
-/* This is just for temporary use and should not be required in a final version! */
-/* #define FX_DBL2FL(val) ((float)(pow(2.,-31.)*(float)val)) */ /* version #1 */
-#define FX_DBL2FL(val) ((float)((double)(val)/(double)DFRACT_FIX_SCALE)) /* version #2 - identical to class dfract cast from dfract to float */
+/* #define FX_DBL2FL(val) ((float)(pow(2.,-31.)*(float)val)) */ /* version #1
+ */
+#define FX_DBL2FL(val) \
+ ((float)((double)(val) / (double)DFRACT_FIX_SCALE)) /* version #2 - \
+ identical to class \
+ dfract cast from \
+ dfract to float */
+#define FX_DBL2DOUBLE(val) (((double)(val) / (double)DFRACT_FIX_SCALE))
/* ############################################################# */
#include "fixmul.h"
-FDK_INLINE LONG fMult(SHORT a, SHORT b) { return fixmul_SS(a, b); }
-FDK_INLINE LONG fMult(SHORT a, LONG b) { return fixmul_SD(a, b); }
-FDK_INLINE LONG fMult(LONG a, SHORT b) { return fixmul_DS(a, b); }
-FDK_INLINE LONG fMult(LONG a, LONG b) { return fixmul_DD(a, b); }
-FDK_INLINE LONG fPow2(LONG a) { return fixpow2_D(a); }
-FDK_INLINE LONG fPow2(SHORT a) { return fixpow2_S(a); }
-
-FDK_INLINE INT fMultI(LONG a, SHORT b) { return ( (INT)(((1<<(FRACT_BITS-2)) +
- fixmuldiv2_DD(a,((INT)b<<FRACT_BITS)))>>(FRACT_BITS-1)) ); }
-
-FDK_INLINE INT fMultIfloor(LONG a, INT b) { return ( (INT)((1 +
- fixmuldiv2_DD(a,(b<<FRACT_BITS))) >> (FRACT_BITS-1)) ); }
-
-FDK_INLINE INT fMultIceil(LONG a, INT b) { return ( (INT)(((INT)0x7fff +
- fixmuldiv2_DD(a,(b<<FRACT_BITS))) >> (FRACT_BITS-1)) ); }
-
-FDK_INLINE LONG fMultDiv2(SHORT a, SHORT b) { return fixmuldiv2_SS(a, b); }
-FDK_INLINE LONG fMultDiv2(SHORT a, LONG b) { return fixmuldiv2_SD(a, b); }
-FDK_INLINE LONG fMultDiv2(LONG a, SHORT b) { return fixmuldiv2_DS(a, b); }
-FDK_INLINE LONG fMultDiv2(LONG a, LONG b) { return fixmuldiv2_DD(a, b); }
-FDK_INLINE LONG fPow2Div2(LONG a) { return fixpow2div2_D(a); }
-FDK_INLINE LONG fPow2Div2(SHORT a) { return fixpow2div2_S(a); }
-
-FDK_INLINE LONG fMultDiv2BitExact(LONG a, LONG b) { return fixmuldiv2BitExact_DD(a, b); }
-FDK_INLINE LONG fMultDiv2BitExact(SHORT a, LONG b) { return fixmuldiv2BitExact_SD(a, b); }
-FDK_INLINE LONG fMultDiv2BitExact(LONG a, SHORT b) { return fixmuldiv2BitExact_DS(a, b); }
-FDK_INLINE LONG fMultBitExact(LONG a, LONG b) { return fixmulBitExact_DD(a, b); }
-FDK_INLINE LONG fMultBitExact(SHORT a, LONG b) { return fixmulBitExact_SD(a, b); }
-FDK_INLINE LONG fMultBitExact(LONG a, SHORT b) { return fixmulBitExact_DS(a, b); }
-
-/* ******************************************************************************** */
+FDK_INLINE LONG fMult(SHORT a, SHORT b) { return fixmul_SS(a, b); }
+FDK_INLINE LONG fMult(SHORT a, LONG b) { return fixmul_SD(a, b); }
+FDK_INLINE LONG fMult(LONG a, SHORT b) { return fixmul_DS(a, b); }
+FDK_INLINE LONG fMult(LONG a, LONG b) { return fixmul_DD(a, b); }
+FDK_INLINE LONG fPow2(LONG a) { return fixpow2_D(a); }
+FDK_INLINE LONG fPow2(SHORT a) { return fixpow2_S(a); }
+
+FDK_INLINE LONG fMultDiv2(SHORT a, SHORT b) { return fixmuldiv2_SS(a, b); }
+FDK_INLINE LONG fMultDiv2(SHORT a, LONG b) { return fixmuldiv2_SD(a, b); }
+FDK_INLINE LONG fMultDiv2(LONG a, SHORT b) { return fixmuldiv2_DS(a, b); }
+FDK_INLINE LONG fMultDiv2(LONG a, LONG b) { return fixmuldiv2_DD(a, b); }
+FDK_INLINE LONG fPow2Div2(LONG a) { return fixpow2div2_D(a); }
+FDK_INLINE LONG fPow2Div2(SHORT a) { return fixpow2div2_S(a); }
+
+FDK_INLINE LONG fMultDiv2BitExact(LONG a, LONG b) {
+ return fixmuldiv2BitExact_DD(a, b);
+}
+FDK_INLINE LONG fMultDiv2BitExact(SHORT a, LONG b) {
+ return fixmuldiv2BitExact_SD(a, b);
+}
+FDK_INLINE LONG fMultDiv2BitExact(LONG a, SHORT b) {
+ return fixmuldiv2BitExact_DS(a, b);
+}
+FDK_INLINE LONG fMultBitExact(LONG a, LONG b) {
+ return fixmulBitExact_DD(a, b);
+}
+FDK_INLINE LONG fMultBitExact(SHORT a, LONG b) {
+ return fixmulBitExact_SD(a, b);
+}
+FDK_INLINE LONG fMultBitExact(LONG a, SHORT b) {
+ return fixmulBitExact_DS(a, b);
+}
+
+/* ********************************************************************************
+ */
#include "abs.h"
-FDK_INLINE FIXP_DBL fAbs(FIXP_DBL x)
- { return fixabs_D(x); }
-FDK_INLINE FIXP_SGL fAbs(FIXP_SGL x)
- { return fixabs_S(x); }
+FDK_INLINE FIXP_DBL fAbs(FIXP_DBL x) { return fixabs_D(x); }
+FDK_INLINE FIXP_SGL fAbs(FIXP_SGL x) { return fixabs_S(x); }
-/* workaround for TI C6x compiler but not for TI ARM9E compiler */
-#if (!defined(__TI_COMPILER_VERSION__) || defined(__TI_TMS470_V5__)) && !defined(__LP64__)
-FDK_INLINE INT fAbs(INT x)
- { return fixabs_I(x); }
+#if !defined(__LP64__)
+FDK_INLINE INT fAbs(INT x) { return fixabs_I(x); }
#endif
-/* ******************************************************************************** */
+ /* ********************************************************************************
+ */
#include "clz.h"
-FDK_INLINE INT fNormz(FIXP_DBL x)
- { return fixnormz_D(x); }
-FDK_INLINE INT fNormz(FIXP_SGL x)
- { return fixnormz_S(x); }
-FDK_INLINE INT fNorm(FIXP_DBL x)
- { return fixnorm_D(x); }
-FDK_INLINE INT fNorm(FIXP_SGL x)
- { return fixnorm_S(x); }
-
-
-/* ******************************************************************************** */
-/* ******************************************************************************** */
-/* ******************************************************************************** */
+FDK_INLINE INT fNormz(INT64 x) {
+ INT clz = fixnormz_D((INT)(x >> 32));
+ if (clz == 32) clz += fixnormz_D((INT)x);
+ return clz;
+}
+FDK_INLINE INT fNormz(FIXP_DBL x) { return fixnormz_D(x); }
+FDK_INLINE INT fNormz(FIXP_SGL x) { return fixnormz_S(x); }
+FDK_INLINE INT fNorm(FIXP_DBL x) { return fixnorm_D(x); }
+FDK_INLINE INT fNorm(FIXP_SGL x) { return fixnorm_S(x); }
+
+ /* ********************************************************************************
+ */
+ /* ********************************************************************************
+ */
+ /* ********************************************************************************
+ */
#include "clz.h"
#define fixp_abs(x) fAbs(x)
-#define fixMin(a,b) fMin(a,b)
-#define fixMax(a,b) fMax(a,b)
-#define CntLeadingZeros(x) fixnormz_D(x)
+#define fixMin(a, b) fMin(a, b)
+#define fixMax(a, b) fMax(a, b)
+#define CntLeadingZeros(x) fixnormz_D(x)
#define CountLeadingBits(x) fixnorm_D(x)
#include "fixmadd.h"
/* y = (x+0.5*a*b) */
-FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b)
- { return fixmadddiv2_DD(x, a, b); }
-FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b)
- { return fixmadddiv2_SD(x, a, b); }
-FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b)
- { return fixmadddiv2_DS(x, a, b); }
-FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b)
- { return fixmadddiv2_SS(x, a, b); }
-
-FDK_INLINE FIXP_DBL fPow2AddDiv2(FIXP_DBL x, FIXP_DBL a)
- { return fixpadddiv2_D(x, a); }
-FDK_INLINE FIXP_DBL fPow2AddDiv2(FIXP_DBL x, FIXP_SGL a)
- { return fixpadddiv2_S(x, a); }
-
+FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b) {
+ return fixmadddiv2_DD(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b) {
+ return fixmadddiv2_SD(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b) {
+ return fixmadddiv2_DS(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultAddDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b) {
+ return fixmadddiv2_SS(x, a, b);
+}
+
+FDK_INLINE FIXP_DBL fPow2AddDiv2(FIXP_DBL x, FIXP_DBL a) {
+ return fixpadddiv2_D(x, a);
+}
+FDK_INLINE FIXP_DBL fPow2AddDiv2(FIXP_DBL x, FIXP_SGL a) {
+ return fixpadddiv2_S(x, a);
+}
/* y = 2*(x+0.5*a*b) = (2x+a*b) */
-FDK_INLINE FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b)
- { return fixmadd_DD(x, a, b); }
-inline FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b)
- { return fixmadd_SD(x, a, b); }
-inline FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b)
- { return fixmadd_DS(x, a, b); }
-inline FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b)
- { return fixmadd_SS(x, a, b); }
-
-inline FIXP_DBL fPow2Add(FIXP_DBL x, FIXP_DBL a)
- { return fixpadd_D(x, a); }
-inline FIXP_DBL fPow2Add(FIXP_DBL x, FIXP_SGL a)
- { return fixpadd_S(x, a); }
-
+FDK_INLINE FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b) {
+ return fixmadd_DD(x, a, b);
+}
+inline FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b) {
+ return fixmadd_SD(x, a, b);
+}
+inline FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b) {
+ return fixmadd_DS(x, a, b);
+}
+inline FIXP_DBL fMultAdd(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b) {
+ return fixmadd_SS(x, a, b);
+}
+
+inline FIXP_DBL fPow2Add(FIXP_DBL x, FIXP_DBL a) { return fixpadd_D(x, a); }
+inline FIXP_DBL fPow2Add(FIXP_DBL x, FIXP_SGL a) { return fixpadd_S(x, a); }
/* y = (x-0.5*a*b) */
-inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b)
- { return fixmsubdiv2_DD(x, a, b); }
-inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b)
- { return fixmsubdiv2_SD(x, a, b); }
-inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b)
- { return fixmsubdiv2_DS(x, a, b); }
-inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b)
- { return fixmsubdiv2_SS(x, a, b); }
+inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b) {
+ return fixmsubdiv2_DD(x, a, b);
+}
+inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b) {
+ return fixmsubdiv2_SD(x, a, b);
+}
+inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b) {
+ return fixmsubdiv2_DS(x, a, b);
+}
+inline FIXP_DBL fMultSubDiv2(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b) {
+ return fixmsubdiv2_SS(x, a, b);
+}
/* y = 2*(x-0.5*a*b) = (2*x-a*b) */
-FDK_INLINE FIXP_DBL fMultSub(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b)
- { return fixmsub_DD(x, a, b); }
-inline FIXP_DBL fMultSub(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b)
- { return fixmsub_SD(x, a, b); }
-inline FIXP_DBL fMultSub(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b)
- { return fixmsub_DS(x, a, b); }
-inline FIXP_DBL fMultSub(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b)
- { return fixmsub_SS(x, a, b); }
-
-FDK_INLINE FIXP_DBL fMultAddDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b)
- { return fixmadddiv2BitExact_DD(x, a, b); }
-FDK_INLINE FIXP_DBL fMultAddDiv2BitExact(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b)
- { return fixmadddiv2BitExact_SD(x, a, b); }
-FDK_INLINE FIXP_DBL fMultAddDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b)
- { return fixmadddiv2BitExact_DS(x, a, b); }
-FDK_INLINE FIXP_DBL fMultSubDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b)
- { return fixmsubdiv2BitExact_DD(x, a, b); }
-FDK_INLINE FIXP_DBL fMultSubDiv2BitExact(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b)
- { return fixmsubdiv2BitExact_SD(x, a, b); }
-FDK_INLINE FIXP_DBL fMultSubDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b)
- { return fixmsubdiv2BitExact_DS(x, a, b); }
+FDK_INLINE FIXP_DBL fMultSub(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b) {
+ return fixmsub_DD(x, a, b);
+}
+inline FIXP_DBL fMultSub(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b) {
+ return fixmsub_SD(x, a, b);
+}
+inline FIXP_DBL fMultSub(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b) {
+ return fixmsub_DS(x, a, b);
+}
+inline FIXP_DBL fMultSub(FIXP_DBL x, FIXP_SGL a, FIXP_SGL b) {
+ return fixmsub_SS(x, a, b);
+}
+
+FDK_INLINE FIXP_DBL fMultAddDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b) {
+ return fixmadddiv2BitExact_DD(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultAddDiv2BitExact(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b) {
+ return fixmadddiv2BitExact_SD(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultAddDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b) {
+ return fixmadddiv2BitExact_DS(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultSubDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_DBL b) {
+ return fixmsubdiv2BitExact_DD(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultSubDiv2BitExact(FIXP_DBL x, FIXP_SGL a, FIXP_DBL b) {
+ return fixmsubdiv2BitExact_SD(x, a, b);
+}
+FDK_INLINE FIXP_DBL fMultSubDiv2BitExact(FIXP_DBL x, FIXP_DBL a, FIXP_SGL b) {
+ return fixmsubdiv2BitExact_DS(x, a, b);
+}
#include "fixminmax.h"
-FDK_INLINE FIXP_DBL fMin(FIXP_DBL a, FIXP_DBL b)
- { return fixmin_D(a,b); }
-FDK_INLINE FIXP_DBL fMax(FIXP_DBL a, FIXP_DBL b)
- { return fixmax_D(a,b); }
-
-FDK_INLINE FIXP_SGL fMin(FIXP_SGL a, FIXP_SGL b)
- { return fixmin_S(a,b); }
-FDK_INLINE FIXP_SGL fMax(FIXP_SGL a, FIXP_SGL b)
- { return fixmax_S(a,b); }
-
-/* workaround for TI C6x compiler but not for TI ARM9E */
-#if ((!defined(__TI_COMPILER_VERSION__) || defined(__TI_TMS470_V5__)) && !defined(__LP64__)) || (FIX_FRACT == 1)
-FDK_INLINE INT fMax(INT a, INT b)
- { return fixmax_I(a,b); }
-FDK_INLINE INT fMin(INT a, INT b)
- { return fixmin_I(a,b); }
+FDK_INLINE FIXP_DBL fMin(FIXP_DBL a, FIXP_DBL b) { return fixmin_D(a, b); }
+FDK_INLINE FIXP_DBL fMax(FIXP_DBL a, FIXP_DBL b) { return fixmax_D(a, b); }
+
+FDK_INLINE FIXP_SGL fMin(FIXP_SGL a, FIXP_SGL b) { return fixmin_S(a, b); }
+FDK_INLINE FIXP_SGL fMax(FIXP_SGL a, FIXP_SGL b) { return fixmax_S(a, b); }
+
+#if !defined(__LP64__)
+FDK_INLINE INT fMax(INT a, INT b) { return fixmax_I(a, b); }
+FDK_INLINE INT fMin(INT a, INT b) { return fixmin_I(a, b); }
+#if !defined(_MSC_VER) && defined(__x86_64__)
+FDK_INLINE SHORT fMax(SHORT a, SHORT b) { return fixmax_S(a, b); }
+FDK_INLINE SHORT fMin(SHORT a, SHORT b) { return fixmin_S(a, b); }
+#endif
#endif
-inline UINT fMax(UINT a, UINT b)
- { return fixmax_UI(a,b); }
-inline UINT fMin(UINT a, UINT b)
- { return fixmin_UI(a,b); }
+inline UINT fMax(UINT a, UINT b) { return fixmax_UI(a, b); }
+inline UINT fMin(UINT a, UINT b) { return fixmin_UI(a, b); }
+
+inline UCHAR fMax(UCHAR a, UCHAR b) {
+ return (UCHAR)fixmax_UI((UINT)a, (UINT)b);
+}
+inline UCHAR fMin(UCHAR a, UCHAR b) {
+ return (UCHAR)fixmin_UI((UINT)a, (UINT)b);
+}
/* Complex data types */
typedef shouldBeUnion {
@@ -357,7 +431,8 @@ typedef shouldBeUnion {
} v;
/* word representation for memory move */
LONG w;
-} FIXP_SPK;
+}
+FIXP_SPK;
typedef shouldBeUnion {
/* vector representation for arithmetic */
@@ -367,12 +442,12 @@ typedef shouldBeUnion {
} v;
/* word representation for memory move */
INT64 w;
-} FIXP_DPK;
+}
+FIXP_DPK;
#include "fixmul.h"
#include "fixmadd.h"
#include "cplx_mul.h"
-#include "scale.h"
#include "fixpoint_math.h"
#endif
diff --git a/libFDK/include/cplx_mul.h b/libFDK/include/cplx_mul.h
index ce5c9f7..9c5da57 100644
--- a/libFDK/include/cplx_mul.h
+++ b/libFDK/include/cplx_mul.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,114 +90,113 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
-#include "common_fix.h"
+#if !defined(CPLX_MUL_H)
+#define CPLX_MUL_H
-#if !defined(__CPLX_Mult_H__)
-#define __CPLX_Mult_H__
+#include "common_fix.h"
-#if defined(__CC_ARM) || defined(__arm__) || defined(_M_ARM) /* cppp replaced: elif */
-#include "arm/cplx_mul.h"
+#if defined(__arm__) || defined(_M_ARM)
+#include "arm/cplx_mul_arm.h"
#elif defined(__GNUC__) && defined(__mips__) && __mips_isa_rev < 6
-#include "mips/cplx_mul.h"
+#include "mips/cplx_mul_mips.h"
#endif /* #if defined all cores: bfin, arm, etc. */
-/* ############################################################################# */
+/* #############################################################################
+ */
/* Fallback generic implementations */
#if !defined(FUNCTION_cplxMultDiv2_32x16X2)
#define FUNCTION_cplxMultDiv2_32x16X2
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SGL b_Re,
- const FIXP_SGL b_Im)
-{
- *c_Re = fMultDiv2(a_Re,b_Re) - fMultDiv2(a_Im,b_Im);
- *c_Im = fMultDiv2(a_Re,b_Im) + fMultDiv2(a_Im,b_Re);
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+ *c_Re = fMultDiv2(a_Re, b_Re) - fMultDiv2(a_Im, b_Im);
+ *c_Im = fMultDiv2(a_Re, b_Im) + fMultDiv2(a_Im, b_Re);
+}
+#endif
+
+#if !defined(FUNCTION_cplxMultDiv2_16x16X2)
+#define FUNCTION_cplxMultDiv2_16x16X2
+
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_SGL a_Re,
+ const FIXP_SGL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+ *c_Re = fMultDiv2(a_Re, b_Re) - fMultDiv2(a_Im, b_Im);
+ *c_Im = fMultDiv2(a_Re, b_Im) + fMultDiv2(a_Im, b_Re);
+}
+
+inline void cplxMultDiv2(FIXP_SGL *c_Re, FIXP_SGL *c_Im, const FIXP_SGL a_Re,
+ const FIXP_SGL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+ *c_Re = FX_DBL2FX_SGL(fMultDiv2(a_Re, b_Re) - fMultDiv2(a_Im, b_Im));
+ *c_Im = FX_DBL2FX_SGL(fMultDiv2(a_Re, b_Im) + fMultDiv2(a_Im, b_Re));
}
#endif
#if !defined(FUNCTION_cplxMultDiv2_32x16)
#define FUNCTION_cplxMultDiv2_32x16
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SPK w )
-{
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SPK w) {
cplxMultDiv2(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
}
#endif
-#if !defined(FUNCTION_cplxMultAddDiv2_32x16X2)
-#define FUNCTION_cplxMultAddDiv2_32x16X2
-
-inline void cplxMultAddDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SGL b_Re,
- const FIXP_SGL b_Im)
-{
- *c_Re += fMultDiv2(a_Re,b_Re) - fMultDiv2(a_Im,b_Im);
- *c_Im += fMultDiv2(a_Re,b_Im) + fMultDiv2(a_Im,b_Re);
+#if !defined(FUNCTION_cplxMultDiv2_16x16)
+#define FUNCTION_cplxMultDiv2_16x16
+
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_SGL a_Re,
+ const FIXP_SGL a_Im, const FIXP_SPK w) {
+ cplxMultDiv2(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
+}
+
+inline void cplxMultDiv2(FIXP_SGL *c_Re, FIXP_SGL *c_Im, const FIXP_SGL a_Re,
+ const FIXP_SGL a_Im, const FIXP_SPK w) {
+ cplxMultDiv2(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
}
#endif
#if !defined(FUNCTION_cplxMultSubDiv2_32x16X2)
#define FUNCTION_cplxMultSubDiv2_32x16X2
-inline void cplxMultSubDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SGL b_Re,
- const FIXP_SGL b_Im)
-{
- *c_Re -= fMultDiv2(a_Re,b_Re) - fMultDiv2(a_Im,b_Im);
- *c_Im -= fMultDiv2(a_Re,b_Im) + fMultDiv2(a_Im,b_Re);
+inline void cplxMultSubDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+ *c_Re -= fMultDiv2(a_Re, b_Re) - fMultDiv2(a_Im, b_Im);
+ *c_Im -= fMultDiv2(a_Re, b_Im) + fMultDiv2(a_Im, b_Re);
}
#endif
#if !defined(FUNCTION_cplxMultDiv2_32x32X2)
#define FUNCTION_cplxMultDiv2_32x32X2
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_DBL b_Re,
- const FIXP_DBL b_Im)
-{
- *c_Re = fMultDiv2(a_Re,b_Re) - fMultDiv2(a_Im,b_Im);
- *c_Im = fMultDiv2(a_Re,b_Im) + fMultDiv2(a_Im,b_Re);
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DBL b_Re,
+ const FIXP_DBL b_Im) {
+ *c_Re = fMultDiv2(a_Re, b_Re) - fMultDiv2(a_Im, b_Im);
+ *c_Im = fMultDiv2(a_Re, b_Im) + fMultDiv2(a_Im, b_Re);
}
#endif
#if !defined(FUNCTION_cplxMultDiv2_32x32)
#define FUNCTION_cplxMultDiv2_32x32
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_DPK w)
-{
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DPK w) {
cplxMultDiv2(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
}
#endif
@@ -194,44 +204,39 @@ inline void cplxMultDiv2( FIXP_DBL *c_Re,
#if !defined(FUNCTION_cplxMultSubDiv2_32x32X2)
#define FUNCTION_cplxMultSubDiv2_32x32X2
-inline void cplxMultSubDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_DBL b_Re,
- const FIXP_DBL b_Im)
-{
- *c_Re -= fMultDiv2(a_Re,b_Re) - fMultDiv2(a_Im,b_Im);
- *c_Im -= fMultDiv2(a_Re,b_Im) + fMultDiv2(a_Im,b_Re);
+inline void cplxMultSubDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DBL b_Re,
+ const FIXP_DBL b_Im) {
+ *c_Re -= fMultDiv2(a_Re, b_Re) - fMultDiv2(a_Im, b_Im);
+ *c_Im -= fMultDiv2(a_Re, b_Im) + fMultDiv2(a_Im, b_Re);
}
#endif
-/* ############################################################################# */
+ /* #############################################################################
+ */
#if !defined(FUNCTION_cplxMult_32x16X2)
#define FUNCTION_cplxMult_32x16X2
-inline void cplxMult( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SGL b_Re,
- const FIXP_SGL b_Im)
-{
- *c_Re = fMult(a_Re,b_Re) - fMult(a_Im,b_Im);
- *c_Im = fMult(a_Re,b_Im) + fMult(a_Im,b_Re);
+inline void cplxMult(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+ *c_Re = fMult(a_Re, b_Re) - fMult(a_Im, b_Im);
+ *c_Im = fMult(a_Re, b_Im) + fMult(a_Im, b_Re);
+}
+inline void cplxMult(FIXP_SGL *c_Re, FIXP_SGL *c_Im, const FIXP_SGL a_Re,
+ const FIXP_SGL a_Im, const FIXP_SGL b_Re,
+ const FIXP_SGL b_Im) {
+ *c_Re = FX_DBL2FX_SGL(fMult(a_Re, b_Re) - fMult(a_Im, b_Im));
+ *c_Im = FX_DBL2FX_SGL(fMult(a_Re, b_Im) + fMult(a_Im, b_Re));
}
#endif
#if !defined(FUNCTION_cplxMult_32x16)
#define FUNCTION_cplxMult_32x16
-inline void cplxMult( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_SPK w )
-{
+inline void cplxMult(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SPK w) {
cplxMult(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
}
#endif
@@ -239,31 +244,43 @@ inline void cplxMult( FIXP_DBL *c_Re,
#if !defined(FUNCTION_cplxMult_32x32X2)
#define FUNCTION_cplxMult_32x32X2
-inline void cplxMult( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_DBL b_Re,
- const FIXP_DBL b_Im)
-{
- *c_Re = fMult(a_Re,b_Re) - fMult(a_Im,b_Im);
- *c_Im = fMult(a_Re,b_Im) + fMult(a_Im,b_Re);
+inline void cplxMult(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DBL b_Re,
+ const FIXP_DBL b_Im) {
+ *c_Re = fMult(a_Re, b_Re) - fMult(a_Im, b_Im);
+ *c_Im = fMult(a_Re, b_Im) + fMult(a_Im, b_Re);
}
#endif
#if !defined(FUNCTION_cplxMult_32x32)
#define FUNCTION_cplxMult_32x32
-inline void cplxMult( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- const FIXP_DBL a_Re,
- const FIXP_DBL a_Im,
- const FIXP_DPK w)
-{
+inline void cplxMult(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DPK w) {
cplxMult(c_Re, c_Im, a_Re, a_Im, w.v.re, w.v.im);
}
#endif
-/* ############################################################################# */
+#if !defined(FUNCTION_cplxMult_nIm)
+#define FUNCTION_cplxMult_nIm
+
+/* Same as cplxMult, but
+ a_Im must be negated, when used
+ c_re must be negated, when output
+*/
+inline void cplxMult_nIm(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_SPK w) {
+ *c_Re = -(fMult(a_Re, w.v.re) + fMult(a_Im, w.v.im));
+ *c_Im = fMult(a_Re, w.v.im) - fMult(a_Im, w.v.re);
+}
+
+inline void cplxMult_nIm(FIXP_DBL *c_Re, FIXP_DBL *c_Im, const FIXP_DBL a_Re,
+ const FIXP_DBL a_Im, const FIXP_DPK w) {
+ *c_Re = -(fMult(a_Re, w.v.re) + fMult(a_Im, w.v.im));
+ *c_Im = fMult(a_Re, w.v.im) - fMult(a_Im, w.v.re);
+}
+#endif
-#endif /* __CPLX_Mult_H__ */
+ /* #############################################################################
+ */
+#endif /* CPLX_MUL_H */
diff --git a/libFDK/include/dct.h b/libFDK/include/dct.h
index af1edd3..308afcb 100644
--- a/libFDK/include/dct.h
+++ b/libFDK/include/dct.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,24 +90,26 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: Library functions to calculate standard DCTs. This will most
likely be replaced by hand-optimized functions for the specific
target processor.
-******************************************************************************/
-
-#ifndef __dct_H
-#define __dct_H
-
+*******************************************************************************/
+#ifndef DCT_H
+#define DCT_H
#include "common_fix.h"
+void dct_getTables(const FIXP_WTP **ptwiddle, const FIXP_STP **sin_twiddle,
+ int *sin_step, int length);
+
/**
* \brief Calculate DCT type II of given length. The DCT IV is
* calculated by a complex FFT, with some pre and post twiddeling.
@@ -121,6 +134,19 @@ void dct_II(FIXP_DBL *pDat, FIXP_DBL *tmp, int size, int *pDat_e);
void dct_III(FIXP_DBL *pDat, FIXP_DBL *tmp, int size, int *pDat_e);
/**
+ * \brief Calculate DST type III of given length. The DST III is
+ * calculated by a DCT III of mirrored input and sign-flipping of odd
+ * output coefficients.
+ * Note that the factor 0.5 for the sum term x[N-1] is 1.0 instead of
+ * 0.5. A factor of sqrt(2/N) is NOT applied.
+ * \param pDat pointer to input/output data (in place processing).
+ * \param size size of pDat.
+ * \param pDat_e pointer to an integer containing the exponent of the data
+ * referenced by pDat. The exponent is updated accordingly.
+ */
+void dst_III(FIXP_DBL *pDat, FIXP_DBL *tmp, int size, int *pDat_e);
+
+/**
* \brief Calculate DCT type IV of given length. The DCT IV is
* calculated by a complex FFT, with some pre and post twiddeling.
* A factor of sqrt(2/N) is NOT applied.
@@ -129,7 +155,7 @@ void dct_III(FIXP_DBL *pDat, FIXP_DBL *tmp, int size, int *pDat_e);
* \param pDat_e pointer to an integer containing the exponent of the data
* referenced by pDat. The exponent is updated accordingly.
*/
-void dct_IV(FIXP_DBL *pDat,int size, int *pDat_e);
+void dct_IV(FIXP_DBL *pDat, int size, int *pDat_e);
/**
* \brief Calculate DST type IV of given length. The DST IV is
@@ -140,8 +166,6 @@ void dct_IV(FIXP_DBL *pDat,int size, int *pDat_e);
* \param pDat_e pointer to an integer containing the exponent of the data
* referenced by pDat. The exponent is updated accordingly.
*/
-void dst_IV(FIXP_DBL *pDat,int size, int *pDat_e);
-
-
+void dst_IV(FIXP_DBL *pDat, int size, int *pDat_e);
#endif
diff --git a/libFDK/include/fft.h b/libFDK/include/fft.h
index 616f350..3576ed3 100644
--- a/libFDK/include/fft.h
+++ b/libFDK/include/fft.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): Josef Hoepfl, DSP Solutions
+
Description: Fix point FFT
-******************************************************************************/
+*******************************************************************************/
-#ifndef __FFT_H__
-#define __FFT_H__
+#ifndef FFT_H
+#define FFT_H
#include "common_fix.h"
@@ -97,10 +109,10 @@ amm-info@iis.fraunhofer.de
* \brief Perform an inplace complex valued FFT of length 2^n
*
* \param length Length of the FFT to be calculated.
- * \param pInput Input/Output data buffer. The input data must have at least 1 bit scale headroom.
- * The values are interleaved, real/imag pairs.
- * \param scalefactor Pointer to an INT, which contains the current scale of the input data,
- * which is updated according to the FFT scale.
+ * \param pInput Input/Output data buffer. The input data must have at least 1
+ * bit scale headroom. The values are interleaved, real/imag pairs.
+ * \param scalefactor Pointer to an INT, which contains the current scale of the
+ * input data, which is updated according to the FFT scale.
*/
void fft(int length, FIXP_DBL *pInput, INT *scalefactor);
@@ -108,146 +120,144 @@ void fft(int length, FIXP_DBL *pInput, INT *scalefactor);
* \brief Perform an inplace complex valued IFFT of length 2^n
*
* \param length Length of the FFT to be calculated.
- * \param pInput Input/Output data buffer. The input data must have at least 1 bit scale headroom.
- * The values are interleaved, real/imag pairs.
- * \param scalefactor Pointer to an INT, which contains the current scale of the input data,
- * which is updated according to the IFFT scale.
+ * \param pInput Input/Output data buffer. The input data must have at least 1
+ * bit scale headroom. The values are interleaved, real/imag pairs.
+ * \param scalefactor Pointer to an INT, which contains the current scale of the
+ * input data, which is updated according to the IFFT scale.
*/
void ifft(int length, FIXP_DBL *pInput, INT *scalefactor);
-
/*
* Frequently used and fixed short length FFTs.
*/
+#ifndef FUNCTION_fft_4
+/**
+ * \brief Perform an inplace complex valued FFT of length 4
+ *
+ * \param pInput Input/Output data buffer. The input data must have at least 1
+ * bit scale headroom. The values are interleaved, real/imag pairs.
+ */
LNK_SECTION_CODE_L1
-static void FORCEINLINE fft_4(FIXP_DBL *x)
-{
- FIXP_DBL a00, a10, a20, a30, tmp0, tmp1;
+static void FDK_FORCEINLINE fft_4(FIXP_DBL *x) {
+ FIXP_DBL a00, a10, a20, a30, tmp0, tmp1;
- a00 = (x[0] + x[4])>>1; /* Re A + Re B */
- a10 = (x[2] + x[6])>>1; /* Re C + Re D */
- a20 = (x[1] + x[5])>>1; /* Im A + Im B */
- a30 = (x[3] + x[7])>>1; /* Im C + Im D */
+ a00 = (x[0] + x[4]) >> 1; /* Re A + Re B */
+ a10 = (x[2] + x[6]) >> 1; /* Re C + Re D */
+ a20 = (x[1] + x[5]) >> 1; /* Im A + Im B */
+ a30 = (x[3] + x[7]) >> 1; /* Im C + Im D */
- x[0] = a00 + a10; /* Re A' = Re A + Re B + Re C + Re D */
- x[1] = a20 + a30; /* Im A' = Im A + Im B + Im C + Im D */
+ x[0] = a00 + a10; /* Re A' = Re A + Re B + Re C + Re D */
+ x[1] = a20 + a30; /* Im A' = Im A + Im B + Im C + Im D */
- tmp0 = a00 - x[4]; /* Re A - Re B */
- tmp1 = a20 - x[5]; /* Im A - Im B */
+ tmp0 = a00 - x[4]; /* Re A - Re B */
+ tmp1 = a20 - x[5]; /* Im A - Im B */
- x[4] = a00 - a10; /* Re C' = Re A + Re B - Re C - Re D */
- x[5] = a20 - a30; /* Im C' = Im A + Im B - Im C - Im D */
+ x[4] = a00 - a10; /* Re C' = Re A + Re B - Re C - Re D */
+ x[5] = a20 - a30; /* Im C' = Im A + Im B - Im C - Im D */
- a10 = a10 - x[6]; /* Re C - Re D */
- a30 = a30 - x[7]; /* Im C - Im D */
+ a10 = a10 - x[6]; /* Re C - Re D */
+ a30 = a30 - x[7]; /* Im C - Im D */
- x[2] = tmp0 + a30; /* Re B' = Re A - Re B + Im C - Im D */
- x[6] = tmp0 - a30; /* Re D' = Re A - Re B - Im C + Im D */
- x[3] = tmp1 - a10; /* Im B' = Im A - Im B - Re C + Re D */
- x[7] = tmp1 + a10; /* Im D' = Im A - Im B + Re C - Re D */
+ x[2] = tmp0 + a30; /* Re B' = Re A - Re B + Im C - Im D */
+ x[6] = tmp0 - a30; /* Re D' = Re A - Re B - Im C + Im D */
+ x[3] = tmp1 - a10; /* Im B' = Im A - Im B - Re C + Re D */
+ x[7] = tmp1 + a10; /* Im D' = Im A - Im B + Re C - Re D */
}
+#endif /* FUNCTION_fft_4 */
+#ifndef FUNCTION_fft_8
LNK_SECTION_CODE_L1
-static void FORCEINLINE fft_8(FIXP_DBL *x)
-{
- #define W_PiFOURTH STC(0x5a82799a)
-
- FIXP_DBL a00, a10, a20, a30;
- FIXP_DBL y[16];
-
- a00 = (x[0] + x[8])>>1;
- a10 = x[4] + x[12];
- a20 = (x[1] + x[9])>>1;
- a30 = x[5] + x[13];
-
- y[0] = a00 + (a10>>1);
- y[4] = a00 - (a10>>1);
- y[1] = a20 + (a30>>1);
- y[5] = a20 - (a30>>1);
-
- a00 = a00 - x[8];
- a10 = (a10>>1) - x[12];
- a20 = a20 - x[9];
- a30 = (a30>>1) - x[13];
-
- y[2] = a00 + a30;
- y[6] = a00 - a30;
- y[3] = a20 - a10;
- y[7] = a20 + a10;
-
- a00 = (x[2] + x[10])>>1;
- a10 = x[6] + x[14];
- a20 = (x[3] + x[11])>>1;
- a30 = x[7] + x[15];
-
- y[8] = a00 + (a10>>1);
- y[12] = a00 - (a10>>1);
- y[9] = a20 + (a30>>1);
- y[13] = a20 - (a30>>1);
-
- a00 = a00 - x[10];
- a10 = (a10>>1) - x[14];
- a20 = a20 - x[11];
- a30 = (a30>>1) - x[15];
-
- y[10] = a00 + a30;
- y[14] = a00 - a30;
- y[11] = a20 - a10;
- y[15] = a20 + a10;
-
- FIXP_DBL vr, vi, ur, ui;
-
- ur = y[0]>>1;
- ui = y[1]>>1;
- vr = y[8];
- vi = y[9];
- x[0] = ur + (vr>>1);
- x[1] = ui + (vi>>1);
- x[8] = ur - (vr>>1);
- x[9] = ui - (vi>>1);
-
- ur = y[4]>>1;
- ui = y[5]>>1;
- vi = y[12];
- vr = y[13];
- x[4] = ur + (vr>>1);
- x[5] = ui - (vi>>1);
- x[12] = ur - (vr>>1);
- x[13] = ui + (vi>>1);
-
- ur = y[10];
- ui = y[11];
- vr = fMultDiv2(ui+ur,W_PiFOURTH);
- vi = fMultDiv2(ui-ur,W_PiFOURTH);
- ur = y[2];
- ui = y[3];
- x[2] = (ur>>1) + vr;
- x[3] = (ui>>1) + vi;
- x[10] = (ur>>1) - vr;
- x[11] = (ui>>1) - vi;
-
- ur = y[14];
- ui = y[15];
- vr = fMultDiv2(ui-ur,W_PiFOURTH);
- vi = fMultDiv2(ui+ur,W_PiFOURTH);
- ur = y[6];
- ui = y[7];
- x[6] = (ur>>1) + vr;
- x[7] = (ui>>1) - vi;
- x[14] = (ur>>1) - vr;
- x[15] = (ui>>1) + vi;
+static void FDK_FORCEINLINE fft_8(FIXP_DBL *x) {
+ FIXP_SPK w_PiFOURTH = {{FIXP_SGL(0x5A82), FIXP_SGL(0x5A82)}};
+
+ FIXP_DBL a00, a10, a20, a30;
+ FIXP_DBL y[16];
+
+ a00 = (x[0] + x[8]) >> 1;
+ a10 = x[4] + x[12];
+ a20 = (x[1] + x[9]) >> 1;
+ a30 = x[5] + x[13];
+
+ y[0] = a00 + (a10 >> 1);
+ y[4] = a00 - (a10 >> 1);
+ y[1] = a20 + (a30 >> 1);
+ y[5] = a20 - (a30 >> 1);
+
+ a00 = a00 - x[8];
+ a10 = (a10 >> 1) - x[12];
+ a20 = a20 - x[9];
+ a30 = (a30 >> 1) - x[13];
+
+ y[2] = a00 + a30;
+ y[6] = a00 - a30;
+ y[3] = a20 - a10;
+ y[7] = a20 + a10;
+
+ a00 = (x[2] + x[10]) >> 1;
+ a10 = x[6] + x[14];
+ a20 = (x[3] + x[11]) >> 1;
+ a30 = x[7] + x[15];
+
+ y[8] = a00 + (a10 >> 1);
+ y[12] = a00 - (a10 >> 1);
+ y[9] = a20 + (a30 >> 1);
+ y[13] = a20 - (a30 >> 1);
+
+ a00 = a00 - x[10];
+ a10 = (a10 >> 1) - x[14];
+ a20 = a20 - x[11];
+ a30 = (a30 >> 1) - x[15];
+
+ y[10] = a00 + a30;
+ y[14] = a00 - a30;
+ y[11] = a20 - a10;
+ y[15] = a20 + a10;
+
+ FIXP_DBL vr, vi, ur, ui;
+
+ ur = y[0] >> 1;
+ ui = y[1] >> 1;
+ vr = y[8];
+ vi = y[9];
+ x[0] = ur + (vr >> 1);
+ x[1] = ui + (vi >> 1);
+ x[8] = ur - (vr >> 1);
+ x[9] = ui - (vi >> 1);
+
+ ur = y[4] >> 1;
+ ui = y[5] >> 1;
+ vi = y[12];
+ vr = y[13];
+ x[4] = ur + (vr >> 1);
+ x[5] = ui - (vi >> 1);
+ x[12] = ur - (vr >> 1);
+ x[13] = ui + (vi >> 1);
+
+ ur = y[10];
+ ui = y[11];
+
+ cplxMultDiv2(&vi, &vr, ui, ur, w_PiFOURTH);
+
+ ur = y[2];
+ ui = y[3];
+ x[2] = (ur >> 1) + vr;
+ x[3] = (ui >> 1) + vi;
+ x[10] = (ur >> 1) - vr;
+ x[11] = (ui >> 1) - vi;
+
+ ur = y[14];
+ ui = y[15];
+
+ cplxMultDiv2(&vr, &vi, ui, ur, w_PiFOURTH);
+
+ ur = y[6];
+ ui = y[7];
+ x[6] = (ur >> 1) + vr;
+ x[7] = (ui >> 1) - vi;
+ x[14] = (ur >> 1) - vr;
+ x[15] = (ui >> 1) + vi;
}
-
-/**
- * \brief FFT of fixed length 16
- */
-inline void fft_16(FIXP_DBL *x);
-
-/**
- * \brief FFT of fixed length 32
- */
-inline void fft_32(FIXP_DBL *x);
-
+#endif /* FUNCTION_fft_8 */
#endif
diff --git a/libFDK/include/fft_rad2.h b/libFDK/include/fft_rad2.h
index 90d14da..b820b7d 100644
--- a/libFDK/include/fft_rad2.h
+++ b/libFDK/include/fft_rad2.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,56 +90,32 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser, M. Gayer
- Description:
-******************************************************************************/
+ Description:
-#ifndef _FFT_RAD2_H
-#define _FFT_RAD2_H
+*******************************************************************************/
+#ifndef FFT_RAD2_H
+#define FFT_RAD2_H
#include "common_fix.h"
/**
* \brief Performe an inplace complex valued FFT of 2^n length
*
- * \param x Input/Output data buffer. The input data must have at least 1 bit scale headroom.
- * The values are interleaved, real/imag pairs.
- * \param ldn log2 of FFT length
- * \param trigdata Pointer to a sinetable of a length of at least (2^ldn)/2 sine values.
- * \param trigDataSize length of the sinetable "trigdata".
- */
-void dit_fft(FIXP_DBL *x, const INT ldn, const FIXP_STP *trigdata, const INT trigDataSize) ;
-
-/**
- * \brief Performe an inplace complex valued inverse FFT of 2^n length
- *
- * \param x Input/Output data buffer. The input data must have at least 1 bit scale headroom.
- * The values are interleaved, real/imag pairs.
+ * \param x Input/Output data buffer. The input data must have at least 1 bit
+ * scale headroom. The values are interleaved, real/imag pairs.
* \param ldn log2 of FFT length
- * \param trigdata Pointer to a sinetable of a length of at least (2^ldn)/2 sine values.
+ * \param trigdata Pointer to a sinetable of a length of at least (2^ldn)/2 sine
+ * values.
* \param trigDataSize length of the sinetable "trigdata".
*/
-void dit_ifft(FIXP_DBL *x, const INT ldn, const FIXP_STP *trigdata, const INT trigDataSize) ;
-
-/* Rest of the world. */
-
-#define SCALEFACTOR2048 10
-#define SCALEFACTOR1024 9
-#define SCALEFACTOR512 8
-#define SCALEFACTOR256 7
-#define SCALEFACTOR128 6
-#define SCALEFACTOR64 5
-#define SCALEFACTOR32 4
-#define SCALEFACTOR16 3
-#define SCALEFACTOR8 2
-#define SCALEFACTOR4 1
-#define SCALEFACTOR2 1
-
-#endif /* _FFT_RAD2_H */
+void dit_fft(FIXP_DBL *x, const INT ldn, const FIXP_STP *trigdata,
+ const INT trigDataSize);
+#endif /* FFT_RAD2_H */
diff --git a/libFDK/include/fixmadd.h b/libFDK/include/fixmadd.h
index 851b7a2..1672456 100644
--- a/libFDK/include/fixmadd.h
+++ b/libFDK/include/fixmadd.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,17 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser, M. Gayer
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
-#if !defined(__FIXMADD_H__)
-#define __FIXMADD_H__
+#if !defined(FIXMADD_H)
+#define FIXMADD_H
#include "FDK_archdef.h"
#include "machine_type.h"
@@ -98,9 +110,6 @@ amm-info@iis.fraunhofer.de
#if defined(__arm__)
#include "arm/fixmadd_arm.h"
-#elif defined(__mips__) /* cppp replaced: elif */
-#include "mips/fixmadd_mips.h"
-
#endif /* all cores */
/*************************************************************************
@@ -112,12 +121,13 @@ amm-info@iis.fraunhofer.de
/* Divide by two versions. */
#if !defined(FUNCTION_fixmadddiv2_DD)
-inline FIXP_DBL fixmadddiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
- { return (x + fMultDiv2 (a, b)); }
+inline FIXP_DBL fixmadddiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ return (x + fMultDiv2(a, b));
+}
#endif
#if !defined(FUNCTION_fixmadddiv2_SD)
-inline FIXP_DBL fixmadddiv2_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmadddiv2_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
#ifdef FUNCTION_fixmadddiv2_DS
return fixmadddiv2_DS(x, b, a);
#else
@@ -127,7 +137,7 @@ inline FIXP_DBL fixmadddiv2_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b)
#endif
#if !defined(FUNCTION_fixmadddiv2_DS)
-inline FIXP_DBL fixmadddiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+inline FIXP_DBL fixmadddiv2_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
#ifdef FUNCTION_fixmadddiv2_SD
return fixmadddiv2_SD(x, b, a);
#else
@@ -137,17 +147,19 @@ inline FIXP_DBL fixmadddiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b)
#endif
#if !defined(FUNCTION_fixmadddiv2_SS)
-inline FIXP_DBL fixmadddiv2_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
- { return x + fMultDiv2(a,b); }
+inline FIXP_DBL fixmadddiv2_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
+ return x + fMultDiv2(a, b);
+}
#endif
#if !defined(FUNCTION_fixmsubdiv2_DD)
-inline FIXP_DBL fixmsubdiv2_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
- { return (x - fMultDiv2 (a, b)); }
+inline FIXP_DBL fixmsubdiv2_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ return (x - fMultDiv2(a, b));
+}
#endif
#if !defined(FUNCTION_fixmsubdiv2_SD)
-inline FIXP_DBL fixmsubdiv2_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmsubdiv2_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
#ifdef FUNCTION_fixmsubdiv2_DS
return fixmsubdiv2_DS(x, b, a);
#else
@@ -157,7 +169,7 @@ inline FIXP_DBL fixmsubdiv2_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b)
#endif
#if !defined(FUNCTION_fixmsubdiv2_DS)
-inline FIXP_DBL fixmsubdiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+inline FIXP_DBL fixmsubdiv2_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
#ifdef FUNCTION_fixmsubdiv2_SD
return fixmsubdiv2_SD(x, b, a);
#else
@@ -167,20 +179,22 @@ inline FIXP_DBL fixmsubdiv2_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b)
#endif
#if !defined(FUNCTION_fixmsubdiv2_SS)
-inline FIXP_DBL fixmsubdiv2_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
- { return x - fMultDiv2(a,b); }
+inline FIXP_DBL fixmsubdiv2_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
+ return x - fMultDiv2(a, b);
+}
#endif
-
#if !defined(FUNCTION_fixmadddiv2BitExact_DD)
#define FUNCTION_fixmadddiv2BitExact_DD
-inline FIXP_DBL fixmadddiv2BitExact_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmadddiv2BitExact_DD(FIXP_DBL x, const FIXP_DBL a,
+ const FIXP_DBL b) {
return x + fMultDiv2BitExact(a, b);
}
#endif
#if !defined(FUNCTION_fixmadddiv2BitExact_SD)
#define FUNCTION_fixmadddiv2BitExact_SD
-inline FIXP_DBL fixmadddiv2BitExact_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmadddiv2BitExact_SD(FIXP_DBL x, const FIXP_SGL a,
+ const FIXP_DBL b) {
#ifdef FUNCTION_fixmadddiv2BitExact_DS
return fixmadddiv2BitExact_DS(x, b, a);
#else
@@ -190,7 +204,8 @@ inline FIXP_DBL fixmadddiv2BitExact_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP
#endif
#if !defined(FUNCTION_fixmadddiv2BitExact_DS)
#define FUNCTION_fixmadddiv2BitExact_DS
-inline FIXP_DBL fixmadddiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+inline FIXP_DBL fixmadddiv2BitExact_DS(FIXP_DBL x, const FIXP_DBL a,
+ const FIXP_SGL b) {
#ifdef FUNCTION_fixmadddiv2BitExact_SD
return fixmadddiv2BitExact_SD(x, b, a);
#else
@@ -201,13 +216,15 @@ inline FIXP_DBL fixmadddiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP
#if !defined(FUNCTION_fixmsubdiv2BitExact_DD)
#define FUNCTION_fixmsubdiv2BitExact_DD
-inline FIXP_DBL fixmsubdiv2BitExact_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmsubdiv2BitExact_DD(FIXP_DBL x, const FIXP_DBL a,
+ const FIXP_DBL b) {
return x - fMultDiv2BitExact(a, b);
}
#endif
#if !defined(FUNCTION_fixmsubdiv2BitExact_SD)
#define FUNCTION_fixmsubdiv2BitExact_SD
-inline FIXP_DBL fixmsubdiv2BitExact_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmsubdiv2BitExact_SD(FIXP_DBL x, const FIXP_SGL a,
+ const FIXP_DBL b) {
#ifdef FUNCTION_fixmsubdiv2BitExact_DS
return fixmsubdiv2BitExact_DS(x, b, a);
#else
@@ -217,7 +234,8 @@ inline FIXP_DBL fixmsubdiv2BitExact_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP
#endif
#if !defined(FUNCTION_fixmsubdiv2BitExact_DS)
#define FUNCTION_fixmsubdiv2BitExact_DS
-inline FIXP_DBL fixmsubdiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+inline FIXP_DBL fixmsubdiv2BitExact_DS(FIXP_DBL x, const FIXP_DBL a,
+ const FIXP_SGL b) {
#ifdef FUNCTION_fixmsubdiv2BitExact_SD
return fixmsubdiv2BitExact_SD(x, b, a);
#else
@@ -226,14 +244,15 @@ inline FIXP_DBL fixmsubdiv2BitExact_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP
}
#endif
-/* Normal versions */
+ /* Normal versions */
#if !defined(FUNCTION_fixmadd_DD)
-inline FIXP_DBL fixmadd_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
- { return fixmadddiv2_DD(x,a,b)<<1; }
+inline FIXP_DBL fixmadd_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ return fixmadddiv2_DD(x, a, b) << 1;
+}
#endif
#if !defined(FUNCTION_fixmadd_SD)
-inline FIXP_DBL fixmadd_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmadd_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
#ifdef FUNCTION_fixmadd_DS
return fixmadd_DS(x, b, a);
#else
@@ -242,7 +261,7 @@ inline FIXP_DBL fixmadd_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
}
#endif
#if !defined(FUNCTION_fixmadd_DS)
-inline FIXP_DBL fixmadd_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+inline FIXP_DBL fixmadd_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
#ifdef FUNCTION_fixmadd_SD
return fixmadd_SD(x, b, a);
#else
@@ -251,16 +270,18 @@ inline FIXP_DBL fixmadd_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
}
#endif
#if !defined(FUNCTION_fixmadd_SS)
-inline FIXP_DBL fixmadd_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
- { return (x + fMultDiv2(a,b))<<1; }
+inline FIXP_DBL fixmadd_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
+ return (x + fMultDiv2(a, b)) << 1;
+}
#endif
#if !defined(FUNCTION_fixmsub_DD)
-inline FIXP_DBL fixmsub_DD (FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b)
- { return fixmsubdiv2_DD(x,a,b)<<1; }
+inline FIXP_DBL fixmsub_DD(FIXP_DBL x, const FIXP_DBL a, const FIXP_DBL b) {
+ return fixmsubdiv2_DD(x, a, b) << 1;
+}
#endif
#if !defined(FUNCTION_fixmsub_SD)
-inline FIXP_DBL fixmsub_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
+inline FIXP_DBL fixmsub_SD(FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
#ifdef FUNCTION_fixmsub_DS
return fixmsub_DS(x, b, a);
#else
@@ -269,7 +290,7 @@ inline FIXP_DBL fixmsub_SD (FIXP_DBL x, const FIXP_SGL a, const FIXP_DBL b) {
}
#endif
#if !defined(FUNCTION_fixmsub_DS)
-inline FIXP_DBL fixmsub_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
+inline FIXP_DBL fixmsub_DS(FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
#ifdef FUNCTION_fixmsub_SD
return fixmsub_SD(x, b, a);
#else
@@ -278,29 +299,35 @@ inline FIXP_DBL fixmsub_DS (FIXP_DBL x, const FIXP_DBL a, const FIXP_SGL b) {
}
#endif
#if !defined(FUNCTION_fixmsub_SS)
-inline FIXP_DBL fixmsub_SS (FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b)
- { return (x - fMultDiv2(a,b))<<1; }
+inline FIXP_DBL fixmsub_SS(FIXP_DBL x, const FIXP_SGL a, const FIXP_SGL b) {
+ return (x - fMultDiv2(a, b)) << 1;
+}
#endif
#if !defined(FUNCTION_fixpow2adddiv2_D)
-inline INT fixpadddiv2_D (FIXP_DBL x, const FIXP_DBL a)
- { return (x + fPow2Div2(a)); }
+#ifdef FUNCTION_fixmadddiv2_DD
+#define fixpadddiv2_D(x, a) fixmadddiv2_DD(x, a, a)
+#else
+inline INT fixpadddiv2_D(FIXP_DBL x, const FIXP_DBL a) {
+ return (x + fPow2Div2(a));
+}
+#endif
#endif
#if !defined(FUNCTION_fixpow2add_D)
-inline INT fixpadd_D (FIXP_DBL x, const FIXP_DBL a)
- { return (x + fPow2(a)); }
+inline INT fixpadd_D(FIXP_DBL x, const FIXP_DBL a) { return (x + fPow2(a)); }
#endif
#if !defined(FUNCTION_fixpow2adddiv2_S)
-inline INT fixpadddiv2_S (FIXP_DBL x, const FIXP_SGL a)
- { return (x + fPow2Div2(a)); }
+#ifdef FUNCTION_fixmadddiv2_SS
+#define fixpadddiv2_S(x, a) fixmadddiv2_SS(x, a, a)
+#else
+inline INT fixpadddiv2_S(FIXP_DBL x, const FIXP_SGL a) {
+ return (x + fPow2Div2(a));
+}
+#endif
#endif
#if !defined(FUNCTION_fixpow2add_S)
-inline INT fixpadd_S (FIXP_DBL x, const FIXP_SGL a)
- { return (x + fPow2(a)); }
+inline INT fixpadd_S(FIXP_DBL x, const FIXP_SGL a) { return (x + fPow2(a)); }
#endif
-
-
-#endif // __FIXMADD_H__
-
+#endif /* FIXMADD_H */
diff --git a/libFDK/include/fixminmax.h b/libFDK/include/fixminmax.h
index 5a52824..69ef35d 100644
--- a/libFDK/include/fixminmax.h
+++ b/libFDK/include/fixminmax.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,42 +90,42 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Lohwasser, M. Gayer
+
Description: min/max inline functions and defines
-******************************************************************************/
+*******************************************************************************/
-#ifndef FIXMINMAX__H
-#define FIXMINMAX__H
+#ifndef FIXMINMAX_H
+#define FIXMINMAX_H
#include "FDK_archdef.h"
#include "machine_type.h"
-/* Inline Function to determine the smaller/bigger value of two values with same type. */
+/* Inline Function to determine the smaller/bigger value of two values with same
+ * type. */
-
-template <class T> inline T fixmin (T a, T b)
-{
- return (a < b ? a : b);
+template <class T>
+inline T fixmin(T a, T b) {
+ return (a < b ? a : b);
}
-template <class T> inline T fixmax (T a, T b)
-{
- return (a > b ? a : b);
+template <class T>
+inline T fixmax(T a, T b) {
+ return (a > b ? a : b);
}
-#define fixmax_D(a,b) fixmax(a,b)
-#define fixmin_D(a,b) fixmin(a,b)
-#define fixmax_S(a,b) fixmax(a,b)
-#define fixmin_S(a,b) fixmin(a,b)
-#define fixmax_I(a,b) fixmax(a,b)
-#define fixmin_I(a,b) fixmin(a,b)
-#define fixmax_UI(a,b) fixmax(a,b)
-#define fixmin_UI(a,b) fixmin(a,b)
-
+#define fixmax_D(a, b) fixmax(a, b)
+#define fixmin_D(a, b) fixmin(a, b)
+#define fixmax_S(a, b) fixmax(a, b)
+#define fixmin_S(a, b) fixmin(a, b)
+#define fixmax_I(a, b) fixmax(a, b)
+#define fixmin_I(a, b) fixmin(a, b)
+#define fixmax_UI(a, b) fixmax(a, b)
+#define fixmin_UI(a, b) fixmin(a, b)
#endif
diff --git a/libFDK/include/fixmul.h b/libFDK/include/fixmul.h
index ea4bc6c..a51ca0c 100644
--- a/libFDK/include/fixmul.h
+++ b/libFDK/include/fixmul.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,29 +90,29 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): Stefan Gewinner
+
Description: fixed point multiplication
-******************************************************************************/
+*******************************************************************************/
-#if !defined(__FIXMUL_H__)
-#define __FIXMUL_H__
+#if !defined(FIXMUL_H)
+#define FIXMUL_H
#include "FDK_archdef.h"
#include "machine_type.h"
-
#if defined(__arm__)
#include "arm/fixmul_arm.h"
-#elif defined(__mips__) /* cppp replaced: elif */
+#elif defined(__mips__)
#include "mips/fixmul_mips.h"
-#elif defined(__x86__) /* cppp replaced: elif */
+#elif defined(__x86__)
#include "x86/fixmul_x86.h"
#endif /* all cores */
@@ -114,173 +125,171 @@ amm-info@iis.fraunhofer.de
#if !defined(FUNCTION_fixmuldiv2_DD)
#define FUNCTION_fixmuldiv2_DD
-#if defined(_MSC_VER) || defined(__CC_ARM) || defined(__ANALOG_EXTENSIONS__) || defined(__TI_COMPILER_VERSION__)
-#pragma message ("Extremely slow implementation of fixmuldiv2_DD !!")
-#else
-#warning Extremely slow implementation of fixmuldiv2_DD !!
-#endif
-inline LONG fixmuldiv2_DD (const LONG a, const LONG b)
-{
- return (LONG) ((((INT64)a) * b) >> 32) ;
+inline LONG fixmuldiv2_DD(const LONG a, const LONG b) {
+ return (LONG)((((INT64)a) * b) >> 32);
}
#endif
#if !defined(FUNCTION_fixmuldiv2BitExact_DD)
#define FUNCTION_fixmuldiv2BitExact_DD
-#if defined(_MSC_VER) || defined(__CC_ARM) || defined(__ANALOG_EXTENSIONS__) || defined(__TI_COMPILER_VERSION__)
-#pragma message ("Extremely slow implementation of fixmuldiv2BitExact_DD !!")
-#else
-#warning Extremely slow implementation of fixmuldiv2BitExact_DD !!
-#endif
-inline LONG fixmuldiv2BitExact_DD (const LONG a, const LONG b)
-{
- return (LONG) ((((INT64)a) * b) >> 32) ;
+inline LONG fixmuldiv2BitExact_DD(const LONG a, const LONG b) {
+ return (LONG)((((INT64)a) * b) >> 32);
}
#endif
#if !defined(FUNCTION_fixmul_DD)
#define FUNCTION_fixmul_DD
-inline LONG fixmul_DD (const LONG a, const LONG b)
- { return fixmuldiv2_DD (a, b) << 1 ; }
+inline LONG fixmul_DD(const LONG a, const LONG b) {
+ return fixmuldiv2_DD(a, b) << 1;
+}
#endif
#if !defined(FUNCTION_fixmulBitExact_DD)
#define FUNCTION_fixmulBitExact_DD
-#if defined(_MSC_VER) || defined(__CC_ARM) || defined(__ANALOG_EXTENSIONS__) || defined(__TI_COMPILER_VERSION__) || defined(__XTENSA__)
-#pragma message ("Extremely slow implementation of fixmulBitExact_DD !!")
-#else
-#warning Extremely slow implementation of fixmulBitExact_DD !!
-#endif
-inline LONG fixmulBitExact_DD (const LONG a, const LONG b)
-{
- return ( (LONG) ((((INT64)a) * b) >> 32) ) << 1;
+inline LONG fixmulBitExact_DD(const LONG a, const LONG b) {
+ return ((LONG)((((INT64)a) * b) >> 32)) << 1;
}
#endif
#if !defined(FUNCTION_fixmuldiv2_SS)
#define FUNCTION_fixmuldiv2_SS
-inline LONG fixmuldiv2_SS (const SHORT a, const SHORT b)
- { return ((LONG)a*b); }
+inline LONG fixmuldiv2_SS(const SHORT a, const SHORT b) {
+ return ((LONG)a * b);
+}
#endif
#if !defined(FUNCTION_fixmul_SS)
#define FUNCTION_fixmul_SS
-inline LONG fixmul_SS (const SHORT a, const SHORT b)
- { return (a*b) <<1; }
+inline LONG fixmul_SS(const SHORT a, const SHORT b) { return (a * b) << 1; }
#endif
#if !defined(FUNCTION_fixmuldiv2_SD)
#define FUNCTION_fixmuldiv2_SD
-inline LONG fixmuldiv2_SD (const SHORT a, const LONG b)
+inline LONG fixmuldiv2_SD(const SHORT a, const LONG b)
#ifdef FUNCTION_fixmuldiv2_DS
- { return fixmuldiv2_DS(b, a); }
+{
+ return fixmuldiv2_DS(b, a);
+}
#else
- { return fixmuldiv2_DD(FX_SGL2FX_DBL(a), b); }
+{
+ return fixmuldiv2_DD(FX_SGL2FX_DBL(a), b);
+}
#endif
#endif
#if !defined(FUNCTION_fixmuldiv2_DS)
#define FUNCTION_fixmuldiv2_DS
-inline LONG fixmuldiv2_DS (const LONG a, const SHORT b)
+inline LONG fixmuldiv2_DS(const LONG a, const SHORT b)
#ifdef FUNCTION_fixmuldiv2_SD
- { return fixmuldiv2_SD(b, a); }
+{
+ return fixmuldiv2_SD(b, a);
+}
#else
- { return fixmuldiv2_DD(a, FX_SGL2FX_DBL(b)); }
+{
+ return fixmuldiv2_DD(a, FX_SGL2FX_DBL(b));
+}
#endif
#endif
#if !defined(FUNCTION_fixmuldiv2BitExact_SD)
#define FUNCTION_fixmuldiv2BitExact_SD
-inline LONG fixmuldiv2BitExact_SD (const SHORT a, const LONG b)
+inline LONG fixmuldiv2BitExact_SD(const SHORT a, const LONG b)
#ifdef FUNCTION_fixmuldiv2BitExact_DS
- { return fixmuldiv2BitExact_DS(b, a); }
+{
+ return fixmuldiv2BitExact_DS(b, a);
+}
#else
- { return (LONG) ((((INT64)a) * b) >> 16) ; }
+{
+ return (LONG)((((INT64)a) * b) >> 16);
+}
#endif
#endif
#if !defined(FUNCTION_fixmuldiv2BitExact_DS)
#define FUNCTION_fixmuldiv2BitExact_DS
-inline LONG fixmuldiv2BitExact_DS (const LONG a, const SHORT b)
+inline LONG fixmuldiv2BitExact_DS(const LONG a, const SHORT b)
#ifdef FUNCTION_fixmuldiv2BitExact_SD
- { return fixmuldiv2BitExact_SD(b, a); }
+{
+ return fixmuldiv2BitExact_SD(b, a);
+}
#else
- { return (LONG) ((((INT64)a) * b) >> 16) ; }
+{
+ return (LONG)((((INT64)a) * b) >> 16);
+}
#endif
#endif
#if !defined(FUNCTION_fixmul_SD)
#define FUNCTION_fixmul_SD
-inline LONG fixmul_SD (const SHORT a, const LONG b) {
+inline LONG fixmul_SD(const SHORT a, const LONG b) {
#ifdef FUNCTION_fixmul_DS
- return fixmul_SD(b, a);
+ return fixmul_DS(b, a);
#else
- return fixmuldiv2_SD (a, b) << 1 ;
+ return fixmuldiv2_SD(a, b) << 1;
#endif
}
#endif
#if !defined(FUNCTION_fixmul_DS)
#define FUNCTION_fixmul_DS
-inline LONG fixmul_DS (const LONG a, const SHORT b) {
+inline LONG fixmul_DS(const LONG a, const SHORT b) {
#ifdef FUNCTION_fixmul_SD
return fixmul_SD(b, a);
#else
- return fixmuldiv2_DS(a, b) << 1 ;
+ return fixmuldiv2_DS(a, b) << 1;
#endif
}
#endif
#if !defined(FUNCTION_fixmulBitExact_SD)
#define FUNCTION_fixmulBitExact_SD
-inline LONG fixmulBitExact_SD (const SHORT a, const LONG b)
+inline LONG fixmulBitExact_SD(const SHORT a, const LONG b)
#ifdef FUNCTION_fixmulBitExact_DS
- { return fixmulBitExact_DS(b, a); }
+{
+ return fixmulBitExact_DS(b, a);
+}
#else
- { return (LONG) (((((INT64)a) * b) >> 16) << 1); }
+{
+ return (LONG)(((((INT64)a) * b) >> 16) << 1);
+}
#endif
#endif
#if !defined(FUNCTION_fixmulBitExact_DS)
#define FUNCTION_fixmulBitExact_DS
-inline LONG fixmulBitExact_DS (const LONG a, const SHORT b)
+inline LONG fixmulBitExact_DS(const LONG a, const SHORT b)
#ifdef FUNCTION_fixmulBitExact_SD
- { return fixmulBitExact_SD(b, a); }
+{
+ return fixmulBitExact_SD(b, a);
+}
#else
- { return (LONG) (((((INT64)a) * b) >> 16) << 1); }
+{
+ return (LONG)(((((INT64)a) * b) >> 16) << 1);
+}
#endif
#endif
-
#if !defined(FUNCTION_fixpow2div2_D)
-#ifdef ARCH_WA_16BITMULT
-#error Fallback for fixpow2div2_D is not 16 bit safe !
-#endif
#define FUNCTION_fixpow2div2_D
-inline LONG fixpow2div2_D (const LONG a)
- { return fixmuldiv2_DD(a, a); }
+inline LONG fixpow2div2_D(const LONG a) { return fixmuldiv2_DD(a, a); }
#endif
#if !defined(FUNCTION_fixpow2_D)
-#ifdef ARCH_WA_16BITMULT
-#error Fallback for fixpow2_D is not 16 bit safe !
-#endif
#define FUNCTION_fixpow2_D
-inline LONG fixpow2_D (const LONG a)
- { return fixpow2div2_D(a)<<1; }
+inline LONG fixpow2_D(const LONG a) { return fixpow2div2_D(a) << 1; }
#endif
#if !defined(FUNCTION_fixpow2div2_S)
#define FUNCTION_fixpow2div2_S
-inline LONG fixpow2div2_S (const SHORT a)
- { return fixmuldiv2_SS(a, a); }
+inline LONG fixpow2div2_S(const SHORT a) { return fixmuldiv2_SS(a, a); }
#endif
#if !defined(FUNCTION_fixpow2_S)
#define FUNCTION_fixpow2_S
-inline LONG fixpow2_S (const SHORT a)
- { return fixpow2div2_S(a)<<1; }
+inline LONG fixpow2_S(const SHORT a) {
+ LONG result = fixpow2div2_S(a) << 1;
+ return result ^ (result >> 31);
+}
#endif
-
-#endif /* __FIXMUL_H__ */
+#endif /* FIXMUL_H */
diff --git a/libFDK/include/fixpoint_math.h b/libFDK/include/fixpoint_math.h
index 0d50f0a..3805892 100644
--- a/libFDK/include/fixpoint_math.h
+++ b/libFDK/include/fixpoint_math.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2015 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,21 +90,77 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s): M. Gayer
- Description: Fixed point specific mathematical functions
-******************************************************************************/
+ Description: Fixed point specific mathematical functions
-#ifndef __fixpoint_math_H
-#define __fixpoint_math_H
+*******************************************************************************/
+#ifndef FIXPOINT_MATH_H
+#define FIXPOINT_MATH_H
#include "common_fix.h"
+#include "scale.h"
+
+/*
+ * Data definitions
+ */
+
+#define LD_DATA_SCALING (64.0f)
+#define LD_DATA_SHIFT 6 /* pow(2, LD_DATA_SHIFT) = LD_DATA_SCALING */
+
+#define MAX_LD_PRECISION 10
+#define LD_PRECISION 10
+
+/* Taylor series coefficients for ln(1-x), centered at 0 (MacLaurin polynomial).
+ */
+#ifndef LDCOEFF_16BIT
+LNK_SECTION_CONSTDATA_L1
+static const FIXP_DBL ldCoeff[MAX_LD_PRECISION] = {
+ FL2FXCONST_DBL(-1.0), FL2FXCONST_DBL(-1.0 / 2.0),
+ FL2FXCONST_DBL(-1.0 / 3.0), FL2FXCONST_DBL(-1.0 / 4.0),
+ FL2FXCONST_DBL(-1.0 / 5.0), FL2FXCONST_DBL(-1.0 / 6.0),
+ FL2FXCONST_DBL(-1.0 / 7.0), FL2FXCONST_DBL(-1.0 / 8.0),
+ FL2FXCONST_DBL(-1.0 / 9.0), FL2FXCONST_DBL(-1.0 / 10.0)};
+#else /* LDCOEFF_16BIT */
+LNK_SECTION_CONSTDATA_L1
+static const FIXP_SGL ldCoeff[MAX_LD_PRECISION] = {
+ FL2FXCONST_SGL(-1.0), FL2FXCONST_SGL(-1.0 / 2.0),
+ FL2FXCONST_SGL(-1.0 / 3.0), FL2FXCONST_SGL(-1.0 / 4.0),
+ FL2FXCONST_SGL(-1.0 / 5.0), FL2FXCONST_SGL(-1.0 / 6.0),
+ FL2FXCONST_SGL(-1.0 / 7.0), FL2FXCONST_SGL(-1.0 / 8.0),
+ FL2FXCONST_SGL(-1.0 / 9.0), FL2FXCONST_SGL(-1.0 / 10.0)};
+#endif /* LDCOEFF_16BIT */
+
+/*****************************************************************************
+ functionname: invSqrtNorm2
+ description: delivers 1/sqrt(op) normalized to .5...1 and the shift value
+of the OUTPUT
+
+*****************************************************************************/
+#define SQRT_BITS 7
+#define SQRT_VALUES (128 + 2)
+#define SQRT_BITS_MASK 0x7f
+#define SQRT_FRACT_BITS_MASK 0x007FFFFF
+
+extern const FIXP_DBL invSqrtTab[SQRT_VALUES];
+
+/*
+ * Hardware specific implementations
+ */
+
+#if defined(__x86__)
+#include "x86/fixpoint_math_x86.h"
+#endif /* target architecture selector */
+
+/*
+ * Fallback implementations
+ */
#if !defined(FUNCTION_fIsLessThan)
/**
* \brief Compares two fixpoint values incl. scaling.
@@ -103,61 +170,83 @@ amm-info@iis.fraunhofer.de
* \param b_e exponent of the second input value.
* \return non-zero if (a_m*2^a_e) < (b_m*2^b_e), 0 otherwise
*/
-FDK_INLINE INT fIsLessThan(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e)
-{
+FDK_INLINE INT fIsLessThan(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e) {
if (a_e > b_e) {
- return (b_m >> fMin(a_e-b_e, DFRACT_BITS-1) > a_m);
+ return ((b_m >> fMin(a_e - b_e, DFRACT_BITS - 1)) > a_m);
} else {
- return (a_m >> fMin(b_e-a_e, DFRACT_BITS-1) < b_m);
+ return ((a_m >> fMin(b_e - a_e, DFRACT_BITS - 1)) < b_m);
}
}
-FDK_INLINE INT fIsLessThan(FIXP_SGL a_m, INT a_e, FIXP_SGL b_m, INT b_e)
-{
+FDK_INLINE INT fIsLessThan(FIXP_SGL a_m, INT a_e, FIXP_SGL b_m, INT b_e) {
if (a_e > b_e) {
- return (b_m >> fMin(a_e-b_e, FRACT_BITS-1) > a_m);
+ return ((b_m >> fMin(a_e - b_e, FRACT_BITS - 1)) > a_m);
} else {
- return (a_m >> fMin(b_e-a_e, FRACT_BITS-1) < b_m);
+ return ((a_m >> fMin(b_e - a_e, FRACT_BITS - 1)) < b_m);
}
}
#endif
-
-
-#define LD_DATA_SCALING (64.0f)
-#define LD_DATA_SHIFT 6 /* pow(2, LD_DATA_SHIFT) = LD_DATA_SCALING */
-
/**
* \brief deprecated. Use fLog2() instead.
*/
-FIXP_DBL CalcLdData(FIXP_DBL op);
+#define CalcLdData(op) fLog2(op, 0)
void LdDataVector(FIXP_DBL *srcVector, FIXP_DBL *destVector, INT number);
-FIXP_DBL CalcInvLdData(FIXP_DBL op);
+extern const UINT exp2_tab_long[32];
+extern const UINT exp2w_tab_long[32];
+extern const UINT exp2x_tab_long[32];
+
+LNK_SECTION_CODE_L1
+FDK_INLINE FIXP_DBL CalcInvLdData(const FIXP_DBL x) {
+ int set_zero = (x < FL2FXCONST_DBL(-31.0 / 64.0)) ? 0 : 1;
+ int set_max = (x >= FL2FXCONST_DBL(31.0 / 64.0)) | (x == FL2FXCONST_DBL(0.0));
+
+ FIXP_SGL frac = (FIXP_SGL)((LONG)x & 0x3FF);
+ UINT index3 = (UINT)(LONG)(x >> 10) & 0x1F;
+ UINT index2 = (UINT)(LONG)(x >> 15) & 0x1F;
+ UINT index1 = (UINT)(LONG)(x >> 20) & 0x1F;
+ int exp = fMin(31, ((x > FL2FXCONST_DBL(0.0f)) ? (31 - (int)(x >> 25))
+ : (int)(-(x >> 25))));
+
+ UINT lookup1 = exp2_tab_long[index1] * set_zero;
+ UINT lookup2 = exp2w_tab_long[index2];
+ UINT lookup3 = exp2x_tab_long[index3];
+ UINT lookup3f =
+ lookup3 + (UINT)(LONG)fMultDiv2((FIXP_DBL)(0x0016302F), (FIXP_SGL)frac);
+
+ UINT lookup12 = (UINT)(LONG)fMult((FIXP_DBL)lookup1, (FIXP_DBL)lookup2);
+ UINT lookup = (UINT)(LONG)fMult((FIXP_DBL)lookup12, (FIXP_DBL)lookup3f);
+ FIXP_DBL retVal = (lookup << 3) >> exp;
-void InitLdInt();
+ if (set_max) {
+ retVal = (FIXP_DBL)MAXVAL_DBL;
+ }
+
+ return retVal;
+}
+
+void InitLdInt();
FIXP_DBL CalcLdInt(INT i);
extern const USHORT sqrt_tab[49];
-inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x)
-{
+inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x) {
UINT y = (INT)x;
- UCHAR is_zero=(y==0);
- INT zeros=fixnormz_D(y) & 0x1e;
- y<<=zeros;
- UINT idx=(y>>26)-16;
- USHORT frac=(y>>10)&0xffff;
- USHORT nfrac=0xffff^frac;
- UINT t=nfrac*sqrt_tab[idx]+frac*sqrt_tab[idx+1];
- t=t>>(zeros>>1);
- return(is_zero ? 0 : t);
+ UCHAR is_zero = (y == 0);
+ INT zeros = fixnormz_D(y) & 0x1e;
+ y <<= zeros;
+ UINT idx = (y >> 26) - 16;
+ USHORT frac = (y >> 10) & 0xffff;
+ USHORT nfrac = 0xffff ^ frac;
+ UINT t = (UINT)nfrac * sqrt_tab[idx] + (UINT)frac * sqrt_tab[idx + 1];
+ t = t >> (zeros >> 1);
+ return (is_zero ? 0 : t);
}
-inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x, INT *x_e)
-{
+inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x, INT *x_e) {
UINT y = (INT)x;
INT e;
@@ -166,106 +255,153 @@ inline FIXP_DBL sqrtFixp_lookup(FIXP_DBL x, INT *x_e)
}
/* Normalize */
- e=fixnormz_D(y);
- y<<=e;
- e = *x_e - e + 2;
+ e = fixnormz_D(y);
+ y <<= e;
+ e = *x_e - e + 2;
/* Correct odd exponent. */
if (e & 1) {
y >>= 1;
- e ++;
+ e++;
}
/* Get square root */
- UINT idx=(y>>26)-16;
- USHORT frac=(y>>10)&0xffff;
- USHORT nfrac=0xffff^frac;
- UINT t=nfrac*sqrt_tab[idx]+frac*sqrt_tab[idx+1];
+ UINT idx = (y >> 26) - 16;
+ USHORT frac = (y >> 10) & 0xffff;
+ USHORT nfrac = 0xffff ^ frac;
+ UINT t = (UINT)nfrac * sqrt_tab[idx] + (UINT)frac * sqrt_tab[idx + 1];
/* Write back exponent */
*x_e = e >> 1;
- return (FIXP_DBL)(LONG)(t>>1);
+ return (FIXP_DBL)(LONG)(t >> 1);
}
-
-
-FIXP_DBL sqrtFixp(FIXP_DBL op);
-
void InitInvSqrtTab();
-FIXP_DBL invSqrtNorm2(FIXP_DBL op, INT *shift);
-
+#ifndef FUNCTION_invSqrtNorm2
+/**
+ * \brief calculate 1.0/sqrt(op)
+ * \param op_m mantissa of input value.
+ * \param result_e pointer to return the exponent of the result
+ * \return mantissa of the result
+ */
/*****************************************************************************
-
- functionname: invFixp
- description: delivers 1/(op)
-
+ delivers 1/sqrt(op) normalized to .5...1 and the shift value of the OUTPUT,
+ i.e. the denormalized result is 1/sqrt(op) = invSqrtNorm(op) * 2^(shift)
+ uses Newton-iteration for approximation
+ Q(n+1) = Q(n) + Q(n) * (0.5 - 2 * V * Q(n)^2)
+ with Q = 0.5* V ^-0.5; 0.5 <= V < 1.0
*****************************************************************************/
-inline FIXP_DBL invFixp(FIXP_DBL op)
-{
- INT tmp_exp ;
- FIXP_DBL tmp_inv = invSqrtNorm2(op, &tmp_exp) ;
- FDK_ASSERT((31-(2*tmp_exp+1))>=0) ;
- return ( fPow2Div2( (FIXP_DBL)tmp_inv ) >> (31-(2*tmp_exp+1)) ) ;
-}
+static FDK_FORCEINLINE FIXP_DBL invSqrtNorm2(FIXP_DBL op, INT *shift) {
+ FIXP_DBL val = op;
+ FIXP_DBL reg1, reg2;
+ if (val == FL2FXCONST_DBL(0.0)) {
+ *shift = 16;
+ return ((LONG)MAXVAL_DBL); /* maximum positive value */
+ }
+#define INVSQRTNORM2_LINEAR_INTERPOLATE
+#define INVSQRTNORM2_LINEAR_INTERPOLATE_HQ
+
+ /* normalize input, calculate shift value */
+ FDK_ASSERT(val > FL2FXCONST_DBL(0.0));
+ *shift = fNormz(val) - 1; /* CountLeadingBits() is not necessary here since
+ test value is always > 0 */
+ val <<= *shift; /* normalized input V */
+ *shift += 2; /* bias for exponent */
+
+#if defined(INVSQRTNORM2_LINEAR_INTERPOLATE)
+ INT index =
+ (INT)(val >> (DFRACT_BITS - 1 - (SQRT_BITS + 1))) & SQRT_BITS_MASK;
+ FIXP_DBL Fract =
+ (FIXP_DBL)(((INT)val & SQRT_FRACT_BITS_MASK) << (SQRT_BITS + 1));
+ FIXP_DBL diff = invSqrtTab[index + 1] - invSqrtTab[index];
+ reg1 = invSqrtTab[index] + (fMultDiv2(diff, Fract) << 1);
+#if defined(INVSQRTNORM2_LINEAR_INTERPOLATE_HQ)
+ /* reg1 = t[i] + (t[i+1]-t[i])*fract ... already computed ...
+ + (1-fract)fract*(t[i+2]-t[i+1])/2 */
+ if (Fract != (FIXP_DBL)0) {
+ /* fract = fract * (1 - fract) */
+ Fract = fMultDiv2(Fract, (FIXP_DBL)((ULONG)0x80000000 - (ULONG)Fract)) << 1;
+ diff = diff - (invSqrtTab[index + 2] - invSqrtTab[index + 1]);
+ reg1 = fMultAddDiv2(reg1, Fract, diff);
+ }
+#endif /* INVSQRTNORM2_LINEAR_INTERPOLATE_HQ */
+#else
+#error \
+ "Either define INVSQRTNORM2_NEWTON_ITERATE or INVSQRTNORM2_LINEAR_INTERPOLATE"
+#endif
+ /* calculate the output exponent = input exp/2 */
+ if (*shift & 0x00000001) { /* odd shift values ? */
+ /* Note: Do not use rounded value 0x5A82799A to avoid overflow with
+ * shift-by-2 */
+ reg2 = (FIXP_DBL)0x5A827999;
+ /* FL2FXCONST_DBL(0.707106781186547524400844362104849f);*/ /* 1/sqrt(2);
+ */
+ reg1 = fMultDiv2(reg1, reg2) << 2;
+ }
-#if defined(__mips__) && (__GNUC__==2)
+ *shift = *shift >> 1;
-#define FUNCTION_schur_div
-inline FIXP_DBL schur_div(FIXP_DBL num,FIXP_DBL denum, INT count)
-{
- INT result, tmp ;
- __asm__ ("srl %1, %2, 15\n"
- "div %3, %1\n" : "=lo" (result)
- : "%d" (tmp), "d" (denum) , "d" (num)
- : "hi" ) ;
- return result<<16 ;
+ return (reg1);
}
+#endif /* FUNCTION_invSqrtNorm2 */
-/*###########################################################################################*/
-#elif defined(__mips__) && (__GNUC__==3)
-
-#define FUNCTION_schur_div
-inline FIXP_DBL schur_div(FIXP_DBL num,FIXP_DBL denum, INT count)
-{
- INT result, tmp;
+#ifndef FUNCTION_sqrtFixp
+static FDK_FORCEINLINE FIXP_DBL sqrtFixp(FIXP_DBL op) {
+ INT tmp_exp = 0;
+ FIXP_DBL tmp_inv = invSqrtNorm2(op, &tmp_exp);
- __asm__ ("srl %[tmp], %[denum], 15\n"
- "div %[result], %[num], %[tmp]\n"
- : [tmp] "+r" (tmp), [result]"=r"(result)
- : [denum]"r"(denum), [num]"r"(num)
- : "hi", "lo");
- return result << (DFRACT_BITS-16);
+ FDK_ASSERT(tmp_exp > 0);
+ return ((FIXP_DBL)(fMultDiv2((op << (tmp_exp - 1)), tmp_inv) << 2));
}
+#endif /* FUNCTION_sqrtFixp */
-/*###########################################################################################*/
-#elif defined(SIMULATE_MIPS_DIV)
-
-#define FUNCTION_schur_div
-inline FIXP_DBL schur_div(FIXP_DBL num, FIXP_DBL denum, INT count)
-{
- FDK_ASSERT (count<=DFRACT_BITS-1);
- FDK_ASSERT (num>=(FIXP_DBL)0);
- FDK_ASSERT (denum>(FIXP_DBL)0);
- FDK_ASSERT (num <= denum);
+#ifndef FUNCTION_invFixp
+/**
+ * \brief calculate 1.0/op
+ * \param op mantissa of the input value.
+ * \return mantissa of the result with implicit exponent of 31
+ * \exceptions are provided for op=0,1 setting max. positive value
+ */
+static inline FIXP_DBL invFixp(FIXP_DBL op) {
+ if ((op == (FIXP_DBL)0x00000000) || (op == (FIXP_DBL)0x00000001)) {
+ return ((LONG)MAXVAL_DBL);
+ }
+ INT tmp_exp;
+ FIXP_DBL tmp_inv = invSqrtNorm2(op, &tmp_exp);
+ FDK_ASSERT((31 - (2 * tmp_exp + 1)) >= 0);
+ int shift = 31 - (2 * tmp_exp + 1);
+ tmp_inv = fPow2Div2(tmp_inv);
+ if (shift) {
+ tmp_inv = ((tmp_inv >> (shift - 1)) + (FIXP_DBL)1) >> 1;
+ }
+ return tmp_inv;
+}
- INT tmp = denum >> (count-1);
- INT result = 0;
+/**
+ * \brief calculate 1.0/(op_m * 2^op_e)
+ * \param op_m mantissa of the input value.
+ * \param op_e pointer into were the exponent of the input value is stored, and
+ * the result will be stored into.
+ * \return mantissa of the result
+ */
+static inline FIXP_DBL invFixp(FIXP_DBL op_m, int *op_e) {
+ if ((op_m == (FIXP_DBL)0x00000000) || (op_m == (FIXP_DBL)0x00000001)) {
+ *op_e = 31 - *op_e;
+ return ((LONG)MAXVAL_DBL);
+ }
- while (num > tmp)
- {
- num -= tmp;
- result++;
- }
+ INT tmp_exp;
+ FIXP_DBL tmp_inv = invSqrtNorm2(op_m, &tmp_exp);
- return result << (DFRACT_BITS-count);
+ *op_e = (tmp_exp << 1) - *op_e + 1;
+ return fPow2Div2(tmp_inv);
}
+#endif /* FUNCTION_invFixp */
-/*###########################################################################################*/
-#endif /* target architecture selector */
+#ifndef FUNCTION_schur_div
-#if !defined(FUNCTION_schur_div)
/**
* \brief Divide two FIXP_DBL values with given precision.
* \param num dividend
@@ -273,31 +409,34 @@ inline FIXP_DBL schur_div(FIXP_DBL num, FIXP_DBL denum, INT count)
* \param count amount of significant bits of the result (starting to the MSB)
* \return num/divisor
*/
-FIXP_DBL schur_div(FIXP_DBL num,FIXP_DBL denum, INT count);
-#endif
+FIXP_DBL schur_div(FIXP_DBL num, FIXP_DBL denum, INT count);
+#endif /* FUNCTION_schur_div */
-FIXP_DBL mul_dbl_sgl_rnd (const FIXP_DBL op1,
- const FIXP_SGL op2);
+FIXP_DBL mul_dbl_sgl_rnd(const FIXP_DBL op1, const FIXP_SGL op2);
+#ifndef FUNCTION_fMultNorm
/**
* \brief multiply two values with normalization, thus max precision.
* Author: Robert Weidner
*
* \param f1 first factor
- * \param f2 secod factor
- * \param result_e pointer to an INT where the exponent of the result is stored into
+ * \param f2 second factor
+ * \param result_e pointer to an INT where the exponent of the result is stored
+ * into
* \return mantissa of the product f1*f2
*/
-FIXP_DBL fMultNorm(
- FIXP_DBL f1,
- FIXP_DBL f2,
- INT *result_e
- );
+FIXP_DBL fMultNorm(FIXP_DBL f1, FIXP_DBL f2, INT *result_e);
-inline FIXP_DBL fMultNorm(FIXP_DBL f1, FIXP_DBL f2)
-{
+/**
+ * \brief Multiply 2 values using maximum precision. The exponent of the result
+ * is 0.
+ * \param f1_m mantissa of factor 1
+ * \param f2_m mantissa of factor 2
+ * \return mantissa of the result with exponent equal to 0
+ */
+inline FIXP_DBL fMultNorm(FIXP_DBL f1, FIXP_DBL f2) {
FIXP_DBL m;
INT e;
@@ -309,51 +448,252 @@ inline FIXP_DBL fMultNorm(FIXP_DBL f1, FIXP_DBL f2)
}
/**
+ * \brief Multiply 2 values with exponent and use given exponent for the
+ * mantissa of the result.
+ * \param f1_m mantissa of factor 1
+ * \param f1_e exponent of factor 1
+ * \param f2_m mantissa of factor 2
+ * \param f2_e exponent of factor 2
+ * \param result_e exponent for the returned mantissa of the result
+ * \return mantissa of the result with exponent equal to result_e
+ */
+inline FIXP_DBL fMultNorm(FIXP_DBL f1_m, INT f1_e, FIXP_DBL f2_m, INT f2_e,
+ INT result_e) {
+ FIXP_DBL m;
+ INT e;
+
+ m = fMultNorm(f1_m, f2_m, &e);
+
+ m = scaleValueSaturate(m, e + f1_e + f2_e - result_e);
+
+ return m;
+}
+#endif /* FUNCTION_fMultNorm */
+
+#ifndef FUNCTION_fMultI
+/**
+ * \brief Multiplies a fractional value and a integer value and performs
+ * rounding to nearest
+ * \param a fractional value
+ * \param b integer value
+ * \return integer value
+ */
+inline INT fMultI(FIXP_DBL a, INT b) {
+ FIXP_DBL m, mi;
+ INT m_e;
+
+ m = fMultNorm(a, (FIXP_DBL)b, &m_e);
+
+ if (m_e < (INT)0) {
+ if (m_e > (INT)-DFRACT_BITS) {
+ m = m >> ((-m_e) - 1);
+ mi = (m + (FIXP_DBL)1) >> 1;
+ } else {
+ mi = (FIXP_DBL)0;
+ }
+ } else {
+ mi = scaleValueSaturate(m, m_e);
+ }
+
+ return ((INT)mi);
+}
+#endif /* FUNCTION_fMultI */
+
+#ifndef FUNCTION_fMultIfloor
+/**
+ * \brief Multiplies a fractional value and a integer value and performs floor
+ * rounding
+ * \param a fractional value
+ * \param b integer value
+ * \return integer value
+ */
+inline INT fMultIfloor(FIXP_DBL a, INT b) {
+ FIXP_DBL m, mi;
+ INT m_e;
+
+ m = fMultNorm(a, (FIXP_DBL)b, &m_e);
+
+ if (m_e < (INT)0) {
+ if (m_e > (INT)-DFRACT_BITS) {
+ mi = m >> (-m_e);
+ } else {
+ mi = (FIXP_DBL)0;
+ if (m < (FIXP_DBL)0) {
+ mi = (FIXP_DBL)-1;
+ }
+ }
+ } else {
+ mi = scaleValueSaturate(m, m_e);
+ }
+
+ return ((INT)mi);
+}
+#endif /* FUNCTION_fMultIfloor */
+
+#ifndef FUNCTION_fMultIceil
+/**
+ * \brief Multiplies a fractional value and a integer value and performs ceil
+ * rounding
+ * \param a fractional value
+ * \param b integer value
+ * \return integer value
+ */
+inline INT fMultIceil(FIXP_DBL a, INT b) {
+ FIXP_DBL m, mi;
+ INT m_e;
+
+ m = fMultNorm(a, (FIXP_DBL)b, &m_e);
+
+ if (m_e < (INT)0) {
+ if (m_e > (INT)-DFRACT_BITS) {
+ mi = (m >> (-m_e));
+ if ((LONG)m & ((1 << (-m_e)) - 1)) {
+ mi = mi + (FIXP_DBL)1;
+ }
+ } else {
+ mi = (FIXP_DBL)1;
+ if (m < (FIXP_DBL)0) {
+ mi = (FIXP_DBL)0;
+ }
+ }
+ } else {
+ mi = scaleValueSaturate(m, m_e);
+ }
+
+ return ((INT)mi);
+}
+#endif /* FUNCTION_fMultIceil */
+
+#ifndef FUNCTION_fDivNorm
+/**
* \brief Divide 2 FIXP_DBL values with normalization of input values.
* \param num numerator
- * \param denum denomintator
- * \return num/denum with exponent = 0
+ * \param denum denominator
+ * \param result_e pointer to an INT where the exponent of the result is stored
+ * into
+ * \return num/denum with exponent = *result_e
*/
FIXP_DBL fDivNorm(FIXP_DBL num, FIXP_DBL denom, INT *result_e);
/**
- * \brief Divide 2 FIXP_DBL values with normalization of input values.
+ * \brief Divide 2 positive FIXP_DBL values with normalization of input values.
* \param num numerator
- * \param denum denomintator
- * \param result_e pointer to an INT where the exponent of the result is stored into
- * \return num/denum with exponent = *result_e
+ * \param denum denominator
+ * \return num/denum with exponent = 0
*/
FIXP_DBL fDivNorm(FIXP_DBL num, FIXP_DBL denom);
/**
- * \brief Divide 2 FIXP_DBL values with normalization of input values.
+ * \brief Divide 2 signed FIXP_DBL values with normalization of input values.
* \param num numerator
- * \param denum denomintator
+ * \param denum denominator
+ * \param result_e pointer to an INT where the exponent of the result is stored
+ * into
+ * \return num/denum with exponent = *result_e
+ */
+FIXP_DBL fDivNormSigned(FIXP_DBL L_num, FIXP_DBL L_denum, INT *result_e);
+
+/**
+ * \brief Divide 2 signed FIXP_DBL values with normalization of input values.
+ * \param num numerator
+ * \param denum denominator
* \return num/denum with exponent = 0
*/
-FIXP_DBL fDivNormHighPrec(FIXP_DBL L_num, FIXP_DBL L_denum, INT *result_e);
+FIXP_DBL fDivNormSigned(FIXP_DBL num, FIXP_DBL denom);
+#endif /* FUNCTION_fDivNorm */
/**
- * \brief Calculate log(argument)/log(2) (logarithm with base 2). deprecated. Use fLog2() instead.
- * \param arg mantissa of the argument
- * \param arg_e exponent of the argument
- * \param result_e pointer to an INT to store the exponent of the result
- * \return the mantissa of the result.
- * \param
+ * \brief Adjust mantissa to exponent -1
+ * \param a_m mantissa of value to be adjusted
+ * \param pA_e pointer to the exponen of a_m
+ * \return adjusted mantissa
*/
-FIXP_DBL CalcLog2(FIXP_DBL arg, INT arg_e, INT *result_e);
+inline FIXP_DBL fAdjust(FIXP_DBL a_m, INT *pA_e) {
+ INT shift;
+ shift = fNorm(a_m) - 1;
+ *pA_e -= shift;
+
+ return scaleValue(a_m, shift);
+}
+
+#ifndef FUNCTION_fAddNorm
/**
- * \brief return 2 ^ (exp * 2^exp_e)
+ * \brief Add two values with normalization
+ * \param a_m mantissa of first summand
+ * \param a_e exponent of first summand
+ * \param a_m mantissa of second summand
+ * \param a_e exponent of second summand
+ * \param pResult_e pointer to where the exponent of the result will be stored
+ * to.
+ * \return mantissa of result
+ */
+inline FIXP_DBL fAddNorm(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e,
+ INT *pResult_e) {
+ INT result_e;
+ FIXP_DBL result_m;
+
+ /* If one of the summands is zero, return the other.
+ This is necessary for the summation of a very small number to zero */
+ if (a_m == (FIXP_DBL)0) {
+ *pResult_e = b_e;
+ return b_m;
+ }
+ if (b_m == (FIXP_DBL)0) {
+ *pResult_e = a_e;
+ return a_m;
+ }
+
+ a_m = fAdjust(a_m, &a_e);
+ b_m = fAdjust(b_m, &b_e);
+
+ if (a_e > b_e) {
+ result_m = a_m + (b_m >> fMin(a_e - b_e, DFRACT_BITS - 1));
+ result_e = a_e;
+ } else {
+ result_m = (a_m >> fMin(b_e - a_e, DFRACT_BITS - 1)) + b_m;
+ result_e = b_e;
+ }
+
+ *pResult_e = result_e;
+ return result_m;
+}
+
+inline FIXP_DBL fAddNorm(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e,
+ INT result_e) {
+ FIXP_DBL result_m;
+
+ a_m = scaleValue(a_m, a_e - result_e);
+ b_m = scaleValue(b_m, b_e - result_e);
+
+ result_m = a_m + b_m;
+
+ return result_m;
+}
+#endif /* FUNCTION_fAddNorm */
+
+/**
+ * \brief Divide 2 FIXP_DBL values with normalization of input values.
+ * \param num numerator
+ * \param denum denomintator
+ * \return num/denum with exponent = 0
+ */
+FIXP_DBL fDivNormHighPrec(FIXP_DBL L_num, FIXP_DBL L_denum, INT *result_e);
+
+#ifndef FUNCTION_fPow
+/**
+ * \brief return 2 ^ (exp_m * 2^exp_e)
* \param exp_m mantissa of the exponent to 2.0f
* \param exp_e exponent of the exponent to 2.0f
- * \param result_e pointer to a INT where the exponent of the result will be stored into
+ * \param result_e pointer to a INT where the exponent of the result will be
+ * stored into
* \return mantissa of the result
*/
FIXP_DBL f2Pow(const FIXP_DBL exp_m, const INT exp_e, INT *result_e);
/**
- * \brief return 2 ^ (exp_m * 2^exp_e). This version returns only the mantissa with implicit exponent of zero.
+ * \brief return 2 ^ (exp_m * 2^exp_e). This version returns only the mantissa
+ * with implicit exponent of zero.
* \param exp_m mantissa of the exponent to 2.0f
* \param exp_e exponent of the exponent to 2.0f
* \return mantissa of the result
@@ -361,57 +701,70 @@ FIXP_DBL f2Pow(const FIXP_DBL exp_m, const INT exp_e, INT *result_e);
FIXP_DBL f2Pow(const FIXP_DBL exp_m, const INT exp_e);
/**
- * \brief return x ^ (exp * 2^exp_e), where log2(x) = baseLd_m * 2^(baseLd_e). This saves
- * the need to compute log2() of constant values (when x is a constant).
- * \param ldx_m mantissa of log2() of x.
- * \param ldx_e exponent of log2() of x.
+ * \brief return x ^ (exp_m * 2^exp_e), where log2(x) = baseLd_m * 2^(baseLd_e).
+ * This saves the need to compute log2() of constant values (when x is a
+ * constant).
+ * \param baseLd_m mantissa of log2() of x.
+ * \param baseLd_e exponent of log2() of x.
* \param exp_m mantissa of the exponent to 2.0f
* \param exp_e exponent of the exponent to 2.0f
- * \param result_e pointer to a INT where the exponent of the result will be stored into
+ * \param result_e pointer to a INT where the exponent of the result will be
+ * stored into
* \return mantissa of the result
*/
-FIXP_DBL fLdPow(
- FIXP_DBL baseLd_m,
- INT baseLd_e,
- FIXP_DBL exp_m, INT exp_e,
- INT *result_e
- );
+FIXP_DBL fLdPow(FIXP_DBL baseLd_m, INT baseLd_e, FIXP_DBL exp_m, INT exp_e,
+ INT *result_e);
/**
- * \brief return x ^ (exp * 2^exp_e), where log2(x) = baseLd_m * 2^(baseLd_e). This saves
- * the need to compute log2() of constant values (when x is a constant). This version
- * does not return an exponent, which is implicitly 0.
- * \param ldx_m mantissa of log2() of x.
- * \param ldx_e exponent of log2() of x.
+ * \brief return x ^ (exp_m * 2^exp_e), where log2(x) = baseLd_m * 2^(baseLd_e).
+ * This saves the need to compute log2() of constant values (when x is a
+ * constant). This version does not return an exponent, which is
+ * implicitly 0.
+ * \param baseLd_m mantissa of log2() of x.
+ * \param baseLd_e exponent of log2() of x.
* \param exp_m mantissa of the exponent to 2.0f
* \param exp_e exponent of the exponent to 2.0f
* \return mantissa of the result
*/
-FIXP_DBL fLdPow(
- FIXP_DBL baseLd_m, INT baseLd_e,
- FIXP_DBL exp_m, INT exp_e
- );
+FIXP_DBL fLdPow(FIXP_DBL baseLd_m, INT baseLd_e, FIXP_DBL exp_m, INT exp_e);
/**
- * \brief return (base * 2^base_e) ^ (exp * 2^exp_e). Use fLdPow() instead whenever possible.
+ * \brief return (base_m * 2^base_e) ^ (exp * 2^exp_e). Use fLdPow() instead
+ * whenever possible.
* \param base_m mantissa of the base.
* \param base_e exponent of the base.
* \param exp_m mantissa of power to be calculated of the base.
* \param exp_e exponent of power to be calculated of the base.
- * \param result_e pointer to a INT where the exponent of the result will be stored into.
+ * \param result_e pointer to a INT where the exponent of the result will be
+ * stored into.
* \return mantissa of the result.
*/
-FIXP_DBL fPow(FIXP_DBL base_m, INT base_e, FIXP_DBL exp_m, INT exp_e, INT *result_e);
+FIXP_DBL fPow(FIXP_DBL base_m, INT base_e, FIXP_DBL exp_m, INT exp_e,
+ INT *result_e);
/**
- * \brief return (base * 2^base_e) ^ N
- * \param base mantissa of the base
+ * \brief return (base_m * 2^base_e) ^ N
+ * \param base_m mantissa of the base
* \param base_e exponent of the base
- * \param power to be calculated of the base
- * \param result_e pointer to a INT where the exponent of the result will be stored into
+ * \param N power to be calculated of the base
+ * \param result_e pointer to a INT where the exponent of the result will be
+ * stored into
* \return mantissa of the result
*/
FIXP_DBL fPowInt(FIXP_DBL base_m, INT base_e, INT N, INT *result_e);
+#endif /* #ifndef FUNCTION_fPow */
+
+#ifndef FUNCTION_fLog2
+/**
+ * \brief Calculate log(argument)/log(2) (logarithm with base 2). deprecated.
+ * Use fLog2() instead.
+ * \param arg mantissa of the argument
+ * \param arg_e exponent of the argument
+ * \param result_e pointer to an INT to store the exponent of the result
+ * \return the mantissa of the result.
+ * \param
+ */
+FIXP_DBL CalcLog2(FIXP_DBL arg, INT arg_e, INT *result_e);
/**
* \brief calculate logarithm of base 2 of x_m * 2^(x_e)
@@ -420,7 +773,68 @@ FIXP_DBL fPowInt(FIXP_DBL base_m, INT base_e, INT N, INT *result_e);
* \param pointer to an INT where the exponent of the result is returned into.
* \return mantissa of the result.
*/
-FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e, INT *result_e);
+FDK_INLINE FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e, INT *result_e) {
+ FIXP_DBL result_m;
+
+ /* Short cut for zero and negative numbers. */
+ if (x_m <= FL2FXCONST_DBL(0.0f)) {
+ *result_e = DFRACT_BITS - 1;
+ return FL2FXCONST_DBL(-1.0f);
+ }
+
+ /* Calculate log2() */
+ {
+ FIXP_DBL x2_m;
+
+ /* Move input value x_m * 2^x_e toward 1.0, where the taylor approximation
+ of the function log(1-x) centered at 0 is most accurate. */
+ {
+ INT b_norm;
+
+ b_norm = fNormz(x_m) - 1;
+ x2_m = x_m << b_norm;
+ x_e = x_e - b_norm;
+ }
+
+ /* map x from log(x) domain to log(1-x) domain. */
+ x2_m = -(x2_m + FL2FXCONST_DBL(-1.0));
+
+ /* Taylor polynomial approximation of ln(1-x) */
+ {
+ FIXP_DBL px2_m;
+ result_m = FL2FXCONST_DBL(0.0);
+ px2_m = x2_m;
+ for (int i = 0; i < LD_PRECISION; i++) {
+ result_m = fMultAddDiv2(result_m, ldCoeff[i], px2_m);
+ px2_m = fMult(px2_m, x2_m);
+ }
+ }
+ /* Multiply result with 1/ln(2) = 1.0 + 0.442695040888 (get log2(x) from
+ * ln(x) result). */
+ result_m =
+ fMultAddDiv2(result_m, result_m,
+ FL2FXCONST_DBL(2.0 * 0.4426950408889634073599246810019));
+
+ /* Add exponent part. log2(x_m * 2^x_e) = log2(x_m) + x_e */
+ if (x_e != 0) {
+ int enorm;
+
+ enorm = DFRACT_BITS - fNorm((FIXP_DBL)x_e);
+ /* The -1 in the right shift of result_m compensates the fMultDiv2() above
+ * in the taylor polynomial evaluation loop.*/
+ result_m = (result_m >> (enorm - 1)) +
+ ((FIXP_DBL)x_e << (DFRACT_BITS - 1 - enorm));
+
+ *result_e = enorm;
+ } else {
+ /* 1 compensates the fMultDiv2() above in the taylor polynomial evaluation
+ * loop.*/
+ *result_e = 1;
+ }
+ }
+
+ return result_m;
+}
/**
* \brief calculate logarithm of base 2 of x_m * 2^(x_e)
@@ -428,16 +842,27 @@ FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e, INT *result_e);
* \param x_e exponent of the input value.
* \return mantissa of the result with implicit exponent of LD_DATA_SHIFT.
*/
-FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e);
+FDK_INLINE FIXP_DBL fLog2(FIXP_DBL x_m, INT x_e) {
+ if (x_m <= FL2FXCONST_DBL(0.0f)) {
+ x_m = FL2FXCONST_DBL(-1.0f);
+ } else {
+ INT result_e;
+ x_m = fLog2(x_m, x_e, &result_e);
+ x_m = scaleValue(x_m, result_e - LD_DATA_SHIFT);
+ }
+ return x_m;
+}
+#endif /* FUNCTION_fLog2 */
+
+#ifndef FUNCTION_fAddSaturate
/**
* \brief Add with saturation of the result.
* \param a first summand
* \param b second summand
* \return saturated sum of a and b.
*/
-inline FIXP_SGL fAddSaturate(const FIXP_SGL a, const FIXP_SGL b)
-{
+inline FIXP_SGL fAddSaturate(const FIXP_SGL a, const FIXP_SGL b) {
LONG sum;
sum = (LONG)(SHORT)a + (LONG)(SHORT)b;
@@ -451,19 +876,26 @@ inline FIXP_SGL fAddSaturate(const FIXP_SGL a, const FIXP_SGL b)
* \param b second summand
* \return saturated sum of a and b.
*/
-inline FIXP_DBL fAddSaturate(const FIXP_DBL a, const FIXP_DBL b)
-{
+inline FIXP_DBL fAddSaturate(const FIXP_DBL a, const FIXP_DBL b) {
LONG sum;
- sum = (LONG)(a>>1) + (LONG)(b>>1);
- sum = fMax(fMin((INT)sum, (INT)(MAXVAL_DBL>>1)), (INT)(MINVAL_DBL>>1));
- return (FIXP_DBL)(LONG)(sum<<1);
+ sum = (LONG)(a >> 1) + (LONG)(b >> 1);
+ sum = fMax(fMin((INT)sum, (INT)(MAXVAL_DBL >> 1)), (INT)(MINVAL_DBL >> 1));
+ return (FIXP_DBL)(LONG)(sum << 1);
}
+#endif /* FUNCTION_fAddSaturate */
-//#define TEST_ROUNDING
+INT fixp_floorToInt(FIXP_DBL f_inp, INT sf);
+FIXP_DBL fixp_floor(FIXP_DBL f_inp, INT sf);
+INT fixp_ceilToInt(FIXP_DBL f_inp, INT sf);
+FIXP_DBL fixp_ceil(FIXP_DBL f_inp, INT sf);
+INT fixp_truncateToInt(FIXP_DBL f_inp, INT sf);
+FIXP_DBL fixp_truncate(FIXP_DBL f_inp, INT sf);
+INT fixp_roundToInt(FIXP_DBL f_inp, INT sf);
+FIXP_DBL fixp_round(FIXP_DBL f_inp, INT sf);
/*****************************************************************************
@@ -471,25 +903,19 @@ inline FIXP_DBL fAddSaturate(const FIXP_DBL a, const FIXP_DBL b)
****************************************************************************/
- extern const FIXP_DBL invCount[80];
-
- LNK_SECTION_INITCODE
- inline void InitInvInt(void) {}
+extern const FIXP_DBL invCount[80];
+LNK_SECTION_INITCODE
+inline void InitInvInt(void) {}
/**
* \brief Calculate the value of 1/i where i is a integer value. It supports
- * input values from 1 upto 80.
+ * input values from 1 upto (80-1).
* \param intValue Integer input value.
* \param FIXP_DBL representation of 1/intValue
*/
-inline FIXP_DBL GetInvInt(int intValue)
-{
- FDK_ASSERT((intValue > 0) && (intValue < 80));
- FDK_ASSERT(intValue<80);
- return invCount[intValue];
+inline FIXP_DBL GetInvInt(int intValue) {
+ return invCount[fMin(fMax(intValue, 0), 80 - 1)];
}
-
-#endif
-
+#endif /* FIXPOINT_MATH_H */
diff --git a/libFDK/include/huff_nodes.h b/libFDK/include/huff_nodes.h
new file mode 100644
index 0000000..0dda5d3
--- /dev/null
+++ b/libFDK/include/huff_nodes.h
@@ -0,0 +1,258 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Omer Osman
+
+ Description: MPEG-D SAC/USAC/SAOC Huffman Part0 Tables
+
+*******************************************************************************/
+
+#ifndef HUFF_NODES_H
+#define HUFF_NODES_H
+
+#include "genericStds.h"
+
+typedef struct {
+ SHORT nodeTab[39][2];
+
+} HUFF_RES_NODES;
+
+/* 1D Nodes */
+typedef struct {
+ SHORT nodeTab[30][2];
+
+} HUFF_CLD_NOD_1D;
+
+typedef struct {
+ SHORT nodeTab[7][2];
+
+} HUFF_ICC_NOD_1D;
+
+typedef struct {
+ SHORT nodeTab[50][2];
+
+} HUFF_CPC_NOD_1D;
+
+typedef struct {
+ SHORT nodeTab[15][2];
+
+} HUFF_OLD_NOD_1D;
+
+typedef struct {
+ SHORT nodeTab[63][2];
+
+} HUFF_NRG_NOD_1D;
+
+/* 2D Nodes */
+typedef struct {
+ SHORT lav3[15][2];
+ SHORT lav5[35][2];
+ SHORT lav7[63][2];
+ SHORT lav9[99][2];
+
+} HUFF_CLD_NOD_2D;
+
+typedef struct {
+ SHORT lav1[3][2];
+ SHORT lav3[15][2];
+ SHORT lav5[35][2];
+ SHORT lav7[63][2];
+
+} HUFF_ICC_NOD_2D;
+
+typedef struct {
+ SHORT lav3[15][2];
+ SHORT lav6[48][2];
+ SHORT lav9[99][2];
+ SHORT lav12[168][2];
+
+} HUFF_OLD_NOD_2D;
+
+typedef struct {
+ SHORT lav3[15][2];
+ SHORT lav5[35][2];
+ SHORT lav7[63][2];
+ SHORT lav9[99][2];
+
+} HUFF_NRG_NOD_2D_df;
+
+typedef struct {
+ SHORT lav3[15][2];
+ SHORT lav6[48][2];
+ SHORT lav9[99][2];
+ SHORT lav12[168][2];
+
+} HUFF_NRG_NOD_2D_dt;
+
+typedef struct {
+ HUFF_NRG_NOD_2D_df df[2];
+ HUFF_NRG_NOD_2D_dt dt[2];
+ HUFF_NRG_NOD_2D_df dp[2];
+
+} HUFF_NRG_NOD_2D;
+
+/* Complete bs Parameter Nodes */
+typedef struct {
+ const HUFF_CLD_NOD_1D *h1D[3];
+ const HUFF_CLD_NOD_2D *h2D[3][2];
+
+} HUFF_CLD_NODES;
+
+typedef struct {
+ const HUFF_ICC_NOD_1D *h1D[3];
+ const HUFF_ICC_NOD_2D *h2D[3][2];
+
+} HUFF_ICC_NODES;
+
+typedef struct {
+ const HUFF_OLD_NOD_1D *h1D[3];
+ const HUFF_OLD_NOD_2D *h2D[3][2];
+
+} HUFF_OLD_NODES;
+
+typedef struct {
+ const HUFF_NRG_NOD_1D *h1D[3];
+ const HUFF_NRG_NOD_2D *h2D;
+
+} HUFF_NRG_NODES;
+
+/* parameter instance */
+typedef struct {
+ SHORT cld[30][2];
+ SHORT icc[7][2];
+ SHORT ipd[7][2];
+ SHORT old[15][2];
+ SHORT nrg[63][2];
+} HUFF_PT0_NODES;
+
+typedef struct {
+ SHORT nodeTab[3][2];
+
+} HUFF_LAV_NODES;
+
+/* USAC specific */
+typedef struct {
+ SHORT nodeTab[7][2];
+
+} HUFF_IPD_NOD_1D;
+
+typedef struct {
+ SHORT lav1[3][2];
+ SHORT lav3[15][2];
+ SHORT lav5[35][2];
+ SHORT lav7[63][2];
+
+} HUFF_IPD_NOD_2D;
+
+typedef struct {
+ HUFF_IPD_NOD_1D h1D[3];
+ HUFF_IPD_NOD_2D h2D[3][2];
+
+} HUFF_IPD_NODES;
+
+/* non-lossy coding decoder */
+extern const HUFF_PT0_NODES FDK_huffPart0Nodes;
+extern const HUFF_LAV_NODES FDK_huffLavIdxNodes;
+
+extern const HUFF_ICC_NODES FDK_huffICCNodes;
+extern const HUFF_CLD_NODES FDK_huffCLDNodes;
+extern const HUFF_RES_NODES FDK_huffReshapeNodes;
+
+extern const HUFF_OLD_NODES huffOLDNodes;
+
+extern const HUFF_IPD_NODES FDK_huffIPDNodes;
+
+#endif /* HUFF_NODES_H */
diff --git a/libFDK/include/mdct.h b/libFDK/include/mdct.h
index e1c2d74..e671da9 100644
--- a/libFDK/include/mdct.h
+++ b/libFDK/include/mdct.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,34 +90,47 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
+----------------------------------------------------------------------------- */
- Author(s): Manuel Jander, Josef Hoepfl
- Description: MDCT routines
+/******************* Library for basic calculation routines ********************
-******************************************************************************/
+ Author(s): Manuel Jander, Josef Hoepfl, Youliy Ninov, Daniel Hagel
-#ifndef __MDCT_H__
-#define __MDCT_H__
+ Description: MDCT/MDST routines
+*******************************************************************************/
+#ifndef MDCT_H
+#define MDCT_H
#include "common_fix.h"
-#define MDCT_OUT_HEADROOM 2 /* Output additional headroom */
-#define MDCT_OUTPUT_SCALE (DFRACT_BITS-SAMPLE_BITS-MDCT_OUT_HEADROOM)
+#define MDCT_OUT_HEADROOM 2 /* Output additional headroom */
+#define PCM_OUT_BITS SAMPLE_BITS
+#define PCM_OUT_HEADROOM 8 /* Must have the same values as DMXH_HEADROOM */
+
+#define MDCT_OUTPUT_SCALE (-MDCT_OUT_HEADROOM + (DFRACT_BITS - SAMPLE_BITS))
/* Refer to "Output word length" in ISO/IEC 14496-3:2008(E) 23.2.3.6 */
-#define MDCT_OUTPUT_GAIN 16
+#define MDCT_OUTPUT_GAIN 16
-#if (SAMPLE_BITS == DFRACT_BITS)
-#define IMDCT_SCALE(x) (INT_PCM)SATURATE_LEFT_SHIFT(x, -MDCT_OUTPUT_SCALE, SAMPLE_BITS)
+#if (MDCT_OUTPUT_SCALE >= 0)
+#define IMDCT_SCALE(x) SATURATE_RIGHT_SHIFT(x, MDCT_OUTPUT_SCALE, PCM_OUT_BITS)
#else
-#define IMDCT_SCALE(x) (INT_PCM)SATURATE_RIGHT_SHIFT(x, MDCT_OUTPUT_SCALE, SAMPLE_BITS)
+#define IMDCT_SCALE(x) SATURATE_LEFT_SHIFT(x, -MDCT_OUTPUT_SCALE, PCM_OUT_BITS)
#endif
#define IMDCT_SCALE_DBL(x) (FIXP_DBL)(x)
+#define MLT_FLAG_CURR_ALIAS_SYMMETRY 1
+
+typedef enum {
+ BLOCK_LONG = 0, /* normal long block */
+ BLOCK_START, /* long start block */
+ BLOCK_SHORT, /* 8 short blocks sequence */
+ BLOCK_STOP /* long stop block*/
+} BLOCK_TYPE;
+
+typedef enum { SHAPE_SINE = 0, SHAPE_KBD, SHAPE_LOL } WINDOW_SHAPE;
+
/**
* \brief MDCT persistent data
*/
@@ -114,18 +138,24 @@ typedef struct {
union {
FIXP_DBL *freq;
FIXP_DBL *time;
- } overlap; /**< Pointer to overlap memory */
+ } overlap; /**< Pointer to overlap memory */
+
+ const FIXP_WTP *prev_wrs; /**< pointer to previous right window slope */
+ int prev_tl; /**< previous transform length */
+ int prev_nr; /**< previous right window offset */
+ int prev_fr; /**< previous right window slope length */
+ int ov_offset; /**< overlap time data fill level */
+ int ov_size; /**< Overlap buffer size in words */
- const FIXP_WTP *prev_wrs; /**< pointer to previous right window slope */
- int prev_tl; /**< previous tranform length */
- int prev_nr; /**< previous right window offset */
- int prev_fr; /**< previous right window slope length */
- int ov_offset; /**< overlap time data fill level */
- int ov_size; /**< Overlap buffer size in words */
+ int prevAliasSymmetry;
+ int prevPrevAliasSymmetry;
+ FIXP_DBL *pFacZir;
+ FIXP_DBL *pAsymOvlp; /**< pointer to asymmetric overlap (used for stereo LPD
+ transition) */
} mdct_t;
-typedef mdct_t* H_MDCT;
+typedef mdct_t *H_MDCT;
/**
* \brief Initialize as valid MDCT handle
@@ -133,68 +163,52 @@ typedef mdct_t* H_MDCT;
* \param hMdct handle of an allocated MDCT handle.
* \param overlap pointer to FIXP_DBL overlap buffer.
* \param overlapBufferSize size in FIXP_DBLs of the given overlap buffer.
- * \return void
*/
-void mdct_init( H_MDCT hMdct,
- FIXP_DBL *overlap,
- INT overlapBufferSize );
+void mdct_init(H_MDCT hMdct, FIXP_DBL *overlap, INT overlapBufferSize);
/**
- * \brief perform MDCT transform (time domain to frequency domain) with given parameters.
+ * \brief perform MDCT transform (time domain to frequency domain) with given
+ * parameters.
*
* \param hMdct handle of an allocated MDCT handle.
- * \param spectrum pointer to where the resulting MDCT spectrum will be stored into.
- * \param scalefactor pointer to the input scale shift value. Updated accordingly on return.
- * \param input pointer to input time domain signal
- * \param tl transformation length.
- * \param nr right window slope offset (amount of window coefficients assumed to be 1.0)
- * \param fr right overlap window slope length
- * \param wrs pointer to the right side overlap window coefficients.
+ * \param pTimeData pointer to input time domain signal
+ * \param noInSamples number of input samples
+ * \param mdctData pointer to where the resulting MDCT spectrum will be stored
+ * into.
+ * \param nSpec number of spectra
+ * \param pMdctData_e pointer to the input data exponent. Updated accordingly on
+ * return for output data.
* \return number of input samples processed.
*/
-INT mdct_block(
- H_MDCT hMdct,
- FIXP_DBL *spectrum,
- INT *scalefactor,
- INT_PCM *input,
- INT tl,
- INT nr,
- INT fr,
- const FIXP_WTB *wrs );
-
+INT mdct_block(H_MDCT hMdct, const INT_PCM *pTimeData, const INT noInSamples,
+ FIXP_DBL *RESTRICT mdctData, const INT nSpec, const INT tl,
+ const FIXP_WTP *pRightWindowPart, const INT fr,
+ SHORT *pMdctData_e);
/**
- * \brief add/multiply 2/N transform gain and MPEG4 part 3 defined output gain (see definition
- * of MDCT_OUTPUT_GAIN) to given mantissa factor and exponent.
- * \param pGain pointer to the mantissa of a gain factor to be applied to IMDCT data.
- * \param pExponent pointer to the exponent of a gain factor to be applied to IMDCT data.
- * \param tl length of the IMDCT where the gain *pGain * (2 ^ *pExponent) will be applied to.
+ * \brief add/multiply 2/N transform gain and MPEG4 part 3 defined output gain
+ * (see definition of MDCT_OUTPUT_GAIN) to given mantissa factor and exponent.
+ * \param pGain pointer to the mantissa of a gain factor to be applied to IMDCT
+ * data.
+ * \param pExponent pointer to the exponent of a gain factor to be applied to
+ * IMDCT data.
+ * \param tl length of the IMDCT where the gain *pGain * (2 ^ *pExponent) will
+ * be applied to.
*/
-void imdct_gain(
- FIXP_DBL *pGain,
- int *pExponent,
- int tl
- );
+void imdct_gain(FIXP_DBL *pGain, int *pExponent, int tl);
/**
- * \brief drain buffered output samples into given buffer. Changes the MDCT state.
+ * \brief drain buffered output samples into given buffer. Changes the MDCT
+ * state.
*/
-INT imdct_drain(
- H_MDCT hMdct,
- FIXP_DBL * pTimeData,
- INT nrSamplesRoom
- );
-
+INT imdct_drain(H_MDCT hMdct, FIXP_DBL *pTimeData, INT nrSamplesRoom);
/**
- * \brief Copy overlap time domain data to given buffer. Does not change the MDCT state.
+ * \brief Copy overlap time domain data to given buffer. Does not change the
+ * MDCT state.
* \return number of actually copied samples (ov + nr).
*/
-INT imdct_copy_ov_and_nr(
- H_MDCT hMdct,
- FIXP_DBL * pTimeData,
- INT nrSamples
- );
+INT imdct_copy_ov_and_nr(H_MDCT hMdct, FIXP_DBL *pTimeData, INT nrSamples);
/**
* \brief Adapt MDCT parameters for non-matching window slopes.
@@ -205,39 +219,34 @@ INT imdct_copy_ov_and_nr(
* \param wls pointer to the left side overlap window coefficients.
* \param noOutSamples desired number of output samples.
*/
-void imdct_adapt_parameters(H_MDCT hMdct, int *pfl, int *pnl, int tl, const FIXP_WTP *wls, int noOutSamples);
+void imdct_adapt_parameters(H_MDCT hMdct, int *pfl, int *pnl, int tl,
+ const FIXP_WTP *wls, int noOutSamples);
/**
- * \brief perform several inverse MDCT transforms (frequency domain to time domain) with given parameters.
+ * \brief perform several inverse MLT transforms (frequency domain to time
+ * domain) with given parameters.
*
* \param hMdct handle of an allocated MDCT handle.
- * \param output pointer to where the output time domain signal will be stored into.
- * \param stride the stride factor for accessing time domain samples in output.
+ * \param output pointer to where the output time domain signal will be stored
+ * into.
* \param spectrum pointer to the input MDCT spectra.
- * \param scalefactors scale shift values of the input spectrum.
+ * \param scalefactors exponents of the input spectrum.
* \param nSpec number of MDCT spectrums.
* \param noOutSamples desired number of output samples.
* \param tl transform length.
* \param wls pointer to the left side overlap window coefficients.
* \param fl left overlap window side length.
- * \param wrs pointer to the right side overlap window coefficients of all individual IMDCTs.
+ * \param wrs pointer to the right side overlap window coefficients of all
+ * individual IMDCTs.
* \param fr right overlap window side length of all individual IMDCTs.
* \param gain factor to apply to output samples (if != 0).
+ * \param flags flags controlling the type of transform
* \return number of output samples returned.
*/
-INT imdct_block(
- H_MDCT hMdct,
- FIXP_DBL *output,
- FIXP_DBL *spectrum,
- const SHORT scalefactor[],
- const INT nSpec,
- const INT noOutSamples,
- const INT tl,
- const FIXP_WTP *wls,
- INT fl,
- const FIXP_WTP *wrs,
- const INT fr,
- FIXP_DBL gain );
-
-
-#endif /* __MDCT_H__ */
+INT imlt_block(H_MDCT hMdct, FIXP_DBL *output, FIXP_DBL *spectrum,
+ const SHORT scalefactor[], const INT nSpec,
+ const INT noOutSamples, const INT tl, const FIXP_WTP *wls,
+ INT fl, const FIXP_WTP *wrs, const INT fr, FIXP_DBL gain,
+ int flags);
+
+#endif /* MDCT_H */
diff --git a/libFDK/include/mips/abs_mips.h b/libFDK/include/mips/abs_mips.h
index 3b9f876..dbb2063 100644
--- a/libFDK/include/mips/abs_mips.h
+++ b/libFDK/include/mips/abs_mips.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,29 +90,36 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(ABS_MIPS_H)
+#define ABS_MIPS_H
#if defined(__mips__)
#if defined(__GNUC__) && defined(__mips__)
- #if defined(__mips_dsp)
- #define FUNCTION_fixabs_D
- #define FUNCTION_fixabs_I
- #define FUNCTION_fixabs_S
- inline FIXP_DBL fixabs_D(FIXP_DBL x) { return __builtin_mips_absq_s_w(x); }
- inline FIXP_SGL fixabs_S(FIXP_SGL x) { return ((x) > (FIXP_SGL)(0)) ? (x) : -(x) ; }
- inline INT fixabs_I(INT x) { return __builtin_mips_absq_s_w(x); }
- #endif /* __mips_dsp */
+#if defined(__mips_dsp)
+#define FUNCTION_fixabs_D
+#define FUNCTION_fixabs_I
+#define FUNCTION_fixabs_S
+inline FIXP_DBL fixabs_D(FIXP_DBL x) { return __builtin_mips_absq_s_w(x); }
+inline FIXP_SGL fixabs_S(FIXP_SGL x) {
+ return ((x) > (FIXP_SGL)(0)) ? (x) : -(x);
+}
+inline INT fixabs_I(INT x) { return __builtin_mips_absq_s_w(x); }
+#endif /* __mips_dsp */
#endif /* defined(__GNUC__) && defined(__mips__) */
#endif /*__mips__ */
+#endif /* !defined(ABS_MIPS_H) */
diff --git a/libFDK/include/mips/clz_mips.h b/libFDK/include/mips/clz_mips.h
index ff40a09..748f6c2 100644
--- a/libFDK/include/mips/clz_mips.h
+++ b/libFDK/include/mips/clz_mips.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,40 +90,45 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(CLZ_MIPS_H)
+#define CLZ_MIPS_H
#if defined(__mips__)
-#if defined(__mips__) && (__GNUC__==2) && (mips>=32)
+#if defined(__mips__) && (__GNUC__ == 2) && (mips >= 32)
- #define FUNCTION_fixnormz_D
- inline INT fixnormz_D(LONG value)
- {
- INT result;
- __asm__ ("clz %0,%1" : "=d" (result) : "d" (value));
+#define FUNCTION_fixnormz_D
+inline INT fixnormz_D(LONG value) {
+ INT result;
+ __asm__("clz %0,%1" : "=d"(result) : "d"(value));
- return result;
- }
+ return result;
+}
-#elif defined(__mips__) && (__GNUC__==3) && (__mips>=32)
+#elif defined(__mips__) && (__GNUC__ == 3) && (__mips >= 32)
- #define FUNCTION_fixnormz_D
- INT inline fixnormz_D(LONG value)
- {
- INT result;
- __asm__ ("clz %[result], %[value]" : [result] "=r" (result) : [value] "r" (value)) ;
+#define FUNCTION_fixnormz_D
+INT inline fixnormz_D(LONG value) {
+ INT result;
+ __asm__("clz %[result], %[value]"
+ : [result] "=r"(result)
+ : [value] "r"(value));
- return result;
- }
+ return result;
+}
#endif
#endif /* __mips__ */
+#endif /* !defined(CLZ_MIPS_H) */
diff --git a/libFDK/include/mips/cplx_mul.h b/libFDK/include/mips/cplx_mul.h
deleted file mode 100644
index 43cdbd0..0000000
--- a/libFDK/include/mips/cplx_mul.h
+++ /dev/null
@@ -1,162 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
-
- Author(s):
- Description: fixed point intrinsics
-
-******************************************************************************/
-
-
-#if defined(__GNUC__) && defined(__mips__) && __mips_isa_rev < 6
-
-
-//#define FUNCTION_cplxMultDiv2_32x16
-//#define FUNCTION_cplxMultDiv2_32x16X2
-#define FUNCTION_cplxMultDiv2_32x32X2
-//#define FUNCTION_cplxMult_32x16
-//#define FUNCTION_cplxMult_32x16X2
-#define FUNCTION_cplxMult_32x32X2
-
-#if defined(FUNCTION_cplxMultDiv2_32x32X2)
-inline void cplxMultDiv2( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- FIXP_DBL a_Re,
- FIXP_DBL a_Im,
- FIXP_DBL b_Re,
- FIXP_DBL b_Im)
-{
- INT result;
-
- __asm__ ("mult %[a_Re], %[b_Re];\n"
- "msub %[a_Im], %[b_Im];\n"
- "mfhi %[result];\n"
- : [result]"=r"(result)
- : [a_Re]"d"(a_Re), [b_Re]"d"(b_Re), [a_Im]"d"(a_Im), [b_Im]"d"(b_Im)
- : "lo");
-
- *c_Re = result;
-
- __asm__ ("mult %[a_Re], %[b_Im];\n"
- "madd %[a_Im], %[b_Re];\n"
- "mfhi %[result];\n"
- : [result]"=r"(result)
- : [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re)
- : "lo");
- *c_Im = result;
-}
-#endif
-
-#if defined(FUNCTION_cplxMult_32x32X2)
-inline void cplxMult( FIXP_DBL *c_Re,
- FIXP_DBL *c_Im,
- FIXP_DBL a_Re,
- FIXP_DBL a_Im,
- FIXP_DBL b_Re,
- FIXP_DBL b_Im)
-{
- INT result;
-
- __asm__ ("mult %[a_Re], %[b_Re];\n"
- "msub %[a_Im], %[b_Im];\n"
- "mfhi %[result];\n"
- //"extr_w %[result], 31;\n"
- : [result]"=r"(result)
- : [a_Re]"r"(a_Re), [b_Re]"r"(b_Re), [a_Im]"r"(a_Im), [b_Im]"r"(b_Im)
- : "lo");
- *c_Re = result<<1;
-
- __asm__ ("mult %[a_Re], %[b_Im];\n"
- "madd %[a_Im], %[b_Re];\n"
- "mfhi %[result];\n"
- //"extr_w %[result], 31;\n"
- : [result]"=r"(result)
- : [a_Re]"r"(a_Re), [b_Im]"r"(b_Im), [a_Im]"r"(a_Im), [b_Re]"r"(b_Re)
- : "lo");
- *c_Im = result<<1;
-}
-#endif
-
-#endif /* defined(__GNUC__) && defined(__mips__) */
-
diff --git a/libFDK/include/mips/cplx_mul_mips.h b/libFDK/include/mips/cplx_mul_mips.h
new file mode 100644
index 0000000..acae118
--- /dev/null
+++ b/libFDK/include/mips/cplx_mul_mips.h
@@ -0,0 +1,170 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description: fixed point intrinsics
+
+*******************************************************************************/
+
+#if !defined(CPLX_MUL_MIPS_H)
+#define CPLX_MUL_MIPS_H
+
+#if defined(__GNUC__) && defined(__mips__) && __mips_isa_rev < 6
+
+//#define FUNCTION_cplxMultDiv2_32x16
+//#define FUNCTION_cplxMultDiv2_32x16X2
+#define FUNCTION_cplxMultDiv2_32x32X2
+//#define FUNCTION_cplxMult_32x16
+//#define FUNCTION_cplxMult_32x16X2
+#define FUNCTION_cplxMult_32x32X2
+
+#if defined(FUNCTION_cplxMultDiv2_32x32X2)
+inline void cplxMultDiv2(FIXP_DBL *c_Re, FIXP_DBL *c_Im, FIXP_DBL a_Re,
+ FIXP_DBL a_Im, FIXP_DBL b_Re, FIXP_DBL b_Im) {
+ INT result;
+
+ __asm__(
+ "mult %[a_Re], %[b_Re];\n"
+ "msub %[a_Im], %[b_Im];\n"
+ "mfhi %[result];\n"
+ : [result] "=r"(result)
+ : [a_Re] "d"(a_Re), [b_Re] "d"(b_Re), [a_Im] "d"(a_Im), [b_Im] "d"(b_Im)
+ : "lo");
+
+ *c_Re = result;
+
+ __asm__(
+ "mult %[a_Re], %[b_Im];\n"
+ "madd %[a_Im], %[b_Re];\n"
+ "mfhi %[result];\n"
+ : [result] "=r"(result)
+ : [a_Re] "r"(a_Re), [b_Im] "r"(b_Im), [a_Im] "r"(a_Im), [b_Re] "r"(b_Re)
+ : "lo");
+ *c_Im = result;
+}
+#endif
+
+#if defined(FUNCTION_cplxMult_32x32X2)
+inline void cplxMult(FIXP_DBL *c_Re, FIXP_DBL *c_Im, FIXP_DBL a_Re,
+ FIXP_DBL a_Im, FIXP_DBL b_Re, FIXP_DBL b_Im) {
+ INT result;
+
+ __asm__(
+ "mult %[a_Re], %[b_Re];\n"
+ "msub %[a_Im], %[b_Im];\n"
+ "mfhi %[result];\n"
+ //"extr_w %[result], 31;\n"
+ : [result] "=r"(result)
+ : [a_Re] "r"(a_Re), [b_Re] "r"(b_Re), [a_Im] "r"(a_Im), [b_Im] "r"(b_Im)
+ : "lo");
+ *c_Re = result << 1;
+
+ __asm__(
+ "mult %[a_Re], %[b_Im];\n"
+ "madd %[a_Im], %[b_Re];\n"
+ "mfhi %[result];\n"
+ //"extr_w %[result], 31;\n"
+ : [result] "=r"(result)
+ : [a_Re] "r"(a_Re), [b_Im] "r"(b_Im), [a_Im] "r"(a_Im), [b_Re] "r"(b_Re)
+ : "lo");
+ *c_Im = result << 1;
+}
+#endif
+
+#endif /* defined(__GNUC__) && defined(__mips__) */
+
+#endif /* !defined(CPLX_MUL_MIPS_H) */
diff --git a/libFDK/include/mips/fixmadd_mips.h b/libFDK/include/mips/fixmadd_mips.h
deleted file mode 100644
index a9575fb..0000000
--- a/libFDK/include/mips/fixmadd_mips.h
+++ /dev/null
@@ -1,95 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
-
- Author(s):
- Description: fixed point intrinsics
-
-******************************************************************************/
-
-#if defined(__mips__)
-
-
-#endif /* __mips__ */
-
diff --git a/libFDK/include/mips/fixmul_mips.h b/libFDK/include/mips/fixmul_mips.h
index 73693e2..06cf530 100644
--- a/libFDK/include/mips/fixmul_mips.h
+++ b/libFDK/include/mips/fixmul_mips.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,30 +90,35 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(FIXMUL_MIPS_H)
+#define FIXMUL_MIPS_H
#if defined(__mips__)
-#if (__GNUC__) && defined(__mips__) /* cppp replaced: elif */
+#if (__GNUC__) && defined(__mips__)
/* MIPS GCC based compiler */
#define FUNCTION_fixmuldiv2_DD
#define FUNCTION_fixmuldiv2BitExact_DD
-#define fixmuldiv2BitExact_DD(a,b) fixmuldiv2_DD(a,b)
+#define fixmuldiv2BitExact_DD(a, b) fixmuldiv2_DD(a, b)
+
+inline INT fixmuldiv2_DD(const INT a, const INT b) {
+ INT result;
+
+ result = ((long long)a * b) >> 32;
-inline INT fixmuldiv2_DD (const INT a, const INT b)
-{
- INT result ;
- result = ((long long)a * b)>>32;
- return result ;
+ return result;
}
#endif /* (__GNUC__) && defined(__mips__) */
@@ -111,3 +127,4 @@ inline INT fixmuldiv2_DD (const INT a, const INT b)
#define FUNCTION_fixmulBitExact_DD
#define fixmulBitExact_DD fixmul_DD
+#endif /* !defined(FIXMUL_MIPS_H) */
diff --git a/libFDK/include/mips/scale.h b/libFDK/include/mips/scale.h
deleted file mode 100644
index edf29da..0000000
--- a/libFDK/include/mips/scale.h
+++ /dev/null
@@ -1,110 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
-
- Author(s):
- Description:
-
-******************************************************************************/
-
-#ifndef MIPS_SCALE_H
-#define MIPS_SCALE_H
-
-#if defined(__mips_dsp)
-
-/*!
-*
-* \brief Scale input value by 2^{scale} and saturate output to 2^{dBits-1}
-* \return scaled and saturated value
-*
-* This macro scales src value right or left and applies saturation to (2^dBits)-1
-* maxima output.
-*/
-#define SATURATE_RIGHT_SHIFT(src, scale, dBits) \
- (__builtin_mips_shll_s_w((src)>>scale,(DFRACT_BITS-(dBits)))>>(DFRACT_BITS-(dBits)))
-
-
-#endif /*__mips_dsp */
-
-#endif /* MIPS_SCALE_H */
diff --git a/libFDK/include/mips/scale_mips.h b/libFDK/include/mips/scale_mips.h
new file mode 100644
index 0000000..3c141fc
--- /dev/null
+++ b/libFDK/include/mips/scale_mips.h
@@ -0,0 +1,122 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description:
+
+*******************************************************************************/
+
+#ifndef SCALE_MIPS_H
+#define SCALE_MIPS_H
+
+#if defined(__mips_dsp)
+
+/*!
+ *
+ * \brief Scale input value by 2^{scale} and saturate output to 2^{dBits-1}
+ * \return scaled and saturated value
+ *
+ * This macro scales src value right or left and applies saturation to
+ * (2^dBits)-1 maxima output.
+ */
+#define SATURATE_RIGHT_SHIFT(src, scale, dBits) \
+ (__builtin_mips_shll_s_w((src) >> (scale), (DFRACT_BITS - (dBits))) >> \
+ (DFRACT_BITS - (dBits)))
+
+#endif /*__mips_dsp */
+
+#endif /* SCALE_MIPS_H */
diff --git a/libFDK/include/mips/scramble.h b/libFDK/include/mips/scramble.h
deleted file mode 100644
index 3f2fe6e..0000000
--- a/libFDK/include/mips/scramble.h
+++ /dev/null
@@ -1,121 +0,0 @@
-
-/* -----------------------------------------------------------------------------------------------------------
-Software License for The Fraunhofer FDK AAC Codec Library for Android
-
-© 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
------------------------------------------------------------------------------------------------------------ */
-
-/*************************** Fraunhofer IIS FDK Tools **********************
-
- Author(s):
- Description:
-
-******************************************************************************/
-
-#ifndef MIPS_SCRAMBLE_H
-#define MIPS_SCRAMBLE_H
-
-#define FUNCTION_scramble
-
-#if defined(FUNCTION_scramble)
-inline void scramble(FIXP_DBL *x, INT n) {
- INT m,j;
- int ldn=1;
- do {ldn++;} while((1<<ldn)<n);
-
- for (m=1,j=0; m<n-1; m++)
- {
- j = __builtin_mips_bitrev(m) >> (16-ldn);
-
- if (j>m)
- {
- FIXP_DBL tmp;
- tmp=x[2*m];
- x[2*m]=x[2*j];
- x[2*j]=tmp;
-
- tmp=x[2*m+1];
- x[2*m+1]=x[2*j+1];
- x[2*j+1]=tmp;
- }
- }
-}
-#endif
-
-#endif /* MIPS_SCRAMBLE_H */
diff --git a/libFDK/include/mips/scramble_mips.h b/libFDK/include/mips/scramble_mips.h
new file mode 100644
index 0000000..08c2e6d
--- /dev/null
+++ b/libFDK/include/mips/scramble_mips.h
@@ -0,0 +1,133 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description:
+
+*******************************************************************************/
+
+#ifndef SCRAMBLE_MIPS_H
+#define SCRAMBLE_MIPS_H
+
+#define FUNCTION_scramble
+
+#if defined(FUNCTION_scramble)
+inline void scramble(FIXP_DBL *x, INT n) {
+ INT m, j;
+ int ldn = 1;
+ do {
+ ldn++;
+ } while ((1 << ldn) < n);
+
+ for (m = 1, j = 0; m < n - 1; m++) {
+ j = __builtin_mips_bitrev(m) >> (16 - ldn);
+
+ if (j > m) {
+ FIXP_DBL tmp;
+ tmp = x[2 * m];
+ x[2 * m] = x[2 * j];
+ x[2 * j] = tmp;
+
+ tmp = x[2 * m + 1];
+ x[2 * m + 1] = x[2 * j + 1];
+ x[2 * j + 1] = tmp;
+ }
+ }
+}
+#endif
+
+#endif /* SCRAMBLE_MIPS_H */
diff --git a/libFDK/include/nlc_dec.h b/libFDK/include/nlc_dec.h
new file mode 100644
index 0000000..cca97f1
--- /dev/null
+++ b/libFDK/include/nlc_dec.h
@@ -0,0 +1,187 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Omer Osman
+
+ Description: SAC/SAOC Dec Noiseless Coding
+
+*******************************************************************************/
+
+#ifndef NLC_DEC_H
+#define NLC_DEC_H
+
+#include "FDK_bitstream.h"
+#include "huff_nodes.h"
+#include "common_fix.h"
+
+typedef enum {
+
+ SAC_DECODER,
+ SAOC_DECODER,
+ USAC_DECODER
+
+} DECODER_TYPE;
+
+typedef enum {
+ t_CLD,
+ t_ICC,
+ t_IPD,
+ t_OLD,
+ t_IOC,
+ t_NRG,
+ t_DCLD,
+ t_DMG,
+ t_PDG
+
+} DATA_TYPE;
+
+typedef enum {
+
+ BACKWARDS = 0x0,
+ FORWARDS = 0x1
+
+} DIRECTION;
+
+typedef enum {
+
+ DIFF_FREQ = 0x0,
+ DIFF_TIME = 0x1
+
+} DIFF_TYPE;
+
+typedef enum {
+
+ HUFF_1D = 0x0,
+ HUFF_2D = 0x1
+
+} CODING_SCHEME;
+
+typedef enum {
+
+ FREQ_PAIR = 0x0,
+ TIME_PAIR = 0x1
+
+} PAIRING;
+
+#ifndef HUFFDEC_PARAMS
+#define HUFFDEC_PARMS
+
+#define PAIR_SHIFT 4
+#define PAIR_MASK 0xf
+
+#define MAX_ENTRIES 168
+#define HANDLE_HUFF_NODE const SHORT(*)[MAX_ENTRIES][2]
+
+#endif /* HUFFDECPARAMS */
+
+#define HUFFDEC_OK 0
+#define HUFFDEC_NOTOK (-1)
+
+typedef int ERROR_t;
+
+ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm,
+ SCHAR *aaOutData1, SCHAR *aaOutData2, SCHAR *aHistory,
+ DATA_TYPE data_type, int startBand, int dataBands,
+ int pair_flag, int coarse_flag,
+ int allowDiffTimeBack_flag);
+
+/* needed for GES- & STP-tool */
+ERROR_t huff_dec_reshape(HANDLE_FDK_BITSTREAM strm, int *out_data, int num_val);
+
+extern ERROR_t sym_restoreIPD(HANDLE_FDK_BITSTREAM strm, int lav,
+ SCHAR data[2]);
+
+#endif
diff --git a/libFDK/include/qmf.h b/libFDK/include/qmf.h
index be69477..609c6f1 100644
--- a/libFDK/include/qmf.h
+++ b/libFDK/include/qmf.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,170 +90,212 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s):
+
+ Description:
+
+*******************************************************************************/
/*!
\file qmf.h
- \brief Complex qmf analysis/synthesis
+ \brief Complex qmf analysis/synthesis
\author Markus Werner
*/
-#ifndef __QMF_H
-#define __QMF_H
-
+#ifndef QMF_H
+#define QMF_H
#include "common_fix.h"
#include "FDK_tools_rom.h"
#include "dct.h"
-/*
- * Filter coefficient type definition
- */
-#ifdef QMF_DATA_16BIT
-#define FIXP_QMF FIXP_SGL
-#define FX_DBL2FX_QMF FX_DBL2FX_SGL
-#define FX_QMF2FX_DBL FX_SGL2FX_DBL
-#define QFRACT_BITS FRACT_BITS
-#else
-#define FIXP_QMF FIXP_DBL
-#define FX_DBL2FX_QMF
-#define FX_QMF2FX_DBL
-#define QFRACT_BITS DFRACT_BITS
-#endif
-
-/* ARM neon optimized QMF analysis filter requires 32 bit input.
- Implemented for RVCT only, currently disabled. See src/arm/qmf_arm.cpp:45 */
#define FIXP_QAS FIXP_PCM
#define QAS_BITS SAMPLE_BITS
-#ifdef QMFSYN_STATES_16BIT
-#define FIXP_QSS FIXP_SGL
-#define QSS_BITS FRACT_BITS
-#else
#define FIXP_QSS FIXP_DBL
#define QSS_BITS DFRACT_BITS
-#endif
/* Flags for QMF intialization */
/* Low Power mode flag */
-#define QMF_FLAG_LP 1
-/* Filter is not symetric. This flag is set internally in the QMF initialization as required. */
+#define QMF_FLAG_LP 1
+/* Filter is not symmetric. This flag is set internally in the QMF
+ * initialization as required. */
+/* DO NOT PASS THIS FLAG TO qmfInitAnalysisFilterBank or
+ * qmfInitSynthesisFilterBank */
#define QMF_FLAG_NONSYMMETRIC 2
/* Complex Low Delay Filter Bank (or std symmetric filter bank) */
-#define QMF_FLAG_CLDFB 4
+#define QMF_FLAG_CLDFB 4
/* Flag indicating that the states should be kept. */
-#define QMF_FLAG_KEEP_STATES 8
+#define QMF_FLAG_KEEP_STATES 8
/* Complex Low Delay Filter Bank used in MPEG Surround Encoder */
-#define QMF_FLAG_MPSLDFB 16
-/* Complex Low Delay Filter Bank used in MPEG Surround Encoder allows a optimized calculation of the modulation in qmfForwardModulationHQ() */
-#define QMF_FLAG_MPSLDFB_OPTIMIZE_MODULATION 32
-/* Flag to indicate HE-AAC down-sampled SBR mode (decoder) -> adapt analysis post twiddling */
-#define QMF_FLAG_DOWNSAMPLED 64
-
-
-typedef struct
-{
- int lb_scale; /*!< Scale of low band area */
- int ov_lb_scale; /*!< Scale of adjusted overlap low band area */
- int hb_scale; /*!< Scale of high band area */
- int ov_hb_scale; /*!< Scale of adjusted overlap high band area */
+#define QMF_FLAG_MPSLDFB 16
+/* Complex Low Delay Filter Bank used in MPEG Surround Encoder allows a
+ * optimized calculation of the modulation in qmfForwardModulationHQ() */
+#define QMF_FLAG_MPSLDFB_OPTIMIZE_MODULATION 32
+/* Flag to indicate HE-AAC down-sampled SBR mode (decoder) -> adapt analysis
+ * post twiddling */
+#define QMF_FLAG_DOWNSAMPLED 64
+
+#define QMF_MAX_SYNTHESIS_BANDS (64)
+
+/*!
+ * \brief Algorithmic scaling in sbrForwardModulation()
+ *
+ * The scaling in sbrForwardModulation() is caused by:
+ *
+ * \li 1 R_SHIFT in sbrForwardModulation()
+ * \li 5/6 R_SHIFT in dct3() if using 32/64 Bands
+ * \li 1 omitted gain of 2.0 in qmfForwardModulation()
+ */
+#define ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK 7
+
+/*!
+ * \brief Algorithmic scaling in cplxSynthesisQmfFiltering()
+ *
+ * The scaling in cplxSynthesisQmfFiltering() is caused by:
+ *
+ * \li 5/6 R_SHIFT in dct2() if using 32/64 Bands
+ * \li 1 omitted gain of 2.0 in qmfInverseModulation()
+ * \li -6 division by 64 in synthesis filterbank
+ * \li x bits external influence
+ */
+#define ALGORITHMIC_SCALING_IN_SYNTHESIS_FILTERBANK 1
+
+typedef struct {
+ int lb_scale; /*!< Scale of low band area */
+ int ov_lb_scale; /*!< Scale of adjusted overlap low band area */
+ int hb_scale; /*!< Scale of high band area */
+ int ov_hb_scale; /*!< Scale of adjusted overlap high band area */
} QMF_SCALE_FACTOR;
-struct QMF_FILTER_BANK
-{
- const FIXP_PFT *p_filter; /*!< Pointer to filter coefficients */
+struct QMF_FILTER_BANK {
+ const FIXP_PFT *p_filter; /*!< Pointer to filter coefficients */
- void *FilterStates; /*!< Pointer to buffer of filter states
- FIXP_PCM in analyse and
- FIXP_DBL in synthesis filter */
- int FilterSize; /*!< Size of prototype filter. */
- const FIXP_QTW *t_cos; /*!< Modulation tables. */
+ void *FilterStates; /*!< Pointer to buffer of filter states
+ FIXP_PCM in analyse and
+ FIXP_DBL in synthesis filter */
+ int FilterSize; /*!< Size of prototype filter. */
+ const FIXP_QTW *t_cos; /*!< Modulation tables. */
const FIXP_QTW *t_sin;
- int filterScale; /*!< filter scale */
-
- int no_channels; /*!< Total number of channels (subbands) */
- int no_col; /*!< Number of time slots */
- int lsb; /*!< Top of low subbands */
- int usb; /*!< Top of high subbands */
+ int filterScale; /*!< filter scale */
- int outScalefactor; /*!< Scale factor of output data (syn only) */
- FIXP_DBL outGain; /*!< Gain output data (syn only) (init with 0x80000000 to ignore) */
+ int no_channels; /*!< Total number of channels (subbands) */
+ int no_col; /*!< Number of time slots */
+ int lsb; /*!< Top of low subbands */
+ int usb; /*!< Top of high subbands */
- UINT flags; /*!< flags */
- UCHAR p_stride; /*!< Stride Factor of polyphase filters */
+ int synScalefactor; /*!< Scale factor of synthesis qmf (syn only) */
+ int outScalefactor; /*!< Scale factor of output data (syn only) */
+ FIXP_DBL outGain_m; /*!< Mantissa of gain output data (syn only) (init with
+ 0x80000000 to ignore) */
+ int outGain_e; /*!< Exponent of gain output data (syn only) */
+ UINT flags; /*!< flags */
+ UCHAR p_stride; /*!< Stride Factor of polyphase filters */
};
typedef struct QMF_FILTER_BANK *HANDLE_QMF_FILTER_BANK;
-void
-qmfAnalysisFiltering( HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank */
- FIXP_QMF **qmfReal, /*!< Pointer to real subband slots */
- FIXP_QMF **qmfImag, /*!< Pointer to imag subband slots */
- QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
- const INT_PCM *timeIn, /*!< Time signal */
- const int stride, /*!< Stride factor of audio data */
- FIXP_QMF *pWorkBuffer /*!< pointer to temporal working buffer */
- );
-
-void
-qmfSynthesisFiltering( HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
- FIXP_QMF **QmfBufferReal, /*!< Pointer to real subband slots */
- FIXP_QMF **QmfBufferImag, /*!< Pointer to imag subband slots */
- const QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
- const int ov_len, /*!< Length of band overlap */
- INT_PCM *timeOut, /*!< Time signal */
- const int stride, /*!< Stride factor of audio data */
- FIXP_QMF *pWorkBuffer /*!< pointer to temporal working buffer */
- );
-
-int
-qmfInitAnalysisFilterBank( HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
- FIXP_QAS *pFilterStates, /*!< Pointer to filter state buffer */
- int noCols, /*!< Number of time slots */
- int lsb, /*!< Number of lower bands */
- int usb, /*!< Number of upper bands */
- int no_channels, /*!< Number of critically sampled bands */
- int flags); /*!< Flags */
-
-void
-qmfAnalysisFilteringSlot( HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank */
- FIXP_QMF *qmfReal, /*!< Low and High band, real */
- FIXP_QMF *qmfImag, /*!< Low and High band, imag */
- const INT_PCM *timeIn, /*!< Pointer to input */
- const int stride, /*!< stride factor of input */
- FIXP_QMF *pWorkBuffer /*!< pointer to temporal working buffer */
- );
-
-int
-qmfInitSynthesisFilterBank( HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
- FIXP_QSS *pFilterStates, /*!< Pointer to filter state buffer */
- int noCols, /*!< Number of time slots */
- int lsb, /*!< Number of lower bands */
- int usb, /*!< Number of upper bands */
- int no_channels, /*!< Number of critically sampled bands */
- int flags); /*!< Flags */
-
-void qmfSynthesisFilteringSlot( HANDLE_QMF_FILTER_BANK synQmf,
- const FIXP_QMF *realSlot,
- const FIXP_QMF *imagSlot,
- const int scaleFactorLowBand,
- const int scaleFactorHighBand,
- INT_PCM *timeOut,
- const int stride,
- FIXP_QMF *pWorkBuffer);
-
-void
-qmfChangeOutScalefactor (HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
- int outScalefactor /*!< New scaling factor for output data */
- );
-
-void
-qmfChangeOutGain (HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
- FIXP_DBL outputGain /*!< New gain for output data */
- );
-
-
-
-#endif /* __QMF_H */
+void qmfAnalysisFiltering(
+ HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank */
+ FIXP_DBL **qmfReal, /*!< Pointer to real subband slots */
+ FIXP_DBL **qmfImag, /*!< Pointer to imag subband slots */
+ QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
+ const LONG *timeIn, /*!< Time signal */
+ const int timeIn_e, /*!< Exponent of audio data */
+ const int stride, /*!< Stride factor of audio data */
+ FIXP_DBL *pWorkBuffer /*!< pointer to temporary working buffer */
+);
+
+void qmfAnalysisFiltering(
+ HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Analysis Bank */
+ FIXP_DBL **qmfReal, /*!< Pointer to real subband slots */
+ FIXP_DBL **qmfImag, /*!< Pointer to imag subband slots */
+ QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
+ const INT_PCM *timeIn, /*!< Time signal */
+ const int timeIn_e, /*!< Exponent of audio data */
+ const int stride, /*!< Stride factor of audio data */
+ FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */
+);
+
+void qmfSynthesisFiltering(
+ HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
+ FIXP_DBL **QmfBufferReal, /*!< Pointer to real subband slots */
+ FIXP_DBL **QmfBufferImag, /*!< Pointer to imag subband slots */
+ const QMF_SCALE_FACTOR *scaleFactor, /*!< Scale factors of QMF data */
+ const int ov_len, /*!< Length of band overlap */
+ INT_PCM *timeOut, /*!< Time signal */
+ const INT stride, /*!< Stride factor of audio data */
+ FIXP_DBL *pWorkBuffer /*!< pointer to temporary working buffer. It must be
+ aligned */
+);
+
+int qmfInitAnalysisFilterBank(
+ HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
+ FIXP_QAS *pFilterStates, /*!< Pointer to filter state buffer */
+ int noCols, /*!< Number of time slots */
+ int lsb, /*!< Number of lower bands */
+ int usb, /*!< Number of upper bands */
+ int no_channels, /*!< Number of critically sampled bands */
+ int flags); /*!< Flags */
+
+void qmfAnalysisFilteringSlot(
+ HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank */
+ FIXP_DBL *qmfReal, /*!< Low and High band, real */
+ FIXP_DBL *qmfImag, /*!< Low and High band, imag */
+ const LONG *timeIn, /*!< Pointer to input */
+ const int stride, /*!< stride factor of input */
+ FIXP_DBL *pWorkBuffer /*!< pointer to temporary working buffer */
+);
+
+void qmfAnalysisFilteringSlot(
+ HANDLE_QMF_FILTER_BANK anaQmf, /*!< Handle of Qmf Synthesis Bank */
+ FIXP_DBL *qmfReal, /*!< Low and High band, real */
+ FIXP_DBL *qmfImag, /*!< Low and High band, imag */
+ const INT_PCM *timeIn, /*!< Pointer to input */
+ const int stride, /*!< stride factor of input */
+ FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */
+);
+int qmfInitSynthesisFilterBank(
+ HANDLE_QMF_FILTER_BANK h_Qmf, /*!< QMF Handle */
+ FIXP_QSS *pFilterStates, /*!< Pointer to filter state buffer */
+ int noCols, /*!< Number of time slots */
+ int lsb, /*!< Number of lower bands */
+ int usb, /*!< Number of upper bands */
+ int no_channels, /*!< Number of critically sampled bands */
+ int flags); /*!< Flags */
+
+void qmfSynthesisFilteringSlot(HANDLE_QMF_FILTER_BANK synQmf,
+ const FIXP_DBL *realSlot,
+ const FIXP_DBL *imagSlot,
+ const int scaleFactorLowBand,
+ const int scaleFactorHighBand, INT_PCM *timeOut,
+ const int timeOut_e, FIXP_DBL *pWorkBuffer);
+
+void qmfChangeOutScalefactor(
+ HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
+ int outScalefactor /*!< New scaling factor for output data */
+);
+
+int qmfGetOutScalefactor(
+ HANDLE_QMF_FILTER_BANK synQmf /*!< Handle of Qmf Synthesis Bank */
+);
+
+void qmfChangeOutGain(
+ HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
+ FIXP_DBL outputGain, /*!< New gain for output data (mantissa) */
+ int outputGainScale /*!< New gain for output data (exponent) */
+);
+void qmfSynPrototypeFirSlot(
+ HANDLE_QMF_FILTER_BANK qmf,
+ FIXP_DBL *RESTRICT realSlot, /*!< Input: Pointer to real Slot */
+ FIXP_DBL *RESTRICT imagSlot, /*!< Input: Pointer to imag Slot */
+ INT_PCM *RESTRICT timeOut, /*!< Time domain data */
+ const int timeOut_e);
+
+#endif /*ifndef QMF_H */
diff --git a/libFDK/include/qmf_pcm.h b/libFDK/include/qmf_pcm.h
new file mode 100644
index 0000000..f24e0cd
--- /dev/null
+++ b/libFDK/include/qmf_pcm.h
@@ -0,0 +1,405 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Markus Lohwasser, Josef Hoepfl, Manuel Jander
+
+ Description: QMF filterbank
+
+*******************************************************************************/
+
+#ifndef QMF_PCM_H
+#define QMF_PCM_H
+
+/*
+ All Synthesis functions dependent on datatype INT_PCM_QMFOUT
+ Should only be included by qmf.cpp, but not compiled separately, please
+ exclude compilation from project, if done otherwise. Is optional included
+ twice to duplicate all functions with two different pre-definitions, as:
+ #define INT_PCM_QMFOUT LONG
+ and ...
+ #define INT_PCM_QMFOUT SHORT
+ needed to run QMF synthesis in both 16bit and 32bit sample output format.
+*/
+
+#define QSSCALE (0)
+#define FX_DBL2FX_QSS(x) (x)
+#define FX_QSS2FX_DBL(x) (x)
+
+/*!
+ \brief Perform Synthesis Prototype Filtering on a single slot of input data.
+
+ The filter takes 2 * qmf->no_channels of input data and
+ generates qmf->no_channels time domain output samples.
+*/
+/* static */
+#ifndef FUNCTION_qmfSynPrototypeFirSlot
+void qmfSynPrototypeFirSlot(
+#else
+void qmfSynPrototypeFirSlot_fallback(
+#endif
+ HANDLE_QMF_FILTER_BANK qmf,
+ FIXP_DBL *RESTRICT realSlot, /*!< Input: Pointer to real Slot */
+ FIXP_DBL *RESTRICT imagSlot, /*!< Input: Pointer to imag Slot */
+ INT_PCM_QMFOUT *RESTRICT timeOut, /*!< Time domain data */
+ int stride) {
+ FIXP_QSS *FilterStates = (FIXP_QSS *)qmf->FilterStates;
+ int no_channels = qmf->no_channels;
+ const FIXP_PFT *p_Filter = qmf->p_filter;
+ int p_stride = qmf->p_stride;
+ int j;
+ FIXP_QSS *RESTRICT sta = FilterStates;
+ const FIXP_PFT *RESTRICT p_flt, *RESTRICT p_fltm;
+ int scale = (DFRACT_BITS - SAMPLE_BITS_QMFOUT) - 1 - qmf->outScalefactor -
+ qmf->outGain_e;
+
+ p_flt =
+ p_Filter + p_stride * QMF_NO_POLY; /* 5th of 330 */
+ p_fltm = p_Filter + (qmf->FilterSize / 2) -
+ p_stride * QMF_NO_POLY; /* 5 + (320 - 2*5) = 315th of 330 */
+
+ FIXP_SGL gain = FX_DBL2FX_SGL(qmf->outGain_m);
+
+ FIXP_DBL rnd_val = 0;
+
+ if (scale > 0) {
+ if (scale < (DFRACT_BITS - 1))
+ rnd_val = FIXP_DBL(1 << (scale - 1));
+ else
+ scale = (DFRACT_BITS - 1);
+ } else {
+ scale = fMax(scale, -(DFRACT_BITS - 1));
+ }
+
+ for (j = no_channels - 1; j >= 0; j--) {
+ FIXP_DBL imag = imagSlot[j]; /* no_channels-1 .. 0 */
+ FIXP_DBL real = realSlot[j]; /* no_channels-1 .. 0 */
+ {
+ INT_PCM_QMFOUT tmp;
+ FIXP_DBL Are = fMultAddDiv2(FX_QSS2FX_DBL(sta[0]), p_fltm[0], real);
+
+ /* This PCM formatting performs:
+ - multiplication with 16-bit gain, if not -1.0f
+ - rounding, if shift right is applied
+ - apply shift left (or right) with saturation to 32 (or 16) bits
+ - store output with --stride in 32 (or 16) bit format
+ */
+ if (gain != (FIXP_SGL)(-32768)) /* -1.0f */
+ {
+ Are = fMult(Are, gain);
+ }
+ if (scale >= 0) {
+ FDK_ASSERT(
+ Are <=
+ (Are + rnd_val)); /* Round-addition must not overflow, might be
+ equal for rnd_val=0 */
+ tmp = (INT_PCM_QMFOUT)(
+ SATURATE_RIGHT_SHIFT(Are + rnd_val, scale, SAMPLE_BITS_QMFOUT));
+ } else {
+ tmp = (INT_PCM_QMFOUT)(
+ SATURATE_LEFT_SHIFT(Are, -scale, SAMPLE_BITS_QMFOUT));
+ }
+
+ { timeOut[(j)*stride] = tmp; }
+ }
+
+ sta[0] = FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[1]), p_flt[4], imag));
+ sta[1] =
+ FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[2]), p_fltm[1], real));
+ sta[2] = FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[3]), p_flt[3], imag));
+ sta[3] =
+ FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[4]), p_fltm[2], real));
+ sta[4] = FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[5]), p_flt[2], imag));
+ sta[5] =
+ FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[6]), p_fltm[3], real));
+ sta[6] = FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[7]), p_flt[1], imag));
+ sta[7] =
+ FX_DBL2FX_QSS(fMultAddDiv2(FX_QSS2FX_DBL(sta[8]), p_fltm[4], real));
+ sta[8] = FX_DBL2FX_QSS(fMultDiv2(p_flt[0], imag));
+ p_flt += (p_stride * QMF_NO_POLY);
+ p_fltm -= (p_stride * QMF_NO_POLY);
+ sta += 9; // = (2*QMF_NO_POLY-1);
+ }
+}
+
+#ifndef FUNCTION_qmfSynPrototypeFirSlot_NonSymmetric
+/*!
+ \brief Perform Synthesis Prototype Filtering on a single slot of input data.
+
+ The filter takes 2 * qmf->no_channels of input data and
+ generates qmf->no_channels time domain output samples.
+*/
+static void qmfSynPrototypeFirSlot_NonSymmetric(
+ HANDLE_QMF_FILTER_BANK qmf,
+ FIXP_DBL *RESTRICT realSlot, /*!< Input: Pointer to real Slot */
+ FIXP_DBL *RESTRICT imagSlot, /*!< Input: Pointer to imag Slot */
+ INT_PCM_QMFOUT *RESTRICT timeOut, /*!< Time domain data */
+ int stride) {
+ FIXP_QSS *FilterStates = (FIXP_QSS *)qmf->FilterStates;
+ int no_channels = qmf->no_channels;
+ const FIXP_PFT *p_Filter = qmf->p_filter;
+ int p_stride = qmf->p_stride;
+ int j;
+ FIXP_QSS *RESTRICT sta = FilterStates;
+ const FIXP_PFT *RESTRICT p_flt, *RESTRICT p_fltm;
+ int scale = (DFRACT_BITS - SAMPLE_BITS_QMFOUT) - 1 - qmf->outScalefactor -
+ qmf->outGain_e;
+
+ p_flt = p_Filter; /*!< Pointer to first half of filter coefficients */
+ p_fltm =
+ &p_flt[qmf->FilterSize / 2]; /* at index 320, overall 640 coefficients */
+
+ FIXP_SGL gain = FX_DBL2FX_SGL(qmf->outGain_m);
+
+ FIXP_DBL rnd_val = (FIXP_DBL)0;
+
+ if (scale > 0) {
+ if (scale < (DFRACT_BITS - 1))
+ rnd_val = FIXP_DBL(1 << (scale - 1));
+ else
+ scale = (DFRACT_BITS - 1);
+ } else {
+ scale = fMax(scale, -(DFRACT_BITS - 1));
+ }
+
+ for (j = no_channels - 1; j >= 0; j--) {
+ FIXP_DBL imag = imagSlot[j]; /* no_channels-1 .. 0 */
+ FIXP_DBL real = realSlot[j]; /* no_channels-1 .. 0 */
+ {
+ INT_PCM_QMFOUT tmp;
+ FIXP_DBL Are = sta[0] + FX_DBL2FX_QSS(fMultDiv2(p_fltm[4], real));
+
+ /* This PCM formatting performs:
+ - multiplication with 16-bit gain, if not -1.0f
+ - rounding, if shift right is applied
+ - apply shift left (or right) with saturation to 32 (or 16) bits
+ - store output with --stride in 32 (or 16) bit format
+ */
+ if (gain != (FIXP_SGL)(-32768)) /* -1.0f */
+ {
+ Are = fMult(Are, gain);
+ }
+ if (scale > 0) {
+ FDK_ASSERT(Are <
+ (Are + rnd_val)); /* Round-addition must not overflow */
+ tmp = (INT_PCM_QMFOUT)(
+ SATURATE_RIGHT_SHIFT(Are + rnd_val, scale, SAMPLE_BITS_QMFOUT));
+ } else {
+ tmp = (INT_PCM_QMFOUT)(
+ SATURATE_LEFT_SHIFT(Are, -scale, SAMPLE_BITS_QMFOUT));
+ }
+ timeOut[j * stride] = tmp;
+ }
+
+ sta[0] = sta[1] + FX_DBL2FX_QSS(fMultDiv2(p_flt[4], imag));
+ sta[1] = sta[2] + FX_DBL2FX_QSS(fMultDiv2(p_fltm[3], real));
+ sta[2] = sta[3] + FX_DBL2FX_QSS(fMultDiv2(p_flt[3], imag));
+
+ sta[3] = sta[4] + FX_DBL2FX_QSS(fMultDiv2(p_fltm[2], real));
+ sta[4] = sta[5] + FX_DBL2FX_QSS(fMultDiv2(p_flt[2], imag));
+ sta[5] = sta[6] + FX_DBL2FX_QSS(fMultDiv2(p_fltm[1], real));
+ sta[6] = sta[7] + FX_DBL2FX_QSS(fMultDiv2(p_flt[1], imag));
+
+ sta[7] = sta[8] + FX_DBL2FX_QSS(fMultDiv2(p_fltm[0], real));
+ sta[8] = FX_DBL2FX_QSS(fMultDiv2(p_flt[0], imag));
+
+ p_flt += (p_stride * QMF_NO_POLY);
+ p_fltm += (p_stride * QMF_NO_POLY);
+ sta += 9; // = (2*QMF_NO_POLY-1);
+ }
+}
+#endif /* FUNCTION_qmfSynPrototypeFirSlot_NonSymmetric */
+
+void qmfSynthesisFilteringSlot(HANDLE_QMF_FILTER_BANK synQmf,
+ const FIXP_DBL *realSlot,
+ const FIXP_DBL *imagSlot,
+ const int scaleFactorLowBand,
+ const int scaleFactorHighBand,
+ INT_PCM_QMFOUT *timeOut, const int stride,
+ FIXP_DBL *pWorkBuffer) {
+ if (!(synQmf->flags & QMF_FLAG_LP))
+ qmfInverseModulationHQ(synQmf, realSlot, imagSlot, scaleFactorLowBand,
+ scaleFactorHighBand, pWorkBuffer);
+ else {
+ if (synQmf->flags & QMF_FLAG_CLDFB) {
+ qmfInverseModulationLP_odd(synQmf, realSlot, scaleFactorLowBand,
+ scaleFactorHighBand, pWorkBuffer);
+ } else {
+ qmfInverseModulationLP_even(synQmf, realSlot, scaleFactorLowBand,
+ scaleFactorHighBand, pWorkBuffer);
+ }
+ }
+
+ if (synQmf->flags & QMF_FLAG_NONSYMMETRIC) {
+ qmfSynPrototypeFirSlot_NonSymmetric(synQmf, pWorkBuffer,
+ pWorkBuffer + synQmf->no_channels,
+ timeOut, stride);
+ } else {
+ qmfSynPrototypeFirSlot(synQmf, pWorkBuffer,
+ pWorkBuffer + synQmf->no_channels, timeOut, stride);
+ }
+}
+
+/*!
+ *
+ * \brief Perform complex-valued subband synthesis of the
+ * low band and the high band and store the
+ * time domain data in timeOut
+ *
+ * First step: Calculate the proper scaling factor of current
+ * spectral data in qmfReal/qmfImag, old spectral data in the overlap
+ * range and filter states.
+ *
+ * Second step: Perform Frequency-to-Time mapping with inverse
+ * Modulation slot-wise.
+ *
+ * Third step: Perform FIR-filter slot-wise. To save space for filter
+ * states, the MAC operations are executed directly on the filter states
+ * instead of accumulating several products in the accumulator. The
+ * buffer shift at the end of the function should be replaced by a
+ * modulo operation, which is available on some DSPs.
+ *
+ * Last step: Copy the upper part of the spectral data to the overlap buffer.
+ *
+ * The qmf coefficient table is symmetric. The symmetry is exploited by
+ * shrinking the coefficient table to half the size. The addressing mode
+ * takes care of the symmetries. If the #define #QMFTABLE_FULL is set,
+ * coefficient addressing works on the full table size. The code will be
+ * slightly faster and slightly more compact.
+ *
+ * Workbuffer requirement: 2 x sizeof(**QmfBufferReal) * synQmf->no_channels
+ * The workbuffer must be aligned
+ */
+void qmfSynthesisFiltering(
+ HANDLE_QMF_FILTER_BANK synQmf, /*!< Handle of Qmf Synthesis Bank */
+ FIXP_DBL **QmfBufferReal, /*!< Low and High band, real */
+ FIXP_DBL **QmfBufferImag, /*!< Low and High band, imag */
+ const QMF_SCALE_FACTOR *scaleFactor,
+ const INT ov_len, /*!< split Slot of overlap and actual slots */
+ INT_PCM_QMFOUT *timeOut, /*!< Pointer to output */
+ const INT stride, /*!< stride factor of output */
+ FIXP_DBL *pWorkBuffer /*!< pointer to temporal working buffer */
+) {
+ int i;
+ int L = synQmf->no_channels;
+ int scaleFactorHighBand;
+ int scaleFactorLowBand_ov, scaleFactorLowBand_no_ov;
+
+ FDK_ASSERT(synQmf->no_channels >= synQmf->lsb);
+ FDK_ASSERT(synQmf->no_channels >= synQmf->usb);
+
+ /* adapt scaling */
+ scaleFactorHighBand = -ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK -
+ scaleFactor->hb_scale - synQmf->filterScale;
+ scaleFactorLowBand_ov = -ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK -
+ scaleFactor->ov_lb_scale - synQmf->filterScale;
+ scaleFactorLowBand_no_ov = -ALGORITHMIC_SCALING_IN_ANALYSIS_FILTERBANK -
+ scaleFactor->lb_scale - synQmf->filterScale;
+
+ for (i = 0; i < synQmf->no_col; i++) /* ----- no_col loop ----- */
+ {
+ const FIXP_DBL *QmfBufferImagSlot = NULL;
+
+ int scaleFactorLowBand =
+ (i < ov_len) ? scaleFactorLowBand_ov : scaleFactorLowBand_no_ov;
+
+ if (!(synQmf->flags & QMF_FLAG_LP)) QmfBufferImagSlot = QmfBufferImag[i];
+
+ qmfSynthesisFilteringSlot(synQmf, QmfBufferReal[i], QmfBufferImagSlot,
+ scaleFactorLowBand, scaleFactorHighBand,
+ timeOut + (i * L * stride), stride, pWorkBuffer);
+ } /* no_col loop i */
+}
+#endif /* QMF_PCM_H */
diff --git a/libFDK/include/scale.h b/libFDK/include/scale.h
index 1587f9f..07bd3af 100644
--- a/libFDK/include/scale.h
+++ b/libFDK/include/scale.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: Scaling operations
-******************************************************************************/
+*******************************************************************************/
#ifndef SCALE_H
#define SCALE_H
@@ -95,19 +107,41 @@ amm-info@iis.fraunhofer.de
#include "genericStds.h"
#include "fixminmax.h"
- #define SCALE_INLINE inline
-
+#define SCALE_INLINE
-#if defined(__arm__) /* cppp replaced: elif */
-#include "arm/scale.h"
+#if defined(__arm__)
+#include "arm/scale_arm.h"
-#elif defined(__mips__) /* cppp replaced: elif */
-#include "mips/scale.h"
+#elif defined(__mips__)
+#include "mips/scale_mips.h"
#endif
-
-#include "../src/scale.cpp"
+void scaleValues(FIXP_SGL *vector, INT len, INT scalefactor);
+void scaleValues(FIXP_DBL *vector, INT len, INT scalefactor);
+void scaleValues(FIXP_DBL *dst, const FIXP_DBL *src, INT len, INT scalefactor);
+#if (SAMPLE_BITS == 16)
+void scaleValues(FIXP_PCM *dst, const FIXP_DBL *src, INT len, INT scalefactor);
+#endif
+void scaleValues(FIXP_PCM *dst, const FIXP_SGL *src, INT len, INT scalefactor);
+void scaleCplxValues(FIXP_DBL *r_dst, FIXP_DBL *i_dst, const FIXP_DBL *r_src,
+ const FIXP_DBL *i_src, INT len, INT scalefactor);
+void scaleValuesWithFactor(FIXP_DBL *vector, FIXP_DBL factor, INT len,
+ INT scalefactor);
+void scaleValuesSaturate(FIXP_DBL *vector, INT len, INT scalefactor);
+void scaleValuesSaturate(FIXP_DBL *dst, FIXP_DBL *src, INT len,
+ INT scalefactor);
+void scaleValuesSaturate(FIXP_SGL *dst, FIXP_DBL *src, INT len,
+ INT scalefactor);
+void scaleValuesSaturate(INT_PCM *dst, FIXP_DBL *src, INT len, INT scalefactor);
+void scaleValuesSaturate(FIXP_SGL *vector, INT len, INT scalefactor);
+void scaleValuesSaturate(FIXP_SGL *dst, FIXP_SGL *src, INT len,
+ INT scalefactor);
+void scaleValuesSaturate(INT_PCM *dst, INT_PCM *src, INT len, INT scalefactor);
+INT getScalefactorShort(const SHORT *vector, INT len);
+INT getScalefactorPCM(const INT_PCM *vector, INT len, INT stride);
+INT getScalefactor(const FIXP_DBL *vector, INT len);
+INT getScalefactor(const FIXP_SGL *vector, INT len);
#ifndef FUNCTION_scaleValue
/*!
@@ -118,15 +152,21 @@ amm-info@iis.fraunhofer.de
*
*/
#define FUNCTION_scaleValue
-inline
-FIXP_DBL scaleValue(const FIXP_DBL value, /*!< Value */
- INT scalefactor /*!< Scalefactor */
- )
-{
- if(scalefactor > 0)
- return (value<<scalefactor);
+inline FIXP_DBL scaleValue(const FIXP_DBL value, /*!< Value */
+ INT scalefactor /*!< Scalefactor */
+) {
+ if (scalefactor > 0)
+ return (value << scalefactor);
else
- return (value>>(-scalefactor));
+ return (value >> (-scalefactor));
+}
+inline FIXP_SGL scaleValue(const FIXP_SGL value, /*!< Value */
+ INT scalefactor /*!< Scalefactor */
+) {
+ if (scalefactor > 0)
+ return (value << scalefactor);
+ else
+ return (value >> (-scalefactor));
}
#endif
@@ -140,27 +180,28 @@ FIXP_DBL scaleValue(const FIXP_DBL value, /*!< Value */
*
*/
#define FUNCTION_scaleValueSaturate
-inline
-FIXP_DBL scaleValueSaturate(
- const FIXP_DBL value,
- INT scalefactor
- )
-{
- if(scalefactor > 0) {
- if (fNorm(value) < scalefactor && value != (FIXP_DBL)0) {
- if (value > (FIXP_DBL)0) {
- return (FIXP_DBL)MAXVAL_DBL;
- } else {
- return (FIXP_DBL)MINVAL_DBL;
- }
+inline FIXP_DBL scaleValueSaturate(const FIXP_DBL value,
+ INT scalefactor /* in range -31 ... +31 */
+) {
+ int headroom = fixnormz_D(
+ (INT)value ^ (INT)((value >> 31))); /* headroom in range 1...32 */
+ if (scalefactor >= 0) {
+ /* shift left: saturate in case of headroom less/equal scalefactor */
+ if (headroom <= scalefactor) {
+ if (value > (FIXP_DBL)0)
+ return (FIXP_DBL)MAXVAL_DBL; /* 0x7FFF.FFFF */
+ else
+ return (FIXP_DBL)MINVAL_DBL + (FIXP_DBL)1; /* 0x8000.0001 */
} else {
- return (value<<scalefactor);
+ return fMax((value << scalefactor), (FIXP_DBL)MINVAL_DBL + (FIXP_DBL)1);
}
} else {
- if (-(DFRACT_BITS-1) > scalefactor) {
+ scalefactor = -scalefactor;
+ /* shift right: clear in case of 32-headroom greater/equal -scalefactor */
+ if ((DFRACT_BITS - headroom) <= scalefactor) {
return (FIXP_DBL)0;
} else {
- return (value>>(-scalefactor));
+ return fMax((value >> scalefactor), (FIXP_DBL)MINVAL_DBL + (FIXP_DBL)1);
}
}
}
@@ -175,14 +216,12 @@ FIXP_DBL scaleValueSaturate(
*
*/
#define FUNCTION_scaleValueInPlace
-inline
-void scaleValueInPlace(
- FIXP_DBL *value, /*!< Value */
- INT scalefactor /*!< Scalefactor */
- )
-{
+inline void scaleValueInPlace(FIXP_DBL *value, /*!< Value */
+ INT scalefactor /*!< Scalefactor */
+) {
INT newscale;
- /* Note: The assignment inside the if conditional allows combining a load with the compare to zero (on ARM and maybe others) */
+ /* Note: The assignment inside the if conditional allows combining a load with
+ * the compare to zero (on ARM and maybe others) */
if ((newscale = (scalefactor)) >= 0) {
*(value) <<= newscale;
} else {
@@ -191,34 +230,37 @@ void scaleValueInPlace(
}
#endif
-/*!
- *
- * \brief Scale input value by 2^{scale} and saturate output to 2^{dBits-1}
- * \return scaled and saturated value
- *
- * This macro scales src value right or left and applies saturation to (2^dBits)-1
- * maxima output.
- */
+ /*!
+ *
+ * \brief Scale input value by 2^{scale} and saturate output to 2^{dBits-1}
+ * \return scaled and saturated value
+ *
+ * This macro scales src value right or left and applies saturation to
+ * (2^dBits)-1 maxima output.
+ */
#ifndef SATURATE_RIGHT_SHIFT
- #define SATURATE_RIGHT_SHIFT(src, scale, dBits) \
- ( (((LONG)(src)>>(scale)) > (LONG)(((1U)<<((dBits)-1))-1)) ? (LONG)(((1U)<<((dBits)-1))-1) \
- : (((LONG)(src)>>(scale)) < ~((LONG)(((1U)<<((dBits)-1))-1))) ? ~((LONG)(((1U)<<((dBits)-1))-1)) \
- : ((LONG)(src) >> (scale)) )
+#define SATURATE_RIGHT_SHIFT(src, scale, dBits) \
+ ((((LONG)(src) >> (scale)) > (LONG)(((1U) << ((dBits)-1)) - 1)) \
+ ? (LONG)(((1U) << ((dBits)-1)) - 1) \
+ : (((LONG)(src) >> (scale)) < ~((LONG)(((1U) << ((dBits)-1)) - 1))) \
+ ? ~((LONG)(((1U) << ((dBits)-1)) - 1)) \
+ : ((LONG)(src) >> (scale)))
#endif
#ifndef SATURATE_LEFT_SHIFT
- #define SATURATE_LEFT_SHIFT(src, scale, dBits) \
- ( ((LONG)(src) > ((LONG)(((1U)<<((dBits)-1))-1)>>(scale))) ? (LONG)(((1U)<<((dBits)-1))-1) \
- : ((LONG)(src) < ~((LONG)(((1U)<<((dBits)-1))-1)>>(scale))) ? ~((LONG)(((1U)<<((dBits)-1))-1)) \
- : ((LONG)(src) << (scale)) )
+#define SATURATE_LEFT_SHIFT(src, scale, dBits) \
+ (((LONG)(src) > ((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \
+ ? (LONG)(((1U) << ((dBits)-1)) - 1) \
+ : ((LONG)(src) < ~((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \
+ ? ~((LONG)(((1U) << ((dBits)-1)) - 1)) \
+ : ((LONG)(src) << (scale)))
#endif
#ifndef SATURATE_SHIFT
-#define SATURATE_SHIFT(src, scale, dBits) \
- ( ((scale) < 0) \
- ? SATURATE_LEFT_SHIFT((src), -(scale), (dBits)) \
- : SATURATE_RIGHT_SHIFT((src), (scale), (dBits)) )
+#define SATURATE_SHIFT(src, scale, dBits) \
+ (((scale) < 0) ? SATURATE_LEFT_SHIFT((src), -(scale), (dBits)) \
+ : SATURATE_RIGHT_SHIFT((src), (scale), (dBits)))
#endif
/*
@@ -226,25 +268,31 @@ void scaleValueInPlace(
* to avoid problems when inverting the sign of the result.
*/
#ifndef SATURATE_LEFT_SHIFT_ALT
-#define SATURATE_LEFT_SHIFT_ALT(src, scale, dBits) \
- ( ((LONG)(src) > ((LONG)(((1U)<<((dBits)-1))-1)>>(scale))) ? (LONG)(((1U)<<((dBits)-1))-1) \
- : ((LONG)(src) < ~((LONG)(((1U)<<((dBits)-1))-2)>>(scale))) ? ~((LONG)(((1U)<<((dBits)-1))-2)) \
- : ((LONG)(src) << (scale)) )
+#define SATURATE_LEFT_SHIFT_ALT(src, scale, dBits) \
+ (((LONG)(src) > ((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \
+ ? (LONG)(((1U) << ((dBits)-1)) - 1) \
+ : ((LONG)(src) < ~((LONG)(((1U) << ((dBits)-1)) - 2) >> (scale))) \
+ ? ~((LONG)(((1U) << ((dBits)-1)) - 2)) \
+ : ((LONG)(src) << (scale)))
#endif
#ifndef SATURATE_RIGHT_SHIFT_ALT
- #define SATURATE_RIGHT_SHIFT_ALT(src, scale, dBits) \
- ( (((LONG)(src)>>(scale)) > (LONG)(((1U)<<((dBits)-1))-1)) ? (LONG)(((1U)<<((dBits)-1))-1) \
- : (((LONG)(src)>>(scale)) < ~((LONG)(((1U)<<((dBits)-1))-2))) ? ~((LONG)(((1U)<<((dBits)-1))-2)) \
- : ((LONG)(src) >> (scale)) )
+#define SATURATE_RIGHT_SHIFT_ALT(src, scale, dBits) \
+ ((((LONG)(src) >> (scale)) > (LONG)(((1U) << ((dBits)-1)) - 1)) \
+ ? (LONG)(((1U) << ((dBits)-1)) - 1) \
+ : (((LONG)(src) >> (scale)) < ~((LONG)(((1U) << ((dBits)-1)) - 2))) \
+ ? ~((LONG)(((1U) << ((dBits)-1)) - 2)) \
+ : ((LONG)(src) >> (scale)))
#endif
#ifndef SATURATE_INT_PCM_RIGHT_SHIFT
-#define SATURATE_INT_PCM_RIGHT_SHIFT(src, scale) SATURATE_RIGHT_SHIFT(src, scale, SAMPLE_BITS)
+#define SATURATE_INT_PCM_RIGHT_SHIFT(src, scale) \
+ SATURATE_RIGHT_SHIFT(src, scale, SAMPLE_BITS)
#endif
#ifndef SATURATE_INT_PCM_LEFT_SHIFT
-#define SATURATE_INT_PCM_LEFT_SHIFT(src, scale) SATURATE_LEFT_SHIFT(src, scale, SAMPLE_BITS)
+#define SATURATE_INT_PCM_LEFT_SHIFT(src, scale) \
+ SATURATE_LEFT_SHIFT(src, scale, SAMPLE_BITS)
#endif
#endif /* #ifndef SCALE_H */
diff --git a/libFDK/include/scramble.h b/libFDK/include/scramble.h
index ceaf527..f07ebed 100644
--- a/libFDK/include/scramble.h
+++ b/libFDK/include/scramble.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,14 +90,15 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description:
-******************************************************************************/
+*******************************************************************************/
#ifndef SCRAMBLE_H
#define SCRAMBLE_H
@@ -94,10 +106,10 @@ amm-info@iis.fraunhofer.de
#include "common_fix.h"
#if defined(__arm__)
-#include "arm/scramble.h"
+#include "arm/scramble_arm.h"
-#elif defined(__mips__) && defined(__mips_dsp) /* cppp replaced: elif */
-#include "mips/scramble.h"
+#elif defined(__mips__) && defined(__mips_dsp)
+#include "mips/scramble_mips.h"
#endif
@@ -110,53 +122,29 @@ amm-info@iis.fraunhofer.de
output:
*****************************************************************************/
-#if !defined(FUNCTION_scramble_sgl)
-
-inline void scramble_sgl(FIXP_SGL *x, INT n)
-{
- INT m,k,j;
-
- for (m=1,j=0; m<n-1; m++)
- {
- {for(k=n>>1; (!((j^=k)&k)); k>>=1);}
-
- if (j>m)
- {
- FIXP_SGL tmp;
- tmp=x[2*m];
- x[2*m]=x[2*j];
- x[2*j]=tmp;
-
- tmp=x[2*m+1];
- x[2*m+1]=x[2*j+1];
- x[2*j+1]=tmp;
- }
- }
-}
-#endif
-
#if !defined(FUNCTION_scramble)
/* default scramble functionality */
-inline void scramble(FIXP_DBL *x, INT n)
-{
- INT m,k,j;
- FDK_ASSERT(!(((UINT64)x)&(ALIGNMENT_DEFAULT-1)));
+inline void scramble(FIXP_DBL *x, INT length) {
+ INT m, k, j;
+ FDK_ASSERT(!(((INT)(INT64)x) & (ALIGNMENT_DEFAULT - 1)));
+ C_ALLOC_ALIGNED_CHECK(x);
- for (m=1,j=0; m<n-1; m++)
- {
- {for(k=n>>1; (!((j^=k)&k)); k>>=1);}
-
- if (j>m)
+ for (m = 1, j = 0; m < length - 1; m++) {
{
+ for (k = length >> 1; (!((j ^= k) & k)); k >>= 1)
+ ;
+ }
+
+ if (j > m) {
FIXP_DBL tmp;
- tmp=x[2*m];
- x[2*m]=x[2*j];
- x[2*j]=tmp;
+ tmp = x[2 * m];
+ x[2 * m] = x[2 * j];
+ x[2 * j] = tmp;
- tmp=x[2*m+1];
- x[2*m+1]=x[2*j+1];
- x[2*j+1]=tmp;
+ tmp = x[2 * m + 1];
+ x[2 * m + 1] = x[2 * j + 1];
+ x[2 * j + 1] = tmp;
}
}
}
diff --git a/libFDK/include/x86/abs_x86.h b/libFDK/include/x86/abs_x86.h
index 96374ec..efd6433 100644
--- a/libFDK/include/x86/abs_x86.h
+++ b/libFDK/include/x86/abs_x86.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,28 +90,34 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(ABS_X86_H)
+#define ABS_X86_H
+
#if defined(__x86__)
- #if defined(__x86_64__)
+#if defined(__x86_64__)
- inline INT fixabs_D(INT x) { return ((x) > (INT)(0)) ? (x) : -(x) ; }
- inline INT fixabs_S(INT x) { return ((x) > (INT)(0)) ? (x) : -(x) ; }
+inline INT fixabs_D(INT x) { return ((x) > (INT)(0)) ? (x) : -(x); }
+inline INT fixabs_S(INT x) { return ((x) > (INT)(0)) ? (x) : -(x); }
- #define fixabs_I(x) fixabs_D(x)
+#define fixabs_I(x) fixabs_D(x)
- #define FUNCTION_fixabs_S
- #define FUNCTION_fixabs_D
- #define FUNCTION_fixabs_I
+#define FUNCTION_fixabs_S
+#define FUNCTION_fixabs_D
+#define FUNCTION_fixabs_I
- #endif /* __x86_64__ */
+#endif /* __x86_64__ */
#endif /*__x86__ */
+#endif /* !defined(ABS_X86_H) */
diff --git a/libFDK/include/x86/clz_x86.h b/libFDK/include/x86/clz_x86.h
index 1bc43e5..badca29 100644
--- a/libFDK/include/x86/clz_x86.h
+++ b/libFDK/include/x86/clz_x86.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,76 +90,76 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Manuel Jander
-/*************************** Fraunhofer IIS FDK Tools **********************
+ Description: x86 version of count leading zero / bits
- Author(s):
- Description: fixed point intrinsics
+*******************************************************************************/
-******************************************************************************/
+#if !defined(CLZ_X86_H)
+#define CLZ_X86_H
#if defined(__GNUC__) && (defined(__x86__) || defined(__x86_64__))
- #define FUNCTION_fixnormz_D
- #define FUNCTION_fixnorm_D
+#define FUNCTION_fixnormz_D
+#define FUNCTION_fixnorm_D
- inline INT fixnormz_D(LONG value)
- {
- INT result;
+inline INT fixnormz_D(LONG value) {
+ INT result;
- if (value != 0) {
- result = __builtin_clz(value);
- } else {
- result = 32;
- }
- return result;
+ if (value != 0) {
+ result = __builtin_clz(value);
+ } else {
+ result = 32;
}
+ return result;
+}
- inline INT fixnorm_D(LONG value)
- {
- INT result;
- if (value == 0) {
- return 0;
- }
- if (value < 0) {
- value = ~value;
- }
- result = fixnormz_D(value);
- return result - 1;
+inline INT fixnorm_D(LONG value) {
+ INT result;
+ if (value == 0) {
+ return 0;
}
+ if (value < 0) {
+ value = ~value;
+ }
+ result = fixnormz_D(value);
+ return result - 1;
+}
-
-#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
+#elif (_MSC_VER > 1200) && (defined(_M_IX86) || defined(_M_X64))
#include <intrin.h>
- #define FUNCTION_fixnormz_D
- #define FUNCTION_fixnorm_D
-
- inline INT fixnormz_D(LONG value)
- {
- unsigned long result = 0;
- unsigned char err;
- err = _BitScanReverse(&result, value);
- if (err) {
- return 31 - result;
- } else {
- return 32;
- }
+#define FUNCTION_fixnormz_D
+#define FUNCTION_fixnorm_D
+
+inline INT fixnormz_D(LONG value) {
+ unsigned long result = 0;
+ unsigned char err;
+ err = _BitScanReverse(&result, value);
+ if (err) {
+ return 31 - result;
+ } else {
+ return 32;
}
+}
- inline INT fixnorm_D(LONG value)
- {
- INT result;
- if (value == 0) {
- return 0;
- }
- if (value < 0) {
- value = ~value;
- }
- result = fixnormz_D(value);
- return result - 1;
+inline INT fixnorm_D(LONG value) {
+ INT result;
+ if (value == 0) {
+ return 0;
+ }
+ if (value < 0) {
+ value = ~value;
}
+ result = fixnormz_D(value);
+ return result - 1;
+}
#endif /* toolchain */
+#endif /* !defined(CLZ_X86_H) */
diff --git a/libFDK/include/x86/fixmul_x86.h b/libFDK/include/x86/fixmul_x86.h
index 7b74cc7..84e6316 100644
--- a/libFDK/include/x86/fixmul_x86.h
+++ b/libFDK/include/x86/fixmul_x86.h
@@ -1,74 +1,85 @@
-
-/* -----------------------------------------------------------------------------------------------------------
+/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2013 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V.
- All rights reserved.
+© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten
+Forschung e.V. All rights reserved.
1. INTRODUCTION
-The Fraunhofer FDK AAC Codec Library for Android ("FDK AAC Codec") is software that implements
-the MPEG Advanced Audio Coding ("AAC") encoding and decoding scheme for digital audio.
-This FDK AAC Codec software is intended to be used on a wide variety of Android devices.
-
-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.
+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:
+Redistribution and use in source and binary forms, with or without modification,
+are permitted without payment of copyright license fees provided that you
+satisfy the following conditions:
-You must retain the complete text of this software license in redistributions of the FDK AAC Codec or
-your modifications thereto in source code form.
+You must retain the complete text of this software license in redistributions of
+the FDK AAC Codec or your modifications thereto in source code form.
-You must retain the complete text of this software license in the documentation and/or other materials
-provided with redistributions of the FDK AAC Codec or your modifications thereto in binary form.
-You must make available free of charge copies of the complete source code of the FDK AAC Codec and your
+You must retain the complete text of this software license in the documentation
+and/or other materials provided with redistributions of the FDK AAC Codec or
+your modifications thereto in binary form. You must make available free of
+charge copies of the complete source code of the FDK AAC Codec and your
modifications thereto to recipients of copies in binary form.
-The name of Fraunhofer may not be used to endorse or promote products derived from this library without
-prior written permission.
+The name of Fraunhofer may not be used to endorse or promote products derived
+from this library without prior written permission.
-You may not charge copyright license fees for anyone to use, copy or distribute the FDK AAC Codec
-software or your modifications thereto.
+You may not charge copyright license fees for anyone to use, copy or distribute
+the FDK AAC Codec software or your modifications thereto.
-Your modified versions of the FDK AAC Codec must carry prominent notices stating that you changed the software
-and the date of any change. For modified versions of the FDK AAC Codec, the term
-"Fraunhofer FDK AAC Codec Library for Android" must be replaced by the term
-"Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android."
+Your modified versions of the FDK AAC Codec must carry prominent notices stating
+that you changed the software and the date of any change. For modified versions
+of the FDK AAC Codec, the term "Fraunhofer FDK AAC Codec Library for Android"
+must be replaced by the term "Third-Party Modified Version of the Fraunhofer FDK
+AAC Codec Library for Android."
3. NO PATENT LICENSE
-NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without limitation the patents of Fraunhofer,
-ARE GRANTED BY THIS SOFTWARE LICENSE. Fraunhofer provides no warranty of patent non-infringement with
-respect to this software.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PATENT CLAIMS, including without
+limitation the patents of Fraunhofer, ARE GRANTED BY THIS SOFTWARE LICENSE.
+Fraunhofer provides no warranty of patent non-infringement with respect to this
+software.
-You may use this FDK AAC Codec software or modifications thereto only for purposes that are authorized
-by appropriate patent licenses.
+You may use this FDK AAC Codec software or modifications thereto only for
+purposes that are authorized by appropriate patent licenses.
4. DISCLAIMER
-This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright holders and contributors
-"AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, including but not limited to the implied warranties
-of merchantability and fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary, or consequential damages,
-including but not limited to procurement of substitute goods or services; loss of use, data, or profits,
-or business interruption, however caused and on any theory of liability, whether in contract, strict
-liability, or tort (including negligence), arising in any way out of the use of this software, even if
-advised of the possibility of such damage.
+This FDK AAC Codec software is provided by Fraunhofer on behalf of the copyright
+holders and contributors "AS IS" and WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
+including but not limited to the implied warranties of merchantability and
+fitness for a particular purpose. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE for any direct, indirect, incidental, special, exemplary,
+or consequential damages, including but not limited to procurement of substitute
+goods or services; loss of use, data, or profits, or business interruption,
+however caused and on any theory of liability, whether in contract, strict
+liability, or tort (including negligence), arising in any way out of the use of
+this software, even if advised of the possibility of such damage.
5. CONTACT INFORMATION
@@ -79,14 +90,18 @@ Am Wolfsmantel 33
www.iis.fraunhofer.de/amm
amm-info@iis.fraunhofer.de
------------------------------------------------------------------------------------------------------------ */
+----------------------------------------------------------------------------- */
-/*************************** Fraunhofer IIS FDK Tools **********************
+/******************* Library for basic calculation routines ********************
Author(s):
+
Description: fixed point intrinsics
-******************************************************************************/
+*******************************************************************************/
+
+#if !defined(FIXMUL_X86_H)
+#define FIXMUL_X86_H
#if defined(__x86__)
@@ -96,18 +111,17 @@ amm-info@iis.fraunhofer.de
#define FUNCTION_fixmul_DD
#define FUNCTION_fixmuldiv2_DD
#define FUNCTION_fixmuldiv2BitExact_DD
-#define fixmuldiv2BitExact_DD(a,b) fixmuldiv2_DD(a,b)
+#define fixmuldiv2BitExact_DD(a, b) fixmuldiv2_DD(a, b)
#define FUNCTION_fixmulBitExact_DD
-#define fixmulBitExact_DD(a,b) fixmul_DD(a,b)
+#define fixmulBitExact_DD(a, b) fixmul_DD(a, b)
#define FUNCTION_fixmuldiv2BitExact_DS
-#define fixmuldiv2BitExact_DS(a,b) fixmuldiv2_DS(a,b)
+#define fixmuldiv2BitExact_DS(a, b) fixmuldiv2_DS(a, b)
#define FUNCTION_fixmulBitExact_DS
-#define fixmulBitExact_DS(a,b) fixmul_DS(a,b)
+#define fixmulBitExact_DS(a, b) fixmul_DS(a, b)
-inline INT fixmul_DD (INT a, const INT b)
-{
+inline INT fixmul_DD(INT a, const INT b) {
__asm
{
mov eax, a
@@ -115,59 +129,53 @@ inline INT fixmul_DD (INT a, const INT b)
shl edx, 1
mov a, edx
}
- return a ;
+ return a;
}
-
-inline INT fixmuldiv2_DD (INT a, const INT b)
-{
+inline INT fixmuldiv2_DD(INT a, const INT b) {
__asm
{
mov eax, a
imul b
mov a, edx
}
- return a ;
+ return a;
}
-/* ############################################################################# */
-#elif (defined(__GNUC__)||defined(__gnu_linux__)) && defined(__x86__)
+/* #############################################################################
+ */
+#elif (defined(__GNUC__) || defined(__gnu_linux__)) && defined(__x86__)
#define FUNCTION_fixmul_DD
#define FUNCTION_fixmuldiv2_DD
#define FUNCTION_fixmuldiv2BitExact_DD
-#define fixmuldiv2BitExact_DD(a,b) fixmuldiv2_DD(a,b)
+#define fixmuldiv2BitExact_DD(a, b) fixmuldiv2_DD(a, b)
#define FUNCTION_fixmulBitExact_DD
-#define fixmulBitExact_DD(a,b) fixmul_DD(a,b)
+#define fixmulBitExact_DD(a, b) fixmul_DD(a, b)
#define FUNCTION_fixmuldiv2BitExact_DS
-#define fixmuldiv2BitExact_DS(a,b) fixmuldiv2_DS(a,b)
+#define fixmuldiv2BitExact_DS(a, b) fixmuldiv2_DS(a, b)
#define FUNCTION_fixmulBitExact_DS
-#define fixmulBitExact_DS(a,b) fixmul_DS(a,b)
+#define fixmulBitExact_DS(a, b) fixmul_DS(a, b)
-inline INT fixmul_DD (INT a, const INT b)
-{
+inline INT fixmul_DD(INT a, const INT b) {
INT result;
- asm( "imul %2;\n"
- "shl $1, %0;\n"
- : "=d"(result), "+a"(a)
- : "r"(b) );
+ asm("imul %2;\n"
+ "shl $1, %0;\n"
+ : "=d"(result), "+a"(a)
+ : "r"(b));
return result;
}
-
-inline INT fixmuldiv2_DD (INT a, const INT b)
-{
+inline INT fixmuldiv2_DD(INT a, const INT b) {
INT result;
- asm ( "imul %2;"
- : "=d"(result), "+a"(a)
- : "r"(b) );
+ asm("imul %2;" : "=d"(result), "+a"(a) : "r"(b));
return result;
}
@@ -176,3 +184,4 @@ inline INT fixmuldiv2_DD (INT a, const INT b)
#endif /* __x86__ */
+#endif /* !defined(FIXMUL_X86_H) */
diff --git a/libFDK/include/x86/fixpoint_math_x86.h b/libFDK/include/x86/fixpoint_math_x86.h
new file mode 100644
index 0000000..d81fb26
--- /dev/null
+++ b/libFDK/include/x86/fixpoint_math_x86.h
@@ -0,0 +1,208 @@
+/* -----------------------------------------------------------------------------
+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
+----------------------------------------------------------------------------- */
+
+/******************* Library for basic calculation routines ********************
+
+ Author(s): Manuel Jander
+
+ Description: Fixed point specific mathematical functions for x86
+
+*******************************************************************************/
+
+#if !defined(FIXPOINT_MATH_X86_H)
+#define FIXPOINT_MATH_X86_H
+
+#define FUNCTION_sqrtFixp
+
+#include <math.h>
+
+#ifdef FUNCTION_sqrtFixp
+static inline FIXP_DBL sqrtFixp(const FIXP_DBL op) {
+ FIXP_DBL result;
+ /* result =
+ * (FIXP_DBL)(INT)(sqrt((double)(INT)op)*46340.950011841578559133736114903);
+ */
+ result = (FIXP_DBL)(INT)(sqrt((float)(INT)op) * 46340.9492f);
+ FDK_ASSERT(result >= (FIXP_DBL)0);
+ return result;
+}
+#endif /* FUNCTION_sqrtFixp */
+
+#include <math.h>
+
+#define FUNCTION_invSqrtNorm2
+/**
+ * \brief calculate 1.0/sqrt(op)
+ * \param op_m mantissa of input value.
+ * \param result_e pointer to return the exponent of the result
+ * \return mantissa of the result
+ */
+#ifdef FUNCTION_invSqrtNorm2
+inline FIXP_DBL invSqrtNorm2(FIXP_DBL op_m, INT *result_e) {
+ float result;
+ if (op_m == (FIXP_DBL)0) {
+ *result_e = 16;
+ return ((LONG)0x7fffffff);
+ }
+ result = (float)(1.0 / sqrt(0.5f * (float)(INT)op_m));
+ result = (float)ldexp(frexpf(result, result_e), DFRACT_BITS - 1);
+ *result_e += 15;
+
+ FDK_ASSERT(result >= 0);
+ return (FIXP_DBL)(INT)result;
+}
+#endif /* FUNCTION_invSqrtNorm2 */
+
+#define FUNCTION_invFixp
+/**
+ * \brief calculate 1.0/op
+ * \param op mantissa of the input value.
+ * \return mantissa of the result with implizit exponent of 31
+ */
+#ifdef FUNCTION_invFixp
+inline FIXP_DBL invFixp(FIXP_DBL op) {
+ float result;
+ INT result_e;
+ if ((op == (FIXP_DBL)0) || (op == (FIXP_DBL)1)) {
+ return ((LONG)0x7fffffff);
+ }
+ result = (float)(1.0 / (float)(INT)op);
+ result = frexpf(result, &result_e);
+ result = ldexpf(result, 31 + result_e);
+
+ return (FIXP_DBL)(INT)result;
+}
+
+/**
+ * \brief calculate 1.0/(op_m * 2^op_e)
+ * \param op_m mantissa of the input value.
+ * \param op_e pointer into were the exponent of the input value is stored, and
+ * the result will be stored into.
+ * \return mantissa of the result
+ */
+inline FIXP_DBL invFixp(FIXP_DBL op_m, int *op_e) {
+ float result;
+ INT result_e;
+ if ((op_m == (FIXP_DBL)0x00000000) || (op_m == (FIXP_DBL)0x00000001)) {
+ *op_e = 31 - *op_e;
+ return ((LONG)0x7fffffff);
+ }
+ result = (float)(1.0 / (float)(INT)op_m);
+ result = ldexpf(frexpf(result, &result_e), DFRACT_BITS - 1);
+ *op_e = result_e - *op_e + 31;
+ return (FIXP_DBL)(INT)result;
+}
+#endif /* FUNCTION_invFixp */
+
+#define FUNCTION_schur_div
+/**
+ * \brief Divide two FIXP_DBL values with given precision.
+ * \param num dividend
+ * \param denum divisor
+ * \param count amount of significant bits of the result (starting to the MSB)
+ * \return num/divisor
+ */
+#ifdef FUNCTION_schur_div
+inline FIXP_DBL schur_div(FIXP_DBL num, FIXP_DBL denum, INT count) {
+ (void)count;
+ /* same asserts than for fallback implementation */
+ FDK_ASSERT(num >= (FIXP_DBL)0);
+ FDK_ASSERT(denum > (FIXP_DBL)0);
+ FDK_ASSERT(num <= denum);
+
+ return (num == denum) ? (FIXP_DBL)MAXVAL_DBL
+ : (FIXP_DBL)(INT)(((INT64)(INT)num << 31) / (INT)denum);
+}
+#endif /* FUNCTION_schur_div */
+#endif /* !defined(FIXPOINT_MATH_X86_H) */