mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 11:36:42 +01:00
z80 branch, but with original (slightly more accurate) prob update
This commit is contained in:
@@ -33,13 +33,12 @@ impl<'a> Context<'a> {
|
||||
|
||||
pub fn update(&mut self, bit: bool) {
|
||||
let old = self.state.contexts[self.index];
|
||||
let offset = if !bit {
|
||||
ONE_PROB as i32 >> UPDATE_RATE
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
if bit {
|
||||
self.state.contexts[self.index] =
|
||||
(offset + old as i32 - ((old as i32 + UPDATE_ADD) >> UPDATE_RATE)) as u8;
|
||||
old - ((old as i32 + UPDATE_ADD) >> UPDATE_RATE) as u8;
|
||||
} else {
|
||||
self.state.contexts[self.index] =
|
||||
old + (((ONE_PROB as i32 - old as i32) + UPDATE_ADD) >> UPDATE_RATE) as u8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user