diff options
Diffstat (limited to 'libDRCdec/src')
-rw-r--r-- | libDRCdec/src/FDK_drcDecLib.cpp | 178 | ||||
-rw-r--r-- | libDRCdec/src/drcDec_gainDecoder.cpp | 26 | ||||
-rw-r--r-- | libDRCdec/src/drcDec_gainDecoder.h | 12 | ||||
-rw-r--r-- | libDRCdec/src/drcDec_reader.cpp | 20 | ||||
-rw-r--r-- | libDRCdec/src/drcDec_selectionProcess.cpp | 25 | ||||
-rw-r--r-- | libDRCdec/src/drcDec_selectionProcess.h | 3 | ||||
-rw-r--r-- | libDRCdec/src/drcDec_types.h | 8 | ||||
-rw-r--r-- | libDRCdec/src/drcGainDec_init.cpp | 27 | ||||
-rw-r--r-- | libDRCdec/src/drcGainDec_init.h | 5 |
9 files changed, 184 insertions, 120 deletions
diff --git a/libDRCdec/src/FDK_drcDecLib.cpp b/libDRCdec/src/FDK_drcDecLib.cpp index b29b79d..4f8ebc7 100644 --- a/libDRCdec/src/FDK_drcDecLib.cpp +++ b/libDRCdec/src/FDK_drcDecLib.cpp @@ -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 @@ -173,13 +173,11 @@ static int isResetNeeded(HANDLE_DRC_DECODER hDrcDec, return resetNeeded; } -static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) { - DRC_ERROR dErr = DE_OK; - DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR; +static void startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) { int uniDrcConfigHasChanged = 0; SEL_PROC_OUTPUT oldSelProcOutput = hDrcDec->selProcOutput; - if (!hDrcDec->status) return DRC_DEC_NOT_READY; + if (!hDrcDec->status) return; if (hDrcDec->functionalRange & DRC_DEC_SELECTION) { uniDrcConfigHasChanged = hDrcDec->uniDrcConfig.diff; @@ -189,10 +187,9 @@ static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) { */ hDrcDec->selProcOutput.numSelectedDrcSets = 0; - sErr = drcDec_SelectionProcess_Process( + drcDec_SelectionProcess_Process( hDrcDec->hSelectionProc, &(hDrcDec->uniDrcConfig), &(hDrcDec->loudnessInfoSet), &(hDrcDec->selProcOutput)); - if (sErr) return DRC_DEC_OK; hDrcDec->selProcInputDiff = 0; hDrcDec->uniDrcConfig.diff = 0; @@ -202,15 +199,12 @@ static DRC_DEC_ERROR startSelectionProcess(HANDLE_DRC_DECODER hDrcDec) { if (hDrcDec->functionalRange & DRC_DEC_GAIN) { if (isResetNeeded(hDrcDec, oldSelProcOutput) || uniDrcConfigHasChanged) { - dErr = - drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig), - hDrcDec->selProcOutput.numSelectedDrcSets, - hDrcDec->selProcOutput.selectedDrcSetIds, - hDrcDec->selProcOutput.selectedDownmixIds); - if (dErr) return DRC_DEC_OK; + drcDec_GainDecoder_Config(hDrcDec->hGainDec, &(hDrcDec->uniDrcConfig), + hDrcDec->selProcOutput.numSelectedDrcSets, + hDrcDec->selProcOutput.selectedDrcSetIds, + hDrcDec->selProcOutput.selectedDownmixIds); } } - return DRC_DEC_OK; } DRC_DEC_ERROR @@ -342,7 +336,13 @@ FDK_drcDec_Init(HANDLE_DRC_DECODER hDrcDec, const int frameSize, } if (hDrcDec->functionalRange & DRC_DEC_GAIN) { - dErr = drcDec_GainDecoder_Init(hDrcDec->hGainDec, frameSize, sampleRate); + dErr = drcDec_GainDecoder_SetParam(hDrcDec->hGainDec, GAIN_DEC_FRAME_SIZE, + frameSize); + if (dErr) return DRC_DEC_NOT_OK; + dErr = drcDec_GainDecoder_SetParam(hDrcDec->hGainDec, GAIN_DEC_SAMPLE_RATE, + sampleRate); + if (dErr) return DRC_DEC_NOT_OK; + dErr = drcDec_GainDecoder_Init(hDrcDec->hGainDec); if (dErr) return DRC_DEC_NOT_OK; } @@ -383,73 +383,99 @@ DRC_DEC_ERROR FDK_drcDec_SetParam(HANDLE_DRC_DECODER hDrcDec, const DRC_DEC_USERPARAM requestType, const FIXP_DBL requestValue) { + DRC_ERROR dErr = DE_OK; DRCDEC_SELECTION_PROCESS_RETURN sErr = DRCDEC_SELECTION_PROCESS_NO_ERROR; + int invalidParameter = 0; if (hDrcDec == NULL) return DRC_DEC_NOT_OPENED; - if (hDrcDec->functionalRange == DRC_DEC_GAIN) - return DRC_DEC_NOT_OK; /* not supported for DRC_DEC_GAIN. All parameters are - handed over to selection process lib. */ + if (hDrcDec->functionalRange & DRC_DEC_GAIN) { + switch (requestType) { + case DRC_DEC_SAMPLE_RATE: + dErr = drcDec_GainDecoder_SetParam( + hDrcDec->hGainDec, GAIN_DEC_SAMPLE_RATE, (int)requestValue); + if (dErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_FRAME_SIZE: + dErr = drcDec_GainDecoder_SetParam( + hDrcDec->hGainDec, GAIN_DEC_FRAME_SIZE, (int)requestValue); + if (dErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + default: + invalidParameter |= DRC_DEC_GAIN; + } + } - switch (requestType) { - case DRC_DEC_BOOST: - sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, - SEL_PROC_BOOST, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_COMPRESS: - sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, - SEL_PROC_COMPRESS, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_LOUDNESS_NORMALIZATION_ON: - sErr = drcDec_SelectionProcess_SetParam( - hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_NORMALIZATION_ON, - requestValue, &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_TARGET_LOUDNESS: - sErr = drcDec_SelectionProcess_SetParam( - hDrcDec->hSelectionProc, SEL_PROC_TARGET_LOUDNESS, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_EFFECT_TYPE: - sErr = drcDec_SelectionProcess_SetParam( - hDrcDec->hSelectionProc, SEL_PROC_EFFECT_TYPE, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_DOWNMIX_ID: - sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, - SEL_PROC_DOWNMIX_ID, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED: - sErr = drcDec_SelectionProcess_SetParam( - hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - case DRC_DEC_BASE_CHANNEL_COUNT: - sErr = drcDec_SelectionProcess_SetParam( - hDrcDec->hSelectionProc, SEL_PROC_BASE_CHANNEL_COUNT, requestValue, - &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_NOT_OK; - break; - case DRC_DEC_LOUDNESS_MEASUREMENT_METHOD: - sErr = drcDec_SelectionProcess_SetParam( - hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD, - requestValue, &(hDrcDec->selProcInputDiff)); - if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; - break; - default: - return DRC_DEC_INVALID_PARAM; + if (hDrcDec->functionalRange & DRC_DEC_SELECTION) { + switch (requestType) { + case DRC_DEC_BOOST: + sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, + SEL_PROC_BOOST, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_COMPRESS: + sErr = drcDec_SelectionProcess_SetParam(hDrcDec->hSelectionProc, + SEL_PROC_COMPRESS, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_LOUDNESS_NORMALIZATION_ON: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_NORMALIZATION_ON, + requestValue, &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_TARGET_LOUDNESS: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_TARGET_LOUDNESS, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_EFFECT_TYPE: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_EFFECT_TYPE, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_DOWNMIX_ID: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_DOWNMIX_ID, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_TARGET_CHANNEL_COUNT_REQUESTED: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_TARGET_CHANNEL_COUNT, + requestValue, &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_BASE_CHANNEL_COUNT: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_BASE_CHANNEL_COUNT, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_NOT_OK; + break; + case DRC_DEC_LOUDNESS_MEASUREMENT_METHOD: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD, + requestValue, &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + case DRC_DEC_ALBUM_MODE: + sErr = drcDec_SelectionProcess_SetParam( + hDrcDec->hSelectionProc, SEL_PROC_ALBUM_MODE, requestValue, + &(hDrcDec->selProcInputDiff)); + if (sErr) return DRC_DEC_PARAM_OUT_OF_RANGE; + break; + default: + invalidParameter |= DRC_DEC_SELECTION; + } } + if (invalidParameter == hDrcDec->functionalRange) + return DRC_DEC_INVALID_PARAM; + /* All parameters need a new start of the selection process */ startSelectionProcess(hDrcDec); @@ -721,9 +747,9 @@ FDK_drcDec_ReadUniDrc(HANDLE_DRC_DECODER hDrcDec, drcDec_GainDecoder_GetFrameSize(hDrcDec->hGainDec), drcDec_GainDecoder_GetDeltaTminDefault(hDrcDec->hGainDec), &(hDrcDec->uniDrcGain)); - if (dErr) return DRC_DEC_NOT_OK; startSelectionProcess(hDrcDec); + if (dErr) return DRC_DEC_NOT_OK; hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD; diff --git a/libDRCdec/src/drcDec_gainDecoder.cpp b/libDRCdec/src/drcDec_gainDecoder.cpp index ca81fad..9d91267 100644 --- a/libDRCdec/src/drcDec_gainDecoder.cpp +++ b/libDRCdec/src/drcDec_gainDecoder.cpp @@ -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 @@ -170,11 +170,10 @@ drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec) { } DRC_ERROR -drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, - const int sampleRate) { +drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec) { DRC_ERROR err = DE_OK; - err = initGainDec(hGainDec, frameSize, sampleRate); + err = initGainDec(hGainDec); if (err) return err; initDrcGainBuffers(hGainDec->frameSize, &hGainDec->drcGainBuffers); @@ -183,6 +182,25 @@ drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, } DRC_ERROR +drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec, + const GAIN_DEC_PARAM paramType, + const int paramValue) { + switch (paramType) { + case GAIN_DEC_FRAME_SIZE: + if (paramValue < 0) return DE_PARAM_OUT_OF_RANGE; + hGainDec->frameSize = paramValue; + break; + case GAIN_DEC_SAMPLE_RATE: + if (paramValue < 0) return DE_PARAM_OUT_OF_RANGE; + hGainDec->deltaTminDefault = getDeltaTmin(paramValue); + break; + default: + return DE_PARAM_INVALID; + } + return DE_OK; +} + +DRC_ERROR drcDec_GainDecoder_SetCodecDependentParameters( HANDLE_DRC_GAIN_DECODER hGainDec, const DELAY_MODE delayMode, const int timeDomainSupported, diff --git a/libDRCdec/src/drcDec_gainDecoder.h b/libDRCdec/src/drcDec_gainDecoder.h index 2f4df4c..394b455 100644 --- a/libDRCdec/src/drcDec_gainDecoder.h +++ b/libDRCdec/src/drcDec_gainDecoder.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 @@ -134,6 +134,8 @@ typedef enum { GAIN_DEC_DRC2_DRC3 } GAIN_DEC_LOCATION; +typedef enum { GAIN_DEC_FRAME_SIZE, GAIN_DEC_SAMPLE_RATE } GAIN_DEC_PARAM; + typedef struct { FIXP_DBL gainLin; /* e = 7 */ SHORT time; @@ -195,8 +197,12 @@ DRC_ERROR drcDec_GainDecoder_Open(HANDLE_DRC_GAIN_DECODER* phGainDec); DRC_ERROR -drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, - const int sampleRate); +drcDec_GainDecoder_Init(HANDLE_DRC_GAIN_DECODER hGainDec); + +DRC_ERROR +drcDec_GainDecoder_SetParam(HANDLE_DRC_GAIN_DECODER hGainDec, + const GAIN_DEC_PARAM paramType, + const int paramValue); DRC_ERROR drcDec_GainDecoder_SetCodecDependentParameters( diff --git a/libDRCdec/src/drcDec_reader.cpp b/libDRCdec/src/drcDec_reader.cpp index 6fe7a04..9b5403a 100644 --- a/libDRCdec/src/drcDec_reader.cpp +++ b/libDRCdec/src/drcDec_reader.cpp @@ -185,10 +185,18 @@ drcDec_readUniDrc(HANDLE_FDK_BITSTREAM hBs, HANDLE_UNI_DRC_CONFIG hUniDrcConfig, uniDrcConfigPresent = FDKreadBits(hBs, 1); if (uniDrcConfigPresent) { err = drcDec_readUniDrcConfig(hBs, hUniDrcConfig); - if (err) return err; + if (err) { + /* clear config, if parsing error occured */ + FDKmemclear(hUniDrcConfig, sizeof(UNI_DRC_CONFIG)); + hUniDrcConfig->diff = 1; + } } err = drcDec_readLoudnessInfoSet(hBs, hLoudnessInfoSet); - if (err) return err; + if (err) { + /* clear config, if parsing error occured */ + FDKmemclear(hLoudnessInfoSet, sizeof(LOUDNESS_INFO_SET)); + hLoudnessInfoSet->diff = 1; + } } if (hUniDrcGain != NULL) { @@ -903,7 +911,7 @@ static void _skipEqCoefficients(HANDLE_FDK_BITSTREAM hBs) { firFilterOrder; int uniqueEqSubbandGainsCount, eqSubbandGainRepresentation, eqSubbandGainCount; - EQ_SUBBAND_GAIN_FORMAT eqSubbandGainFormat; + int eqSubbandGainFormat; eqDelayMaxPresent = FDKreadBits(hBs, 1); if (eqDelayMaxPresent) { @@ -944,7 +952,7 @@ static void _skipEqCoefficients(HANDLE_FDK_BITSTREAM hBs) { uniqueEqSubbandGainsCount = FDKreadBits(hBs, 6); if (uniqueEqSubbandGainsCount > 0) { eqSubbandGainRepresentation = FDKreadBits(hBs, 1); - eqSubbandGainFormat = (EQ_SUBBAND_GAIN_FORMAT)FDKreadBits(hBs, 4); + eqSubbandGainFormat = FDKreadBits(hBs, 4); switch (eqSubbandGainFormat) { case GF_QMF32: eqSubbandGainCount = 32; @@ -1130,7 +1138,7 @@ static DRC_ERROR _readDrcCoefficientsUniDrc(HANDLE_FDK_BITSTREAM hBs, drcCharacteristicLeftPresent = FDKreadBits(hBs, 1); if (drcCharacteristicLeftPresent) { pCoef->characteristicLeftCount = FDKreadBits(hBs, 4); - if ((pCoef->characteristicLeftCount + 1) > 8) return DE_MEMORY_ERROR; + if ((pCoef->characteristicLeftCount + 1) > 16) return DE_MEMORY_ERROR; for (i = 0; i < pCoef->characteristicLeftCount; i++) { err = _readCustomDrcCharacteristic( hBs, CS_LEFT, &(pCoef->characteristicLeftFormat[i + 1]), @@ -1141,7 +1149,7 @@ static DRC_ERROR _readDrcCoefficientsUniDrc(HANDLE_FDK_BITSTREAM hBs, drcCharacteristicRightPresent = FDKreadBits(hBs, 1); if (drcCharacteristicRightPresent) { pCoef->characteristicRightCount = FDKreadBits(hBs, 4); - if ((pCoef->characteristicRightCount + 1) > 8) return DE_MEMORY_ERROR; + if ((pCoef->characteristicRightCount + 1) > 16) return DE_MEMORY_ERROR; for (i = 0; i < pCoef->characteristicRightCount; i++) { err = _readCustomDrcCharacteristic( hBs, CS_RIGHT, &(pCoef->characteristicRightFormat[i + 1]), diff --git a/libDRCdec/src/drcDec_selectionProcess.cpp b/libDRCdec/src/drcDec_selectionProcess.cpp index 9228197..c33bf74 100644 --- a/libDRCdec/src/drcDec_selectionProcess.cpp +++ b/libDRCdec/src/drcDec_selectionProcess.cpp @@ -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 @@ -555,6 +555,11 @@ drcDec_SelectionProcess_SetParam(HANDLE_DRC_SELECTION_PROCESS hInstance, diff |= _compAssign(&pSelProcInput->loudnessMeasurementMethod, requestValueInt); break; + case SEL_PROC_ALBUM_MODE: + if ((requestValueInt < 0) || (requestValueInt > 1)) + return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE; + diff |= _compAssign(&pSelProcInput->albumMode, requestValueInt); + break; case SEL_PROC_DOWNMIX_ID: diff |= _compAssign(&pSelProcInput->targetConfigRequestType, TCRT_DOWNMIX_ID); @@ -598,14 +603,21 @@ drcDec_SelectionProcess_SetParam(HANDLE_DRC_SELECTION_PROCESS hInstance, if ((requestValue < (FIXP_DBL)0) || (requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1)))) return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE; - diff |= _compAssign(&pSelProcInput->boost, FX_DBL2FX_SGL(requestValue)); + diff |= _compAssign( + &pSelProcInput->boost, + FX_DBL2FX_SGL( + requestValue + + (FIXP_DBL)(1 << 15))); /* convert to FIXP_SGL with rounding */ break; case SEL_PROC_COMPRESS: if ((requestValue < (FIXP_DBL)0) || (requestValue > FL2FXCONST_DBL(1.0f / (float)(1 << 1)))) return DRCDEC_SELECTION_PROCESS_PARAM_OUT_OF_RANGE; - diff |= - _compAssign(&pSelProcInput->compress, FX_DBL2FX_SGL(requestValue)); + diff |= _compAssign( + &pSelProcInput->compress, + FX_DBL2FX_SGL( + requestValue + + (FIXP_DBL)(1 << 15))); /* convert to FIXP_SGL with rounding */ break; default: return DRCDEC_SELECTION_PROCESS_INVALID_PARAM; @@ -2173,6 +2185,9 @@ static DRCDEC_SELECTION_PROCESS_RETURN _selectDownmixMatrix( if (hSelProcOutput->activeDownmixId != 0) { for (i = 0; i < hUniDrcConfig->downmixInstructionsCount; i++) { DOWNMIX_INSTRUCTIONS* pDown = &(hUniDrcConfig->downmixInstructions[i]); + if (pDown->targetChannelCount > 8) { + continue; + } if (hSelProcOutput->activeDownmixId == pDown->downmixId) { hSelProcOutput->targetChannelCount = pDown->targetChannelCount; @@ -2825,6 +2840,8 @@ static int _downmixCoefficientsArePresent(HANDLE_UNI_DRC_CONFIG hUniDrcConfig, for (i = 0; i < hUniDrcConfig->downmixInstructionsCount; i++) { if (hUniDrcConfig->downmixInstructions[i].downmixId == downmixId) { if (hUniDrcConfig->downmixInstructions[i].downmixCoefficientsPresent) { + if (hUniDrcConfig->downmixInstructions[i].targetChannelCount > 8) + return 0; *pIndex = i; return 1; } diff --git a/libDRCdec/src/drcDec_selectionProcess.h b/libDRCdec/src/drcDec_selectionProcess.h index 9e0e3fb..420bae6 100644 --- a/libDRCdec/src/drcDec_selectionProcess.h +++ b/libDRCdec/src/drcDec_selectionProcess.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 @@ -146,6 +146,7 @@ typedef enum { SEL_PROC_EFFECT_TYPE, SEL_PROC_EFFECT_TYPE_FALLBACK_CODE, SEL_PROC_LOUDNESS_MEASUREMENT_METHOD, + SEL_PROC_ALBUM_MODE, SEL_PROC_DOWNMIX_ID, SEL_PROC_TARGET_LAYOUT, SEL_PROC_TARGET_CHANNEL_COUNT, diff --git a/libDRCdec/src/drcDec_types.h b/libDRCdec/src/drcDec_types.h index 28c17f3..6b99018 100644 --- a/libDRCdec/src/drcDec_types.h +++ b/libDRCdec/src/drcDec_types.h @@ -249,11 +249,11 @@ typedef struct { UCHAR drcFrameSizePresent; USHORT drcFrameSize; UCHAR characteristicLeftCount; - UCHAR characteristicLeftFormat[8]; - CUSTOM_DRC_CHAR customCharacteristicLeft[8]; + UCHAR characteristicLeftFormat[16]; + CUSTOM_DRC_CHAR customCharacteristicLeft[16]; UCHAR characteristicRightCount; - UCHAR characteristicRightFormat[8]; - CUSTOM_DRC_CHAR customCharacteristicRight[8]; + UCHAR characteristicRightFormat[16]; + CUSTOM_DRC_CHAR customCharacteristicRight[16]; UCHAR gainSequenceCount; /* unsaturated value, i.e. as provided in bitstream */ UCHAR gainSetCount; /* saturated to 12 */ diff --git a/libDRCdec/src/drcGainDec_init.cpp b/libDRCdec/src/drcGainDec_init.cpp index 38f3243..89d0f55 100644 --- a/libDRCdec/src/drcGainDec_init.cpp +++ b/libDRCdec/src/drcGainDec_init.cpp @@ -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 @@ -184,24 +184,11 @@ static DRC_ERROR _generateDrcInstructionsDerivedData( } DRC_ERROR -initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, - const int sampleRate) { +initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec) { int i, j, k; - if (frameSize < 1) { - return DE_NOT_OK; - } - - hGainDec->frameSize = frameSize; - - if (hGainDec->frameSize * 1000 < sampleRate) { - return DE_NOT_OK; - } - - hGainDec->deltaTminDefault = getDeltaTmin(sampleRate); - if (hGainDec->deltaTminDefault > hGainDec->frameSize) { - return DE_NOT_OK; - } + /* sanity check */ + if (hGainDec->deltaTminDefault > hGainDec->frameSize) return DE_NOT_OK; for (i = 0; i < MAX_ACTIVE_DRCS; i++) { for (j = 0; j < 8; j++) { @@ -336,9 +323,11 @@ initActiveDrcOffset(HANDLE_DRC_GAIN_DECODER hGainDec) { for (a = 0; a < hGainDec->nActiveDrcs; a++) { hGainDec->activeDrc[a].activeDrcOffset = accGainElementCount; accGainElementCount += hGainDec->activeDrc[a].gainElementCount; + if (accGainElementCount > 12) { + hGainDec->nActiveDrcs = a; + return DE_NOT_OK; + } } - if (accGainElementCount > 12) return DE_NOT_OK; - return DE_OK; } diff --git a/libDRCdec/src/drcGainDec_init.h b/libDRCdec/src/drcGainDec_init.h index 9215bc3..c0b9853 100644 --- a/libDRCdec/src/drcGainDec_init.h +++ b/libDRCdec/src/drcGainDec_init.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 @@ -104,8 +104,7 @@ amm-info@iis.fraunhofer.de #define DRCGAINDEC_INIT_H DRC_ERROR -initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec, const int frameSize, - const int sampleRate); +initGainDec(HANDLE_DRC_GAIN_DECODER hGainDec); void initDrcGainBuffers(const int frameSize, DRC_GAIN_BUFFERS* drcGainBuffers); |