diff options
Diffstat (limited to 'libFDK/include')
-rw-r--r-- | libFDK/include/FDK_bitstream.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libFDK/include/FDK_bitstream.h b/libFDK/include/FDK_bitstream.h index d47a750..e75e570 100644 --- a/libFDK/include/FDK_bitstream.h +++ b/libFDK/include/FDK_bitstream.h @@ -245,7 +245,7 @@ FDK_INLINE UINT FDKreadBits(HANDLE_FDK_BITSTREAM hBitStream, if (hBitStream->BitsInCache <= numberOfBits) { - const UINT validBits = FDK_getValidBits (&hBitStream->hBitBuf) ; + const INT validBits = FDK_getValidBits (&hBitStream->hBitBuf) ; const INT freeBits = (CACHE_BITS-1) - hBitStream->BitsInCache ; const INT bitsToRead = (freeBits <= validBits) ? freeBits : validBits ; @@ -277,11 +277,15 @@ FDK_INLINE UINT FDKreadBit(HANDLE_FDK_BITSTREAM hBitStream) hBitStream->CacheWord = FDK_get32 (&hBitStream->hBitBuf); hBitStream->BitsInCache = CACHE_BITS; } - else + else if (validBits > 0) { hBitStream->CacheWord = FDK_get (&hBitStream->hBitBuf,validBits); hBitStream->BitsInCache = validBits; } + else + { + return 0; + } } hBitStream->BitsInCache--; @@ -305,7 +309,7 @@ inline UINT FDKread2Bits(HANDLE_FDK_BITSTREAM hBitStream) UINT BitsInCache = hBitStream->BitsInCache; if (BitsInCache < 2) /* Comparison changed from 'less-equal' to 'less' */ { - const UINT validBits = FDK_getValidBits (&hBitStream->hBitBuf) ; + const INT validBits = FDK_getValidBits (&hBitStream->hBitBuf) ; const INT freeBits = (CACHE_BITS-1) - BitsInCache ; const INT bitsToRead = (freeBits <= validBits) ? freeBits : validBits ; |