random_utils.[hc],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.

Change-Id: Ib58d676fa79c5a4a95c676a98b62b548097f3c48
This commit is contained in:
James Zern 2025-04-14 12:35:17 -07:00
parent a99d0e6f04
commit 3a23b0f008
2 changed files with 14 additions and 14 deletions

View File

@ -31,12 +31,12 @@ static const uint32_t kRandomTable[VP8_RANDOM_TABLE_SIZE] = {
};
void VP8InitRandom(VP8Random* const rg, float dithering) {
memcpy(rg->tab_, kRandomTable, sizeof(rg->tab_));
rg->index1_ = 0;
rg->index2_ = 31;
rg->amp_ = (dithering < 0.0) ? 0
: (dithering > 1.0) ? (1 << VP8_RANDOM_DITHER_FIX)
: (uint32_t)((1 << VP8_RANDOM_DITHER_FIX) * dithering);
memcpy(rg->tab, kRandomTable, sizeof(rg->tab));
rg->index1 = 0;
rg->index2 = 31;
rg->amp = (dithering < 0.0) ? 0
: (dithering > 1.0) ? (1 << VP8_RANDOM_DITHER_FIX)
: (uint32_t)((1 << VP8_RANDOM_DITHER_FIX) * dithering);
}
//------------------------------------------------------------------------------

View File

@ -25,9 +25,9 @@ extern "C" {
#define VP8_RANDOM_TABLE_SIZE 55
typedef struct {
int index1_, index2_;
uint32_t tab_[VP8_RANDOM_TABLE_SIZE];
int amp_;
int index1, index2;
uint32_t tab[VP8_RANDOM_TABLE_SIZE];
int amp;
} VP8Random;
// Initializes random generator with an amplitude 'dithering' in range [0..1].
@ -40,11 +40,11 @@ static WEBP_INLINE int VP8RandomBits2(VP8Random* const rg, int num_bits,
int amp) {
int diff;
assert(num_bits + VP8_RANDOM_DITHER_FIX <= 31);
diff = rg->tab_[rg->index1_] - rg->tab_[rg->index2_];
diff = rg->tab[rg->index1] - rg->tab[rg->index2];
if (diff < 0) diff += (1u << 31);
rg->tab_[rg->index1_] = diff;
if (++rg->index1_ == VP8_RANDOM_TABLE_SIZE) rg->index1_ = 0;
if (++rg->index2_ == VP8_RANDOM_TABLE_SIZE) rg->index2_ = 0;
rg->tab[rg->index1] = diff;
if (++rg->index1 == VP8_RANDOM_TABLE_SIZE) rg->index1 = 0;
if (++rg->index2 == VP8_RANDOM_TABLE_SIZE) rg->index2 = 0;
// sign-extend, 0-center
diff = (int)((uint32_t)diff << 1) >> (32 - num_bits);
diff = (diff * amp) >> VP8_RANDOM_DITHER_FIX; // restrict range
@ -53,7 +53,7 @@ static WEBP_INLINE int VP8RandomBits2(VP8Random* const rg, int num_bits,
}
static WEBP_INLINE int VP8RandomBits(VP8Random* const rg, int num_bits) {
return VP8RandomBits2(rg, num_bits, rg->amp_);
return VP8RandomBits2(rg, num_bits, rg->amp);
}
#ifdef __cplusplus