summaryrefslogtreecommitdiff
path: root/vendor/github.com/ulikunitz/xz/lzma/prob.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-07-08 07:55:30 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-19 18:43:32 +0000
commit98703eb204923f06555605c648fc165a55214520 (patch)
treea407bae8b3489d4f9b0f0d0f228658bbfe95a38e /vendor/github.com/ulikunitz/xz/lzma/prob.go
parentc020db8cd21cb221cfbe36b264e0ec02999596ed (diff)
downloadpodman-98703eb204923f06555605c648fc165a55214520.tar.gz
podman-98703eb204923f06555605c648fc165a55214520.tar.bz2
podman-98703eb204923f06555605c648fc165a55214520.zip
Vendor in latest code for storage,image, buildah
vendor in containers/storage vendor in containers/image vendor in projectatomic/buildah Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1114 Approved by: mheon
Diffstat (limited to 'vendor/github.com/ulikunitz/xz/lzma/prob.go')
-rw-r--r--vendor/github.com/ulikunitz/xz/lzma/prob.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/github.com/ulikunitz/xz/lzma/prob.go b/vendor/github.com/ulikunitz/xz/lzma/prob.go
new file mode 100644
index 000000000..24d50ec68
--- /dev/null
+++ b/vendor/github.com/ulikunitz/xz/lzma/prob.go
@@ -0,0 +1,53 @@
+// Copyright 2014-2017 Ulrich Kunitz. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package lzma
+
+// movebits defines the number of bits used for the updates of probability
+// values.
+const movebits = 5
+
+// probbits defines the number of bits of a probability value.
+const probbits = 11
+
+// probInit defines 0.5 as initial value for prob values.
+const probInit prob = 1 << (probbits - 1)
+
+// Type prob represents probabilities. The type can also be used to encode and
+// decode single bits.
+type prob uint16
+
+// Dec decreases the probability. The decrease is proportional to the
+// probability value.
+func (p *prob) dec() {
+ *p -= *p >> movebits
+}
+
+// Inc increases the probability. The Increase is proportional to the
+// difference of 1 and the probability value.
+func (p *prob) inc() {
+ *p += ((1 << probbits) - *p) >> movebits
+}
+
+// Computes the new bound for a given range using the probability value.
+func (p prob) bound(r uint32) uint32 {
+ return (r >> probbits) * uint32(p)
+}
+
+// Bits returns 1. One is the number of bits that can be encoded or decoded
+// with a single prob value.
+func (p prob) Bits() int {
+ return 1
+}
+
+// Encode encodes the least-significant bit of v. Note that the p value will be
+// changed.
+func (p *prob) Encode(e *rangeEncoder, v uint32) error {
+ return e.EncodeBit(v, p)
+}
+
+// Decode decodes a single bit. Note that the p value will change.
+func (p *prob) Decode(d *rangeDecoder) (v uint32, err error) {
+ return d.DecodeBit(p)
+}