BE bitstream, flip bit encoding

This commit is contained in:
2022-09-10 11:31:09 +02:00
parent 629c5fce7d
commit 36cb6d77b5
2 changed files with 13 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
use crate::rans::{PROB_BITS, ONE_PROB};
use crate::rans::{ONE_PROB, PROB_BITS};
const INIT_PROB: u16 = 1 << (PROB_BITS - 1);
const UPDATE_RATE: u32 = 4;
@@ -33,7 +33,7 @@ impl<'a> Context<'a> {
pub fn update(&mut self, bit: bool) {
let old = self.state.contexts[self.index];
self.state.contexts[self.index] = if bit {
self.state.contexts[self.index] = if !bit {
old + ((ONE_PROB - old as u32 + UPDATE_ADD) >> UPDATE_RATE) as u8
} else {
old - ((old as u32 + UPDATE_ADD) >> UPDATE_RATE) as u8