From: Kostya Shishkov Date: Thu, 8 Jun 2017 16:06:00 +0000 (+0200) Subject: bitreader: read logic flags explicitly X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=0a1d94d94c8c0b1442d701afe6360fc141b4b0c6;p=nihav.git bitreader: read logic flags explicitly --- 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(); }