aboutsummaryrefslogtreecommitdiffstats
path: root/libDRCdec/src/FDK_drcDecLib.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-09-15 16:54:16 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-09-15 16:54:16 +0200
commit97182034e8829014bdfc0449c2116d629196f1d4 (patch)
tree6c3f4e3ef63d33aa16c79e530b46382faf0ab406 /libDRCdec/src/FDK_drcDecLib.cpp
parentbafe5616b88cc52f9f0ded6403a6b3ec68d8c27c (diff)
parent3a831a5fbc990c83e9b5b804a082bb158364e793 (diff)
downloadfdk-aac-97182034e8829014bdfc0449c2116d629196f1d4.tar.gz
fdk-aac-97182034e8829014bdfc0449c2116d629196f1d4.tar.bz2
fdk-aac-97182034e8829014bdfc0449c2116d629196f1d4.zip
Merge remote-tracking branch 'mstorjo/master' into dabplus2
Diffstat (limited to 'libDRCdec/src/FDK_drcDecLib.cpp')
-rw-r--r--libDRCdec/src/FDK_drcDecLib.cpp178
1 files changed, 102 insertions, 76 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;