From 57c9355de0269afb462ad4a8aa8814f6a6486ff1 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Thu, 19 Dec 2019 17:27:53 +0100 Subject: Create new applyDrcLevelNormalization() function for subsequent usage. Bug: 149514474 Test: atest DecoderTestXheAac DecoderTestAacDrc Change-Id: I23cc3081ff71830bc96766a31131594499dbdd04 --- libAACdec/src/aacdec_drc.h | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'libAACdec/src/aacdec_drc.h') diff --git a/libAACdec/src/aacdec_drc.h b/libAACdec/src/aacdec_drc.h index 924ec6f..1873c5b 100644 --- a/libAACdec/src/aacdec_drc.h +++ b/libAACdec/src/aacdec_drc.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -109,6 +109,11 @@ amm-info@iis.fraunhofer.de #include "channel.h" #include "FDK_bitstream.h" +#define AACDEC_DRC_GAIN_SCALING (11) /* Scaling of DRC gains */ +#define AACDEC_DRC_GAIN_INIT_VALUE \ + (FL2FXCONST_DBL( \ + 1.0f / (1 << AACDEC_DRC_GAIN_SCALING))) /* Init value for DRC gains */ + #define AACDEC_DRC_DFLT_EXPIRY_FRAMES \ (0) /* Default DRC data expiry time in AAC frames */ @@ -136,6 +141,8 @@ typedef enum { /** * \brief DRC module interface functions */ +void aacDecoder_drcReset(HANDLE_AAC_DRC self); + void aacDecoder_drcInit(HANDLE_AAC_DRC self); void aacDecoder_drcInitChannelData(CDrcChannelData *pDrcChannel); @@ -189,4 +196,45 @@ int aacDecoder_drcEpilog( void aacDecoder_drcGetInfo(HANDLE_AAC_DRC self, SCHAR *pPresMode, SCHAR *pProgRefLevel); +/** + * \brief Apply DRC Level Normalization. + * + * This function prepares/applies the gain values for the DRC Level + * Normalization and returns the exponent of the time data. The following two + * cases are handled: + * + * - Limiter enabled: + * The input data must be interleaved. + * One gain per sample is written to the buffer pGainPerSample. + * If necessary the time data is rescaled. + * + * - Limiter disabled: + * The input data can be interleaved or deinterleaved. + * The gain values are applied to the time data. + * If necessary the time data is rescaled. + * + * \param hDrcInfo [i/o] handle to drc data structure. + * \param samplesIn [i/o] pointer to time data. + * \param pGain [i ] pointer to gain to be applied to + * the time data. + * \param pGainPerSample [o ] pointer to the gain per sample to + * be applied to the time data in the limiter. + * \param gain_scale [i ] exponent to be applied to the time + * data. + * \param gain_delay [i ] delay[samples] with which the gains + * in pGain shall be applied (gain_delay <= nSamples). + * \param nSamples [i ] number of samples per frame. + * \param channels [i ] number of channels. + * \param stride [i ] channel stride of time data. + * \param limiterEnabled [i ] 1 if limiter is enabled, otherwise + * 0. + * + * \return exponent of time data + */ +INT applyDrcLevelNormalization(HANDLE_AAC_DRC hDrcInfo, PCM_DEC *samplesIn, + FIXP_DBL *pGain, FIXP_DBL *pGainPerSample, + const INT gain_scale, const UINT gain_delay, + const UINT nSamples, const UINT channels, + const UINT stride, const UINT limiterEnabled); + #endif /* AACDEC_DRC_H */ -- cgit v1.2.3 From 261fadc3a2221829196158824a512f11268756ef Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Thu, 19 Dec 2019 17:28:33 +0100 Subject: Remove outdated apply_normalization parameter from legacy DRC module. Bug: 149514474 Test: atest DecoderTestXheAac DecoderTestAacDrc Change-Id: I9b894007fc9d80da6aaee09d84c2b356f2c06ff7 --- libAACdec/src/aacdec_drc.cpp | 22 +++------------------- libAACdec/src/aacdec_drc.h | 1 - libAACdec/src/aacdec_drc_types.h | 1 - libAACdec/src/aacdecoder.cpp | 3 --- 4 files changed, 3 insertions(+), 24 deletions(-) (limited to 'libAACdec/src/aacdec_drc.h') diff --git a/libAACdec/src/aacdec_drc.cpp b/libAACdec/src/aacdec_drc.cpp index 6066a64..b6f5b49 100644 --- a/libAACdec/src/aacdec_drc.cpp +++ b/libAACdec/src/aacdec_drc.cpp @@ -190,7 +190,6 @@ void aacDecoder_drcInit(HANDLE_AAC_DRC self) { pParams->usrBoost = FL2FXCONST_DBL(0.0f); pParams->targetRefLevel = 96; pParams->expiryFrame = AACDEC_DRC_DFLT_EXPIRY_FRAMES; - pParams->applyDigitalNorm = ON; pParams->applyHeavyCompression = OFF; pParams->usrApplyHeavyCompression = OFF; @@ -274,11 +273,8 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam(HANDLE_AAC_DRC self, return AAC_DEC_INVALID_HANDLE; } if (value < 0) { - self->params.applyDigitalNorm = OFF; self->params.targetRefLevel = -1; } else { - /* ref_level must be between 0 and MAX_REFERENCE_LEVEL, inclusive */ - self->params.applyDigitalNorm = ON; if (self->params.targetRefLevel != (SCHAR)value) { self->params.targetRefLevel = (SCHAR)value; self->progRefLevel = (SCHAR)value; /* Always set the program reference @@ -289,16 +285,6 @@ AAC_DECODER_ERROR aacDecoder_drcSetParam(HANDLE_AAC_DRC self, self->update = 1; } break; - case APPLY_NORMALIZATION: - if ((value != OFF) && (value != ON)) { - return AAC_DEC_SET_PARAM_FAIL; - } - if (self == NULL) { - return AAC_DEC_INVALID_HANDLE; - } - /* Store new parameter value */ - self->params.applyDigitalNorm = (UCHAR)value; - break; case APPLY_HEAVY_COMPRESSION: if ((value != OFF) && (value != ON)) { return AAC_DEC_SET_PARAM_FAIL; @@ -926,11 +912,9 @@ void aacDecoder_drcApply(HANDLE_AAC_DRC self, void *pSbrDec, FDK_ASSERT(0); } } - if (self->params.applyDigitalNorm == OFF) { - /* Reset normalization gain since this module must not apply it */ - norm_mantissa = FL2FXCONST_DBL(0.5f); - norm_exponent = 1; - } + /* Reset normalization gain since this module must not apply it */ + norm_mantissa = FL2FXCONST_DBL(0.5f); + norm_exponent = 1; /* calc scale factors */ for (band = 0; band < numBands; band++) { diff --git a/libAACdec/src/aacdec_drc.h b/libAACdec/src/aacdec_drc.h index 1873c5b..76a44d6 100644 --- a/libAACdec/src/aacdec_drc.h +++ b/libAACdec/src/aacdec_drc.h @@ -130,7 +130,6 @@ typedef enum { TARGET_REF_LEVEL, DRC_BS_DELAY, DRC_DATA_EXPIRY_FRAME, - APPLY_NORMALIZATION, APPLY_HEAVY_COMPRESSION, DEFAULT_PRESENTATION_MODE, ENCODER_TARGET_LEVEL, diff --git a/libAACdec/src/aacdec_drc_types.h b/libAACdec/src/aacdec_drc_types.h index 873bd60..d4393f7 100644 --- a/libAACdec/src/aacdec_drc_types.h +++ b/libAACdec/src/aacdec_drc_types.h @@ -168,7 +168,6 @@ typedef struct { UINT expiryFrame; UCHAR bsDelayEnable; - UCHAR applyDigitalNorm; AACDEC_DRC_PARAMETER_HANDLING defaultPresentationMode; UCHAR encoderTargetLevel; diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index 6a0254d..965631b 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -3177,9 +3177,6 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( FDKmemcpy(drcChMap, self->chMapping, (8) * sizeof(UCHAR)); } - /* Turn off DRC modules level normalization in digital domain. */ - aacDecoder_drcSetParam(self->hDrcInfo, APPLY_NORMALIZATION, 0); - /* deactivate legacy DRC in case uniDrc is active, i.e. uniDrc payload is * present and one of DRC or Loudness Normalization is switched on */ aacDecoder_drcSetParam( -- cgit v1.2.3