From 61381bd0f4bc012876ccf4b63eafddd2d60c35c9 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Wed, 15 Aug 2018 14:35:00 +0200 Subject: Break audio element loop in case element_count becomes too large. Bug: 112891564 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I35f02d23c0cfd620088291a52d9996a0d5a17199 (cherry picked from commit 3347cfb91a7ecabf5800d72e936f04ce44752bf3) --- libAACdec/src/aacdecoder.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index b8b1327..362e0b6 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -2519,8 +2519,14 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( if (!(self->flags[0] & (AC_USAC | AC_RSVD50 | AC_RSV603DA | AC_ELD | AC_SCALABLE | AC_ER))) type = (MP4_ELEMENT_ID)FDKreadBits(bs, 3); - else + else { + if (element_count >= (3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)) { + self->frameOK = 0; + ErrorStatus = AAC_DEC_PARSE_ERROR; + break; + } type = self->elements[element_count]; + } if ((self->flags[streamIndex] & (AC_USAC | AC_RSVD50) && element_count == 0) || @@ -2564,6 +2570,11 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( case ID_USAC_SCE: case ID_USAC_CPE: case ID_USAC_LFE: + if (element_count >= (3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)) { + self->frameOK = 0; + ErrorStatus = AAC_DEC_PARSE_ERROR; + break; + } el_channels = CAacDecoder_GetELChannels( type, self->usacStereoConfigIndex[element_count]); @@ -2795,12 +2806,24 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( } break; case ID_EXT: + if (element_count >= (3 * ((8) * 2) + (((8) * 2)) / 2 + 4 * (1) + 1)) { + self->frameOK = 0; + ErrorStatus = AAC_DEC_PARSE_ERROR; + break; + } + ErrorStatus = aacDecoder_ParseExplicitMpsAndSbr( self, bs, previous_element, previous_element_index, element_count, el_cnt); break; case ID_USAC_EXT: { + if ((element_count - element_count_prev_streams) >= + TP_USAC_MAX_ELEMENTS) { + self->frameOK = 0; + ErrorStatus = AAC_DEC_PARSE_ERROR; + break; + } /* parse extension element payload q.v. rsv603daExtElement() ISO/IEC DIS 23008-3 Table 30 or UsacExElement() ISO/IEC FDIS 23003-3:2011(E) Table 21 -- cgit v1.2.3 From ce97e7d55e1f69683b5bc8f19cc8da8c85bc2cd4 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 8 Jun 2018 18:07:14 +0200 Subject: Always check whether given channel config is supported. Bug: 112660981 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I169161dd31bc624f2cab6be2b4c6518946ed32ba Merged-In: I169161dd31bc624f2cab6be2b4c6518946ed32ba (cherry picked from commit 25b209f229879a155759d791fe463b8abd283677) --- libAACdec/src/aacdecoder.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index 362e0b6..fab30de 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -1630,17 +1630,9 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc, aacChannelsOffset = 0; aacChannelsOffsetIdx = 0; elementOffset = 0; - if (configMode & AC_CM_ALLOC_MEM) { - if ((ascChannels <= 0) || - (asc->m_channelConfiguration > AACDEC_MAX_CH_CONF)) { - return AAC_DEC_UNSUPPORTED_CHANNELCONFIG; - } - if ((ascChannels + aacChannelsOffsetIdx) > ((8) * 2)) { - return AAC_DEC_UNSUPPORTED_CHANNELCONFIG; - } - if ((ascChannels + aacChannelsOffset) > (8)) { - return AAC_DEC_UNSUPPORTED_CHANNELCONFIG; - } + if ((ascChannels <= 0) || (ascChannels > (8)) || + (asc->m_channelConfiguration > AACDEC_MAX_CH_CONF)) { + return AAC_DEC_UNSUPPORTED_CHANNELCONFIG; } /* Set syntax flags */ -- cgit v1.2.3 From 0e5db9fee912d367a572b88f0d86f9a33006fa29 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Wed, 15 Aug 2018 14:33:56 +0200 Subject: Unify audio element loop abort criterion in ER syntax Bug: 112891548 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Iea56cf804cfb9d396810124c718fc91bdff68392 (cherry picked from commit f2bc07da2ed70eb069f3faab1179c4c89792bf3d) --- libAACdec/src/aacdecoder.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index fab30de..24907ee 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -2047,17 +2047,12 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc, if (self->flags[streamIndex] & (AC_RSV603DA | AC_USAC)) { _numElements = (int)asc->m_sc.m_usacConfig.m_usacNumElements; } - if (self->flags[streamIndex] & (AC_ER | AC_LD | AC_ELD)) { - _numElements = (asc->m_channelConfiguration == 7) - ? 8 - : asc->m_channelConfiguration; - } for (int _el = 0; _el < _numElements; _el++) { int el_channels = 0; int el = elementOffset + _el; if (self->flags[streamIndex] & - (AC_ELD | AC_RSV603DA | AC_USAC | AC_RSVD50)) { + (AC_ER | AC_LD | AC_ELD | AC_RSV603DA | AC_USAC | AC_RSVD50)) { if (ch >= ascChannels) { break; } @@ -2107,7 +2102,9 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc, (SPECTRAL_PTR)&self->workBufferCore2[ch * 1024]; if (el_channels == 2) { - FDK_ASSERT(ch < (8) - 1); + if (ch >= (8) - 1) { + return AAC_DEC_UNSUPPORTED_CHANNELCONFIG; + } self->pAacDecoderChannelInfo[ch + 1]->pComData = self->pAacDecoderChannelInfo[ch]->pComData; self->pAacDecoderChannelInfo[ch + 1]->pComStaticData = -- cgit v1.2.3 From 512898b2985f8da79a07fd137b0ff0b6c614bf37 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 29 Jun 2018 16:34:34 +0200 Subject: Unsigned Integer Overflow in CAacDecoder_PreRollExtensionPayloadParse() Bug: 112661610 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I96e2c10328fec8fd12f9c752904860b87a72bed2 --- libAACdec/src/aacdecoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index 24907ee..8993927 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -775,7 +775,7 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_PreRollExtensionPayloadParse( /* For every AU get length and offset in the bitstream */ prerollAULength[i] = escapedValue(hBs, 16, 16, 0); if (prerollAULength[i] > 0) { - prerollAUOffset[i] = auStartAnchor - FDKgetValidBits(hBs); + prerollAUOffset[i] = auStartAnchor - (INT)FDKgetValidBits(hBs); independencyFlag = FDKreadBit(hBs); if (i == 0 && !independencyFlag) { *numPrerollAU = 0; -- cgit v1.2.3 From 64134e60b348bb1686986e217f4020d6d108ed46 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 19 Oct 2018 16:37:31 +0200 Subject: Add FDK_FALLTHROUGH macro to prevent implicit-fallthrough compiler warnings Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I9f9064fb63ac40e18f245c00b7375b4874f2925b --- libAACdec/src/aacdecoder.cpp | 7 ++++++- libAACdec/src/channel.cpp | 1 + libAACdec/src/conceal.cpp | 1 + libAACenc/src/aacenc_lib.cpp | 3 +++ libAACenc/src/bitenc.cpp | 2 ++ libMpegTPDec/src/tpdec_asc.cpp | 13 +++++++++++-- libMpegTPDec/src/tpdec_lib.cpp | 1 + libMpegTPEnc/src/tpenc_lib.cpp | 1 + libPCMutils/src/pcmdmx_lib.cpp | 3 +++ libSACdec/src/sac_dec_lib.cpp | 1 + libSYS/include/machine_type.h | 11 +++++++++++ 11 files changed, 41 insertions(+), 3 deletions(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index 8993927..c2ddc48 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -234,7 +234,8 @@ void CAacDecoder_SyncQmfMode(HANDLE_AACDECODER self) { MODE_HQ))) { /* MPS decoder does support the requested mode. */ break; } - } /* Fall-through: */ + } + FDK_FALLTHROUGH; default: if (self->qmfModeUser == NOT_DEFINED) { /* Revert in case mpegSurroundDecoder_SetParam() fails. */ @@ -938,6 +939,7 @@ static AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse( case EXT_SBR_DATA_CRC: crcFlag = 1; + FDK_FALLTHROUGH; case EXT_SBR_DATA: if (IS_CHANNEL_ELEMENT(previous_element)) { SBR_ERROR sbrError; @@ -1076,6 +1078,7 @@ static AAC_DECODER_ERROR CAacDecoder_ExtPayloadParse( * intentional. */ break; } + FDK_FALLTHROUGH; case EXT_FIL: @@ -1495,11 +1498,13 @@ CAacDecoder_Init(HANDLE_AACDECODER self, const CSAudioSpecificConfig *asc, switch (asc->m_aot) { case AOT_AAC_LC: self->streamInfo.profile = 1; + FDK_FALLTHROUGH; case AOT_ER_AAC_SCAL: if (asc->m_sc.m_gaSpecificConfig.m_layer > 0) { /* aac_scalable_extension_element() currently not supported. */ return AAC_DEC_UNSUPPORTED_FORMAT; } + FDK_FALLTHROUGH; case AOT_SBR: case AOT_PS: case AOT_ER_AAC_LC: diff --git a/libAACdec/src/channel.cpp b/libAACdec/src/channel.cpp index cfffd57..a020034 100644 --- a/libAACdec/src/channel.cpp +++ b/libAACdec/src/channel.cpp @@ -592,6 +592,7 @@ AAC_DECODER_ERROR CChannelElement_Read( line: ~599 */ /* Note: The missing "break" is intentional here, since we need to call * CBlock_ReadScaleFactorData(). */ + FDK_FALLTHROUGH; case scale_factor_data: if (flags & AC_ER_RVLC) { diff --git a/libAACdec/src/conceal.cpp b/libAACdec/src/conceal.cpp index a6064b6..cc6de75 100644 --- a/libAACdec/src/conceal.cpp +++ b/libAACdec/src/conceal.cpp @@ -1894,6 +1894,7 @@ INT CConcealment_TDFading( case ConcealState_FadeIn: idx = cntFadeFrames; idx -= TDFadeInStopBeforeFullLevel; + FDK_FALLTHROUGH; case ConcealState_Ok: fadeFactor = pConcealParams->fadeInFactor; idx = (concealState == ConcealState_Ok) ? -1 : idx; diff --git a/libAACenc/src/aacenc_lib.cpp b/libAACenc/src/aacenc_lib.cpp index f92cff4..9e0630c 100644 --- a/libAACenc/src/aacenc_lib.cpp +++ b/libAACenc/src/aacenc_lib.cpp @@ -907,6 +907,7 @@ static AACENC_ERROR FDKaacEnc_AdjustEncSettings(HANDLE_AACENCODER hAacEncoder, case AOT_MP2_AAC_LC: case AOT_MP2_SBR: hAacConfig->usePns = 0; + FDK_FALLTHROUGH; case AOT_AAC_LC: case AOT_SBR: case AOT_PS: @@ -2091,12 +2092,14 @@ AACENC_ERROR aacEncoder_SetParam(const HANDLE_AACENCODER hAacEncoder, err = AACENC_INVALID_CONFIG; goto bail; } + FDK_FALLTHROUGH; case AOT_SBR: case AOT_MP2_SBR: if (!(hAacEncoder->encoder_modis & (ENC_MODE_FLAG_SBR))) { err = AACENC_INVALID_CONFIG; goto bail; } + FDK_FALLTHROUGH; case AOT_AAC_LC: case AOT_MP2_AAC_LC: case AOT_ER_AAC_LD: diff --git a/libAACenc/src/bitenc.cpp b/libAACenc/src/bitenc.cpp index 652d1fd..957e821 100644 --- a/libAACenc/src/bitenc.cpp +++ b/libAACenc/src/bitenc.cpp @@ -643,6 +643,7 @@ static INT FDKaacEnc_writeExtensionPayload(HANDLE_FDK_BITSTREAM hBitStream, FDKwriteBits(hBitStream, *extPayloadData++, 4); /* nibble */ } extBitsUsed += 4; + FDK_FALLTHROUGH; case EXT_DYNAMIC_RANGE: case EXT_SBR_DATA: case EXT_SBR_DATA_CRC: @@ -690,6 +691,7 @@ static INT FDKaacEnc_writeExtensionPayload(HANDLE_FDK_BITSTREAM hBitStream, case EXT_FILL_DATA: fillByte = 0xA5; + FDK_FALLTHROUGH; case EXT_FIL: default: if (hBitStream != NULL) { diff --git a/libMpegTPDec/src/tpdec_asc.cpp b/libMpegTPDec/src/tpdec_asc.cpp index 8d411e8..6260cad 100644 --- a/libMpegTPDec/src/tpdec_asc.cpp +++ b/libMpegTPDec/src/tpdec_asc.cpp @@ -467,6 +467,7 @@ void CProgramConfig_GetDefault(CProgramConfig *pPce, const UINT channelConfig) { pPce->BackElementIsCpe[1] = 1; pPce->NumChannels += 1; pPce->NumEffectiveChannels += 1; + FDK_FALLTHROUGH; case 11: /* 3/0/3.1ch */ pPce->NumFrontChannelElements += 2; pPce->FrontElementIsCpe[0] = 0; @@ -482,25 +483,30 @@ void CProgramConfig_GetDefault(CProgramConfig *pPce, const UINT channelConfig) { /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ case 14: /* 2/0/0-3/0/2-0.1ch front height */ pPce->FrontElementHeightInfo[2] = 1; /* Top speaker */ - case 7: /* 5/0/2.1ch front */ + FDK_FALLTHROUGH; + case 7: /* 5/0/2.1ch front */ pPce->NumFrontChannelElements += 1; pPce->FrontElementIsCpe[2] = 1; pPce->NumChannels += 2; pPce->NumEffectiveChannels += 2; + FDK_FALLTHROUGH; case 6: /* 3/0/2.1ch */ pPce->NumLfeChannelElements += 1; pPce->NumChannels += 1; + FDK_FALLTHROUGH; case 5: /* 3/0/2.0ch */ case 4: /* 3/0/1.0ch */ pPce->NumBackChannelElements += 1; pPce->BackElementIsCpe[0] = (channelConfig > 4) ? 1 : 0; pPce->NumChannels += (channelConfig > 4) ? 2 : 1; pPce->NumEffectiveChannels += (channelConfig > 4) ? 2 : 1; + FDK_FALLTHROUGH; case 3: /* 3/0/0.0ch */ pPce->NumFrontChannelElements += 1; pPce->FrontElementIsCpe[1] = 1; pPce->NumChannels += 2; pPce->NumEffectiveChannels += 2; + FDK_FALLTHROUGH; case 1: /* 1/0/0.0ch */ pPce->NumFrontChannelElements += 1; pPce->FrontElementIsCpe[0] = 0; @@ -713,6 +719,7 @@ int CProgramConfig_LookupElement(CProgramConfig *pPce, UINT channelConfig, switch (elType) { case ID_CPE: isCpe = 1; + FDK_FALLTHROUGH; case ID_SCE: /* search in front channels */ for (i = 0; i < pPce->NumFrontChannelElements; i++) { @@ -1412,7 +1419,7 @@ static TRANSPORTDEC_ERROR EldSpecificConfig_Parse(CSAudioSpecificConfig *asc, break; } - /* fall-through */ + FDK_FALLTHROUGH; default: for (cnt = 0; cnt < eldExtLen; cnt++) { FDKreadBits(hBs, 8); @@ -2022,6 +2029,7 @@ static TRANSPORTDEC_ERROR AudioSpecificConfig_ExtensionParse( break; case ASCEXT_MPS: /* 0x76a */ if (self->m_extensionAudioObjectType == AOT_MPEGS) break; + FDK_FALLTHROUGH; case ASCEXT_LDMPS: /* 0x7cc */ if ((ascExtId == ASCEXT_LDMPS) && (self->m_extensionAudioObjectType == AOT_LD_MPEGS)) @@ -2498,6 +2506,7 @@ TRANSPORTDEC_ERROR DrmRawSdcAudioConfig_Parse( switch (audioMode) { case 1: /* parametric stereo */ self->m_psPresentFlag = 1; + FDK_FALLTHROUGH; case 0: /* mono */ self->m_channelConfiguration = 1; break; diff --git a/libMpegTPDec/src/tpdec_lib.cpp b/libMpegTPDec/src/tpdec_lib.cpp index 2a40187..1976cb9 100644 --- a/libMpegTPDec/src/tpdec_lib.cpp +++ b/libMpegTPDec/src/tpdec_lib.cpp @@ -956,6 +956,7 @@ static TRANSPORTDEC_ERROR transportDec_readHeader( hTp->parser.latm.m_audioMuxLengthBytes = syncLayerFrameBits; syncLayerFrameBits <<= 3; } + FDK_FALLTHROUGH; case TT_MP4_LATM_MCP1: case TT_MP4_LATM_MCP0: if (hTp->numberOfRawDataBlocks <= 0) { diff --git a/libMpegTPEnc/src/tpenc_lib.cpp b/libMpegTPEnc/src/tpenc_lib.cpp index a8567b9..14ea5fe 100644 --- a/libMpegTPEnc/src/tpenc_lib.cpp +++ b/libMpegTPEnc/src/tpenc_lib.cpp @@ -212,6 +212,7 @@ static INT getPceRepetitionRate(const CHANNEL_MODE channelMode, for potential matrix mixdown */ break; } + FDK_FALLTHROUGH; case TT_MP4_LOAS: /* PCE in ASC if chChonfig==0 */ case TT_MP4_LATM_MCP1: /* PCE in ASC if chChonfig==0 */ default: diff --git a/libPCMutils/src/pcmdmx_lib.cpp b/libPCMutils/src/pcmdmx_lib.cpp index b09a848..2070dbc 100644 --- a/libPCMutils/src/pcmdmx_lib.cpp +++ b/libPCMutils/src/pcmdmx_lib.cpp @@ -1043,6 +1043,7 @@ static PCMDMX_ERROR getMixFactors(const UCHAR inModeIsCfg, case CH_MODE_3_2_1_0: isValidCfg = FALSE; err = PCMDMX_INVALID_MODE; + FDK_FALLTHROUGH; case CH_MODE_3_0_3_1: /* chCfg 11 */ /* 6.1ch: C' = C; L' = L; R' = R; LFE' = LFE; Ls' = Ls*dmix_a_idx + Cs*dmix_b_idx; @@ -1080,9 +1081,11 @@ static PCMDMX_ERROR getMixFactors(const UCHAR inModeIsCfg, LEFT_REAR_CHANNEL, FL2FXCONST_DMX(0.5f), 1); dmxSetChannel(mixFactors, mixScales, LEFT_REAR_CHANNEL, LEFT_REAR_CHANNEL, FL2FXCONST_DMX(0.5f), 1); + FDK_FALLTHROUGH; case CH_MODE_5_2_1_0: isValidCfg = FALSE; err = PCMDMX_INVALID_MODE; + FDK_FALLTHROUGH; case CH_MODE_5_0_2_1: /* chCfg 7 || 14 */ if (inChCfg == 14) { /* 7.1ch Front Height: C' = C; Ls' = Ls; Rs' = Rs; LFE' = LFE; diff --git a/libSACdec/src/sac_dec_lib.cpp b/libSACdec/src/sac_dec_lib.cpp index 5ae89d1..e881599 100644 --- a/libSACdec/src/sac_dec_lib.cpp +++ b/libSACdec/src/sac_dec_lib.cpp @@ -1349,6 +1349,7 @@ int mpegSurroundDecoder_Parse(CMpegSurroundDecoder *pMpegSurroundDecoder, pMpegSurroundDecoder->mpegSurroundSscIsGlobalCfg = 0; } } + FDK_FALLTHROUGH; case MPEGS_ANCTYPE_FRAME: if (pMpegSurroundDecoder diff --git a/libSYS/include/machine_type.h b/libSYS/include/machine_type.h index be8de37..b66d5ad 100644 --- a/libSYS/include/machine_type.h +++ b/libSYS/include/machine_type.h @@ -379,6 +379,17 @@ it. Hence, a fully platform-independant way to use alignment is not supported. #define LNK_SECTION_L1_DATA_A #define LNK_SECTION_L1_DATA_B +/************************************************** + * Macros regarding static code analysis + **************************************************/ +#if defined(__clang__) +#define FDK_FALLTHROUGH [[clang::fallthrough]] +#elif defined(__GNUC__) && (__GNUC__ >= 7) +#define FDK_FALLTHROUGH __attribute__((fallthrough)) +#else +#define FDK_FALLTHROUGH +#endif + #ifdef _MSC_VER /* * Sometimes certain features are excluded from compilation and therefore the -- cgit v1.2.3 From 0cebd077b61cc0946ea4062bf816defdffaef72b Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 19 Oct 2018 16:41:27 +0200 Subject: Apply sbrDecoder_Parse() function for all explict SBR elements Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I97471c4db309307a21100f1d5d88d3c4e24d2670 --- libAACdec/src/aacdecoder.cpp | 20 ++++++++++++-------- libSBRdec/src/sbrdecoder.cpp | 5 +++++ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index c2ddc48..a529389 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -1111,12 +1111,13 @@ static AAC_DECODER_ERROR aacDecoder_ParseExplicitMpsAndSbr( /* get the remaining bits of this frame */ bitCnt = transportDec_GetAuBitsRemaining(self->hInput, 0); - if ((bitCnt > 0) && (self->flags[0] & AC_SBR_PRESENT) && + if ((self->flags[0] & AC_SBR_PRESENT) && (self->flags[0] & (AC_USAC | AC_RSVD50 | AC_ELD | AC_DRM))) { SBR_ERROR err = SBRDEC_OK; int chElIdx, numChElements = el_cnt[ID_SCE] + el_cnt[ID_CPE] + el_cnt[ID_LFE] + el_cnt[ID_USAC_SCE] + el_cnt[ID_USAC_CPE] + el_cnt[ID_USAC_LFE]; + INT bitCntTmp = bitCnt; if (self->flags[0] & AC_USAC) { chElIdx = numChElements - 1; @@ -1126,6 +1127,7 @@ static AAC_DECODER_ERROR aacDecoder_ParseExplicitMpsAndSbr( for (; chElIdx < numChElements; chElIdx += 1) { MP4_ELEMENT_ID sbrType; + SBR_ERROR errTmp; if (self->flags[0] & (AC_USAC)) { FDK_ASSERT((self->elements[element_index] == ID_USAC_SCE) || (self->elements[element_index] == ID_USAC_CPE)); @@ -1135,19 +1137,21 @@ static AAC_DECODER_ERROR aacDecoder_ParseExplicitMpsAndSbr( : ID_SCE; } else sbrType = self->elements[chElIdx]; - err = sbrDecoder_Parse(self->hSbrDecoder, bs, self->pDrmBsBuffer, - self->drmBsBufferSize, &bitCnt, -1, - self->flags[0] & AC_SBRCRC, sbrType, chElIdx, - self->flags[0], self->elFlags); - if (err != SBRDEC_OK) { - break; + errTmp = sbrDecoder_Parse(self->hSbrDecoder, bs, self->pDrmBsBuffer, + self->drmBsBufferSize, &bitCnt, -1, + self->flags[0] & AC_SBRCRC, sbrType, chElIdx, + self->flags[0], self->elFlags); + if (errTmp != SBRDEC_OK) { + err = errTmp; + bitCntTmp = bitCnt; + bitCnt = 0; } } switch (err) { case SBRDEC_PARSE_ERROR: /* Can not go on parsing because we do not know the length of the SBR extension data. */ - FDKpushFor(bs, bitCnt); + FDKpushFor(bs, bitCntTmp); bitCnt = 0; break; case SBRDEC_OK: diff --git a/libSBRdec/src/sbrdecoder.cpp b/libSBRdec/src/sbrdecoder.cpp index f40639b..4bc6f69 100644 --- a/libSBRdec/src/sbrdecoder.cpp +++ b/libSBRdec/src/sbrdecoder.cpp @@ -1150,6 +1150,11 @@ SBR_ERROR sbrDecoder_Parse(HANDLE_SBRDECODER self, HANDLE_FDK_BITSTREAM hBs, int lastSlot, lastHdrSlot = 0, thisHdrSlot = 0; + if (*count <= 0) { + setFrameErrorFlag(self->pSbrElement[elementIndex], FRAME_ERROR); + return SBRDEC_OK; + } + /* SBR sanity checks */ if (self == NULL) { errorStatus = SBRDEC_NOT_INITIALIZED; -- cgit v1.2.3 From 0ca9742ad246a1a0fe9835074c2f65e3de7b69dc Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 19 Oct 2018 16:45:56 +0200 Subject: Skip CRC check when flushing or concealment is applied Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I0f340eb0fe7f5ee8778a73fbe27199ba4915de70 --- libAACdec/src/aacdecoder.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index a529389..fffc1f0 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -3033,9 +3033,11 @@ LINKSPEC_CPP AAC_DECODER_ERROR CAacDecoder_DecodeFrame( aacChannels = 0; } - if (TRANSPORTDEC_OK != transportDec_CrcCheck(self->hInput)) { - ErrorStatus = AAC_DEC_CRC_ERROR; - self->frameOK = 0; + if (!(flags & (AACDEC_CONCEAL | AACDEC_FLUSH))) { + if (TRANSPORTDEC_OK != transportDec_CrcCheck(self->hInput)) { + ErrorStatus = AAC_DEC_CRC_ERROR; + self->frameOK = 0; + } } /* Ensure that in case of concealment a proper error status is set. */ -- cgit v1.2.3 From e81e8c2cc0b978e986fcb59dfca0ebfcd4db2a8e Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Thu, 20 Dec 2018 15:52:46 +0100 Subject: Do not support channel configuration change within PCE Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I94bddad6c88148dd01fff0850e261d98ef691793 --- libAACdec/src/aacdecoder.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'libAACdec/src/aacdecoder.cpp') diff --git a/libAACdec/src/aacdecoder.cpp b/libAACdec/src/aacdecoder.cpp index fffc1f0..8f03328 100644 --- a/libAACdec/src/aacdecoder.cpp +++ b/libAACdec/src/aacdecoder.cpp @@ -539,13 +539,7 @@ static int CProgramConfigElement_Read(HANDLE_FDK_BITSTREAM bs, sizeof(CProgramConfig)); /* Store the complete PCE */ pceStatus = 1; /* New PCE but no change of config */ break; - case 2: /* The number of channels are identical but not the config */ - if (channelConfig == 0) { - FDKmemcpy(pce, tmpPce, - sizeof(CProgramConfig)); /* Store the complete PCE */ - pceStatus = 2; /* Decoder needs re-configuration */ - } - break; + case 2: /* The number of channels are identical but not the config */ case -1: /* The channel configuration is completely different */ pceStatus = -1; /* Not supported! */ break; -- cgit v1.2.3