mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-14 21:09:55 +02:00
fix the bit-writer for lossless in 32bit mode
Sometimes, we can write 18bit or more at time, and it would overflow the 32bit accumulator. Also clarified the num-bits limitations (and exposed VP8L_MAX_NUM_BIT_READ in bit_reader.h) fixes http://code.google.com/p/webp/issues/detail?id=200 Seems a bit faster (use of local fields for bits_ / used_) also: added the __QNX__ bswap while at it. Change-Id: I876db93a931db15b083cf1d838c70105effa7167
This commit is contained in:
@ -316,6 +316,9 @@ static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
|
||||
// -----------------------------------------------------------------------------
|
||||
// Bitreader for lossless format
|
||||
|
||||
// maximum number of bits (inclusive) the bit-reader can handle:
|
||||
#define VP8L_MAX_NUM_BIT_READ 24
|
||||
|
||||
typedef uint64_t vp8l_val_t; // right now, this bit-reader can only use 64bit.
|
||||
|
||||
typedef struct {
|
||||
@ -336,9 +339,10 @@ void VP8LInitBitReader(VP8LBitReader* const br,
|
||||
void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
|
||||
const uint8_t* const buffer, size_t length);
|
||||
|
||||
// Reads the specified number of bits from Read Buffer.
|
||||
// Flags an error in case end_of_stream or n_bits is more than allowed limit.
|
||||
// Flags eos if this read attempt is going to cross the read buffer.
|
||||
// Reads the specified number of bits from read buffer.
|
||||
// Flags an error in case end_of_stream or n_bits is more than the allowed limit
|
||||
// of VP8L_MAX_NUM_BIT_READ (inclusive).
|
||||
// Flags eos_ if this read attempt is going to cross the read buffer.
|
||||
uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits);
|
||||
|
||||
// Return the prefetched bits, so they can be looked up.
|
||||
|
Reference in New Issue
Block a user