From 804f41ac64168ea32bdf822aba930b1cfa4e1646 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 19 Oct 2018 16:39:04 +0200 Subject: Add error path to generateFixFixOnly() Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I1f1767403068a9eafd7b20edb96669b71b0110fc --- libSBRdec/src/env_extr.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libSBRdec') diff --git a/libSBRdec/src/env_extr.cpp b/libSBRdec/src/env_extr.cpp index e6ae6dc..c72a7b6 100644 --- a/libSBRdec/src/env_extr.cpp +++ b/libSBRdec/src/env_extr.cpp @@ -1145,10 +1145,10 @@ static int sbrGetEnvelope( \brief Generates frame info for FIXFIXonly frame class used for low delay version - \return nothing + \return zero for error, one for correct. ****************************************************************************/ -static void generateFixFixOnly(FRAME_INFO *hSbrFrameInfo, int tranPosInternal, - int numberTimeSlots, const UINT flags) { +static int generateFixFixOnly(FRAME_INFO *hSbrFrameInfo, int tranPosInternal, + int numberTimeSlots, const UINT flags) { int nEnv, i, tranIdx; const int *pTable; @@ -1159,12 +1159,11 @@ static void generateFixFixOnly(FRAME_INFO *hSbrFrameInfo, int tranPosInternal, case 15: pTable = FDK_sbrDecoder_envelopeTable_15[tranPosInternal]; break; - default: - FDK_ASSERT(0); - /* fall through */ case 16: pTable = FDK_sbrDecoder_envelopeTable_16[tranPosInternal]; break; + default: + return 0; } /* look number of envelopes in table */ @@ -1187,6 +1186,8 @@ static void generateFixFixOnly(FRAME_INFO *hSbrFrameInfo, int tranPosInternal, /* nEnv is always > 1, so nNoiseEnvelopes is always 2 (IEC 14496-3 4.6.19.3.2) */ hSbrFrameInfo->nNoiseEnvelopes = 2; + + return 1; } /*! @@ -1230,7 +1231,9 @@ static int extractLowDelayGrid( } /* calculate borders according to the transient position */ - generateFixFixOnly(pFrameInfo, temp, numberTimeSlots, flags); + if (!generateFixFixOnly(pFrameInfo, temp, numberTimeSlots, flags)) { + return 0; + } /* decode freq res: */ for (k = 0; k < pFrameInfo->nEnvelopes; k++) { -- cgit v1.2.3 From 0271d6a6f3111be142456bf185e834aa5bc10309 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 19 Oct 2018 16:41:01 +0200 Subject: Call QMF transposer initialization only with successful SBR processing Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I8a8626a83e1bd87b2c14fad7c90174e4172c01b6 --- libSBRdec/src/hbe.cpp | 4 ++++ libSBRdec/src/sbr_dec.cpp | 2 +- libSBRdec/src/sbrdecoder.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'libSBRdec') diff --git a/libSBRdec/src/hbe.cpp b/libSBRdec/src/hbe.cpp index 53b21c9..1141e9c 100644 --- a/libSBRdec/src/hbe.cpp +++ b/libSBRdec/src/hbe.cpp @@ -1056,6 +1056,10 @@ SBR_ERROR QmfTransposerReInit(HANDLE_HBE_TRANSPOSER hQmfTransposer, const FIXP_QTW* tmp_t_sin; hQmfTransposer->startBand = FreqBandTable[0][0]; + FDK_ASSERT((!hQmfTransposer->bSbr41 && hQmfTransposer->startBand <= 32) || + (hQmfTransposer->bSbr41 && + hQmfTransposer->startBand <= + 16)); /* is checked by resetFreqBandTables() */ hQmfTransposer->stopBand = FreqBandTable[0][NSfb[0]]; hQmfTransposer->synthSize = diff --git a/libSBRdec/src/sbr_dec.cpp b/libSBRdec/src/sbr_dec.cpp index 2e18e6c..30611e7 100644 --- a/libSBRdec/src/sbr_dec.cpp +++ b/libSBRdec/src/sbr_dec.cpp @@ -1248,7 +1248,7 @@ resetSbrDec(HANDLE_SBR_DEC hSbrDec, HANDLE_SBR_HEADER_DATA hHeaderData, hSbrDec->savedStates = 0; - if (flags & SBRDEC_USAC_HARMONICSBR) { + if ((flags & SBRDEC_USAC_HARMONICSBR) && applySbrProc) { sbrError = QmfTransposerReInit(hSbrDec->hHBE, hHeaderData->freqBandData.freqBandTable, hHeaderData->freqBandData.nSfb); diff --git a/libSBRdec/src/sbrdecoder.cpp b/libSBRdec/src/sbrdecoder.cpp index e2455da..f40639b 100644 --- a/libSBRdec/src/sbrdecoder.cpp +++ b/libSBRdec/src/sbrdecoder.cpp @@ -1677,6 +1677,9 @@ static SBR_ERROR sbrDecoder_DecodeElement( /* reset */ if (hSbrHeader->status & SBRDEC_HDR_STAT_RESET) { int ch; + int applySbrProc = (hSbrHeader->syncState == SBR_ACTIVE || + (hSbrHeader->frameErrorFlag == 0 && + hSbrHeader->syncState == SBR_HEADER)); for (ch = 0; ch < numElementChannels; ch++) { SBR_ERROR errorStatusTmp = SBRDEC_OK; @@ -1688,7 +1691,9 @@ static SBR_ERROR sbrDecoder_DecodeElement( hSbrHeader->syncState = UPSAMPLING; } } - hSbrHeader->status &= ~SBRDEC_HDR_STAT_RESET; + if (applySbrProc) { + hSbrHeader->status &= ~SBRDEC_HDR_STAT_RESET; + } } /* decoding */ -- 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 'libSBRdec') 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