aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-01-24 04:13:28 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-01-24 04:13:28 +0000
commit5d864894785ccf240717f78aa35e8a2b9371b62f (patch)
treee4bd2c8d1c13085e3c2babcfeb39ea867a3f596e
parent3a6eca5c661f7e7596c39aa9e4a5c6763bbef035 (diff)
parentf04a8a855cf8ddb5996c8e191fd3fa15b3808657 (diff)
downloadfdk-aac-5d864894785ccf240717f78aa35e8a2b9371b62f.tar.gz
fdk-aac-5d864894785ccf240717f78aa35e8a2b9371b62f.tar.bz2
fdk-aac-5d864894785ccf240717f78aa35e8a2b9371b62f.zip
Snap for 6157842 from f04a8a855cf8ddb5996c8e191fd3fa15b3808657 to rvc-release
Change-Id: Icd800c3d313c30fc67595fc70baaf69b12188cd7
-rw-r--r--libAACdec/src/aacdecoder.cpp39
-rw-r--r--libDRCdec/src/FDK_drcDecLib.cpp12
-rw-r--r--libDRCdec/src/drcDec_gainDecoder.cpp8
-rw-r--r--libDRCdec/src/drcDec_reader.cpp23
-rw-r--r--libDRCdec/src/drcDec_selectionProcess.cpp64
-rw-r--r--libDRCdec/src/drcDec_types.h3
-rw-r--r--libMpegTPDec/src/tpdec_adts.cpp48
-rw-r--r--libMpegTPDec/src/tpdec_lib.cpp5
8 files changed, 169 insertions, 33 deletions
diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp
index 6b5a86c..bd12d96 100644
--- a/libAACdec/src/aacdecoder.cpp
+++ b/libAACdec/src/aacdecoder.cpp
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android
-© Copyright 1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten
+© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -1848,6 +1848,12 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
self->streamInfo.extSamplingRate / self->downscaleFactor;
}
}
+ if ((asc->m_aot == AOT_AAC_LC) && (asc->m_sbrPresentFlag == 1) &&
+ (asc->m_extensionSamplingFrequency > (2 * asc->m_samplingFrequency))) {
+ return AAC_DEC_UNSUPPORTED_SAMPLINGRATE; /* Core decoder supports at most a
+ 1:2 upsampling for HE-AAC and
+ HE-AACv2 */
+ }
/* --------- vcb11 ------------ */
self->flags[streamIndex] |= (asc->m_vcb11Flag) ? AC_ER_VCB11 : 0;
@@ -2366,6 +2372,13 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
goto bail;
}
+ if (*configChanged) {
+ if (asc->m_aot == AOT_USAC) {
+ self->hDrcInfo->enable = 0;
+ self->hDrcInfo->progRefLevelPresent = 0;
+ }
+ }
+
if (asc->m_aot == AOT_USAC) {
pcmLimiter_SetAttack(self->hLimiter, (5));
pcmLimiter_SetThreshold(self->hLimiter, FL2FXCONST_DBL(0.89125094f));
@@ -3172,9 +3185,15 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->hDrcInfo, bs, self->pAacDecoderStaticChannelInfo,
pce->ElementInstanceTag, drcChMap, aacChannels);
if (mapped > 0) {
- /* If at least one DRC thread has been mapped to a channel threre was DRC
- * data in the bitstream. */
- self->flags[streamIndex] |= AC_DRC_PRESENT;
+ if (!(self->flags[streamIndex] & (AC_USAC | AC_RSV603DA))) {
+ /* If at least one DRC thread has been mapped to a channel there was DRC
+ * data in the bitstream. */
+ self->flags[streamIndex] |= AC_DRC_PRESENT;
+ } else {
+ self->hDrcInfo->enable = 0;
+ self->hDrcInfo->progRefLevelPresent = 0;
+ ErrorStatus = AAC_DEC_UNSUPPORTED_FORMAT;
+ }
}
/* Create a reverse mapping table */
@@ -3419,9 +3438,15 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
self->hDrcInfo, bs, self->pAacDecoderStaticChannelInfo,
pce->ElementInstanceTag, drcChMap, aacChannels);
if (mapped > 0) {
- /* If at least one DRC thread has been mapped to a channel threre was DRC
- * data in the bitstream. */
- self->flags[streamIndex] |= AC_DRC_PRESENT;
+ if (!(self->flags[streamIndex] & (AC_USAC | AC_RSV603DA))) {
+ /* If at least one DRC thread has been mapped to a channel there was DRC
+ * data in the bitstream. */
+ self->flags[streamIndex] |= AC_DRC_PRESENT;
+ } else {
+ self->hDrcInfo->enable = 0;
+ self->hDrcInfo->progRefLevelPresent = 0;
+ ErrorStatus = AAC_DEC_UNSUPPORTED_FORMAT;
+ }
}
}
diff --git a/libDRCdec/src/FDK_drcDecLib.cpp b/libDRCdec/src/FDK_drcDecLib.cpp
index 4f8ebc7..e43279f 100644
--- a/libDRCdec/src/FDK_drcDecLib.cpp
+++ b/libDRCdec/src/FDK_drcDecLib.cpp
@@ -145,6 +145,10 @@ struct s_drc_decoder {
SEL_PROC_OUTPUT selProcOutput;
} DRC_DECODER;
+static int _getGainStatus(HANDLE_UNI_DRC_GAIN hUniDrcGain) {
+ return hUniDrcGain->status;
+}
+
static int isResetNeeded(HANDLE_DRC_DECODER hDrcDec,
const SEL_PROC_OUTPUT oldSelProcOutput) {
int i, resetNeeded = 0;
@@ -729,7 +733,9 @@ FDK_drcDec_ReadUniDrcGain(HANDLE_DRC_DECODER hDrcDec,
&(hDrcDec->uniDrcGain));
if (dErr) return DRC_DEC_NOT_OK;
- hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD;
+ if (_getGainStatus(&(hDrcDec->uniDrcGain))) {
+ hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD;
+ }
return DRC_DEC_OK;
}
@@ -751,7 +757,9 @@ FDK_drcDec_ReadUniDrc(HANDLE_DRC_DECODER hDrcDec,
startSelectionProcess(hDrcDec);
if (dErr) return DRC_DEC_NOT_OK;
- hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD;
+ if (_getGainStatus(&(hDrcDec->uniDrcGain))) {
+ hDrcDec->status = DRC_DEC_NEW_GAIN_PAYLOAD;
+ }
return DRC_DEC_OK;
}
diff --git a/libDRCdec/src/drcDec_gainDecoder.cpp b/libDRCdec/src/drcDec_gainDecoder.cpp
index 9d91267..de54dde 100644
--- a/libDRCdec/src/drcDec_gainDecoder.cpp
+++ b/libDRCdec/src/drcDec_gainDecoder.cpp
@@ -297,9 +297,11 @@ drcDec_GainDecoder_Conceal(HANDLE_DRC_GAIN_DECODER hGainDec,
int seq, gainSequenceCount;
DRC_COEFFICIENTS_UNI_DRC* pCoef =
selectDrcCoefficients(hUniDrcConfig, LOCATION_SELECTED);
- if (pCoef == NULL) return DE_OK;
-
- gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
+ if (pCoef && pCoef->gainSequenceCount) {
+ gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
+ } else {
+ gainSequenceCount = 1;
+ }
for (seq = 0; seq < gainSequenceCount; seq++) {
int lastNodeIndex = 0;
diff --git a/libDRCdec/src/drcDec_reader.cpp b/libDRCdec/src/drcDec_reader.cpp
index 9e37246..367a352 100644
--- a/libDRCdec/src/drcDec_reader.cpp
+++ b/libDRCdec/src/drcDec_reader.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
@@ -199,11 +199,8 @@ drcDec_readUniDrc(HANDLE_FDK_BITSTREAM hBs, HANDLE_UNI_DRC_CONFIG hUniDrcConfig,
}
}
- if (hUniDrcGain != NULL) {
- err = drcDec_readUniDrcGain(hBs, hUniDrcConfig, frameSize, deltaTminDefault,
- hUniDrcGain);
- if (err) return err;
- }
+ err = drcDec_readUniDrcGain(hBs, hUniDrcConfig, frameSize, deltaTminDefault,
+ hUniDrcGain);
return err;
}
@@ -487,10 +484,13 @@ drcDec_readUniDrcGain(HANDLE_FDK_BITSTREAM hBs,
int seq, gainSequenceCount;
DRC_COEFFICIENTS_UNI_DRC* pCoef =
selectDrcCoefficients(hUniDrcConfig, LOCATION_SELECTED);
- if (pCoef == NULL) return DE_OK;
- if (hUniDrcGain == NULL) return DE_OK; /* hUniDrcGain not initialized yet */
-
- gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
+ if (hUniDrcGain == NULL) return DE_NOT_OK;
+ hUniDrcGain->status = 0;
+ if (pCoef) {
+ gainSequenceCount = fMin(pCoef->gainSequenceCount, (UCHAR)12);
+ } else {
+ gainSequenceCount = 0;
+ }
for (seq = 0; seq < gainSequenceCount; seq++) {
UCHAR index = pCoef->gainSetIndexForGainSequence[seq];
@@ -518,6 +518,9 @@ drcDec_readUniDrcGain(HANDLE_FDK_BITSTREAM hBs,
if (err) return err;
}
+ if (err == DE_OK && gainSequenceCount > 0) {
+ hUniDrcGain->status = 1;
+ }
return err;
}
diff --git a/libDRCdec/src/drcDec_selectionProcess.cpp b/libDRCdec/src/drcDec_selectionProcess.cpp
index c33bf74..d806ae9 100644
--- a/libDRCdec/src/drcDec_selectionProcess.cpp
+++ b/libDRCdec/src/drcDec_selectionProcess.cpp
@@ -956,17 +956,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 +988,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 +1004,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 +1104,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(
@@ -2051,8 +2090,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 +2113,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 +2141,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 +2168,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 +2276,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);
diff --git a/libDRCdec/src/drcDec_types.h b/libDRCdec/src/drcDec_types.h
index 6b99018..b0d89c1 100644
--- a/libDRCdec/src/drcDec_types.h
+++ b/libDRCdec/src/drcDec_types.h
@@ -130,6 +130,9 @@ typedef struct {
UCHAR uniDrcGainExtPresent;
UNI_DRC_GAIN_EXTENSION uniDrcGainExtension;
+
+ /* derived data */
+ UCHAR status;
} UNI_DRC_GAIN, *HANDLE_UNI_DRC_GAIN;
/****************/
diff --git a/libMpegTPDec/src/tpdec_adts.cpp b/libMpegTPDec/src/tpdec_adts.cpp
index 1a4e3fd..f936634 100644
--- a/libMpegTPDec/src/tpdec_adts.cpp
+++ b/libMpegTPDec/src/tpdec_adts.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 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -213,8 +213,8 @@ TRANSPORTDEC_ERROR adtsRead_DecodeHeader(HANDLE_ADTS pAdts,
goto bail;
}
+ FDKcrcReset(&pAdts->crcInfo);
if (!bs.protection_absent) {
- FDKcrcReset(&pAdts->crcInfo);
FDKpushBack(hBs, 56); /* complete fixed and variable header! */
crcReg = FDKcrcStartReg(&pAdts->crcInfo, hBs, 0);
FDKpushFor(hBs, 56);
@@ -314,15 +314,55 @@ TRANSPORTDEC_ERROR adtsRead_DecodeHeader(HANDLE_ADTS pAdts,
if (bs.channel_config == 0) {
int pceBits = 0;
UINT alignAnchor = FDKgetValidBits(hBs);
+ CProgramConfig tmpPce;
if (FDKreadBits(hBs, 3) == ID_PCE) {
/* Got luck! Parse the PCE */
crcReg = adtsRead_CrcStartReg(pAdts, hBs, 0);
- CProgramConfig_Read(&pAsc->m_progrConfigElement, hBs, alignAnchor);
+ CProgramConfig_Init(&tmpPce);
+ CProgramConfig_Read(&tmpPce, hBs, alignAnchor);
+
+ if (CProgramConfig_IsValid(&tmpPce)) {
+ if (CProgramConfig_IsValid(&oldPce)) {
+ /* Compare the new and the old PCE (tags ignored) */
+ switch (CProgramConfig_Compare(&tmpPce, &oldPce)) {
+ case 0: /* Nothing to do because PCE matches the old one exactly. */
+ case 1: /* Channel configuration not changed. Just new metadata. */
+ FDKmemcpy(&pAsc->m_progrConfigElement, &tmpPce,
+ sizeof(CProgramConfig));
+ break;
+ case 2: /* The number of channels are identical but not the config
+ */
+ case -1: /* The channel configuration is completely different */
+ default:
+ FDKmemcpy(&pAsc->m_progrConfigElement, &oldPce,
+ sizeof(CProgramConfig));
+ FDKpushBack(hBs, adtsHeaderLength);
+ return TRANSPORTDEC_PARSE_ERROR;
+ }
+ } else {
+ FDKmemcpy(&pAsc->m_progrConfigElement, &tmpPce,
+ sizeof(CProgramConfig));
+ }
+ } else {
+ if (CProgramConfig_IsValid(&oldPce)) {
+ FDKmemcpy(&pAsc->m_progrConfigElement, &oldPce,
+ sizeof(CProgramConfig));
+ } else {
+ FDKpushBack(hBs, adtsHeaderLength);
+ return TRANSPORTDEC_PARSE_ERROR;
+ }
+ }
adtsRead_CrcEndReg(pAdts, hBs, crcReg);
- pceBits = alignAnchor - FDKgetValidBits(hBs);
+ pceBits = (INT)alignAnchor - (INT)FDKgetValidBits(hBs);
+ adtsHeaderLength += pceBits;
+
+ if (pceBits > (INT)alignAnchor) {
+ goto bail;
+ }
+
/* store the number of PCE bits */
bs.num_pce_bits = pceBits;
} else {
diff --git a/libMpegTPDec/src/tpdec_lib.cpp b/libMpegTPDec/src/tpdec_lib.cpp
index 7bebbaa..ca35184 100644
--- a/libMpegTPDec/src/tpdec_lib.cpp
+++ b/libMpegTPDec/src/tpdec_lib.cpp
@@ -929,6 +929,11 @@ static TRANSPORTDEC_ERROR transportDec_readHeader(
}
}
}
+ /* if an error is detected terminate config parsing to avoid that an
+ * invalid config is accepted in the second pass */
+ if (err != TRANSPORTDEC_OK) {
+ break;
+ }
}
} else {
/* Reset CRC because the next bits are the beginning of a