From 0a1d94d94c8c0b1442d701afe6360fc141b4b0c6 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 8 Jun 2017 18:06:00 +0200 Subject: [PATCH] bitreader: read logic flags explicitly --- src/io/bitreader.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/io/bitreader.rs b/src/io/bitreader.rs index ba783eb..99bb34f 100644 --- a/src/io/bitreader.rs +++ b/src/io/bitreader.rs @@ -155,6 +155,16 @@ impl<'a> BitReader<'a> { Ok(res) } + pub fn read_bool(&mut self) -> BitReaderResult { + if self.bits < 1 { + if let Err(err) = self.refill() { return Err(err) } + if self.bits < 1 { return Err(BitstreamEnd) } + } + let res = self.read_cache(1); + self.skip_cache(1); + Ok(res == 1) + } + pub fn peek(&mut self, nbits: u8) -> u32 { if nbits > 32 { return 0 } if self.bits < nbits { let _ = self.refill(); } -- 2.39.5