diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2018-02-26 20:17:00 +0100 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2018-04-19 11:21:15 -0700 |
commit | 6cfabd35363c3ef5e3b209b867169a500b3ccc3c (patch) | |
tree | 01c0a19f2735e8b5d2407555fe992d4230d089eb /libSBRenc/src/ton_corr.cpp | |
parent | 6288a1e34c4dede4c2806beb1736ece6580558c7 (diff) | |
download | fdk-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 'libSBRenc/src/ton_corr.cpp')
-rw-r--r-- | libSBRenc/src/ton_corr.cpp | 920 |
1 files changed, 465 insertions, 455 deletions
diff --git a/libSBRenc/src/ton_corr.cpp b/libSBRenc/src/ton_corr.cpp index af5afba..1c050e2 100644 --- a/libSBRenc/src/ton_corr.cpp +++ b/libSBRenc/src/ton_corr.cpp @@ -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,22 +90,26 @@ Am Wolfsmantel 33 www.iis.fraunhofer.de/amm amm-info@iis.fraunhofer.de ------------------------------------------------------------------------------------------------------------ */ +----------------------------------------------------------------------------- */ -#include "ton_corr.h" +/**************************** SBR encoder library ****************************** -#include "sbr_ram.h" -#include "sbr_misc.h" -#include "genericStds.h" -#include "autocorr2nd.h" + Author(s): + Description: +*******************************************************************************/ -/*************************************************************************** +#include "ton_corr.h" - Send autoCorrSecondOrder to mlfile +#include "sbrenc_ram.h" +#include "sbr_misc.h" +#include "genericStds.h" +#include "autocorr2nd.h" -****************************************************************************/ +#define BAND_V_SIZE 32 +#define NUM_V_COMBINE \ + 8 /* Must be a divisor of 64 and fulfill the ASSERTs below */ /**************************************************************************/ /*! @@ -107,7 +122,7 @@ amm-info@iis.fraunhofer.de (noise energy B). Hence the quota-matrix contains A/B = q/(1-q). The samples in nrgVector are scaled by 1.0/16.0 - The samples in pNrgVectorFreq are scaled by 1.0/2.0 + The samples in pNrgVectorFreq are scaled by 1.0/2.0 The samples in quotaMatrix are scaled by RELAXATION \return none. @@ -115,84 +130,83 @@ amm-info@iis.fraunhofer.de */ /**************************************************************************/ -void -FDKsbrEnc_CalculateTonalityQuotas( HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ - FIXP_DBL **RESTRICT sourceBufferReal, /*!< The real part of the QMF-matrix. */ - FIXP_DBL **RESTRICT sourceBufferImag, /*!< The imaginary part of the QMF-matrix. */ - INT usb, /*!< upper side band, highest + 1 QMF band in the SBR range. */ - INT qmfScale /*!< sclefactor of QMF subsamples */ - ) -{ - INT i, k, r, r2, timeIndex, autoCorrScaling; - - INT startIndexMatrix = hTonCorr->startIndexMatrix; - INT totNoEst = hTonCorr->numberOfEstimates; - INT noEstPerFrame = hTonCorr->numberOfEstimatesPerFrame; - INT move = hTonCorr->move; - INT noQmfChannels = hTonCorr->noQmfChannels; /* Numer of Bands */ - INT buffLen = hTonCorr->bufferLength; /* Numer of Slots */ - INT stepSize = hTonCorr->stepSize; - INT *pBlockLength = hTonCorr->lpcLength; - INT** RESTRICT signMatrix = hTonCorr->signMatrix; - FIXP_DBL* RESTRICT nrgVector = hTonCorr->nrgVector; - FIXP_DBL** RESTRICT quotaMatrix = hTonCorr->quotaMatrix; - FIXP_DBL* RESTRICT pNrgVectorFreq = hTonCorr->nrgVectorFreq; - -#define BAND_V_SIZE QMF_MAX_TIME_SLOTS -#define NUM_V_COMBINE 8 /* Must be a divisor of 64 and fulfill the ASSERTs below */ +void FDKsbrEnc_CalculateTonalityQuotas( + HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ + FIXP_DBL **RESTRICT + sourceBufferReal, /*!< The real part of the QMF-matrix. */ + FIXP_DBL **RESTRICT + sourceBufferImag, /*!< The imaginary part of the QMF-matrix. */ + INT usb, /*!< upper side band, highest + 1 QMF band in the SBR range. */ + INT qmfScale /*!< sclefactor of QMF subsamples */ +) { + INT i, k, r, r2, timeIndex, autoCorrScaling; + + INT startIndexMatrix = hTonCorr->startIndexMatrix; + INT totNoEst = hTonCorr->numberOfEstimates; + INT noEstPerFrame = hTonCorr->numberOfEstimatesPerFrame; + INT move = hTonCorr->move; + INT noQmfChannels = hTonCorr->noQmfChannels; /* Number of Bands */ + INT buffLen = hTonCorr->bufferLength; /* Number of Slots */ + INT stepSize = hTonCorr->stepSize; + INT *pBlockLength = hTonCorr->lpcLength; + INT **RESTRICT signMatrix = hTonCorr->signMatrix; + FIXP_DBL *RESTRICT nrgVector = hTonCorr->nrgVector; + FIXP_DBL **RESTRICT quotaMatrix = hTonCorr->quotaMatrix; + FIXP_DBL *RESTRICT pNrgVectorFreq = hTonCorr->nrgVectorFreq; FIXP_DBL *realBuf; FIXP_DBL *imagBuf; - FIXP_DBL alphar[2],alphai[2],fac; - - C_ALLOC_SCRATCH_START(ac, ACORR_COEFS, 1); - C_ALLOC_SCRATCH_START(realBufRef, FIXP_DBL, 2*BAND_V_SIZE*NUM_V_COMBINE); + FIXP_DBL alphar[2], alphai[2], fac; + C_ALLOC_SCRATCH_START(ac, ACORR_COEFS, 1) + C_ALLOC_SCRATCH_START(realBufRef, FIXP_DBL, 2 * BAND_V_SIZE * NUM_V_COMBINE) realBuf = realBufRef; - imagBuf = realBuf + BAND_V_SIZE*NUM_V_COMBINE; - + imagBuf = realBuf + BAND_V_SIZE * NUM_V_COMBINE; FDK_ASSERT(buffLen <= BAND_V_SIZE); - FDK_ASSERT(sizeof(FIXP_DBL)*NUM_V_COMBINE*BAND_V_SIZE*2 < (1024*sizeof(FIXP_DBL)-sizeof(ACORR_COEFS)) ); + FDK_ASSERT(sizeof(FIXP_DBL) * NUM_V_COMBINE * BAND_V_SIZE * 2 < + (1024 * sizeof(FIXP_DBL) - sizeof(ACORR_COEFS))); /* * Buffering of the quotaMatrix and the quotaMatrixTransp. *********************************************************/ - for(i = 0 ; i < move; i++){ - FDKmemcpy(quotaMatrix[i],quotaMatrix[i + noEstPerFrame],noQmfChannels * sizeof(FIXP_DBL)); - FDKmemcpy(signMatrix[i],signMatrix[i + noEstPerFrame],noQmfChannels * sizeof(INT)); + for (i = 0; i < move; i++) { + FDKmemcpy(quotaMatrix[i], quotaMatrix[i + noEstPerFrame], + noQmfChannels * sizeof(FIXP_DBL)); + FDKmemcpy(signMatrix[i], signMatrix[i + noEstPerFrame], + noQmfChannels * sizeof(INT)); } - FDKmemmove(nrgVector,nrgVector+noEstPerFrame,move*sizeof(FIXP_DBL)); - FDKmemclear(nrgVector+startIndexMatrix,(totNoEst-startIndexMatrix)*sizeof(FIXP_DBL)); - FDKmemclear(pNrgVectorFreq,noQmfChannels * sizeof(FIXP_DBL)); + FDKmemmove(nrgVector, nrgVector + noEstPerFrame, move * sizeof(FIXP_DBL)); + FDKmemclear(nrgVector + startIndexMatrix, + (totNoEst - startIndexMatrix) * sizeof(FIXP_DBL)); + FDKmemclear(pNrgVectorFreq, noQmfChannels * sizeof(FIXP_DBL)); /* * Calculate the quotas for the current time steps. **************************************************/ - for (r = 0; r < usb; r++) - { + for (r = 0; r < usb; r++) { int blockLength; k = hTonCorr->nextSample; /* startSample */ timeIndex = startIndexMatrix; - /* Copy as many as possible Band accross all Slots at once */ + /* Copy as many as possible Band across all Slots at once */ if (realBuf != realBufRef) { realBuf -= BAND_V_SIZE; imagBuf -= BAND_V_SIZE; } else { - realBuf += BAND_V_SIZE*(NUM_V_COMBINE-1); - imagBuf += BAND_V_SIZE*(NUM_V_COMBINE-1); + realBuf += BAND_V_SIZE * (NUM_V_COMBINE - 1); + imagBuf += BAND_V_SIZE * (NUM_V_COMBINE - 1); + for (i = 0; i < buffLen; i++) { int v; FIXP_DBL *ptr; - ptr = realBuf+i; - for (v=0; v<NUM_V_COMBINE; v++) - { - ptr[0] = sourceBufferReal[i][r+v]; - ptr[0+BAND_V_SIZE*NUM_V_COMBINE] = sourceBufferImag[i][r+v]; + ptr = realBuf + i; + for (v = 0; v < NUM_V_COMBINE; v++) { + ptr[0] = sourceBufferReal[i][r + v]; + ptr[0 + BAND_V_SIZE * NUM_V_COMBINE] = sourceBufferImag[i][r + v]; ptr -= BAND_V_SIZE; } } @@ -200,54 +214,66 @@ FDKsbrEnc_CalculateTonalityQuotas( HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< H blockLength = pBlockLength[0]; - while(k <= buffLen - blockLength) - { - autoCorrScaling = fixMin(getScalefactor(&realBuf[k-LPC_ORDER], LPC_ORDER+blockLength), getScalefactor(&imagBuf[k-LPC_ORDER], LPC_ORDER+blockLength)); - autoCorrScaling = fixMax(0, autoCorrScaling-1); + while (k <= buffLen - blockLength) { + autoCorrScaling = fixMin( + getScalefactor(&realBuf[k - LPC_ORDER], LPC_ORDER + blockLength), + getScalefactor(&imagBuf[k - LPC_ORDER], LPC_ORDER + blockLength)); + autoCorrScaling = fixMax(0, autoCorrScaling - 1); - scaleValues(&realBuf[k-LPC_ORDER], LPC_ORDER+blockLength, autoCorrScaling); - scaleValues(&imagBuf[k-LPC_ORDER], LPC_ORDER+blockLength, autoCorrScaling); + scaleValues(&realBuf[k - LPC_ORDER], LPC_ORDER + blockLength, + autoCorrScaling); + scaleValues(&imagBuf[k - LPC_ORDER], LPC_ORDER + blockLength, + autoCorrScaling); autoCorrScaling <<= 1; /* consider qmf buffer scaling twice */ - autoCorrScaling += autoCorr2nd_cplx ( ac, realBuf+k, imagBuf+k, blockLength ); + autoCorrScaling += + autoCorr2nd_cplx(ac, realBuf + k, imagBuf + k, blockLength); - - if(ac->det == FL2FXCONST_DBL(0.0f)){ + if (ac->det == FL2FXCONST_DBL(0.0f)) { alphar[1] = alphai[1] = FL2FXCONST_DBL(0.0f); - alphar[0] = (ac->r01r)>>2; - alphai[0] = (ac->r01i)>>2; - - fac = fMultDiv2(ac->r00r, ac->r11r)>>1; + alphar[0] = (ac->r01r) >> 2; + alphai[0] = (ac->r01i) >> 2; + + fac = fMultDiv2(ac->r00r, ac->r11r) >> 1; + } else { + alphar[1] = (fMultDiv2(ac->r01r, ac->r12r) >> 1) - + (fMultDiv2(ac->r01i, ac->r12i) >> 1) - + (fMultDiv2(ac->r02r, ac->r11r) >> 1); + alphai[1] = (fMultDiv2(ac->r01i, ac->r12r) >> 1) + + (fMultDiv2(ac->r01r, ac->r12i) >> 1) - + (fMultDiv2(ac->r02i, ac->r11r) >> 1); + + alphar[0] = (fMultDiv2(ac->r01r, ac->det) >> (ac->det_scale + 1)) + + fMult(alphar[1], ac->r12r) + fMult(alphai[1], ac->r12i); + alphai[0] = (fMultDiv2(ac->r01i, ac->det) >> (ac->det_scale + 1)) + + fMult(alphai[1], ac->r12r) - fMult(alphar[1], ac->r12i); + + fac = fMultDiv2(ac->r00r, fMult(ac->det, ac->r11r)) >> + (ac->det_scale + 1); } - else{ - alphar[1] = (fMultDiv2(ac->r01r, ac->r12r)>>1) - (fMultDiv2(ac->r01i, ac->r12i)>>1) - (fMultDiv2(ac->r02r, ac->r11r)>>1); - alphai[1] = (fMultDiv2(ac->r01i, ac->r12r)>>1) + (fMultDiv2(ac->r01r, ac->r12i)>>1) - (fMultDiv2(ac->r02i, ac->r11r)>>1); - alphar[0] = (fMultDiv2(ac->r01r, ac->det)>>(ac->det_scale+1)) + fMult(alphar[1], ac->r12r) + fMult(alphai[1], ac->r12i); - alphai[0] = (fMultDiv2(ac->r01i, ac->det)>>(ac->det_scale+1)) + fMult(alphai[1], ac->r12r) - fMult(alphar[1], ac->r12i); - - fac = fMultDiv2(ac->r00r, fMult(ac->det, ac->r11r))>>(ac->det_scale+1); - } - - if(fac == FL2FXCONST_DBL(0.0f)){ + if (fac == FL2FXCONST_DBL(0.0f)) { quotaMatrix[timeIndex][r] = FL2FXCONST_DBL(0.0f); signMatrix[timeIndex][r] = 0; - } - else { + } else { /* quotaMatrix is scaled with the factor RELAXATION - parse RELAXATION in fractional part and shift factor: 1/(1/0.524288 * 2^RELAXATION_SHIFT) */ - FIXP_DBL tmp,num,denom; - INT numShift,denomShift,commonShift; + parse RELAXATION in fractional part and shift factor: 1/(1/0.524288 * + 2^RELAXATION_SHIFT) */ + FIXP_DBL tmp, num, denom; + INT numShift, denomShift, commonShift; INT sign; - num = fMultDiv2(alphar[0], ac->r01r) + fMultDiv2(alphai[0], ac->r01i) - fMultDiv2(alphar[1], fMult(ac->r02r, ac->r11r)) - fMultDiv2(alphai[1], fMult(ac->r02i, ac->r11r)); + num = fMultDiv2(alphar[0], ac->r01r) + fMultDiv2(alphai[0], ac->r01i) - + fMultDiv2(alphar[1], fMult(ac->r02r, ac->r11r)) - + fMultDiv2(alphai[1], fMult(ac->r02i, ac->r11r)); num = fixp_abs(num); - denom = (fac>>1) + (fMultDiv2(fac,RELAXATION_FRACT)>>RELAXATION_SHIFT) - num; + denom = (fac >> 1) + + (fMultDiv2(fac, RELAXATION_FRACT) >> RELAXATION_SHIFT) - num; denom = fixp_abs(denom); - num = fMult(num,RELAXATION_FRACT); + num = fMult(num, RELAXATION_FRACT); numShift = CountLeadingBits(num) - 2; num = scaleValue(num, numShift); @@ -256,46 +282,53 @@ FDKsbrEnc_CalculateTonalityQuotas( HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< H denom = (FIXP_DBL)denom << denomShift; if ((num > FL2FXCONST_DBL(0.0f)) && (denom != FL2FXCONST_DBL(0.0f))) { - commonShift = fixMin(numShift - denomShift + RELAXATION_SHIFT, DFRACT_BITS-1); + commonShift = + fixMin(numShift - denomShift + RELAXATION_SHIFT, DFRACT_BITS - 1); if (commonShift < 0) { commonShift = -commonShift; - tmp = schur_div(num,denom,16); - commonShift = fixMin(commonShift,CountLeadingBits(tmp)); + tmp = schur_div(num, denom, 16); + commonShift = fixMin(commonShift, CountLeadingBits(tmp)); quotaMatrix[timeIndex][r] = tmp << commonShift; + } else { + quotaMatrix[timeIndex][r] = + schur_div(num, denom, 16) >> commonShift; } - else { - quotaMatrix[timeIndex][r] = schur_div(num,denom,16) >> commonShift; - } - } - else { + } else { quotaMatrix[timeIndex][r] = FL2FXCONST_DBL(0.0f); } if (ac->r11r != FL2FXCONST_DBL(0.0f)) { - if ( ( (ac->r01r >= FL2FXCONST_DBL(0.0f) ) && ( ac->r11r >= FL2FXCONST_DBL(0.0f) ) ) - ||( (ac->r01r < FL2FXCONST_DBL(0.0f) ) && ( ac->r11r < FL2FXCONST_DBL(0.0f) ) ) ) { + if (((ac->r01r >= FL2FXCONST_DBL(0.0f)) && + (ac->r11r >= FL2FXCONST_DBL(0.0f))) || + ((ac->r01r < FL2FXCONST_DBL(0.0f)) && + (ac->r11r < FL2FXCONST_DBL(0.0f)))) { sign = 1; - } - else { + } else { sign = -1; } - } - else { + } else { sign = 1; } - if(sign < 0) { - r2 = r; /* (INT) pow(-1, band); */ - } - else { - r2 = r + 1; /* (INT) pow(-1, band+1); */ + if (sign < 0) { + r2 = r; /* (INT) pow(-1, band); */ + } else { + r2 = r + 1; /* (INT) pow(-1, band+1); */ } - signMatrix[timeIndex][r] = 1 - 2*(r2 & 0x1); + signMatrix[timeIndex][r] = 1 - 2 * (r2 & 0x1); } - nrgVector[timeIndex] += ((ac->r00r) >> fixMin(DFRACT_BITS-1,(2*qmfScale+autoCorrScaling + SCALE_NRGVEC))); - /* pNrgVectorFreq[r] finally has to be divided by noEstPerFrame, replaced division by shifting with one */ - pNrgVectorFreq[r] = pNrgVectorFreq[r] + ((ac->r00r) >> fixMin(DFRACT_BITS-1,(2*qmfScale+autoCorrScaling + SCALE_NRGVEC))); + nrgVector[timeIndex] += + ((ac->r00r) >> + fixMin(DFRACT_BITS - 1, + (2 * qmfScale + autoCorrScaling + SCALE_NRGVEC))); + /* pNrgVectorFreq[r] finally has to be divided by noEstPerFrame, replaced + * division by shifting with one */ + pNrgVectorFreq[r] = + pNrgVectorFreq[r] + + ((ac->r00r) >> + fixMin(DFRACT_BITS - 1, + (2 * qmfScale + autoCorrScaling + SCALE_NRGVEC))); blockLength = pBlockLength[1]; k += stepSize; @@ -303,9 +336,8 @@ FDKsbrEnc_CalculateTonalityQuotas( HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< H } } - - C_ALLOC_SCRATCH_END(realBuf, FIXP_DBL, 2*BAND_V_SIZE*NUM_V_COMBINE); - C_ALLOC_SCRATCH_END(ac, ACORR_COEFS, 1); + C_ALLOC_SCRATCH_END(realBufRef, FIXP_DBL, 2 * BAND_V_SIZE * NUM_V_COMBINE) + C_ALLOC_SCRATCH_END(ac, ACORR_COEFS, 1) } /**************************************************************************/ @@ -324,117 +356,101 @@ FDKsbrEnc_CalculateTonalityQuotas( HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< H */ /**************************************************************************/ -void -FDKsbrEnc_TonCorrParamExtr(HANDLE_SBR_TON_CORR_EST hTonCorr,/*!< Handle to SBR_TON_CORR struct. */ - INVF_MODE* infVec, /*!< Vector where the inverse filtering levels will be stored. */ - FIXP_DBL * noiseLevels, /*!< Vector where the noise levels will be stored. */ - INT* missingHarmonicFlag, /*!< Flag set to one or zero, dependent on if any strong sines are missing.*/ - UCHAR * missingHarmonicsIndex, /*!< Vector indicating where sines are missing. */ - UCHAR * envelopeCompensation, /*!< Vector to store compensation values for the energies in. */ - const SBR_FRAME_INFO *frameInfo, /*!< Frame info struct, contains the time and frequency grid of the current frame.*/ - UCHAR* transientInfo, /*!< Transient info.*/ - UCHAR* freqBandTable, /*!< Frequency band tables for high-res.*/ - INT nSfb, /*!< Number of scalefactor bands for high-res. */ - XPOS_MODE xposType, /*!< Type of transposer used in the decoder.*/ - UINT sbrSyntaxFlags - ) -{ +void FDKsbrEnc_TonCorrParamExtr( + HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ + INVF_MODE *infVec, /*!< Vector where the inverse filtering levels will be + stored. */ + FIXP_DBL *noiseLevels, /*!< Vector where the noise levels will be stored. */ + INT *missingHarmonicFlag, /*!< Flag set to one or zero, dependent on if any + strong sines are missing.*/ + UCHAR *missingHarmonicsIndex, /*!< Vector indicating where sines are + missing. */ + UCHAR *envelopeCompensation, /*!< Vector to store compensation values for + the energies in. */ + const SBR_FRAME_INFO *frameInfo, /*!< Frame info struct, contains the time + and frequency grid of the current + frame.*/ + UCHAR *transientInfo, /*!< Transient info.*/ + UCHAR *freqBandTable, /*!< Frequency band tables for high-res.*/ + INT nSfb, /*!< Number of scalefactor bands for high-res. */ + XPOS_MODE xposType, /*!< Type of transposer used in the decoder.*/ + UINT sbrSyntaxFlags) { INT band; - INT transientFlag = transientInfo[1] ; /*!< Flag indicating if a transient is present in the current frame. */ - INT transientPos = transientInfo[0]; /*!< Position of the transient.*/ + INT transientFlag = transientInfo[1]; /*!< Flag indicating if a transient is + present in the current frame. */ + INT transientPos = transientInfo[0]; /*!< Position of the transient.*/ INT transientFrame, transientFrameInvfEst; - INVF_MODE* infVecPtr; - + INVF_MODE *infVecPtr; /* Determine if this is a frame where a transient starts... - The detection of noise-floor, missing harmonics and invf_est, is not in sync for the - non-buf-opt decoder such as AAC. Hence we need to keep track on the transient in the - present frame as well as in the next. + The detection of noise-floor, missing harmonics and invf_est, is not in sync + for the non-buf-opt decoder such as AAC. Hence we need to keep track on the + transient in the present frame as well as in the next. */ transientFrame = 0; - if(hTonCorr->transientNextFrame){ /* The transient was detected in the previous frame, but is actually */ + if (hTonCorr->transientNextFrame) { /* The transient was detected in the + previous frame, but is actually */ transientFrame = 1; hTonCorr->transientNextFrame = 0; - if(transientFlag){ - if(transientPos + hTonCorr->transientPosOffset >= frameInfo->borders[frameInfo->nEnvelopes]){ + if (transientFlag) { + if (transientPos + hTonCorr->transientPosOffset >= + frameInfo->borders[frameInfo->nEnvelopes]) { hTonCorr->transientNextFrame = 1; } } - } - else{ - if(transientFlag){ - if(transientPos + hTonCorr->transientPosOffset < frameInfo->borders[frameInfo->nEnvelopes]){ + } else { + if (transientFlag) { + if (transientPos + hTonCorr->transientPosOffset < + frameInfo->borders[frameInfo->nEnvelopes]) { transientFrame = 1; hTonCorr->transientNextFrame = 0; - } - else{ + } else { hTonCorr->transientNextFrame = 1; } } } transientFrameInvfEst = transientFrame; - /* Estimate the required invese filtereing level. */ if (hTonCorr->switchInverseFilt) - FDKsbrEnc_qmfInverseFilteringDetector(&hTonCorr->sbrInvFilt, - hTonCorr->quotaMatrix, - hTonCorr->nrgVector, - hTonCorr->indexVector, - hTonCorr->frameStartIndexInvfEst, - hTonCorr->numberOfEstimatesPerFrame + hTonCorr->frameStartIndexInvfEst, - transientFrameInvfEst, - infVec); + FDKsbrEnc_qmfInverseFilteringDetector( + &hTonCorr->sbrInvFilt, hTonCorr->quotaMatrix, hTonCorr->nrgVector, + hTonCorr->indexVector, hTonCorr->frameStartIndexInvfEst, + hTonCorr->numberOfEstimatesPerFrame + hTonCorr->frameStartIndexInvfEst, + transientFrameInvfEst, infVec); /* Detect what tones will be missing. */ - if (xposType == XPOS_LC ){ - FDKsbrEnc_SbrMissingHarmonicsDetectorQmf(&hTonCorr->sbrMissingHarmonicsDetector, - hTonCorr->quotaMatrix, - hTonCorr->signMatrix, - hTonCorr->indexVector, - frameInfo, - transientInfo, - missingHarmonicFlag, - missingHarmonicsIndex, - freqBandTable, - nSfb, - envelopeCompensation, - hTonCorr->nrgVectorFreq); - } - else{ + if (xposType == XPOS_LC) { + FDKsbrEnc_SbrMissingHarmonicsDetectorQmf( + &hTonCorr->sbrMissingHarmonicsDetector, hTonCorr->quotaMatrix, + hTonCorr->signMatrix, hTonCorr->indexVector, frameInfo, transientInfo, + missingHarmonicFlag, missingHarmonicsIndex, freqBandTable, nSfb, + envelopeCompensation, hTonCorr->nrgVectorFreq); + } else { *missingHarmonicFlag = 0; - FDKmemclear(missingHarmonicsIndex,nSfb*sizeof(UCHAR)); + FDKmemclear(missingHarmonicsIndex, nSfb * sizeof(UCHAR)); } - - /* Noise floor estimation */ infVecPtr = hTonCorr->sbrInvFilt.prevInvfMode; - FDKsbrEnc_sbrNoiseFloorEstimateQmf(&hTonCorr->sbrNoiseFloorEstimate, - frameInfo, - noiseLevels, - hTonCorr->quotaMatrix, - hTonCorr->indexVector, - *missingHarmonicFlag, - hTonCorr->frameStartIndex, - hTonCorr->numberOfEstimatesPerFrame, - transientFrame, - infVecPtr, - sbrSyntaxFlags); - + FDKsbrEnc_sbrNoiseFloorEstimateQmf( + &hTonCorr->sbrNoiseFloorEstimate, frameInfo, noiseLevels, + hTonCorr->quotaMatrix, hTonCorr->indexVector, *missingHarmonicFlag, + hTonCorr->frameStartIndex, hTonCorr->numberOfEstimatesPerFrame, + transientFrame, infVecPtr, sbrSyntaxFlags); /* Store the invfVec data for the next frame...*/ - for(band = 0 ; band < hTonCorr->sbrInvFilt.noDetectorBands; band++){ + for (band = 0; band < hTonCorr->sbrInvFilt.noDetectorBands; band++) { hTonCorr->sbrInvFilt.prevInvfMode[band] = infVec[band]; } } @@ -449,28 +465,22 @@ FDKsbrEnc_TonCorrParamExtr(HANDLE_SBR_TON_CORR_EST hTonCorr,/*!< Handle to SBR_T */ /**************************************************************************/ -static INT -findClosestEntry(INT goalSb, - UCHAR *v_k_master, - INT numMaster, - INT direction) -{ +static INT findClosestEntry(INT goalSb, UCHAR *v_k_master, INT numMaster, + INT direction) { INT index; - if( goalSb <= v_k_master[0] ) - return v_k_master[0]; + if (goalSb <= v_k_master[0]) return v_k_master[0]; - if( goalSb >= v_k_master[numMaster] ) - return v_k_master[numMaster]; + if (goalSb >= v_k_master[numMaster]) return v_k_master[numMaster]; - if(direction) { + if (direction) { index = 0; - while( v_k_master[index] < goalSb ) { + while (v_k_master[index] < goalSb) { index++; } } else { index = numMaster; - while( v_k_master[index] > goalSb ) { + while (v_k_master[index] > goalSb) { index--; } } @@ -478,7 +488,6 @@ findClosestEntry(INT goalSb, return v_k_master[index]; } - /**************************************************************************/ /*! \brief resets the patch @@ -489,32 +498,36 @@ findClosestEntry(INT goalSb, */ /**************************************************************************/ -static INT -resetPatch(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ - INT xposctrl, /*!< Different patch modes. */ - INT highBandStartSb, /*!< Start band of the SBR range. */ - UCHAR *v_k_master, /*!< Master frequency table from which all other table are derived.*/ - INT numMaster, /*!< Number of elements in the master table. */ - INT fs, /*!< Sampling frequency. */ - INT noChannels) /*!< Number of QMF-channels. */ +static INT resetPatch( + HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ + INT xposctrl, /*!< Different patch modes. */ + INT highBandStartSb, /*!< Start band of the SBR range. */ + UCHAR *v_k_master, /*!< Master frequency table from which all other table + are derived.*/ + INT numMaster, /*!< Number of elements in the master table. */ + INT fs, /*!< Sampling frequency. */ + INT noChannels) /*!< Number of QMF-channels. */ { - INT patch,k,i; + INT patch, k, i; INT targetStopBand; - PATCH_PARAM *patchParam = hTonCorr->patchParam; + PATCH_PARAM *patchParam = hTonCorr->patchParam; INT sbGuard = hTonCorr->guard; INT sourceStartBand; INT patchDistance; INT numBandsInPatch; - INT lsb = v_k_master[0]; /* Lowest subband related to the synthesis filterbank */ - INT usb = v_k_master[numMaster]; /* Stop subband related to the synthesis filterbank */ - INT xoverOffset = highBandStartSb - v_k_master[0]; /* Calculate distance in subbands between k0 and kx */ + INT lsb = + v_k_master[0]; /* Lowest subband related to the synthesis filterbank */ + INT usb = v_k_master[numMaster]; /* Stop subband related to the synthesis + filterbank */ + INT xoverOffset = + highBandStartSb - + v_k_master[0]; /* Calculate distance in subbands between k0 and kx */ INT goalSb; - /* * Initialize the patching parameter */ @@ -524,47 +537,55 @@ resetPatch(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct xoverOffset = 0; } - goalSb = (INT)( (2 * noChannels * 16000 + (fs>>1)) / fs ); /* 16 kHz band */ - goalSb = findClosestEntry(goalSb, v_k_master, numMaster, 1); /* Adapt region to master-table */ + goalSb = (INT)((2 * noChannels * 16000 + (fs >> 1)) / fs); /* 16 kHz band */ + goalSb = findClosestEntry(goalSb, v_k_master, numMaster, + 1); /* Adapt region to master-table */ /* First patch */ sourceStartBand = hTonCorr->shiftStartSb + xoverOffset; targetStopBand = lsb + xoverOffset; - /* even (odd) numbered channel must be patched to even (odd) numbered channel */ + /* even (odd) numbered channel must be patched to even (odd) numbered channel + */ patch = 0; - while(targetStopBand < usb) { - + while (targetStopBand < usb) { /* To many patches */ - if (patch >= MAX_NUM_PATCHES) - return(1); /*Number of patches to high */ + if (patch >= MAX_NUM_PATCHES) return (1); /*Number of patches to high */ patchParam[patch].guardStartBand = targetStopBand; targetStopBand += sbGuard; patchParam[patch].targetStartBand = targetStopBand; - numBandsInPatch = goalSb - targetStopBand; /* get the desired range of the patch */ + numBandsInPatch = + goalSb - targetStopBand; /* get the desired range of the patch */ - if ( numBandsInPatch >= lsb - sourceStartBand ) { + if (numBandsInPatch >= lsb - sourceStartBand) { /* desired number bands are not available -> patch whole source range */ - patchDistance = targetStopBand - sourceStartBand; /* get the targetOffset */ - patchDistance = patchDistance & ~1; /* rounding off odd numbers and make all even */ + patchDistance = + targetStopBand - sourceStartBand; /* get the targetOffset */ + patchDistance = + patchDistance & ~1; /* rounding off odd numbers and make all even */ numBandsInPatch = lsb - (targetStopBand - patchDistance); - numBandsInPatch = findClosestEntry(targetStopBand + numBandsInPatch, v_k_master, numMaster, 0) - - targetStopBand; /* Adapt region to master-table */ + numBandsInPatch = findClosestEntry(targetStopBand + numBandsInPatch, + v_k_master, numMaster, 0) - + targetStopBand; /* Adapt region to master-table */ } - /* desired number bands are available -> get the minimal even patching distance */ - patchDistance = numBandsInPatch + targetStopBand - lsb; /* get minimal distance */ - patchDistance = (patchDistance + 1) & ~1; /* rounding up odd numbers and make all even */ + /* desired number bands are available -> get the minimal even patching + * distance */ + patchDistance = + numBandsInPatch + targetStopBand - lsb; /* get minimal distance */ + patchDistance = (patchDistance + 1) & + ~1; /* rounding up odd numbers and make all even */ if (numBandsInPatch <= 0) { patch--; } else { patchParam[patch].sourceStartBand = targetStopBand - patchDistance; - patchParam[patch].targetBandOffs = patchDistance; + patchParam[patch].targetBandOffs = patchDistance; patchParam[patch].numBandsInPatch = numBandsInPatch; - patchParam[patch].sourceStopBand = patchParam[patch].sourceStartBand + numBandsInPatch; + patchParam[patch].sourceStopBand = + patchParam[patch].sourceStartBand + numBandsInPatch; targetStopBand += patchParam[patch].numBandsInPatch; } @@ -573,42 +594,38 @@ resetPatch(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct sourceStartBand = hTonCorr->shiftStartSb; /* Check if we are close to goalSb */ - if( fixp_abs(targetStopBand - goalSb) < 3) { + if (fixp_abs(targetStopBand - goalSb) < 3) { goalSb = usb; } patch++; - } patch--; /* if highest patch contains less than three subband: skip it */ - if ( patchParam[patch].numBandsInPatch < 3 && patch > 0 ) { + if (patchParam[patch].numBandsInPatch < 3 && patch > 0) { patch--; - targetStopBand = patchParam[patch].targetStartBand + patchParam[patch].numBandsInPatch; } hTonCorr->noOfPatches = patch + 1; - /* Assign the index-vector, so we know where to look for the high-band. -1 represents a guard-band. */ - for(k = 0; k < hTonCorr->patchParam[0].guardStartBand; k++) + for (k = 0; k < hTonCorr->patchParam[0].guardStartBand; k++) hTonCorr->indexVector[k] = k; - for(i = 0; i < hTonCorr->noOfPatches; i++) - { - INT sourceStart = hTonCorr->patchParam[i].sourceStartBand; - INT targetStart = hTonCorr->patchParam[i].targetStartBand; - INT numberOfBands = hTonCorr->patchParam[i].numBandsInPatch; + for (i = 0; i < hTonCorr->noOfPatches; i++) { + INT sourceStart = hTonCorr->patchParam[i].sourceStartBand; + INT targetStart = hTonCorr->patchParam[i].targetStartBand; + INT numberOfBands = hTonCorr->patchParam[i].numBandsInPatch; INT startGuardBand = hTonCorr->patchParam[i].guardStartBand; - for(k = 0; k < (targetStart- startGuardBand); k++) - hTonCorr->indexVector[startGuardBand+k] = -1; + for (k = 0; k < (targetStart - startGuardBand); k++) + hTonCorr->indexVector[startGuardBand + k] = -1; - for(k = 0; k < numberOfBands; k++) - hTonCorr->indexVector[targetStart+k] = sourceStart+k; + for (k = 0; k < numberOfBands; k++) + hTonCorr->indexVector[targetStart + k] = sourceStart + k; } return (0); @@ -624,27 +641,41 @@ resetPatch(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct \return errorCode, noError if successful. */ /**************************************************************************/ -INT -FDKsbrEnc_CreateTonCorrParamExtr(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Pointer to handle to SBR_TON_CORR struct. */ - INT chan) /*!< Channel index, needed for mem allocation */ +INT FDKsbrEnc_CreateTonCorrParamExtr( + HANDLE_SBR_TON_CORR_EST + hTonCorr, /*!< Pointer to handle to SBR_TON_CORR struct. */ + INT chan) /*!< Channel index, needed for mem allocation */ { INT i; - FIXP_DBL* quotaMatrix = GetRam_Sbr_quotaMatrix(chan); - INT* signMatrix = GetRam_Sbr_signMatrix(chan); + FIXP_DBL *quotaMatrix = GetRam_Sbr_quotaMatrix(chan); + INT *signMatrix = GetRam_Sbr_signMatrix(chan); + + if ((NULL == quotaMatrix) || (NULL == signMatrix)) { + goto bail; + } FDKmemclear(hTonCorr, sizeof(SBR_TON_CORR_EST)); - for (i=0; i<MAX_NO_OF_ESTIMATES; i++) { - hTonCorr->quotaMatrix[i] = quotaMatrix + (i*QMF_CHANNELS); - hTonCorr->signMatrix[i] = signMatrix + (i*QMF_CHANNELS); + for (i = 0; i < MAX_NO_OF_ESTIMATES; i++) { + hTonCorr->quotaMatrix[i] = quotaMatrix + (i * 64); + hTonCorr->signMatrix[i] = signMatrix + (i * 64); } - FDKsbrEnc_CreateSbrMissingHarmonicsDetector (&hTonCorr->sbrMissingHarmonicsDetector, chan); + if (0 != FDKsbrEnc_CreateSbrMissingHarmonicsDetector( + &hTonCorr->sbrMissingHarmonicsDetector, chan)) { + goto bail; + } return 0; -} +bail: + hTonCorr->quotaMatrix[0] = quotaMatrix; + hTonCorr->signMatrix[0] = signMatrix; + + FDKsbrEnc_DeleteTonCorrParamExtr(hTonCorr); + return -1; +} /**************************************************************************/ /*! @@ -656,27 +687,29 @@ FDKsbrEnc_CreateTonCorrParamExtr(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Pointer \return errorCode, noError if successful. */ /**************************************************************************/ -INT -FDKsbrEnc_InitTonCorrParamExtr (INT frameSize, /*!< Current SBR frame size. */ - HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Pointer to handle to SBR_TON_CORR struct. */ - HANDLE_SBR_CONFIG_DATA sbrCfg, /*!< Pointer to SBR configuration parameters. */ - INT timeSlots, /*!< Number of time-slots per frame */ - INT xposCtrl, /*!< Different patch modes. */ - INT ana_max_level, /*!< Maximum level of the adaptive noise. */ - INT noiseBands, /*!< Number of noise bands per octave. */ - INT noiseFloorOffset, /*!< Noise floor offset. */ - UINT useSpeechConfig) /*!< Speech or music tuning. */ +INT FDKsbrEnc_InitTonCorrParamExtr( + INT frameSize, /*!< Current SBR frame size. */ + HANDLE_SBR_TON_CORR_EST + hTonCorr, /*!< Pointer to handle to SBR_TON_CORR struct. */ + HANDLE_SBR_CONFIG_DATA + sbrCfg, /*!< Pointer to SBR configuration parameters. */ + INT timeSlots, /*!< Number of time-slots per frame */ + INT xposCtrl, /*!< Different patch modes. */ + INT ana_max_level, /*!< Maximum level of the adaptive noise. */ + INT noiseBands, /*!< Number of noise bands per octave. */ + INT noiseFloorOffset, /*!< Noise floor offset. */ + UINT useSpeechConfig) /*!< Speech or music tuning. */ { INT nCols = sbrCfg->noQmfSlots; - INT fs = sbrCfg->sampleFreq; + INT fs = sbrCfg->sampleFreq; INT noQmfChannels = sbrCfg->noQmfBands; INT highBandStartSb = sbrCfg->freqBandTable[LOW_RES][0]; - UCHAR *v_k_master = sbrCfg->v_k_master; - INT numMaster = sbrCfg->num_Master; + UCHAR *v_k_master = sbrCfg->v_k_master; + INT numMaster = sbrCfg->num_Master; - UCHAR **freqBandTable = sbrCfg->freqBandTable; - INT *nSfb = sbrCfg->nSfb; + UCHAR **freqBandTable = sbrCfg->freqBandTable; + INT *nSfb = sbrCfg->nSfb; INT i; @@ -686,113 +719,102 @@ FDKsbrEnc_InitTonCorrParamExtr (INT frameSize, /*!< Current */ if (sbrCfg->sbrSyntaxFlags & SBR_SYNTAX_LOW_DELAY) { switch (timeSlots) { - case NUMBER_TIME_SLOTS_1920: - hTonCorr->lpcLength[0] = 8 - LPC_ORDER; - hTonCorr->lpcLength[1] = 7 - LPC_ORDER; - hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LD; - hTonCorr->numberOfEstimatesPerFrame = 2; /* sbrCfg->noQmfSlots / 7 */ - hTonCorr->frameStartIndexInvfEst = 0; - hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_512LD; - break; - case NUMBER_TIME_SLOTS_2048: - hTonCorr->lpcLength[0] = 8 - LPC_ORDER; - hTonCorr->lpcLength[1] = 8 - LPC_ORDER; - hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LD; - hTonCorr->numberOfEstimatesPerFrame = 2; /* sbrCfg->noQmfSlots / 8 */ - hTonCorr->frameStartIndexInvfEst = 0; - hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_512LD; - break; + case NUMBER_TIME_SLOTS_1920: + hTonCorr->lpcLength[0] = 8 - LPC_ORDER; + hTonCorr->lpcLength[1] = 7 - LPC_ORDER; + hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LD; + hTonCorr->numberOfEstimatesPerFrame = 2; /* sbrCfg->noQmfSlots / 7 */ + hTonCorr->frameStartIndexInvfEst = 0; + hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_512LD; + break; + case NUMBER_TIME_SLOTS_2048: + hTonCorr->lpcLength[0] = 8 - LPC_ORDER; + hTonCorr->lpcLength[1] = 8 - LPC_ORDER; + hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LD; + hTonCorr->numberOfEstimatesPerFrame = 2; /* sbrCfg->noQmfSlots / 8 */ + hTonCorr->frameStartIndexInvfEst = 0; + hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_512LD; + break; } } else - switch (timeSlots) { - case NUMBER_TIME_SLOTS_2048: - hTonCorr->lpcLength[0] = 16 - LPC_ORDER; /* blockLength[0] */ - hTonCorr->lpcLength[1] = 16 - LPC_ORDER; /* blockLength[0] */ - hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LC; - hTonCorr->numberOfEstimatesPerFrame = sbrCfg->noQmfSlots / 16; - hTonCorr->frameStartIndexInvfEst = 0; - hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_2048; - break; - case NUMBER_TIME_SLOTS_1920: - hTonCorr->lpcLength[0] = 15 - LPC_ORDER; /* blockLength[0] */ - hTonCorr->lpcLength[1] = 15 - LPC_ORDER; /* blockLength[0] */ - hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LC; - hTonCorr->numberOfEstimatesPerFrame = sbrCfg->noQmfSlots / 15; - hTonCorr->frameStartIndexInvfEst = 0; - hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_1920; - break; - default: - return -1; - } + switch (timeSlots) { + case NUMBER_TIME_SLOTS_2048: + hTonCorr->lpcLength[0] = 16 - LPC_ORDER; /* blockLength[0] */ + hTonCorr->lpcLength[1] = 16 - LPC_ORDER; /* blockLength[0] */ + hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LC; + hTonCorr->numberOfEstimatesPerFrame = sbrCfg->noQmfSlots / 16; + hTonCorr->frameStartIndexInvfEst = 0; + hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_2048; + break; + case NUMBER_TIME_SLOTS_1920: + hTonCorr->lpcLength[0] = 15 - LPC_ORDER; /* blockLength[0] */ + hTonCorr->lpcLength[1] = 15 - LPC_ORDER; /* blockLength[0] */ + hTonCorr->numberOfEstimates = NO_OF_ESTIMATES_LC; + hTonCorr->numberOfEstimatesPerFrame = sbrCfg->noQmfSlots / 15; + hTonCorr->frameStartIndexInvfEst = 0; + hTonCorr->transientPosOffset = FRAME_MIDDLE_SLOT_1920; + break; + default: + return -1; + } - hTonCorr->bufferLength = nCols; - hTonCorr->stepSize = hTonCorr->lpcLength[0] + LPC_ORDER; /* stepSize[0] implicitly 0. */ + hTonCorr->bufferLength = nCols; + hTonCorr->stepSize = + hTonCorr->lpcLength[0] + LPC_ORDER; /* stepSize[0] implicitly 0. */ - hTonCorr->nextSample = LPC_ORDER; /* firstSample */ - hTonCorr->move = hTonCorr->numberOfEstimates - hTonCorr->numberOfEstimatesPerFrame; /* Number of estimates to move when buffering.*/ - hTonCorr->startIndexMatrix = hTonCorr->numberOfEstimates - hTonCorr->numberOfEstimatesPerFrame; /* Where to store the latest estimations in the tonality Matrix.*/ - hTonCorr->frameStartIndex = 0; /* Where in the tonality matrix the current frame (to be sent to the decoder) starts. */ + hTonCorr->nextSample = LPC_ORDER; /* firstSample */ + hTonCorr->move = hTonCorr->numberOfEstimates - + hTonCorr->numberOfEstimatesPerFrame; /* Number of estimates + to move when + buffering.*/ + if (hTonCorr->move < 0) { + return -1; + } + hTonCorr->startIndexMatrix = + hTonCorr->numberOfEstimates - + hTonCorr->numberOfEstimatesPerFrame; /* Where to store the latest + estimations in the tonality + Matrix.*/ + hTonCorr->frameStartIndex = 0; /* Where in the tonality matrix the current + frame (to be sent to the decoder) starts. */ hTonCorr->prevTransientFlag = 0; hTonCorr->transientNextFrame = 0; hTonCorr->noQmfChannels = noQmfChannels; - for (i=0; i<hTonCorr->numberOfEstimates; i++) { - FDKmemclear (hTonCorr->quotaMatrix[i] , sizeof(FIXP_DBL)*noQmfChannels); - FDKmemclear (hTonCorr->signMatrix[i] , sizeof(INT)*noQmfChannels); + for (i = 0; i < hTonCorr->numberOfEstimates; i++) { + FDKmemclear(hTonCorr->quotaMatrix[i], sizeof(FIXP_DBL) * noQmfChannels); + FDKmemclear(hTonCorr->signMatrix[i], sizeof(INT) * noQmfChannels); } - /* Reset the patch.*/ + /* Reset the patch.*/ hTonCorr->guard = 0; hTonCorr->shiftStartSb = 1; - if(resetPatch(hTonCorr, - xposCtrl, - highBandStartSb, - v_k_master, - numMaster, - fs, - noQmfChannels)) - return(1); - - if(FDKsbrEnc_InitSbrNoiseFloorEstimate (&hTonCorr->sbrNoiseFloorEstimate, - ana_max_level, - freqBandTable[LO], - nSfb[LO], - noiseBands, - noiseFloorOffset, - timeSlots, - useSpeechConfig)) - return(1); - - - if(FDKsbrEnc_initInvFiltDetector(&hTonCorr->sbrInvFilt, - hTonCorr->sbrNoiseFloorEstimate.freqBandTableQmf, - hTonCorr->sbrNoiseFloorEstimate.noNoiseBands, - useSpeechConfig)) - return(1); - + if (resetPatch(hTonCorr, xposCtrl, highBandStartSb, v_k_master, numMaster, fs, + noQmfChannels)) + return (1); + if (FDKsbrEnc_InitSbrNoiseFloorEstimate( + &hTonCorr->sbrNoiseFloorEstimate, ana_max_level, freqBandTable[LO], + nSfb[LO], noiseBands, noiseFloorOffset, timeSlots, useSpeechConfig)) + return (1); - if(FDKsbrEnc_InitSbrMissingHarmonicsDetector( - &hTonCorr->sbrMissingHarmonicsDetector, - fs, - frameSize, - nSfb[HI], - noQmfChannels, - hTonCorr->numberOfEstimates, - hTonCorr->move, - hTonCorr->numberOfEstimatesPerFrame, - sbrCfg->sbrSyntaxFlags)) - return(1); - + if (FDKsbrEnc_initInvFiltDetector( + &hTonCorr->sbrInvFilt, + hTonCorr->sbrNoiseFloorEstimate.freqBandTableQmf, + hTonCorr->sbrNoiseFloorEstimate.noNoiseBands, useSpeechConfig)) + return (1); + if (FDKsbrEnc_InitSbrMissingHarmonicsDetector( + &hTonCorr->sbrMissingHarmonicsDetector, fs, frameSize, nSfb[HI], + noQmfChannels, hTonCorr->numberOfEstimates, hTonCorr->move, + hTonCorr->numberOfEstimatesPerFrame, sbrCfg->sbrSyntaxFlags)) + return (1); return (0); } - - /**************************************************************************/ /*! \brief resets tonality correction parameter module. @@ -803,59 +825,48 @@ FDKsbrEnc_InitTonCorrParamExtr (INT frameSize, /*!< Current */ /**************************************************************************/ -INT -FDKsbrEnc_ResetTonCorrParamExtr(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ - INT xposctrl, /*!< Different patch modes. */ - INT highBandStartSb, /*!< Start band of the SBR range. */ - UCHAR *v_k_master, /*!< Master frequency table from which all other table are derived.*/ - INT numMaster, /*!< Number of elements in the master table. */ - INT fs, /*!< Sampling frequency (of the SBR part). */ - UCHAR ** freqBandTable, /*!< Frequency band table for low-res and high-res. */ - INT* nSfb, /*!< Number of frequency bands (hig-res and low-res). */ - INT noQmfChannels /*!< Number of QMF channels. */ - ) -{ - +INT FDKsbrEnc_ResetTonCorrParamExtr( + HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to SBR_TON_CORR struct. */ + INT xposctrl, /*!< Different patch modes. */ + INT highBandStartSb, /*!< Start band of the SBR range. */ + UCHAR *v_k_master, /*!< Master frequency table from which all other table + are derived.*/ + INT numMaster, /*!< Number of elements in the master table. */ + INT fs, /*!< Sampling frequency (of the SBR part). */ + UCHAR * + *freqBandTable, /*!< Frequency band table for low-res and high-res. */ + INT *nSfb, /*!< Number of frequency bands (hig-res and low-res). */ + INT noQmfChannels /*!< Number of QMF channels. */ +) { /* Reset the patch.*/ hTonCorr->guard = 0; hTonCorr->shiftStartSb = 1; - if(resetPatch(hTonCorr, - xposctrl, - highBandStartSb, - v_k_master, - numMaster, - fs, - noQmfChannels)) - return(1); - - + if (resetPatch(hTonCorr, xposctrl, highBandStartSb, v_k_master, numMaster, fs, + noQmfChannels)) + return (1); /* Reset the noise floor estimate.*/ - if(FDKsbrEnc_resetSbrNoiseFloorEstimate (&hTonCorr->sbrNoiseFloorEstimate, - freqBandTable[LO], - nSfb[LO])) - return(1); + if (FDKsbrEnc_resetSbrNoiseFloorEstimate(&hTonCorr->sbrNoiseFloorEstimate, + freqBandTable[LO], nSfb[LO])) + return (1); /* Reset the inveerse filtereing detector. */ - if(FDKsbrEnc_resetInvFiltDetector(&hTonCorr->sbrInvFilt, - hTonCorr->sbrNoiseFloorEstimate.freqBandTableQmf, - hTonCorr->sbrNoiseFloorEstimate.noNoiseBands)) - return(1); -/* Reset the missing harmonics detector. */ - if(FDKsbrEnc_ResetSbrMissingHarmonicsDetector (&hTonCorr->sbrMissingHarmonicsDetector, - nSfb[HI])) - return(1); + if (FDKsbrEnc_resetInvFiltDetector( + &hTonCorr->sbrInvFilt, + hTonCorr->sbrNoiseFloorEstimate.freqBandTableQmf, + hTonCorr->sbrNoiseFloorEstimate.noNoiseBands)) + return (1); + /* Reset the missing harmonics detector. */ + if (FDKsbrEnc_ResetSbrMissingHarmonicsDetector( + &hTonCorr->sbrMissingHarmonicsDetector, nSfb[HI])) + return (1); return (0); } - - - - /**************************************************************************/ /*! \brief Deletes the tonality correction paramtere module. @@ -866,16 +877,15 @@ FDKsbrEnc_ResetTonCorrParamExtr(HANDLE_SBR_TON_CORR_EST hTonCorr, /*!< Handle to */ /**************************************************************************/ -void -FDKsbrEnc_DeleteTonCorrParamExtr (HANDLE_SBR_TON_CORR_EST hTonCorr) /*!< Handle to SBR_TON_CORR struct. */ +void FDKsbrEnc_DeleteTonCorrParamExtr( + HANDLE_SBR_TON_CORR_EST hTonCorr) /*!< Handle to SBR_TON_CORR struct. */ { - if (hTonCorr) { + FreeRam_Sbr_quotaMatrix(hTonCorr->quotaMatrix); - FreeRam_Sbr_quotaMatrix(hTonCorr->quotaMatrix); - - FreeRam_Sbr_signMatrix(hTonCorr->signMatrix); + FreeRam_Sbr_signMatrix(hTonCorr->signMatrix); - FDKsbrEnc_DeleteSbrMissingHarmonicsDetector (&hTonCorr->sbrMissingHarmonicsDetector); + FDKsbrEnc_DeleteSbrMissingHarmonicsDetector( + &hTonCorr->sbrMissingHarmonicsDetector); } } |