mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
bit_writer: convert VP8L macro values to immediates
allows the values to be used in preproc checks, fixing a -Wunreachable-code warning in 64-bit builds where VP8L_WRITER_BITS != 16 Change-Id: Ie98dff4e8ef896436557c64d5da2c5d70228a730
This commit is contained in:
parent
b969f888ab
commit
c2f9dc06cf
@ -202,10 +202,6 @@ void VP8BitWriterWipeOut(VP8BitWriter* const bw) {
|
||||
// when extra space is needed.
|
||||
#define MIN_EXTRA_SIZE (32768ULL)
|
||||
|
||||
#define VP8L_WRITER_BYTES ((int)sizeof(vp8l_wtype_t))
|
||||
#define VP8L_WRITER_BITS (VP8L_WRITER_BYTES * 8)
|
||||
#define VP8L_WRITER_MAX_BITS (8 * (int)sizeof(vp8l_atype_t))
|
||||
|
||||
// Returns 1 on success.
|
||||
static int VP8LBitWriterResize(VP8LBitWriter* const bw, size_t extra_size) {
|
||||
uint8_t* allocated_buf;
|
||||
@ -275,17 +271,17 @@ void VP8LPutBitsInternal(VP8LBitWriter* const bw, uint32_t bits, int n_bits) {
|
||||
vp8l_atype_t lbits = bw->bits_;
|
||||
int used = bw->used_;
|
||||
// Special case of overflow handling for 32bit accumulator (2-steps flush).
|
||||
if (VP8L_WRITER_BITS == 16) {
|
||||
if (used + n_bits >= VP8L_WRITER_MAX_BITS) {
|
||||
// Fill up all the VP8L_WRITER_MAX_BITS so it can be flushed out below.
|
||||
const int shift = VP8L_WRITER_MAX_BITS - used;
|
||||
lbits |= (vp8l_atype_t)bits << used;
|
||||
used = VP8L_WRITER_MAX_BITS;
|
||||
n_bits -= shift;
|
||||
bits >>= shift;
|
||||
assert(n_bits <= VP8L_WRITER_MAX_BITS);
|
||||
}
|
||||
#if VP8L_WRITER_BITS == 16
|
||||
if (used + n_bits >= VP8L_WRITER_MAX_BITS) {
|
||||
// Fill up all the VP8L_WRITER_MAX_BITS so it can be flushed out below.
|
||||
const int shift = VP8L_WRITER_MAX_BITS - used;
|
||||
lbits |= (vp8l_atype_t)bits << used;
|
||||
used = VP8L_WRITER_MAX_BITS;
|
||||
n_bits -= shift;
|
||||
bits >>= shift;
|
||||
assert(n_bits <= VP8L_WRITER_MAX_BITS);
|
||||
}
|
||||
#endif
|
||||
// If needed, make some room by flushing some bits out.
|
||||
while (used >= VP8L_WRITER_BITS) {
|
||||
if (bw->cur_ + VP8L_WRITER_BYTES > bw->end_) {
|
||||
|
@ -73,10 +73,16 @@ static WEBP_INLINE size_t VP8BitWriterSize(const VP8BitWriter* const bw) {
|
||||
typedef uint64_t vp8l_atype_t; // accumulator type
|
||||
typedef uint32_t vp8l_wtype_t; // writing type
|
||||
#define WSWAP HToLE32
|
||||
#define VP8L_WRITER_BYTES 4 // sizeof(vp8l_wtype_t)
|
||||
#define VP8L_WRITER_BITS 32 // 8 * sizeof(vp8l_wtype_t)
|
||||
#define VP8L_WRITER_MAX_BITS 64 // 8 * sizeof(vp8l_atype_t)
|
||||
#else
|
||||
typedef uint32_t vp8l_atype_t;
|
||||
typedef uint16_t vp8l_wtype_t;
|
||||
#define WSWAP HToLE16
|
||||
#define VP8L_WRITER_BYTES 2
|
||||
#define VP8L_WRITER_BITS 16
|
||||
#define VP8L_WRITER_MAX_BITS 32
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user