summaryrefslogtreecommitdiffstats
path: root/libFDK
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2018-06-08 18:03:16 +0200
committerWolf-Dieter Enders <grzwolf1@gmail.com>2018-11-18 22:07:46 +0100
commitac21d11767b75a2aa34d92d5f384d6e4b26ef683 (patch)
treecb1cc91f62d182b702bcfe9146d68cc925add6dc /libFDK
parent70d7432d80779dfd5b61d0b6b6c45c18a2701066 (diff)
downloadandroid_external_aac-ac21d11767b75a2aa34d92d5f384d6e4b26ef683.tar.gz
android_external_aac-ac21d11767b75a2aa34d92d5f384d6e4b26ef683.tar.bz2
android_external_aac-ac21d11767b75a2aa34d92d5f384d6e4b26ef683.zip
Prevent bit buffer counter overflow.
While long-term test we discovered a bit counter overflow in the bit buffer. The bit buffer state was only used by HCR and RVLC tool and can easily be substituted with FDKgetValidBits() call. The following patch completely removes the bit counter and all its obsolete functions. Bug: 112662184 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Icee0519d26a2aa62367d2dece59cd3d60ffcade7 (cherry picked from commit 15292f7e9620caf9e8df26a62efc2a2891ea822e)
Diffstat (limited to 'libFDK')
-rw-r--r--libFDK/include/FDK_bitbuffer.h6
-rw-r--r--libFDK/include/FDK_bitstream.h51
-rw-r--r--libFDK/src/FDK_bitbuffer.cpp35
3 files changed, 0 insertions, 92 deletions
diff --git a/libFDK/include/FDK_bitbuffer.h b/libFDK/include/FDK_bitbuffer.h
index 65fa04b..c2c3a30 100644
--- a/libFDK/include/FDK_bitbuffer.h
+++ b/libFDK/include/FDK_bitbuffer.h
@@ -100,7 +100,6 @@ typedef struct
UINT ValidBits;
UINT ReadOffset;
UINT WriteOffset;
- UINT BitCnt;
UINT BitNdx;
UCHAR *Buffer;
@@ -142,14 +141,9 @@ void FDK_putBwd (HANDLE_FDK_BITBUF hBitBuffer, UINT value, const UINT n
void FDK_pushBack (HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits, UCHAR config) ;
void FDK_pushForward (HANDLE_FDK_BITBUF hBitBuffer, const UINT numberOfBits, UCHAR config) ;
-void FDK_byteAlign (HANDLE_FDK_BITBUF hBitBuffer, UCHAR config) ;
-
UINT FDK_getValidBits (HANDLE_FDK_BITBUF hBitBuffer) ;
INT FDK_getFreeBits (HANDLE_FDK_BITBUF hBitBuffer) ;
-void FDK_setBitCnt (HANDLE_FDK_BITBUF hBitBuffer, const UINT value) ;
-INT FDK_getBitCnt (HANDLE_FDK_BITBUF hBitBuffer) ;
-
void FDK_Feed (HANDLE_FDK_BITBUF hBitBuffer, UCHAR inputBuffer [],
const UINT bufferSize, UINT *bytesValid) ;
diff --git a/libFDK/include/FDK_bitstream.h b/libFDK/include/FDK_bitstream.h
index fc8d7de..fc564fd 100644
--- a/libFDK/include/FDK_bitstream.h
+++ b/libFDK/include/FDK_bitstream.h
@@ -415,22 +415,6 @@ FDK_INLINE void FDKsyncCacheBwd (HANDLE_FDK_BITSTREAM hBitStream)
/**
- * \brief Byte Alignment Function.
- * This function performs the byte_alignment() syntactic function on the input stream,
- * i.e. some bits will be discarded/padded so that the next bits to be read/written will
- * be aligned on a byte boundary with respect to the bit position 0.
- *
- * \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \return void
- */
-FDK_INLINE void FDKbyteAlign (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache (hBitStream) ;
- FDK_byteAlign (&hBitStream->hBitBuf, (UCHAR)hBitStream->ConfigCache) ;
-}
-
-
-/**
* \brief Byte Alignment Function with anchor
* This function performs the byte_alignment() syntactic function on the input stream,
* i.e. some bits will be discarded so that the next bits to be read/written would be aligned
@@ -532,41 +516,6 @@ FDK_INLINE INT FDKgetFreeBits (HANDLE_FDK_BITSTREAM hBitStream)
}
/**
- * \brief reset bitcounter in bitBuffer to zero.
- * \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \return void
- */
-FDK_INLINE void FDKresetBitCnt (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache (hBitStream) ;
- FDK_setBitCnt (&hBitStream->hBitBuf, 0) ;
-}
-
-/**
- * \brief set bitcoutner in bitBuffer to given value.
- * \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \param value new value to be assigned to the bit counter
- * \return void
- */
-FDK_INLINE void FDKsetBitCnt (HANDLE_FDK_BITSTREAM hBitStream, UINT value)
-{
- FDKsyncCache (hBitStream) ;
- FDK_setBitCnt (&hBitStream->hBitBuf, value) ;
-}
-
-/**
- * \brief get bitcounter state from bitBuffer.
- * \param hBitStream HANDLE_FDK_BITSTREAM handle
- * \return current bit counter value
- */
-FDK_INLINE INT FDKgetBitCnt (HANDLE_FDK_BITSTREAM hBitStream)
-{
- FDKsyncCache(hBitStream) ;
- return FDK_getBitCnt(&hBitStream->hBitBuf) ;
-}
-
-
-/**
* \brief Fill the BitBuffer with a number of input bytes from external source.
* The bytesValid variable returns the number of ramaining valid bytes in extern inputBuffer.
*
diff --git a/libFDK/src/FDK_bitbuffer.cpp b/libFDK/src/FDK_bitbuffer.cpp
index 680ceae..f0f0ac6 100644
--- a/libFDK/src/FDK_bitbuffer.cpp
+++ b/libFDK/src/FDK_bitbuffer.cpp
@@ -128,7 +128,6 @@ void FDK_InitBitBuffer (HANDLE_FDK_BITBUF hBitBuf, UCHAR *pBuffer,
hBitBuf->ValidBits = validBits ;
hBitBuf->ReadOffset = 0 ;
hBitBuf->WriteOffset = 0 ;
- hBitBuf->BitCnt = 0 ;
hBitBuf->BitNdx = 0 ;
hBitBuf->Buffer = pBuffer ;
@@ -151,7 +150,6 @@ void FDK_ResetBitBuffer ( HANDLE_FDK_BITBUF hBitBuf )
hBitBuf->ValidBits = 0 ;
hBitBuf->ReadOffset = 0 ;
hBitBuf->WriteOffset = 0 ;
- hBitBuf->BitCnt = 0 ;
hBitBuf->BitNdx = 0 ;
}
@@ -161,7 +159,6 @@ INT FDK_get (HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits)
UINT bitOffset = hBitBuf->BitNdx & 0x07 ;
hBitBuf->BitNdx = (hBitBuf->BitNdx + numberOfBits) & (hBitBuf->bufBits - 1) ;
- hBitBuf->BitCnt += numberOfBits ;
hBitBuf->ValidBits -= numberOfBits ;
UINT byteMask = hBitBuf->bufSize - 1 ;
@@ -186,7 +183,6 @@ INT FDK_get32 (HANDLE_FDK_BITBUF hBitBuf)
if (BitNdx <= hBitBuf->bufBits)
{
hBitBuf->BitNdx = BitNdx;
- hBitBuf->BitCnt += 32;
hBitBuf->ValidBits -= 32;
UINT byteOffset = (BitNdx-1) >> 3;
@@ -219,7 +215,6 @@ INT FDK_getBwd (HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits)
int i;
hBitBuf->BitNdx = (hBitBuf->BitNdx - numberOfBits) & (hBitBuf->bufBits - 1) ;
- hBitBuf->BitCnt -= numberOfBits ;
hBitBuf->ValidBits += numberOfBits ;
UINT tx = hBitBuf->Buffer [(byteOffset-3) & byteMask] << 24 |
@@ -253,7 +248,6 @@ void FDK_put (HANDLE_FDK_BITBUF hBitBuf, UINT value, const UINT numberOfBits)
UINT bitOffset = hBitBuf->BitNdx & 0x07 ;
hBitBuf->BitNdx = (hBitBuf->BitNdx + numberOfBits) & (hBitBuf->bufBits - 1) ;
- hBitBuf->BitCnt += numberOfBits ;
hBitBuf->ValidBits += numberOfBits ;
UINT byteMask = hBitBuf->bufSize - 1 ;
@@ -284,7 +278,6 @@ void FDK_putBwd (HANDLE_FDK_BITBUF hBitBuf, UINT value, const UINT numberOfBits)
int i;
hBitBuf->BitNdx = (hBitBuf->BitNdx - numberOfBits) & (hBitBuf->bufBits - 1) ;
- hBitBuf->BitCnt -= numberOfBits ;
hBitBuf->ValidBits -= numberOfBits ;
/* in place turn around */
@@ -313,34 +306,17 @@ void FDK_putBwd (HANDLE_FDK_BITBUF hBitBuf, UINT value, const UINT numberOfBits)
void FDK_pushBack (HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits, UCHAR config)
{
- hBitBuf->BitCnt -= numberOfBits ;
hBitBuf->ValidBits += (config==0) ? numberOfBits : (-(INT)numberOfBits) ;
hBitBuf->BitNdx = (hBitBuf->BitNdx - numberOfBits) & (hBitBuf->bufBits - 1) ;
}
void FDK_pushForward (HANDLE_FDK_BITBUF hBitBuf, const UINT numberOfBits, UCHAR config)
{
- hBitBuf->BitCnt += numberOfBits ;
hBitBuf->ValidBits -= (config==0) ? numberOfBits : (-(INT)numberOfBits) ;
hBitBuf->BitNdx = (hBitBuf->BitNdx + numberOfBits) & (hBitBuf->bufBits - 1) ;
}
-void FDK_byteAlign (HANDLE_FDK_BITBUF hBitBuf, UCHAR config)
-{
- INT alignment = hBitBuf->BitCnt & 0x07 ;
-
- if (alignment)
- {
- if (config==0)
- FDK_pushForward (hBitBuf, 8 - alignment, config) ; /* BS_READER */
- else
- FDK_put (hBitBuf,0 , 8 - alignment) ; /* BS_WRITER */
- }
-
- hBitBuf->BitCnt = 0 ;
-}
-
UINT FDK_getValidBits (HANDLE_FDK_BITBUF hBitBuf)
{
return hBitBuf->ValidBits;
@@ -351,16 +327,6 @@ INT FDK_getFreeBits (HANDLE_FDK_BITBUF hBitBuf)
return (hBitBuf->bufBits - hBitBuf->ValidBits) ;
}
-void FDK_setBitCnt (HANDLE_FDK_BITBUF hBitBuf, const UINT value)
-{
- hBitBuf->BitCnt = value ;
-}
-
-INT FDK_getBitCnt (HANDLE_FDK_BITBUF hBitBuf)
-{
- return hBitBuf->BitCnt ;
-}
-
void FDK_Feed(HANDLE_FDK_BITBUF hBitBuf,
UCHAR *RESTRICT inputBuffer,
const UINT bufferSize,
@@ -408,7 +374,6 @@ void CopyAlignedBlock (HANDLE_FDK_BITBUF h_BitBufSrc, UCHAR *RESTRICT dstBuffer,
bToRead <<= 3 ;
h_BitBufSrc->BitNdx = (h_BitBufSrc->BitNdx + bToRead) & (h_BitBufSrc->bufBits - 1) ;
- h_BitBufSrc->BitCnt += bToRead ;
h_BitBufSrc->ValidBits -= bToRead ;
}