aboutsummaryrefslogtreecommitdiffstats
path: root/fdk-aac/libAACdec/src/aacdecoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fdk-aac/libAACdec/src/aacdecoder.cpp')
-rw-r--r--fdk-aac/libAACdec/src/aacdecoder.cpp89
1 files changed, 60 insertions, 29 deletions
diff --git a/fdk-aac/libAACdec/src/aacdecoder.cpp b/fdk-aac/libAACdec/src/aacdecoder.cpp
index 7617937..965631b 100644
--- a/fdk-aac/libAACdec/src/aacdecoder.cpp
+++ b/fdk-aac/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
@@ -1225,6 +1225,8 @@ static void CStreamInfoInit(CStreamInfo *pStreamInfo) {
pStreamInfo->drcProgRefLev =
-1; /* set program reference level to not indicated */
pStreamInfo->drcPresMode = -1; /* default: presentation mode not indicated */
+
+ pStreamInfo->outputLoudness = -1; /* default: no loudness metadata present */
}
/*!
@@ -1279,6 +1281,7 @@ LINKSPEC_CPP HANDLE_AACDECODER CAacDecoder_Open(
/* Set default frame delay */
aacDecoder_drcSetParam(self->hDrcInfo, DRC_BS_DELAY,
CConcealment_GetDelay(&self->concealCommonData));
+ self->workBufferCore1 = (FIXP_DBL *)GetWorkBufferCore1();
self->workBufferCore2 = GetWorkBufferCore2();
if (self->workBufferCore2 == NULL) goto bail;
@@ -1303,7 +1306,8 @@ static void CAacDecoder_DeInit(HANDLE_AACDECODER self,
const int subStreamIndex) {
int ch;
int aacChannelOffset = 0, aacChannels = (8);
- int numElements = (((8)) + (8)), elementOffset = 0;
+ int numElements = (3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1),
+ elementOffset = 0;
if (self == NULL) return;
@@ -1453,6 +1457,10 @@ LINKSPEC_CPP void CAacDecoder_Close(HANDLE_AACDECODER self) {
FreeDrcInfo(&self->hDrcInfo);
}
+ if (self->workBufferCore1 != NULL) {
+ FreeWorkBufferCore1((CWorkBufferCore1 **)&self->workBufferCore1);
+ }
+
/* Free WorkBufferCore2 */
if (self->workBufferCore2 != NULL) {
FreeWorkBufferCore2(&self->workBufferCore2);
@@ -1490,6 +1498,8 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
UCHAR downscaleFactor = self->downscaleFactor;
UCHAR downscaleFactorInBS = self->downscaleFactorInBS;
+ self->aacOutDataHeadroom = (3);
+
// set profile and check for supported aot
// leave profile on default (=-1) for all other supported MPEG-4 aot's except
// aot=2 (=AAC-LC)
@@ -1847,6 +1857,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;
@@ -1928,6 +1944,9 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
self->samplingRateInfo[0].samplingRate / self->downscaleFactor;
self->streamInfo.aacSamplesPerFrame =
asc->m_samplesPerFrame / self->downscaleFactor;
+ if (self->streamInfo.aacSampleRate <= 0) {
+ return AAC_DEC_UNSUPPORTED_SAMPLINGRATE;
+ }
}
}
@@ -2362,6 +2381,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));
@@ -2375,7 +2401,7 @@ bail:
}
LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
- HANDLE_AACDECODER self, const UINT flags, FIXP_PCM *pTimeData,
+ HANDLE_AACDECODER self, const UINT flags, PCM_DEC *pTimeData,
const INT timeDataSize, const int timeDataChannelOffset) {
AAC_DECODER_ERROR ErrorStatus = AAC_DEC_OK;
@@ -3151,11 +3177,6 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
FDKmemcpy(drcChMap, self->chMapping, (8) * sizeof(UCHAR));
}
- /* Turn on/off DRC modules level normalization in digital domain depending
- * on the limiter status. */
- aacDecoder_drcSetParam(self->hDrcInfo, APPLY_NORMALIZATION,
- (self->limiterEnableCurr) ? 0 : 1);
-
/* 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(
@@ -3168,9 +3189,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 */
@@ -3300,9 +3327,11 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
&pAacDecoderStaticChannelInfo->drcData);
}
}
+
/* The DRC module demands to be called with the gain field holding the
* gain scale. */
- self->extGain[0] = (FIXP_DBL)TDL_GAIN_SCALING;
+ self->extGain[0] = (FIXP_DBL)AACDEC_DRC_GAIN_SCALING;
+
/* DRC processing */
aacDecoder_drcApply(
self->hDrcInfo, self->hSbrDecoder, pAacDecoderChannelInfo,
@@ -3318,7 +3347,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
if (self->flushStatus && (self->flushCnt > 0) &&
!(flags & AACDEC_CONCEAL)) {
FDKmemclear(pTimeData + offset,
- sizeof(FIXP_PCM) * self->streamInfo.aacSamplesPerFrame);
+ sizeof(PCM_DEC) * self->streamInfo.aacSamplesPerFrame);
} else
switch (pAacDecoderChannelInfo->renderMode) {
case AACDEC_RENDER_IMDCT:
@@ -3330,7 +3359,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
!frameOk_butConceal),
pAacDecoderChannelInfo->pComStaticData->pWorkBufferCore1
->mdctOutTemp,
- self->elFlags[el], elCh);
+ self->aacOutDataHeadroom, self->elFlags[el], elCh);
self->extGainDelay = self->streamInfo.aacSamplesPerFrame;
break;
@@ -3351,7 +3380,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
&self->samplingRateInfo[streamIndex],
(self->frameOK && !(flags & AACDEC_CONCEAL) &&
!frameOk_butConceal),
- flags, self->flags[streamIndex]);
+ self->aacOutDataHeadroom, flags, self->flags[streamIndex]);
self->extGainDelay = self->streamInfo.aacSamplesPerFrame;
break;
@@ -3363,7 +3392,8 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
if (!CConceal_TDFading_Applied[c]) {
CConceal_TDFading_Applied[c] = CConcealment_TDFading(
self->streamInfo.aacSamplesPerFrame,
- &self->pAacDecoderStaticChannelInfo[c], pTimeData + offset, 0);
+ &self->pAacDecoderStaticChannelInfo[c], self->aacOutDataHeadroom,
+ pTimeData + offset, 0);
if (c + 1 < (8) && c < aacChannels - 1) {
/* update next TDNoise Seed to avoid muting in case of Parametric
* Stereo */
@@ -3385,22 +3415,17 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
if ((aacChannels == 2) && bsPseudoLr) {
int i, offset2;
const FIXP_SGL invSqrt2 = FL2FXCONST_SGL(0.707106781186547f);
- FIXP_PCM *pTD = pTimeData;
+ PCM_DEC *pTD = pTimeData;
offset2 = timeDataChannelOffset;
for (i = 0; i < self->streamInfo.aacSamplesPerFrame; i++) {
- FIXP_DBL L = FX_PCM2FX_DBL(pTD[0]);
- FIXP_DBL R = FX_PCM2FX_DBL(pTD[offset2]);
+ FIXP_DBL L = PCM_DEC2FIXP_DBL(pTD[0]);
+ FIXP_DBL R = PCM_DEC2FIXP_DBL(pTD[offset2]);
L = fMult(L, invSqrt2);
R = fMult(R, invSqrt2);
-#if (SAMPLE_BITS == 16)
- pTD[0] = FX_DBL2FX_PCM(fAddSaturate(L + R, (FIXP_DBL)0x8000));
- pTD[offset2] = FX_DBL2FX_PCM(fAddSaturate(L - R, (FIXP_DBL)0x8000));
-#else
- pTD[0] = FX_DBL2FX_PCM(L + R);
- pTD[offset2] = FX_DBL2FX_PCM(L - R);
-#endif
+ pTD[0] = L + R;
+ pTD[offset2] = L - R;
pTD++;
}
}
@@ -3411,9 +3436,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;
+ }
}
}