mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +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.
|
// when extra space is needed.
|
||||||
#define MIN_EXTRA_SIZE (32768ULL)
|
#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.
|
// Returns 1 on success.
|
||||||
static int VP8LBitWriterResize(VP8LBitWriter* const bw, size_t extra_size) {
|
static int VP8LBitWriterResize(VP8LBitWriter* const bw, size_t extra_size) {
|
||||||
uint8_t* allocated_buf;
|
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_;
|
vp8l_atype_t lbits = bw->bits_;
|
||||||
int used = bw->used_;
|
int used = bw->used_;
|
||||||
// Special case of overflow handling for 32bit accumulator (2-steps flush).
|
// Special case of overflow handling for 32bit accumulator (2-steps flush).
|
||||||
if (VP8L_WRITER_BITS == 16) {
|
#if VP8L_WRITER_BITS == 16
|
||||||
if (used + n_bits >= VP8L_WRITER_MAX_BITS) {
|
if (used + n_bits >= VP8L_WRITER_MAX_BITS) {
|
||||||
// Fill up all the VP8L_WRITER_MAX_BITS so it can be flushed out below.
|
// Fill up all the VP8L_WRITER_MAX_BITS so it can be flushed out below.
|
||||||
const int shift = VP8L_WRITER_MAX_BITS - used;
|
const int shift = VP8L_WRITER_MAX_BITS - used;
|
||||||
lbits |= (vp8l_atype_t)bits << used;
|
lbits |= (vp8l_atype_t)bits << used;
|
||||||
used = VP8L_WRITER_MAX_BITS;
|
used = VP8L_WRITER_MAX_BITS;
|
||||||
n_bits -= shift;
|
n_bits -= shift;
|
||||||
bits >>= shift;
|
bits >>= shift;
|
||||||
assert(n_bits <= VP8L_WRITER_MAX_BITS);
|
assert(n_bits <= VP8L_WRITER_MAX_BITS);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// If needed, make some room by flushing some bits out.
|
// If needed, make some room by flushing some bits out.
|
||||||
while (used >= VP8L_WRITER_BITS) {
|
while (used >= VP8L_WRITER_BITS) {
|
||||||
if (bw->cur_ + VP8L_WRITER_BYTES > bw->end_) {
|
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 uint64_t vp8l_atype_t; // accumulator type
|
||||||
typedef uint32_t vp8l_wtype_t; // writing type
|
typedef uint32_t vp8l_wtype_t; // writing type
|
||||||
#define WSWAP HToLE32
|
#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
|
#else
|
||||||
typedef uint32_t vp8l_atype_t;
|
typedef uint32_t vp8l_atype_t;
|
||||||
typedef uint16_t vp8l_wtype_t;
|
typedef uint16_t vp8l_wtype_t;
|
||||||
#define WSWAP HToLE16
|
#define WSWAP HToLE16
|
||||||
|
#define VP8L_WRITER_BYTES 2
|
||||||
|
#define VP8L_WRITER_BITS 16
|
||||||
|
#define VP8L_WRITER_MAX_BITS 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user