aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fuzzer/aac_dec_fuzzer.cpp3
-rw-r--r--libAACdec/src/aacdec_drc.cpp15
-rw-r--r--libAACdec/src/aacdec_drc.h4
-rw-r--r--libAACdec/src/aacdec_hcrs.cpp4
-rw-r--r--libAACdec/src/aacdecoder.cpp160
-rw-r--r--libAACdec/src/aacdecoder_lib.cpp28
-rw-r--r--libAACenc/src/aacenc_lib.cpp4
-rw-r--r--libFDK/src/FDK_hybrid.cpp26
-rw-r--r--libFDK/src/dct.cpp28
-rw-r--r--libMpegTPDec/include/tp_data.h4
-rw-r--r--libMpegTPDec/src/tpdec_asc.cpp191
-rw-r--r--libMpegTPEnc/include/tp_data.h4
-rw-r--r--libMpegTPEnc/src/tpenc_asc.cpp6
-rw-r--r--libSACdec/include/sac_dec_lib.h6
-rw-r--r--libSACdec/src/sac_dec.cpp75
-rw-r--r--libSACdec/src/sac_dec_lib.cpp21
-rw-r--r--libSACdec/src/sac_stp.cpp8
-rw-r--r--libSBRdec/src/env_calc.cpp19
-rw-r--r--libSBRdec/src/sbrdec_drc.cpp53
19 files changed, 474 insertions, 185 deletions
diff --git a/fuzzer/aac_dec_fuzzer.cpp b/fuzzer/aac_dec_fuzzer.cpp
index b5545fc..c970197 100644
--- a/fuzzer/aac_dec_fuzzer.cpp
+++ b/fuzzer/aac_dec_fuzzer.cpp
@@ -118,7 +118,8 @@ void Codec::decodeFrames(UCHAR *data, UINT size) {
INT_PCM outputBuf[kMaxOutBufferSize];
do {
mErrorCode =
- aacDecoder_DecodeFrame(mAacDecoderHandle, outputBuf, sizeof(outputBuf), 0);
+ aacDecoder_DecodeFrame(mAacDecoderHandle, outputBuf,
+ kMaxOutBufferSize /*size in number of INT_PCM, not bytes*/, 0);
} while (mErrorCode == AAC_DEC_OK);
UINT offset = inputSize - valid;
data += offset;
diff --git a/libAACdec/src/aacdec_drc.cpp b/libAACdec/src/aacdec_drc.cpp
index b6f5b49..760a9ba 100644
--- a/libAACdec/src/aacdec_drc.cpp
+++ b/libAACdec/src/aacdec_drc.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
@@ -150,6 +150,19 @@ static INT convert_drcParam(FIXP_DBL param_dbl) {
}
/*!
+\brief Disable DRC
+
+\self Handle of DRC info
+
+\return none
+*/
+void aacDecoder_drcDisable(HANDLE_AAC_DRC self) {
+ self->enable = 0;
+ self->applyExtGain = 0;
+ self->progRefLevelPresent = 0;
+}
+
+/*!
\brief Reset DRC information
\self Handle of DRC info
diff --git a/libAACdec/src/aacdec_drc.h b/libAACdec/src/aacdec_drc.h
index 76a44d6..2bb945d 100644
--- a/libAACdec/src/aacdec_drc.h
+++ b/libAACdec/src/aacdec_drc.h
@@ -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
@@ -140,6 +140,8 @@ typedef enum {
/**
* \brief DRC module interface functions
*/
+void aacDecoder_drcDisable(HANDLE_AAC_DRC self);
+
void aacDecoder_drcReset(HANDLE_AAC_DRC self);
void aacDecoder_drcInit(HANDLE_AAC_DRC self);
diff --git a/libAACdec/src/aacdec_hcrs.cpp b/libAACdec/src/aacdec_hcrs.cpp
index 44b32a5..5e3f9ac 100644
--- a/libAACdec/src/aacdec_hcrs.cpp
+++ b/libAACdec/src/aacdec_hcrs.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
@@ -173,7 +173,9 @@ void DecodeNonPCWs(HANDLE_FDK_BITSTREAM bs, H_HCR_INFO pHcr) {
pHcr->segmentInfo.readDirection = FROM_RIGHT_TO_LEFT;
/* Process sets subsequently */
+ numSet = fMin(numSet, (UCHAR)MAX_HCR_SETS);
for (currentSet = 1; currentSet < numSet; currentSet++) {
+
/* step 1 */
numCodeword -=
*pNumSegment; /* number of remaining non PCWs [for all sets] */
diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp
index 965631b..c6d1832 100644
--- a/libAACdec/src/aacdecoder.cpp
+++ b/libAACdec/src/aacdecoder.cpp
@@ -1397,6 +1397,31 @@ static void CAacDecoder_DeInit(HANDLE_AACDECODER self,
}
/*!
+ * \brief CAacDecoder_AcceptFlags Accept flags and element flags
+ *
+ * \param self [o] handle to AACDECODER structure
+ * \param asc [i] handle to ASC structure
+ * \param flags [i] flags
+ * \param elFlags [i] pointer to element flags
+ * \param streamIndex [i] stream index
+ * \param elementOffset [i] element offset
+ *
+ * \return void
+ */
+static void CAacDecoder_AcceptFlags(HANDLE_AACDECODER self,
+ const CSAudioSpecificConfig *asc,
+ UINT flags, UINT *elFlags, int streamIndex,
+ int elementOffset) {
+ {
+ FDKmemcpy(
+ self->elFlags, elFlags,
+ sizeof(*elFlags) * (3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1));
+ }
+
+ self->flags[streamIndex] = flags;
+}
+
+/*!
* \brief CAacDecoder_CtrlCFGChange Set config change parameters.
*
* \param self [i] handle to AACDECODER structure
@@ -1493,6 +1518,9 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
const int streamIndex = 0;
INT flushChannels = 0;
+ UINT flags;
+ UINT elFlags[(3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)];
+
if (!self) return AAC_DEC_INVALID_HANDLE;
UCHAR downscaleFactor = self->downscaleFactor;
@@ -1649,8 +1677,8 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
}
/* Set syntax flags */
- self->flags[streamIndex] = 0;
- { FDKmemclear(self->elFlags, sizeof(self->elFlags)); }
+ flags = 0;
+ { FDKmemclear(elFlags, sizeof(elFlags)); }
if ((asc->m_channelConfiguration > 0) || IS_USAC(asc->m_aot)) {
if (IS_USAC(asc->m_aot)) {
@@ -1700,31 +1728,30 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
}
}
- self->elFlags[el] |=
- (asc->m_sc.m_usacConfig.element[_el].m_noiseFilling)
- ? AC_EL_USAC_NOISE
- : 0;
- self->elFlags[el] |=
+ elFlags[el] |= (asc->m_sc.m_usacConfig.element[_el].m_noiseFilling)
+ ? AC_EL_USAC_NOISE
+ : 0;
+ elFlags[el] |=
(asc->m_sc.m_usacConfig.element[_el].m_stereoConfigIndex > 0)
? AC_EL_USAC_MPS212
: 0;
- self->elFlags[el] |= (asc->m_sc.m_usacConfig.element[_el].m_interTes)
- ? AC_EL_USAC_ITES
- : 0;
- self->elFlags[el] |=
+ elFlags[el] |= (asc->m_sc.m_usacConfig.element[_el].m_interTes)
+ ? AC_EL_USAC_ITES
+ : 0;
+ elFlags[el] |=
(asc->m_sc.m_usacConfig.element[_el].m_pvc) ? AC_EL_USAC_PVC : 0;
- self->elFlags[el] |=
+ elFlags[el] |=
(asc->m_sc.m_usacConfig.element[_el].usacElementType == ID_USAC_LFE)
? AC_EL_USAC_LFE
: 0;
- self->elFlags[el] |=
+ elFlags[el] |=
(asc->m_sc.m_usacConfig.element[_el].usacElementType == ID_USAC_LFE)
? AC_EL_LFE
: 0;
if ((asc->m_sc.m_usacConfig.element[_el].usacElementType ==
ID_USAC_CPE) &&
((self->usacStereoConfigIndex[el] == 0))) {
- self->elFlags[el] |= AC_EL_USAC_CP_POSSIBLE;
+ elFlags[el] |= AC_EL_USAC_CP_POSSIBLE;
}
}
@@ -1791,9 +1818,17 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
downscaleFactorInBS =
asc->m_samplingFrequency /
asc->m_sc.m_eldSpecificConfig.m_downscaledSamplingFrequency;
- if (downscaleFactorInBS == 1 || downscaleFactorInBS == 2 ||
- downscaleFactorInBS == 3 || downscaleFactorInBS == 4) {
+ if ((downscaleFactorInBS == 1 || downscaleFactorInBS == 2 ||
+ (downscaleFactorInBS == 3 &&
+ asc->m_sc.m_eldSpecificConfig.m_frameLengthFlag) ||
+ downscaleFactorInBS == 4) &&
+ ((asc->m_samplingFrequency %
+ asc->m_sc.m_eldSpecificConfig.m_downscaledSamplingFrequency) ==
+ 0)) {
downscaleFactor = downscaleFactorInBS;
+ } else {
+ downscaleFactorInBS = 1;
+ downscaleFactor = 1;
}
}
} else {
@@ -1838,8 +1873,8 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
if (configMode & AC_CM_ALLOC_MEM) {
self->streamInfo.extSamplingRate = asc->m_extensionSamplingFrequency;
}
- self->flags[streamIndex] |= (asc->m_sbrPresentFlag) ? AC_SBR_PRESENT : 0;
- self->flags[streamIndex] |= (asc->m_psPresentFlag) ? AC_PS_PRESENT : 0;
+ flags |= (asc->m_sbrPresentFlag) ? AC_SBR_PRESENT : 0;
+ flags |= (asc->m_psPresentFlag) ? AC_PS_PRESENT : 0;
if (asc->m_sbrPresentFlag) {
self->sbrEnabled = 1;
self->sbrEnabledPrev = 1;
@@ -1865,51 +1900,47 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
}
/* --------- vcb11 ------------ */
- self->flags[streamIndex] |= (asc->m_vcb11Flag) ? AC_ER_VCB11 : 0;
+ flags |= (asc->m_vcb11Flag) ? AC_ER_VCB11 : 0;
/* ---------- rvlc ------------ */
- self->flags[streamIndex] |= (asc->m_rvlcFlag) ? AC_ER_RVLC : 0;
+ flags |= (asc->m_rvlcFlag) ? AC_ER_RVLC : 0;
/* ----------- hcr ------------ */
- self->flags[streamIndex] |= (asc->m_hcrFlag) ? AC_ER_HCR : 0;
+ flags |= (asc->m_hcrFlag) ? AC_ER_HCR : 0;
if (asc->m_aot == AOT_ER_AAC_ELD) {
self->mpsEnableCurr = 0;
- self->flags[streamIndex] |= AC_ELD;
- self->flags[streamIndex] |=
- (asc->m_sbrPresentFlag)
- ? AC_SBR_PRESENT
- : 0; /* Need to set the SBR flag for backward-compatibility
- reasons. Even if SBR is not supported. */
- self->flags[streamIndex] |=
- (asc->m_sc.m_eldSpecificConfig.m_sbrCrcFlag) ? AC_SBRCRC : 0;
- self->flags[streamIndex] |=
- (asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign) ? AC_MPS_PRESENT
- : 0;
+ flags |= AC_ELD;
+ flags |= (asc->m_sbrPresentFlag)
+ ? AC_SBR_PRESENT
+ : 0; /* Need to set the SBR flag for backward-compatibility
+ reasons. Even if SBR is not supported. */
+ flags |= (asc->m_sc.m_eldSpecificConfig.m_sbrCrcFlag) ? AC_SBRCRC : 0;
+ flags |= (asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign)
+ ? AC_MPS_PRESENT
+ : 0;
if (self->mpsApplicable) {
self->mpsEnableCurr = asc->m_sc.m_eldSpecificConfig.m_useLdQmfTimeAlign;
}
}
- self->flags[streamIndex] |= (asc->m_aot == AOT_ER_AAC_LD) ? AC_LD : 0;
- self->flags[streamIndex] |= (asc->m_epConfig >= 0) ? AC_ER : 0;
+ flags |= (asc->m_aot == AOT_ER_AAC_LD) ? AC_LD : 0;
+ flags |= (asc->m_epConfig >= 0) ? AC_ER : 0;
if (asc->m_aot == AOT_USAC) {
- self->flags[streamIndex] |= AC_USAC;
- self->flags[streamIndex] |=
- (asc->m_sc.m_usacConfig.element[0].m_stereoConfigIndex > 0)
- ? AC_MPS_PRESENT
- : 0;
+ flags |= AC_USAC;
+ flags |= (asc->m_sc.m_usacConfig.element[0].m_stereoConfigIndex > 0)
+ ? AC_MPS_PRESENT
+ : 0;
}
if (asc->m_aot == AOT_DRM_AAC) {
- self->flags[streamIndex] |= AC_DRM | AC_SBRCRC | AC_SCALABLE;
+ flags |= AC_DRM | AC_SBRCRC | AC_SCALABLE;
}
if (asc->m_aot == AOT_DRM_SURROUND) {
- self->flags[streamIndex] |=
- AC_DRM | AC_SBRCRC | AC_SCALABLE | AC_MPS_PRESENT;
+ flags |= AC_DRM | AC_SBRCRC | AC_SCALABLE | AC_MPS_PRESENT;
FDK_ASSERT(!asc->m_psPresentFlag);
}
if ((asc->m_aot == AOT_AAC_SCAL) || (asc->m_aot == AOT_ER_AAC_SCAL)) {
- self->flags[streamIndex] |= AC_SCALABLE;
+ flags |= AC_SCALABLE;
}
if ((asc->m_epConfig >= 0) && (asc->m_channelConfiguration <= 0)) {
@@ -1960,6 +1991,10 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
if (ascChanged != 0) {
*configChanged = 1;
}
+
+ CAacDecoder_AcceptFlags(self, asc, flags, elFlags, streamIndex,
+ elementOffset);
+
return err;
}
@@ -1988,7 +2023,7 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
}
if (usacStereoConfigIndex == 3) {
- self->flags[streamIndex] |= AC_USAC_SCFGI3;
+ flags |= AC_USAC_SCFGI3;
}
}
break;
@@ -2069,14 +2104,14 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
ch = aacChannelsOffset;
int _numElements;
_numElements = (((8)) + (8));
- if (self->flags[streamIndex] & (AC_RSV603DA | AC_USAC)) {
+ if (flags & (AC_RSV603DA | AC_USAC)) {
_numElements = (int)asc->m_sc.m_usacConfig.m_usacNumElements;
}
for (int _el = 0; _el < _numElements; _el++) {
int el_channels = 0;
int el = elementOffset + _el;
- if (self->flags[streamIndex] &
+ if (flags &
(AC_ER | AC_LD | AC_ELD | AC_RSV603DA | AC_USAC | AC_RSVD50)) {
if (ch >= ascChannels) {
break;
@@ -2176,15 +2211,14 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
if (self->pAacDecoderStaticChannelInfo[ch]->pOverlapBuffer == NULL) {
goto bail;
}
- if (self->flags[streamIndex] &
- (AC_USAC | AC_RSVD50 | AC_RSV603DA /*|AC_BSAC*/)) {
+ if (flags & (AC_USAC | AC_RSVD50 | AC_RSV603DA /*|AC_BSAC*/)) {
self->pAacDecoderStaticChannelInfo[ch]->hArCo = CArco_Create();
if (self->pAacDecoderStaticChannelInfo[ch]->hArCo == NULL) {
goto bail;
}
}
- if (!(self->flags[streamIndex] & (AC_USAC | AC_RSV603DA))) {
+ if (!(flags & (AC_USAC | AC_RSV603DA))) {
CPns_UpdateNoiseState(
&self->pAacDecoderChannelInfo[ch]->data.aac.PnsData,
&self->pAacDecoderStaticChannelInfo[ch]->pnsCurrentSeed,
@@ -2195,7 +2229,7 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
chIdx++;
}
- if (self->flags[streamIndex] & AC_USAC) {
+ if (flags & AC_USAC) {
for (int _ch = 0; _ch < flushChannels; _ch++) {
ch = aacChannelsOffset + _ch;
if (self->pTimeDataFlush[ch] == NULL) {
@@ -2207,7 +2241,7 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
}
}
- if (self->flags[streamIndex] & (AC_USAC | AC_RSV603DA)) {
+ if (flags & (AC_USAC | AC_RSV603DA)) {
int complexStereoPredPossible = 0;
ch = aacChannelsOffset;
chIdx = aacChannelsOffsetIdx;
@@ -2223,7 +2257,7 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
elCh = 1;
}
- if (self->elFlags[el2] & AC_EL_USAC_CP_POSSIBLE) {
+ if (elFlags[el2] & AC_EL_USAC_CP_POSSIBLE) {
complexStereoPredPossible = 1;
if (self->cpeStaticData[el2] == NULL) {
self->cpeStaticData[el2] = GetCpePersistentData();
@@ -2360,9 +2394,6 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
}
}
- /* Update externally visible copy of flags */
- self->streamInfo.flags = self->flags[0];
-
if (*configChanged) {
int drcDecSampleRate, drcDecFrameSize;
@@ -2383,8 +2414,7 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
if (*configChanged) {
if (asc->m_aot == AOT_USAC) {
- self->hDrcInfo->enable = 0;
- self->hDrcInfo->progRefLevelPresent = 0;
+ aacDecoder_drcDisable(self->hDrcInfo);
}
}
@@ -2393,6 +2423,12 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc,
pcmLimiter_SetThreshold(self->hLimiter, FL2FXCONST_DBL(0.89125094f));
}
+ CAacDecoder_AcceptFlags(self, asc, flags, elFlags, streamIndex,
+ elementOffset);
+
+ /* Update externally visible copy of flags */
+ self->streamInfo.flags = self->flags[0];
+
return err;
bail:
@@ -3194,11 +3230,12 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
* data in the bitstream. */
self->flags[streamIndex] |= AC_DRC_PRESENT;
} else {
- self->hDrcInfo->enable = 0;
- self->hDrcInfo->progRefLevelPresent = 0;
ErrorStatus = AAC_DEC_UNSUPPORTED_FORMAT;
}
}
+ if (self->flags[streamIndex] & (AC_USAC | AC_RSV603DA)) {
+ aacDecoder_drcDisable(self->hDrcInfo);
+ }
/* Create a reverse mapping table */
UCHAR Reverse_chMapping[((8) * 2)];
@@ -3441,11 +3478,12 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame(
* data in the bitstream. */
self->flags[streamIndex] |= AC_DRC_PRESENT;
} else {
- self->hDrcInfo->enable = 0;
- self->hDrcInfo->progRefLevelPresent = 0;
ErrorStatus = AAC_DEC_UNSUPPORTED_FORMAT;
}
}
+ if (self->flags[streamIndex] & (AC_USAC | AC_RSV603DA)) {
+ aacDecoder_drcDisable(self->hDrcInfo);
+ }
}
/* Add additional concealment delay */
diff --git a/libAACdec/src/aacdecoder_lib.cpp b/libAACdec/src/aacdecoder_lib.cpp
index 0f281eb..6fb7bf1 100644
--- a/libAACdec/src/aacdecoder_lib.cpp
+++ b/libAACdec/src/aacdecoder_lib.cpp
@@ -385,21 +385,19 @@ static INT aacDecoder_SbrCallback(
return errTp;
}
-static INT aacDecoder_SscCallback(void *handle, HANDLE_FDK_BITSTREAM hBs,
- const AUDIO_OBJECT_TYPE coreCodec,
- const INT samplingRate, const INT frameSize,
- const INT stereoConfigIndex,
- const INT coreSbrFrameLengthIndex,
- const INT configBytes, const UCHAR configMode,
- UCHAR *configChanged) {
+static INT aacDecoder_SscCallback(
+ void *handle, HANDLE_FDK_BITSTREAM hBs, const AUDIO_OBJECT_TYPE coreCodec,
+ const INT samplingRate, const INT frameSize, const INT numChannels,
+ const INT stereoConfigIndex, const INT coreSbrFrameLengthIndex,
+ const INT configBytes, const UCHAR configMode, UCHAR *configChanged) {
SACDEC_ERROR err;
TRANSPORTDEC_ERROR errTp;
HANDLE_AACDECODER hAacDecoder = (HANDLE_AACDECODER)handle;
err = mpegSurroundDecoder_Config(
(CMpegSurroundDecoder *)hAacDecoder->pMpegSurroundDecoder, hBs, coreCodec,
- samplingRate, frameSize, stereoConfigIndex, coreSbrFrameLengthIndex,
- configBytes, configMode, configChanged);
+ samplingRate, frameSize, numChannels, stereoConfigIndex,
+ coreSbrFrameLengthIndex, configBytes, configMode, configChanged);
switch (err) {
case MPS_UNSUPPORTED_CONFIG:
@@ -822,6 +820,9 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_SetParam(
case AAC_DRC_ATTENUATION_FACTOR:
/* DRC compression factor (where 0 is no and 127 is max compression) */
+ if ((value < 0) || (value > 127)) {
+ return AAC_DEC_SET_PARAM_FAIL;
+ }
errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_CUT_SCALE, value);
uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_COMPRESS,
value * (FL2FXCONST_DBL(0.5f / 127.0f)));
@@ -829,6 +830,9 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_SetParam(
case AAC_DRC_BOOST_FACTOR:
/* DRC boost factor (where 0 is no and 127 is max boost) */
+ if ((value < 0) || (value > 127)) {
+ return AAC_DEC_SET_PARAM_FAIL;
+ }
errorStatus = aacDecoder_drcSetParam(hDrcInfo, DRC_BOOST_SCALE, value);
uniDrcErr = FDK_drcDec_SetParam(self->hUniDrcDecoder, DRC_DEC_BOOST,
value * (FL2FXCONST_DBL(0.5f / 127.0f)));
@@ -1173,8 +1177,10 @@ LINKSPEC_CPP AAC_DECODER_ERROR aacDecoder_DecodeFrame(HANDLE_AACDECODER self,
aacDecoder_FreeMemCallback(self, &asc);
self->streamInfo.numChannels = 0;
/* 3) restore AudioSpecificConfig */
- transportDec_OutOfBandConfig(self->hInput, asc.config,
- (asc.configBits + 7) >> 3, 0);
+ if (asc.configBits <= (TP_USAC_MAX_CONFIG_LEN << 3)) {
+ transportDec_OutOfBandConfig(self->hInput, asc.config,
+ (asc.configBits + 7) >> 3, 0);
+ }
}
}
diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp
index 0ae329b..8a0819e 100644
--- a/libAACenc/src/aacenc_lib.cpp
+++ b/libAACenc/src/aacenc_lib.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
@@ -1242,7 +1242,7 @@ static INT aacenc_SbrCallback(void *self, HANDLE_FDK_BITSTREAM hBs,
INT aacenc_SscCallback(void *self, HANDLE_FDK_BITSTREAM hBs,
const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize,
- const INT stereoConfigIndex,
+ const INT numChannels, const INT stereoConfigIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes,
const UCHAR configMode, UCHAR *configChanged) {
HANDLE_AACENCODER hAacEncoder = (HANDLE_AACENCODER)self;
diff --git a/libFDK/src/FDK_hybrid.cpp b/libFDK/src/FDK_hybrid.cpp
index 08d32a8..d208abd 100644
--- a/libFDK/src/FDK_hybrid.cpp
+++ b/libFDK/src/FDK_hybrid.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
@@ -539,11 +539,11 @@ static void dualChannelFiltering(const FIXP_DBL *const pQmfReal,
i6 = pQmfImag[pReadIdx[6]] >> 2;
FDK_ASSERT((invert == 0) || (invert == 1));
- mHybridReal[0 + invert] = (r6 + r1) << 1;
- mHybridImag[0 + invert] = (i6 + i1) << 1;
+ mHybridReal[0 + invert] = SATURATE_LEFT_SHIFT((r6 + r1), 1, DFRACT_BITS);
+ mHybridImag[0 + invert] = SATURATE_LEFT_SHIFT((i6 + i1), 1, DFRACT_BITS);
- mHybridReal[1 - invert] = (r6 - r1) << 1;
- mHybridImag[1 - invert] = (i6 - i1) << 1;
+ mHybridReal[1 - invert] = SATURATE_LEFT_SHIFT((r6 - r1), 1, DFRACT_BITS);
+ mHybridImag[1 - invert] = SATURATE_LEFT_SHIFT((i6 - i1), 1, DFRACT_BITS);
}
static void fourChannelFiltering(const FIXP_DBL *const pQmfReal,
@@ -766,15 +766,15 @@ static void eightChannelFiltering(const FIXP_DBL *const pQmfReal,
mHybridReal[3] = pfft[FFT_IDX_R(1)] << sc;
mHybridImag[3] = pfft[FFT_IDX_I(1)] << sc;
- mHybridReal[4] = pfft[FFT_IDX_R(2)] << sc;
- mHybridReal[4] += pfft[FFT_IDX_R(5)] << sc;
- mHybridImag[4] = pfft[FFT_IDX_I(2)] << sc;
- mHybridImag[4] += pfft[FFT_IDX_I(5)] << sc;
+ mHybridReal[4] = SATURATE_LEFT_SHIFT(
+ (pfft[FFT_IDX_R(2)] + pfft[FFT_IDX_R(5)]), sc, DFRACT_BITS);
+ mHybridImag[4] = SATURATE_LEFT_SHIFT(
+ (pfft[FFT_IDX_I(2)] + pfft[FFT_IDX_I(5)]), sc, DFRACT_BITS);
- mHybridReal[5] = pfft[FFT_IDX_R(3)] << sc;
- mHybridReal[5] += pfft[FFT_IDX_R(4)] << sc;
- mHybridImag[5] = pfft[FFT_IDX_I(3)] << sc;
- mHybridImag[5] += pfft[FFT_IDX_I(4)] << sc;
+ mHybridReal[5] = SATURATE_LEFT_SHIFT(
+ (pfft[FFT_IDX_R(3)] + pfft[FFT_IDX_R(4)]), sc, DFRACT_BITS);
+ mHybridImag[5] = SATURATE_LEFT_SHIFT(
+ (pfft[FFT_IDX_I(3)] + pfft[FFT_IDX_I(4)]), sc, DFRACT_BITS);
} else {
for (k = 0; k < 8; k++) {
mHybridReal[k] = pfft[FFT_IDX_R(k)] << sc;
diff --git a/libFDK/src/dct.cpp b/libFDK/src/dct.cpp
index bd26736..35507b5 100644
--- a/libFDK/src/dct.cpp
+++ b/libFDK/src/dct.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
@@ -305,9 +305,8 @@ void dct_II(
{
for (i = 0; i < M; i++) {
- tmp[i] = pDat[2 * i] >> 1; /* dit_fft expects 1 bit scaled input values */
- tmp[L - 1 - i] =
- pDat[2 * i + 1] >> 1; /* dit_fft expects 1 bit scaled input values */
+ tmp[i] = pDat[2 * i] >> 2;
+ tmp[L - 1 - i] = pDat[2 * i + 1] >> 2;
}
}
@@ -337,15 +336,14 @@ void dct_II(
a1 = ((pTmp_0[0] >> 1) + (pTmp_1[0] >> 1));
a2 = ((pTmp_0[1] >> 1) - (pTmp_1[1] >> 1));
- cplxMultDiv2(&accu3, &accu4, (a1 + accu2), -(accu1 + a2),
- sin_twiddle[i * inc]);
- pDat[L - i] = accu4;
- pDat[i] = accu3;
+ cplxMult(&accu3, &accu4, (accu1 + a2), (a1 + accu2), sin_twiddle[i * inc]);
+ pDat[L - i] = -accu3;
+ pDat[i] = accu4;
- cplxMultDiv2(&accu3, &accu4, (a1 - accu2), -(accu1 - a2),
- sin_twiddle[(M - i) * inc]);
- pDat[M + i] = accu4;
- pDat[M - i] = accu3;
+ cplxMult(&accu3, &accu4, (accu1 - a2), (a1 - accu2),
+ sin_twiddle[(M - i) * inc]);
+ pDat[M + i] = -accu3;
+ pDat[M - i] = accu4;
/* Create index helper variables for (4*i)*inc indexed equivalent values of
* short tables. */
@@ -356,12 +354,12 @@ void dct_II(
}
}
- cplxMultDiv2(&accu1, &accu2, tmp[M], tmp[M + 1], sin_twiddle[(M / 2) * inc]);
+ cplxMult(&accu1, &accu2, tmp[M], tmp[M + 1], sin_twiddle[(M / 2) * inc]);
pDat[L - (M / 2)] = accu2;
pDat[M / 2] = accu1;
- pDat[0] = (tmp[0] >> 1) + (tmp[1] >> 1);
- pDat[M] = fMult(((tmp[0] >> 1) - (tmp[1] >> 1)),
+ pDat[0] = tmp[0] + tmp[1];
+ pDat[M] = fMult(tmp[0] - tmp[1],
sin_twiddle[M * inc].v.re); /* cos((PI/(2*L))*M); */
*pDat_e += 2;
diff --git a/libMpegTPDec/include/tp_data.h b/libMpegTPDec/include/tp_data.h
index b015332..b63087a 100644
--- a/libMpegTPDec/include/tp_data.h
+++ b/libMpegTPDec/include/tp_data.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 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -368,7 +368,7 @@ typedef INT (*cbCtrlCFGChange_t)(void *, const CCtrlCFGChange *);
typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM,
const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize,
- const INT stereoConfigIndex,
+ const INT numChannels, const INT stereoConfigIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes,
const UCHAR configMode, UCHAR *configChanged);
diff --git a/libMpegTPDec/src/tpdec_asc.cpp b/libMpegTPDec/src/tpdec_asc.cpp
index 82f840e..a2baaaf 100644
--- a/libMpegTPDec/src/tpdec_asc.cpp
+++ b/libMpegTPDec/src/tpdec_asc.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
@@ -266,11 +266,118 @@ static int CProgramConfig_ReadHeightExt(CProgramConfig *pPce,
return (err);
}
+/**
+ * \brief Sanity checks for program config element.
+ * Check order of elements according to ISO/IEC 13818-7:2003(E),
+ * chapter 8.5.1
+ *
+ * \param pPce pointer to program config element.
+ *
+ * \return 0 if successful, otherwise 1.
+ */
+static int CProgramConfig_Check(CProgramConfig *pPce) {
+ INT i;
+ INT err = 0;
+ INT numBackChannels[3] = {0};
+ INT numSideChannels[3] = {0};
+ INT numFrontChannels[3] = {0};
+ UCHAR *pCpeFront = pPce->FrontElementIsCpe;
+ UCHAR *pCpeSide = pPce->SideElementIsCpe;
+ UCHAR *pCpeBack = pPce->BackElementIsCpe;
+ UCHAR *pHeight;
+
+ pHeight = pPce->BackElementHeightInfo;
+ for (i = 0; i < pPce->NumBackChannelElements; i++) {
+ numBackChannels[*pHeight] += pPce->BackElementIsCpe[i] ? 2 : 1;
+ pHeight++;
+ }
+ pHeight = pPce->SideElementHeightInfo;
+ for (i = 0; i < pPce->NumSideChannelElements; i++) {
+ numSideChannels[*pHeight] += pPce->SideElementIsCpe[i] ? 2 : 1;
+ pHeight++;
+ }
+ pHeight = pPce->FrontElementHeightInfo;
+ for (i = 0; i < pPce->NumFrontChannelElements; i++) {
+ numFrontChannels[*pHeight] += pPce->FrontElementIsCpe[i] ? 2 : 1;
+ pHeight++;
+ }
+
+ /* 0 = normal height channels, 1 = top height channels, 2 = bottom height
+ * channels */
+ for (i = 0; i < 3; i++) {
+ /* if number of channels is odd => first element must be a SCE (front center
+ * channel) */
+ if (numFrontChannels[i] & 1) {
+ if (*pCpeFront++ == ID_CPE) {
+ err = 1;
+ goto bail;
+ }
+ numFrontChannels[i]--;
+ }
+ while (numFrontChannels[i] > 0) {
+ /* must be CPE or paired SCE */
+ if (*pCpeFront++ == ID_SCE) {
+ if (*pCpeFront++ == ID_CPE) {
+ err = 1;
+ goto bail;
+ }
+ }
+ numFrontChannels[i] -= 2;
+ };
+
+ /* in case that a top center surround channel (Ts) is transmitted the number
+ * of channels can be odd */
+ if (i != 1) {
+ /* number of channels must be even */
+ if (numSideChannels[i] & 1) {
+ err = 1;
+ goto bail;
+ }
+ while (numSideChannels[i] > 0) {
+ /* must be CPE or paired SCE */
+ if (*pCpeSide++ == ID_SCE) {
+ if (*pCpeSide++ == ID_CPE) {
+ err = 1;
+ goto bail;
+ }
+ }
+ numSideChannels[i] -= 2;
+ };
+ }
+
+ while (numBackChannels[i] > 1) {
+ /* must be CPE or paired SCE */
+ if (*pCpeBack++ == ID_SCE) {
+ if (*pCpeBack++ == ID_CPE) {
+ err = 1;
+ goto bail;
+ }
+ }
+ numBackChannels[i] -= 2;
+ };
+ /* if number of channels is odd => last element must be a SCE (back center
+ * channel) */
+ if (numBackChannels[i]) {
+ if (*pCpeBack++ == ID_CPE) {
+ err = 1;
+ goto bail;
+ }
+ }
+ }
+
+bail:
+
+ return err;
+}
+
void CProgramConfig_Read(CProgramConfig *pPce, HANDLE_FDK_BITSTREAM bs,
UINT alignmentAnchor) {
- int i, err = 0;
+ int i;
int commentBytes;
+ UCHAR tag, isCpe;
+ UCHAR checkElementTagSelect[3][PC_FSB_CHANNELS_MAX] = {{0}};
+ pPce->isValid = 1;
pPce->NumEffectiveChannels = 0;
pPce->NumChannels = 0;
pPce->ElementInstanceTag = (UCHAR)FDKreadBits(bs, 4);
@@ -297,28 +404,60 @@ void CProgramConfig_Read(CProgramConfig *pPce, HANDLE_FDK_BITSTREAM bs,
}
for (i = 0; i < pPce->NumFrontChannelElements; i++) {
- pPce->FrontElementIsCpe[i] = (UCHAR)FDKreadBits(bs, 1);
- pPce->FrontElementTagSelect[i] = (UCHAR)FDKreadBits(bs, 4);
+ pPce->FrontElementIsCpe[i] = isCpe = (UCHAR)FDKreadBits(bs, 1);
+ pPce->FrontElementTagSelect[i] = tag = (UCHAR)FDKreadBits(bs, 4);
pPce->NumChannels += pPce->FrontElementIsCpe[i] ? 2 : 1;
+
+ /* Check element instance tag according to ISO/IEC 13818-7:2003(E),
+ * chapter 8.2.1.1 */
+ if (checkElementTagSelect[isCpe][tag] == 0) {
+ checkElementTagSelect[isCpe][tag] = 1;
+ } else {
+ pPce->isValid = 0;
+ }
}
for (i = 0; i < pPce->NumSideChannelElements; i++) {
- pPce->SideElementIsCpe[i] = (UCHAR)FDKreadBits(bs, 1);
- pPce->SideElementTagSelect[i] = (UCHAR)FDKreadBits(bs, 4);
+ pPce->SideElementIsCpe[i] = isCpe = (UCHAR)FDKreadBits(bs, 1);
+ pPce->SideElementTagSelect[i] = tag = (UCHAR)FDKreadBits(bs, 4);
pPce->NumChannels += pPce->SideElementIsCpe[i] ? 2 : 1;
+
+ /* Check element instance tag according to ISO/IEC 13818-7:2003(E),
+ * chapter 8.2.1.1 */
+ if (checkElementTagSelect[isCpe][tag] == 0) {
+ checkElementTagSelect[isCpe][tag] = 1;
+ } else {
+ pPce->isValid = 0;
+ }
}
for (i = 0; i < pPce->NumBackChannelElements; i++) {
- pPce->BackElementIsCpe[i] = (UCHAR)FDKreadBits(bs, 1);
- pPce->BackElementTagSelect[i] = (UCHAR)FDKreadBits(bs, 4);
+ pPce->BackElementIsCpe[i] = isCpe = (UCHAR)FDKreadBits(bs, 1);
+ pPce->BackElementTagSelect[i] = tag = (UCHAR)FDKreadBits(bs, 4);
pPce->NumChannels += pPce->BackElementIsCpe[i] ? 2 : 1;
+
+ /* Check element instance tag according to ISO/IEC 13818-7:2003(E),
+ * chapter 8.2.1.1 */
+ if (checkElementTagSelect[isCpe][tag] == 0) {
+ checkElementTagSelect[isCpe][tag] = 1;
+ } else {
+ pPce->isValid = 0;
+ }
}
pPce->NumEffectiveChannels = pPce->NumChannels;
for (i = 0; i < pPce->NumLfeChannelElements; i++) {
- pPce->LfeElementTagSelect[i] = (UCHAR)FDKreadBits(bs, 4);
+ pPce->LfeElementTagSelect[i] = tag = (UCHAR)FDKreadBits(bs, 4);
pPce->NumChannels += 1;
+
+ /* Check element instance tag according to ISO/IEC 13818-7:2003(E),
+ * chapter 8.2.1.1 */
+ if (checkElementTagSelect[2][tag] == 0) {
+ checkElementTagSelect[2][tag] = 1;
+ } else {
+ pPce->isValid = 0;
+ }
}
for (i = 0; i < pPce->NumAssocDataElements; i++) {
@@ -336,7 +475,15 @@ void CProgramConfig_Read(CProgramConfig *pPce, HANDLE_FDK_BITSTREAM bs,
commentBytes = pPce->CommentFieldBytes;
/* Search for height info extension and read it if available */
- err = CProgramConfig_ReadHeightExt(pPce, bs, &commentBytes, alignmentAnchor);
+ if (CProgramConfig_ReadHeightExt(pPce, bs, &commentBytes, alignmentAnchor)) {
+ pPce->isValid = 0;
+ }
+
+ /* Check order of elements according to ISO / IEC 13818 - 7:2003(E),
+ * chapter 8.5.1 */
+ if (CProgramConfig_Check(pPce)) {
+ pPce->isValid = 0;
+ }
for (i = 0; i < commentBytes; i++) {
UCHAR text;
@@ -347,8 +494,6 @@ void CProgramConfig_Read(CProgramConfig *pPce, HANDLE_FDK_BITSTREAM bs,
pPce->Comment[i] = text;
}
}
-
- pPce->isValid = (err) ? 0 : 1;
}
/*
@@ -1415,7 +1560,7 @@ static TRANSPORTDEC_ERROR EldSpecificConfig_Parse(CSAudioSpecificConfig *asc,
cb->cbSscData, hBs, asc->m_aot,
asc->m_samplingFrequency << esc->m_sbrSamplingRate,
asc->m_samplesPerFrame << esc->m_sbrSamplingRate,
- 1, /* stereoConfigIndex */
+ asc->m_channelConfiguration, 1, /* stereoConfigIndex */
-1, /* nTimeSlots: read from bitstream */
eldExtLen, asc->configMode, &asc->SacConfigChanged);
if (ErrorStatus != TRANSPORTDEC_OK) {
@@ -1827,6 +1972,8 @@ static TRANSPORTDEC_ERROR UsacRsv60DecoderConfig_Parse(
/* Mps212Config() ISO/IEC FDIS 23003-3 */
if (cb->cbSsc(cb->cbSscData, hBs, asc->m_aot,
asc->m_extensionSamplingFrequency, samplesPerFrame,
+ 1, /* only downmix channels (residual channels are
+ not counted) */
usc->element[i].m_stereoConfigIndex,
usc->m_coreSbrFrameLengthIndex,
0, /* don't know the length */
@@ -1996,9 +2143,11 @@ static TRANSPORTDEC_ERROR UsacConfig_Parse(CSAudioSpecificConfig *asc,
/* Copy UsacConfig() to asc->m_sc.m_usacConfig.UsacConfig[] buffer. */
INT configSize_bits = (INT)FDKgetValidBits(hBs) - nbits;
- StoreConfigAsBitstream(hBs, configSize_bits,
- asc->m_sc.m_usacConfig.UsacConfig,
- TP_USAC_MAX_CONFIG_LEN);
+ if (StoreConfigAsBitstream(hBs, configSize_bits,
+ asc->m_sc.m_usacConfig.UsacConfig,
+ TP_USAC_MAX_CONFIG_LEN)) {
+ return TRANSPORTDEC_PARSE_ERROR;
+ }
asc->m_sc.m_usacConfig.UsacConfigBits = fAbs(configSize_bits);
return err;
@@ -2219,7 +2368,7 @@ TRANSPORTDEC_ERROR AudioSpecificConfig_Parse(
case AOT_MPEGS:
if (cb->cbSsc != NULL) {
if (cb->cbSsc(cb->cbSscData, bs, self->m_aot, self->m_samplingFrequency,
- self->m_samplesPerFrame, 1,
+ self->m_samplesPerFrame, self->m_channelConfiguration, 1,
-1, /* nTimeSlots: read from bitstream */
0, /* don't know the length */
self->configMode, &self->SacConfigChanged)) {
@@ -2300,8 +2449,10 @@ TRANSPORTDEC_ERROR AudioSpecificConfig_Parse(
/* Copy config() to asc->config[] buffer. */
if ((ErrorStatus == TRANSPORTDEC_OK) && (self->m_aot == AOT_USAC)) {
INT configSize_bits = (INT)FDKgetValidBits(bs) - (INT)ascStartAnchor;
- StoreConfigAsBitstream(bs, configSize_bits, self->config,
- TP_USAC_MAX_CONFIG_LEN);
+ if (StoreConfigAsBitstream(bs, configSize_bits, self->config,
+ TP_USAC_MAX_CONFIG_LEN)) {
+ return TRANSPORTDEC_PARSE_ERROR;
+ }
self->configBits = fAbs(configSize_bits);
}
@@ -2415,6 +2566,8 @@ static TRANSPORTDEC_ERROR Drm_xHEAACDecoderConfig(
cb->cbSscData, hBs,
AOT_DRM_USAC, /* syntax differs from MPEG Mps212Config() */
asc->m_extensionSamplingFrequency, samplesPerFrame,
+ 1, /* only downmix channels (residual channels are not
+ counted) */
usc->element[elemIdx].m_stereoConfigIndex,
usc->m_coreSbrFrameLengthIndex, 0, /* don't know the length */
asc->configMode, &asc->SacConfigChanged);
diff --git a/libMpegTPEnc/include/tp_data.h b/libMpegTPEnc/include/tp_data.h
index 00de356..464c485 100644
--- a/libMpegTPEnc/include/tp_data.h
+++ b/libMpegTPEnc/include/tp_data.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 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V. All rights reserved.
1. INTRODUCTION
@@ -368,7 +368,7 @@ typedef INT (*cbCtrlCFGChange_t)(void *, const CCtrlCFGChange *);
typedef INT (*cbSsc_t)(void *, HANDLE_FDK_BITSTREAM,
const AUDIO_OBJECT_TYPE coreCodec,
const INT samplingRate, const INT frameSize,
- const INT stereoConfigIndex,
+ const INT numChannels, const INT stereoConfigIndex,
const INT coreSbrFrameLengthIndex, const INT configBytes,
const UCHAR configMode, UCHAR *configChanged);
diff --git a/libMpegTPEnc/src/tpenc_asc.cpp b/libMpegTPEnc/src/tpenc_asc.cpp
index 0b484a0..9591ba8 100644
--- a/libMpegTPEnc/src/tpenc_asc.cpp
+++ b/libMpegTPEnc/src/tpenc_asc.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
@@ -795,7 +795,7 @@ static int transportEnc_writeELDSpecificConfig(HANDLE_FDK_BITSTREAM hBs,
const INT eldExtLen =
(cb->cbSsc(cb->cbSscData, NULL, config->aot, config->extSamplingRate, 0,
- 0, 0, 0, 0, NULL) +
+ 0, 0, 0, 0, 0, NULL) +
7) >>
3;
INT cnt = eldExtLen;
@@ -818,7 +818,7 @@ static int transportEnc_writeELDSpecificConfig(HANDLE_FDK_BITSTREAM hBs,
}
cb->cbSsc(cb->cbSscData, hBs, config->aot, config->extSamplingRate, 0, 0, 0,
- 0, 0, NULL);
+ 0, 0, 0, NULL);
}
if (config->downscaleSamplingRate != 0 &&
diff --git a/libSACdec/include/sac_dec_lib.h b/libSACdec/include/sac_dec_lib.h
index 1827504..5aad4e0 100644
--- a/libSACdec/include/sac_dec_lib.h
+++ b/libSACdec/include/sac_dec_lib.h
@@ -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
@@ -316,8 +316,8 @@ SACDEC_ERROR mpegSurroundDecoder_Init(
SACDEC_ERROR mpegSurroundDecoder_Config(
CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs,
AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize,
- INT stereoConfigIndex, INT coreSbrFrameLengthIndex, INT configBytes,
- const UCHAR configMode, UCHAR *configChanged);
+ INT numChannels, INT stereoConfigIndex, INT coreSbrFrameLengthIndex,
+ INT configBytes, const UCHAR configMode, UCHAR *configChanged);
SACDEC_ERROR
mpegSurroundDecoder_ConfigureQmfDomain(
diff --git a/libSACdec/src/sac_dec.cpp b/libSACdec/src/sac_dec.cpp
index a7b50df..a26e251 100644
--- a/libSACdec/src/sac_dec.cpp
+++ b/libSACdec/src/sac_dec.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
@@ -1098,6 +1098,28 @@ static void SpatialDecApplyBypass(spatialDec *self, FIXP_DBL **hybInputReal,
}
}
+/**
+ * \brief Set internal error and reset error status
+ *
+ * \param self spatialDec handle.
+ * \param bypassMode pointer to bypassMode.
+ * \param err error status.
+ *
+ * \return error status.
+ */
+static SACDEC_ERROR SpatialDecSetInternalError(spatialDec *self,
+ int *bypassMode,
+ SACDEC_ERROR err) {
+ *bypassMode = 1;
+
+ if (self->errInt == MPS_OK) {
+ /* store internal error before it gets overwritten */
+ self->errInt = err;
+ }
+
+ return MPS_OK;
+}
+
/*******************************************************************************
Functionname: SpatialDecApplyParameterSets
*******************************************************************************
@@ -1118,7 +1140,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
const FDK_channelMapDescr *const mapDescr) {
SACDEC_ERROR err = MPS_OK;
- FIXP_SGL alpha;
+ FIXP_SGL alpha = FL2FXCONST_SGL(0.0);
int ts;
int ch;
@@ -1141,20 +1163,22 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
ts++, ts_io++) {
int currSlot = frame->paramSlot[ps];
+ err = (currSlot < ts) ? MPS_WRONG_PARAMETERSETS : MPS_OK;
+ if (err != MPS_OK) {
+ err = SpatialDecSetInternalError(self, &bypassMode, err);
+ }
+
/*
* Get new parameter set
*/
if (ts == prevSlot + 1) {
- err = SpatialDecCalculateM1andM2(self, ps,
- frame); /* input: ottCLD, ottICC, ... */
- /* output: M1param(Real/Imag), M2(Real/Imag) */
- if (err != MPS_OK) {
- bypassMode = 1;
- if (self->errInt == MPS_OK) {
- /* store internal error befor it gets overwritten */
- self->errInt = err;
+ if (bypassMode == 0) {
+ err = SpatialDecCalculateM1andM2(
+ self, ps, frame); /* input: ottCLD, ottICC, ... */
+ /* output: M1param(Real/Imag), M2(Real/Imag) */
+ if (err != MPS_OK) {
+ err = SpatialDecSetInternalError(self, &bypassMode, err);
}
- err = MPS_OK;
}
if ((ps == 0) && (self->bOverwriteM1M2prev != 0)) {
@@ -1168,13 +1192,16 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
self->bOverwriteM1M2prev = 0;
}
- SpatialDecSmoothM1andM2(
- self, frame,
- ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */
- /* output: M1param(Real/Imag), M2(Real/Imag) */
+ if (bypassMode == 0) {
+ SpatialDecSmoothM1andM2(
+ self, frame,
+ ps); /* input: M1param(Real/Imag)(Prev), M2(Real/Imag)(Prev) */
+ } /* output: M1param(Real/Imag), M2(Real/Imag) */
}
- alpha = FX_DBL2FX_SGL(fDivNorm(ts - prevSlot, currSlot - prevSlot));
+ if (bypassMode == 0) {
+ alpha = FX_DBL2FX_SGL(fDivNorm(ts - prevSlot, currSlot - prevSlot));
+ }
switch (mode) {
case INPUTMODE_QMF_SBR:
@@ -1182,15 +1209,17 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
self->bShareDelayWithSBR = 0; /* We got no hybrid delay */
else
self->bShareDelayWithSBR = 1;
- SpatialDecFeedQMF(self, qmfInDataReal, qmfInDataImag, ts_io, bypassMode,
- self->qmfInputReal__FDK, self->qmfInputImag__FDK,
- self->numInputChannels);
+ SpatialDecFeedQMF(
+ self, qmfInDataReal, qmfInDataImag, ts_io, bypassMode,
+ self->qmfInputReal__FDK, self->qmfInputImag__FDK,
+ (bypassMode) ? numInputChannels : self->numInputChannels);
break;
case INPUTMODE_TIME:
self->bShareDelayWithSBR = 0;
- SpatialDecQMFAnalysis(self, inData, ts_io, bypassMode,
- self->qmfInputReal__FDK, self->qmfInputImag__FDK,
- self->numInputChannels);
+ SpatialDecQMFAnalysis(
+ self, inData, ts_io, bypassMode, self->qmfInputReal__FDK,
+ self->qmfInputImag__FDK,
+ (bypassMode) ? numInputChannels : self->numInputChannels);
break;
default:
break;
@@ -1360,7 +1389,7 @@ static SACDEC_ERROR SpatialDecApplyParameterSets(
} /* !self->tempShapeConfig == 1 */
} /* !bypassMode */
- if (self->phaseCoding == 1) {
+ if ((self->phaseCoding == 1) && (bypassMode == 0)) {
/* only if bsPhaseCoding == 1 and bsResidualCoding == 0 */
SpatialDecApplyPhase(
diff --git a/libSACdec/src/sac_dec_lib.cpp b/libSACdec/src/sac_dec_lib.cpp
index 57446f8..d30131f 100644
--- a/libSACdec/src/sac_dec_lib.cpp
+++ b/libSACdec/src/sac_dec_lib.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
@@ -700,9 +700,10 @@ bail:
SACDEC_ERROR mpegSurroundDecoder_Config(
CMpegSurroundDecoder *pMpegSurroundDecoder, HANDLE_FDK_BITSTREAM hBs,
AUDIO_OBJECT_TYPE coreCodec, INT samplingRate, INT frameSize,
- INT stereoConfigIndex, INT coreSbrFrameLengthIndex, INT configBytes,
- const UCHAR configMode, UCHAR *configChanged) {
+ INT numChannels, INT stereoConfigIndex, INT coreSbrFrameLengthIndex,
+ INT configBytes, const UCHAR configMode, UCHAR *configChanged) {
SACDEC_ERROR err = MPS_OK;
+ INT nInputChannels;
SPATIAL_SPECIFIC_CONFIG spatialSpecificConfig;
SPATIAL_SPECIFIC_CONFIG *pSsc =
&pMpegSurroundDecoder->spatialSpecificConfigBackup;
@@ -716,12 +717,18 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
err = SpatialDecParseMps212Config(
hBs, &spatialSpecificConfig, samplingRate, coreCodec,
stereoConfigIndex, coreSbrFrameLengthIndex);
+ nInputChannels = spatialSpecificConfig.nInputChannels;
pSsc = &spatialSpecificConfig;
} else {
err = SpatialDecParseMps212Config(
hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup,
samplingRate, coreCodec, stereoConfigIndex,
coreSbrFrameLengthIndex);
+ nInputChannels =
+ pMpegSurroundDecoder->spatialSpecificConfigBackup.nInputChannels;
+ }
+ if ((err == MPS_OK) && (numChannels != nInputChannels)) {
+ err = MPS_PARSE_ERROR;
}
break;
case AOT_ER_AAC_ELD:
@@ -731,11 +738,19 @@ SACDEC_ERROR mpegSurroundDecoder_Config(
* into temporarily allocated structure */
err = SpatialDecParseSpecificConfig(hBs, &spatialSpecificConfig,
configBytes, coreCodec);
+ nInputChannels = spatialSpecificConfig.nInputChannels;
pSsc = &spatialSpecificConfig;
} else {
err = SpatialDecParseSpecificConfig(
hBs, &pMpegSurroundDecoder->spatialSpecificConfigBackup,
configBytes, coreCodec);
+ nInputChannels =
+ pMpegSurroundDecoder->spatialSpecificConfigBackup.nInputChannels;
+ }
+ /* check number of channels for channel_configuration > 0 */
+ if ((err == MPS_OK) && (numChannels > 0) &&
+ (numChannels != nInputChannels)) {
+ err = MPS_PARSE_ERROR;
}
break;
default:
diff --git a/libSACdec/src/sac_stp.cpp b/libSACdec/src/sac_stp.cpp
index bb66277..b328c82 100644
--- a/libSACdec/src/sac_stp.cpp
+++ b/libSACdec/src/sac_stp.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
@@ -369,15 +369,15 @@ SACDEC_ERROR subbandTPApply(spatialDec *self, const SPATIAL_BS_FRAME *frame) {
hStpDec->update_old_ener = 1;
for (ch = 0; ch < self->numInputChannels; ch++) {
hStpDec->oldDryEnerLD64[ch] =
- CalcLdData(hStpDec->runDryEner[ch] + ABS_THR__FDK);
+ CalcLdData(fAddSaturate(hStpDec->runDryEner[ch], ABS_THR__FDK));
}
for (ch = 0; ch < self->numOutputChannels; ch++) {
if (self->treeConfig == TREE_212)
hStpDec->oldWetEnerLD64[ch] =
- CalcLdData(hStpDec->runWetEner[ch] + ABS_THR__FDK);
+ CalcLdData(fAddSaturate(hStpDec->runWetEner[ch], ABS_THR__FDK));
else
hStpDec->oldWetEnerLD64[ch] =
- CalcLdData(hStpDec->runWetEner[ch] + ABS_THR2__FDK);
+ CalcLdData(fAddSaturate(hStpDec->runWetEner[ch], ABS_THR2__FDK));
}
} else {
hStpDec->update_old_ener++;
diff --git a/libSBRdec/src/env_calc.cpp b/libSBRdec/src/env_calc.cpp
index 0b2f651..ad5edfe 100644
--- a/libSBRdec/src/env_calc.cpp
+++ b/libSBRdec/src/env_calc.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
@@ -1398,6 +1398,17 @@ void calculateSbrEnvelope(
*/
noise_e = (start_pos < no_cols) ? adj_e : final_e;
+ if (start_pos >= no_cols) {
+ int diff = h_sbr_cal_env->filtBufferNoise_e - noise_e;
+ if (diff > 0) {
+ int s = getScalefactor(h_sbr_cal_env->filtBufferNoise, noSubbands);
+ if (diff > s) {
+ final_e += diff - s;
+ noise_e = final_e;
+ }
+ }
+ }
+
/*
Convert energies to amplitude levels
*/
@@ -2741,6 +2752,9 @@ static void adjustTimeSlotHQ_GainAndNoise(
fMult(direct_ratio, noiseLevel[k]);
}
+ smoothedNoise = fMax(fMin(smoothedNoise, (FIXP_DBL)(MAXVAL_DBL / 2)),
+ (FIXP_DBL)(MINVAL_DBL / 2));
+
/*
The next 2 multiplications constitute the actual envelope adjustment
of the signal and should be carried out with full accuracy
@@ -2930,6 +2944,9 @@ static void adjustTimeSlotHQ(
fMult(direct_ratio, noiseLevel[k]);
}
+ smoothedNoise = fMax(fMin(smoothedNoise, (FIXP_DBL)(MAXVAL_DBL / 2)),
+ (FIXP_DBL)(MINVAL_DBL / 2));
+
/*
The next 2 multiplications constitute the actual envelope adjustment
of the signal and should be carried out with full accuracy
diff --git a/libSBRdec/src/sbrdec_drc.cpp b/libSBRdec/src/sbrdec_drc.cpp
index 2d73f32..089d046 100644
--- a/libSBRdec/src/sbrdec_drc.cpp
+++ b/libSBRdec/src/sbrdec_drc.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
@@ -233,14 +233,19 @@ void sbrDecoder_drcApplySlot(HANDLE_SBR_DRC_CHANNEL hDrcData,
if (hDrcData->winSequenceCurr != 2) { /* long window */
int j = col + (numQmfSubSamples >> 1);
- if (hDrcData->drcInterpolationSchemeCurr == 0) {
- INT k = (frameLenFlag) ? 0x4444445 : 0x4000000;
+ if (j < winBorderToColMap[15]) {
+ if (hDrcData->drcInterpolationSchemeCurr == 0) {
+ INT k = (frameLenFlag) ? 0x4444445 : 0x4000000;
- alphaValue = (FIXP_DBL)(j * k);
- } else {
- if (j >= (int)winBorderToColMap[hDrcData->drcInterpolationSchemeCurr]) {
- alphaValue = (FIXP_DBL)MAXVAL_DBL;
+ alphaValue = (FIXP_DBL)(j * k);
+ } else {
+ if (j >=
+ (int)winBorderToColMap[hDrcData->drcInterpolationSchemeCurr]) {
+ alphaValue = (FIXP_DBL)MAXVAL_DBL;
+ }
}
+ } else {
+ alphaValue = (FIXP_DBL)MAXVAL_DBL;
}
} else { /* short windows */
shortDrc = 1;
@@ -254,14 +259,19 @@ void sbrDecoder_drcApplySlot(HANDLE_SBR_DRC_CHANNEL hDrcData,
if (hDrcData->winSequenceNext != 2) { /* next: long window */
int j = col - (numQmfSubSamples >> 1);
- if (hDrcData->drcInterpolationSchemeNext == 0) {
- INT k = (frameLenFlag) ? 0x4444445 : 0x4000000;
+ if (j < winBorderToColMap[15]) {
+ if (hDrcData->drcInterpolationSchemeNext == 0) {
+ INT k = (frameLenFlag) ? 0x4444445 : 0x4000000;
- alphaValue = (FIXP_DBL)(j * k);
- } else {
- if (j >= (int)winBorderToColMap[hDrcData->drcInterpolationSchemeNext]) {
- alphaValue = (FIXP_DBL)MAXVAL_DBL;
+ alphaValue = (FIXP_DBL)(j * k);
+ } else {
+ if (j >=
+ (int)winBorderToColMap[hDrcData->drcInterpolationSchemeNext]) {
+ alphaValue = (FIXP_DBL)MAXVAL_DBL;
+ }
}
+ } else {
+ alphaValue = (FIXP_DBL)MAXVAL_DBL;
}
fact_mag = hDrcData->nextFact_mag;
@@ -289,14 +299,19 @@ void sbrDecoder_drcApplySlot(HANDLE_SBR_DRC_CHANNEL hDrcData,
if (hDrcData->winSequenceNext != 2) { /* long window */
int j = col - (numQmfSubSamples >> 1);
- if (hDrcData->drcInterpolationSchemeNext == 0) {
- INT k = (frameLenFlag) ? 0x4444445 : 0x4000000;
+ if (j < winBorderToColMap[15]) {
+ if (hDrcData->drcInterpolationSchemeNext == 0) {
+ INT k = (frameLenFlag) ? 0x4444445 : 0x4000000;
- alphaValue = (FIXP_DBL)(j * k);
- } else {
- if (j >= (int)winBorderToColMap[hDrcData->drcInterpolationSchemeNext]) {
- alphaValue = (FIXP_DBL)MAXVAL_DBL;
+ alphaValue = (FIXP_DBL)(j * k);
+ } else {
+ if (j >=
+ (int)winBorderToColMap[hDrcData->drcInterpolationSchemeNext]) {
+ alphaValue = (FIXP_DBL)MAXVAL_DBL;
+ }
}
+ } else {
+ alphaValue = (FIXP_DBL)MAXVAL_DBL;
}
} else { /* short windows */
shortDrc = 1;