summaryrefslogtreecommitdiffstats
path: root/fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp')
-rw-r--r--fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp79
1 files changed, 64 insertions, 15 deletions
diff --git a/fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp b/fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp
index c33bf74..46ed740 100644
--- a/fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp
+++ b/fdk-aac/libDRCdec/src/drcDec_selectionProcess.cpp
@@ -103,8 +103,6 @@ amm-info@iis.fraunhofer.de
#include "drcDec_selectionProcess.h"
#include "drcDec_tools.h"
-#define UNDEFINED_LOUDNESS_VALUE (FIXP_DBL) MAXVAL_DBL
-
typedef enum {
DETR_NONE = 0,
DETR_NIGHT = 1,
@@ -753,8 +751,8 @@ static DRCDEC_SELECTION_PROCESS_RETURN _initDefaultParams(
hSelProcInput->loudnessNormalizationOn = 1;
hSelProcInput->targetLoudness = FL2FXCONST_DBL(-24.0f / (float)(1 << 7));
hSelProcInput->loudnessDeviationMax = DEFAULT_LOUDNESS_DEVIATION_MAX;
- hSelProcInput->loudnessMeasurementMethod = MDR_DEFAULT;
- hSelProcInput->loudnessMeasurementSystem = MSR_DEFAULT;
+ hSelProcInput->loudnessMeasurementMethod = MDR_ANCHOR_LOUDNESS;
+ hSelProcInput->loudnessMeasurementSystem = MSR_EXPERT_PANEL;
hSelProcInput->loudnessMeasurementPreProc = LPR_DEFAULT;
hSelProcInput->deviceCutOffFrequency = 500;
hSelProcInput->loudnessNormalizationGainDbMax =
@@ -956,17 +954,31 @@ static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement4(
return DRCDEC_SELECTION_PROCESS_NO_ERROR;
}
-/* #5: The number of DRC bands is supported. */
+/* #5: The number of DRC bands is supported. Moreover, gainSetIndex and
+ * gainSequenceIndex are within the allowed range. */
static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement5(
DRC_INSTRUCTIONS_UNI_DRC* pDrcInstructionUniDrc,
DRC_COEFFICIENTS_UNI_DRC* pCoef, int* pMatchFound) {
- int i;
+ int b, i;
*pMatchFound = 1;
+ if (pDrcInstructionUniDrc->drcSetId < 0) /* virtual DRC sets are okay */
+ {
+ return DRCDEC_SELECTION_PROCESS_NO_ERROR;
+ }
+
if (pCoef == NULL) /* check for parametricDRC */
{
- *pMatchFound = 1;
+ *pMatchFound = 0; /* parametricDRC not supported */
+ return DRCDEC_SELECTION_PROCESS_NO_ERROR;
+ }
+
+ if (pCoef->drcLocation !=
+ pDrcInstructionUniDrc
+ ->drcLocation) /* drcLocation must be LOCATION_SELECTED */
+ {
+ *pMatchFound = 0;
return DRCDEC_SELECTION_PROCESS_NO_ERROR;
}
@@ -974,10 +986,14 @@ static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement5(
int indexDrcCoeff = pDrcInstructionUniDrc->gainSetIndexForChannelGroup[i];
int bandCount = 0;
+ if (indexDrcCoeff >= 12) {
+ *pMatchFound = 0;
+ return DRCDEC_SELECTION_PROCESS_NO_ERROR;
+ }
+
if (indexDrcCoeff > pCoef->gainSetCount - 1) /* check for parametricDRC */
{
- *pMatchFound = 1;
- return DRCDEC_SELECTION_PROCESS_NO_ERROR;
+ continue;
}
GAIN_SET* gainSet = &(pCoef->gainSet[indexDrcCoeff]);
@@ -986,6 +1002,14 @@ static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement5(
if (bandCount > 4) {
*pMatchFound = 0;
}
+
+ for (b = 0; b < bandCount; b++) {
+ if ((gainSet->gainSequenceIndex[b] >= 12) ||
+ (gainSet->gainSequenceIndex[b] >= pCoef->gainSequenceCount)) {
+ *pMatchFound = 0;
+ return DRCDEC_SELECTION_PROCESS_NO_ERROR;
+ }
+ }
}
return DRCDEC_SELECTION_PROCESS_NO_ERROR;
@@ -1078,6 +1102,19 @@ static int _targetLoudnessInRange(
return retVal;
}
+static int _drcSetIsUsable(HANDLE_UNI_DRC_CONFIG hUniDrcConfig,
+ DRC_INSTRUCTIONS_UNI_DRC* pInst) {
+ int usable = 0;
+ DRC_COEFFICIENTS_UNI_DRC* pCoef =
+ selectDrcCoefficients(hUniDrcConfig, LOCATION_SELECTED);
+
+ /* check if ID is unique */
+ if (selectDrcInstructions(hUniDrcConfig, pInst->drcSetId) != pInst) return 0;
+ /* sanity check on drcInstructions */
+ _preSelectionRequirement5(pInst, pCoef, &usable);
+ return usable;
+}
+
/* #8: The range of the target loudness specified for a DRC set has to include
* the requested decoder target loudness. */
static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement8(
@@ -1097,9 +1134,8 @@ static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement8(
FIXP_DBL loudnessDeviationMax =
((FIXP_DBL)hSelProcInput->loudnessDeviationMax) << (DFRACT_BITS - 1 - 7);
- ;
- if (hSelProcInput->loudnessNormalizationOn) {
+ {
retVal = _getLoudness(hLoudnessInfoSet, hSelProcInput->albumMode,
hSelProcInput->loudnessMeasurementMethod,
hSelProcInput->loudnessMeasurementSystem,
@@ -1108,9 +1144,10 @@ static DRCDEC_SELECTION_PROCESS_RETURN _preSelectionRequirement8(
hSelProcInput->downmixIdRequested[downmixIdIndex],
&loudnessNormalizationGainDb, &loudness);
if (retVal) return (retVal);
- } else {
+ }
+
+ if (!hSelProcInput->loudnessNormalizationOn) {
loudnessNormalizationGainDb = (FIXP_DBL)0;
- loudness = UNDEFINED_LOUDNESS_VALUE;
}
retVal = _getSignalPeakLevel(
@@ -2031,6 +2068,7 @@ static DRCDEC_SELECTION_PROCESS_RETURN _generateOutputInfo(
pSelectionData->loudnessNormalizationGainDbAdjusted +
hSelProcInput->loudnessNormalizationGainModificationDb;
hSelProcOutput->outputPeakLevelDb = pSelectionData->outputPeakLevel;
+ hSelProcOutput->outputLoudness = pSelectionData->outputLoudness;
hSelProcOutput->boost = boost;
hSelProcOutput->compress = compress;
@@ -2051,8 +2089,11 @@ static DRCDEC_SELECTION_PROCESS_RETURN _generateOutputInfo(
int dependsOnDrcSetID = pSelectionData->pInst->dependsOnDrcSet;
for (i = 0; i < hUniDrcConfig->drcInstructionsCountInclVirtual; i++) {
- if (hUniDrcConfig->drcInstructionsUniDrc[i].drcSetId ==
- dependsOnDrcSetID) {
+ DRC_INSTRUCTIONS_UNI_DRC* pInst =
+ &(hUniDrcConfig->drcInstructionsUniDrc[i]);
+ if (!_drcSetIsUsable(hUniDrcConfig, pInst)) continue;
+
+ if (pInst->drcSetId == dependsOnDrcSetID) {
hSelProcOutput->selectedDrcSetIds[hSelProcOutput->numSelectedDrcSets] =
hUniDrcConfig->drcInstructionsUniDrc[i].drcSetId;
hSelProcOutput->selectedDownmixIds[hSelProcOutput->numSelectedDrcSets] =
@@ -2071,6 +2112,7 @@ static DRCDEC_SELECTION_PROCESS_RETURN _generateOutputInfo(
for (i = 0; i < hUniDrcConfig->drcInstructionsUniDrcCount; i++) {
DRC_INSTRUCTIONS_UNI_DRC* pInst =
&(hUniDrcConfig->drcInstructionsUniDrc[i]);
+ if (!_drcSetIsUsable(hUniDrcConfig, pInst)) continue;
if (pInst->drcSetEffect & EB_FADE) {
if (pInst->downmixId[0] == DOWNMIX_ID_ANY_DOWNMIX) {
@@ -2098,6 +2140,7 @@ static DRCDEC_SELECTION_PROCESS_RETURN _generateOutputInfo(
for (i = 0; i < hUniDrcConfig->drcInstructionsUniDrcCount; i++) {
DRC_INSTRUCTIONS_UNI_DRC* pInst =
&(hUniDrcConfig->drcInstructionsUniDrc[i]);
+ if (!_drcSetIsUsable(hUniDrcConfig, pInst)) continue;
if (pInst->drcSetEffect & (EB_DUCK_OTHER | EB_DUCK_SELF)) {
for (j = 0; j < pInst->downmixIdCount; j++) {
@@ -2124,6 +2167,7 @@ static DRCDEC_SELECTION_PROCESS_RETURN _generateOutputInfo(
for (i = 0; i < hUniDrcConfig->drcInstructionsUniDrcCount; i++) {
DRC_INSTRUCTIONS_UNI_DRC* pInst =
&(hUniDrcConfig->drcInstructionsUniDrc[i]);
+ if (!_drcSetIsUsable(hUniDrcConfig, pInst)) continue;
if (pInst->drcSetEffect & (EB_DUCK_OTHER | EB_DUCK_SELF)) {
for (j = 0; j < pInst->downmixIdCount; j++) {
@@ -2231,6 +2275,11 @@ static DRCDEC_SELECTION_PROCESS_RETURN _drcSetPreSelection(
for (j = 0; j < hUniDrcConfig->drcInstructionsCountInclVirtual; j++) {
DRC_INSTRUCTIONS_UNI_DRC* pDrcInstruction =
&(hUniDrcConfig->drcInstructionsUniDrc[j]);
+ /* check if ID is unique */
+ if (selectDrcInstructions(hUniDrcConfig, pDrcInstruction->drcSetId) !=
+ pDrcInstruction)
+ continue;
+
retVal = _drcSetPreSelectionSingleInstruction(
hSelProcInput, i, hUniDrcConfig, hLoudnessInfoSet, pDrcInstruction,
*ppCandidatesPotential, *ppCandidatesSelected, codecMode);