Lines Matching +full:diff +full:- +full:tree
3 // Use of this source code is governed by a BSD-style license
5 // tree. An additional intellectual property rights grant can be found
7 // be found in the AUTHORS file in the root of the source tree.
8 // -----------------------------------------------------------------------------
10 // Pseudo-random utilities
24 #define VP8_RANDOM_DITHER_FIX 8 // fixed-point precision for dithering
36 // Returns a centered pseudo-random number with 'num_bits' amplitude.
37 // (uses D.Knuth's Difference-based random generator).
38 // 'amp' is in VP8_RANDOM_DITHER_FIX fixed-point precision.
41 int diff; in VP8RandomBits2() local
43 diff = rg->tab_[rg->index1_] - rg->tab_[rg->index2_]; in VP8RandomBits2()
44 if (diff < 0) diff += (1u << 31); in VP8RandomBits2()
45 rg->tab_[rg->index1_] = diff; in VP8RandomBits2()
46 if (++rg->index1_ == VP8_RANDOM_TABLE_SIZE) rg->index1_ = 0; in VP8RandomBits2()
47 if (++rg->index2_ == VP8_RANDOM_TABLE_SIZE) rg->index2_ = 0; in VP8RandomBits2()
48 // sign-extend, 0-center in VP8RandomBits2()
49 diff = (int)((uint32_t)diff << 1) >> (32 - num_bits); in VP8RandomBits2()
50 diff = (diff * amp) >> VP8_RANDOM_DITHER_FIX; // restrict range in VP8RandomBits2()
51 diff += 1 << (num_bits - 1); // shift back to 0.5-center in VP8RandomBits2()
52 return diff; in VP8RandomBits2()
56 return VP8RandomBits2(rg, num_bits, rg->amp_); in VP8RandomBits()