mirror of
https://github.com/webmproject/libwebp.git
synced 2025-09-03 09:42:30 +02:00
dec/dsp/enc/utils,cosmetics: rm struct member '_' suffix
This is a follow up to:
ee8e8c62
Fix member naming for VP8LHistogram
This better matches Google style and clears some clang-tidy warnings.
This is the final change in this set. It is rather large due to the
shared dependencies between dec/enc.
Change-Id: I89de06b5653ae0bb627f904fa6060334831f7e3b
This commit is contained in:
@@ -53,33 +53,33 @@ void VP8LoadFinalBytes(VP8BitReader* const br);
|
||||
//------------------------------------------------------------------------------
|
||||
// Inlined critical functions
|
||||
|
||||
// makes sure br->value_ has at least BITS bits worth of data
|
||||
// makes sure br->value has at least BITS bits worth of data
|
||||
static WEBP_UBSAN_IGNORE_UNDEF WEBP_INLINE
|
||||
void VP8LoadNewBytes(VP8BitReader* WEBP_RESTRICT const br) {
|
||||
assert(br != NULL && br->buf_ != NULL);
|
||||
assert(br != NULL && br->buf != NULL);
|
||||
// Read 'BITS' bits at a time if possible.
|
||||
if (br->buf_ < br->buf_max_) {
|
||||
if (br->buf < br->buf_max) {
|
||||
// convert memory type to register type (with some zero'ing!)
|
||||
bit_t bits;
|
||||
#if defined(WEBP_USE_MIPS32)
|
||||
// This is needed because of un-aligned read.
|
||||
lbit_t in_bits;
|
||||
lbit_t* p_buf_ = (lbit_t*)br->buf_;
|
||||
lbit_t* p_buf = (lbit_t*)br->buf;
|
||||
__asm__ volatile(
|
||||
".set push \n\t"
|
||||
".set at \n\t"
|
||||
".set macro \n\t"
|
||||
"ulw %[in_bits], 0(%[p_buf_]) \n\t"
|
||||
"ulw %[in_bits], 0(%[p_buf]) \n\t"
|
||||
".set pop \n\t"
|
||||
: [in_bits]"=r"(in_bits)
|
||||
: [p_buf_]"r"(p_buf_)
|
||||
: [p_buf]"r"(p_buf)
|
||||
: "memory", "at"
|
||||
);
|
||||
#else
|
||||
lbit_t in_bits;
|
||||
memcpy(&in_bits, br->buf_, sizeof(in_bits));
|
||||
memcpy(&in_bits, br->buf, sizeof(in_bits));
|
||||
#endif
|
||||
br->buf_ += BITS >> 3;
|
||||
br->buf += BITS >> 3;
|
||||
#if !defined(WORDS_BIGENDIAN)
|
||||
#if (BITS > 32)
|
||||
bits = BSwap64(in_bits);
|
||||
@@ -96,8 +96,8 @@ void VP8LoadNewBytes(VP8BitReader* WEBP_RESTRICT const br) {
|
||||
bits = (bit_t)in_bits;
|
||||
if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS);
|
||||
#endif
|
||||
br->value_ = bits | (br->value_ << BITS);
|
||||
br->bits_ += BITS;
|
||||
br->value = bits | (br->value << BITS);
|
||||
br->bits += BITS;
|
||||
} else {
|
||||
VP8LoadFinalBytes(br); // no need to be inlined
|
||||
}
|
||||
@@ -108,28 +108,28 @@ static WEBP_INLINE int VP8GetBit(VP8BitReader* WEBP_RESTRICT const br,
|
||||
int prob, const char label[]) {
|
||||
// Don't move this declaration! It makes a big speed difference to store
|
||||
// 'range' *before* calling VP8LoadNewBytes(), even if this function doesn't
|
||||
// alter br->range_ value.
|
||||
range_t range = br->range_;
|
||||
if (br->bits_ < 0) {
|
||||
// alter br->range value.
|
||||
range_t range = br->range;
|
||||
if (br->bits < 0) {
|
||||
VP8LoadNewBytes(br);
|
||||
}
|
||||
{
|
||||
const int pos = br->bits_;
|
||||
const int pos = br->bits;
|
||||
const range_t split = (range * prob) >> 8;
|
||||
const range_t value = (range_t)(br->value_ >> pos);
|
||||
const range_t value = (range_t)(br->value >> pos);
|
||||
const int bit = (value > split);
|
||||
if (bit) {
|
||||
range -= split;
|
||||
br->value_ -= (bit_t)(split + 1) << pos;
|
||||
br->value -= (bit_t)(split + 1) << pos;
|
||||
} else {
|
||||
range = split + 1;
|
||||
}
|
||||
{
|
||||
const int shift = 7 ^ BitsLog2Floor(range);
|
||||
range <<= shift;
|
||||
br->bits_ -= shift;
|
||||
br->bits -= shift;
|
||||
}
|
||||
br->range_ = range - 1;
|
||||
br->range = range - 1;
|
||||
BT_TRACK(br);
|
||||
return bit;
|
||||
}
|
||||
@@ -139,18 +139,18 @@ static WEBP_INLINE int VP8GetBit(VP8BitReader* WEBP_RESTRICT const br,
|
||||
static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE
|
||||
int VP8GetSigned(VP8BitReader* WEBP_RESTRICT const br, int v,
|
||||
const char label[]) {
|
||||
if (br->bits_ < 0) {
|
||||
if (br->bits < 0) {
|
||||
VP8LoadNewBytes(br);
|
||||
}
|
||||
{
|
||||
const int pos = br->bits_;
|
||||
const range_t split = br->range_ >> 1;
|
||||
const range_t value = (range_t)(br->value_ >> pos);
|
||||
const int pos = br->bits;
|
||||
const range_t split = br->range >> 1;
|
||||
const range_t value = (range_t)(br->value >> pos);
|
||||
const int32_t mask = (int32_t)(split - value) >> 31; // -1 or 0
|
||||
br->bits_ -= 1;
|
||||
br->range_ += (range_t)mask;
|
||||
br->range_ |= 1;
|
||||
br->value_ -= (bit_t)((split + 1) & (uint32_t)mask) << pos;
|
||||
br->bits -= 1;
|
||||
br->range += (range_t)mask;
|
||||
br->range |= 1;
|
||||
br->value -= (bit_t)((split + 1) & (uint32_t)mask) << pos;
|
||||
BT_TRACK(br);
|
||||
return (v ^ mask) - mask;
|
||||
}
|
||||
@@ -160,19 +160,19 @@ static WEBP_INLINE int VP8GetBitAlt(VP8BitReader* WEBP_RESTRICT const br,
|
||||
int prob, const char label[]) {
|
||||
// Don't move this declaration! It makes a big speed difference to store
|
||||
// 'range' *before* calling VP8LoadNewBytes(), even if this function doesn't
|
||||
// alter br->range_ value.
|
||||
range_t range = br->range_;
|
||||
if (br->bits_ < 0) {
|
||||
// alter br->range value.
|
||||
range_t range = br->range;
|
||||
if (br->bits < 0) {
|
||||
VP8LoadNewBytes(br);
|
||||
}
|
||||
{
|
||||
const int pos = br->bits_;
|
||||
const int pos = br->bits;
|
||||
const range_t split = (range * prob) >> 8;
|
||||
const range_t value = (range_t)(br->value_ >> pos);
|
||||
const range_t value = (range_t)(br->value >> pos);
|
||||
int bit; // Don't use 'const int bit = (value > split);", it's slower.
|
||||
if (value > split) {
|
||||
range -= split + 1;
|
||||
br->value_ -= (bit_t)(split + 1) << pos;
|
||||
br->value -= (bit_t)(split + 1) << pos;
|
||||
bit = 1;
|
||||
} else {
|
||||
range = split;
|
||||
@@ -181,9 +181,9 @@ static WEBP_INLINE int VP8GetBitAlt(VP8BitReader* WEBP_RESTRICT const br,
|
||||
if (range <= (range_t)0x7e) {
|
||||
const int shift = kVP8Log2Range[range];
|
||||
range = kVP8NewRange[range];
|
||||
br->bits_ -= shift;
|
||||
br->bits -= shift;
|
||||
}
|
||||
br->range_ = range;
|
||||
br->range = range;
|
||||
BT_TRACK(br);
|
||||
return bit;
|
||||
}
|
||||
|
Reference in New Issue
Block a user