Fix assert in synchronization() for loas streams with multiple sub frames.

Bug: 131430997
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: Icb7d4b0b00a17367c8ec762b112fbb25268d9f67
This commit is contained in:
Fraunhofer IIS FDK 2019-08-09 17:06:06 +02:00 committed by Jean-Michel Trivi
parent cc825aecf5
commit dbfa1cd71b
1 changed files with 15 additions and 6 deletions

View File

@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Software License for The Fraunhofer FDK AAC Codec Library for Android 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. Forschung e.V. All rights reserved.
1. INTRODUCTION 1. INTRODUCTION
@ -663,10 +663,14 @@ TRANSPORTDEC_ERROR transportDec_FillData(const HANDLE_TRANSPORTDEC hTp,
if (*pBytesValid == 0) { if (*pBytesValid == 0) {
/* nothing to do */ /* nothing to do */
return TRANSPORTDEC_OK; return TRANSPORTDEC_OK;
} } else {
const int bytesValid = *pBytesValid;
if (hTp->numberOfRawDataBlocks <= 0) {
FDKfeedBuffer(hBs, pBuffer, bufferSize, pBytesValid); FDKfeedBuffer(hBs, pBuffer, bufferSize, pBytesValid);
if (hTp->numberOfRawDataBlocks > 0) {
hTp->globalFramePos += (bytesValid - *pBytesValid) * 8;
hTp->accessUnitAnchor[layer] = FDKgetValidBits(hBs);
}
} }
} }
@ -1151,6 +1155,11 @@ static TRANSPORTDEC_ERROR synchronization(HANDLE_TRANSPORTDEC hTp,
&rawDataBlockLength, &fTraverseMoreFrames, &rawDataBlockLength, &fTraverseMoreFrames,
&syncLayerFrameBits, &fConfigFound, &syncLayerFrameBits, &fConfigFound,
&headerBits); &headerBits);
if (headerBits > bitsAvail) {
err = (headerBits < (INT)hBs->hBitBuf.bufBits)
? TRANSPORTDEC_NOT_ENOUGH_BITS
: TRANSPORTDEC_SYNC_ERROR;
}
if (TPDEC_IS_FATAL_ERROR(err)) { if (TPDEC_IS_FATAL_ERROR(err)) {
/* Rewind - TPDEC_SYNCSKIP, in order to look for a synch one bit ahead /* Rewind - TPDEC_SYNCSKIP, in order to look for a synch one bit ahead
* next time. Ensure that the bit amount lands at a multiple of * next time. Ensure that the bit amount lands at a multiple of
@ -1181,8 +1190,6 @@ static TRANSPORTDEC_ERROR synchronization(HANDLE_TRANSPORTDEC hTp,
} }
if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) { if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) {
/* Enforce reading of new data */
hTp->numberOfRawDataBlocks = 0;
break; break;
} }
@ -1273,7 +1280,9 @@ static TRANSPORTDEC_ERROR synchronization(HANDLE_TRANSPORTDEC hTp,
/* Rewind for retry because of not enough bits */ /* Rewind for retry because of not enough bits */
if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) { if (err == TRANSPORTDEC_NOT_ENOUGH_BITS) {
FDKpushBack(hBs, headerBits); FDKpushBack(hBs, headerBits);
hTp->numberOfRawDataBlocks = numRawDataBlocksPrevious;
headerBits = 0; headerBits = 0;
rawDataBlockLength = rawDataBlockLengthPrevious;
} else { } else {
/* reset hold off frame counter */ /* reset hold off frame counter */
hTp->holdOffFrames = 0; hTp->holdOffFrames = 0;