mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 19:46:42 +01:00
add parameter to print out margin for overlapped unpacking
This commit is contained in:
10
src/rans.rs
10
src/rans.rs
@@ -149,6 +149,7 @@ impl EntropyCoder for CostCounter {
|
||||
|
||||
pub struct RansDecoder<'a> {
|
||||
data: &'a [u8],
|
||||
pos: usize,
|
||||
state: u32,
|
||||
use_bitstream: bool,
|
||||
byte: u8,
|
||||
@@ -163,6 +164,7 @@ impl<'a> RansDecoder<'a> {
|
||||
pub fn new(data: &'a [u8], config: &Config) -> RansDecoder<'a> {
|
||||
RansDecoder {
|
||||
data,
|
||||
pos: 0,
|
||||
state: 0,
|
||||
use_bitstream: config.use_bitstream,
|
||||
byte: 0,
|
||||
@@ -172,6 +174,10 @@ impl<'a> RansDecoder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pos(&self) -> usize {
|
||||
self.pos
|
||||
}
|
||||
|
||||
pub fn decode_with_context(&mut self, context: &mut Context) -> bool {
|
||||
let bit = self.decode_bit(context.prob());
|
||||
context.update(bit);
|
||||
@@ -183,8 +189,8 @@ impl<'a> RansDecoder<'a> {
|
||||
if self.use_bitstream {
|
||||
while self.state < 32768 {
|
||||
if self.bits_left == 0 {
|
||||
self.byte = self.data[0];
|
||||
self.data = &self.data[1..];
|
||||
self.byte = self.data[self.pos];
|
||||
self.pos += 1;
|
||||
self.bits_left = 8;
|
||||
}
|
||||
if self.bitstream_is_big_endian {
|
||||
|
||||
Reference in New Issue
Block a user