From: Kostya Shishkov Date: Wed, 12 May 2021 16:29:34 +0000 (+0200) Subject: h264: use 6-bit state_idx in CABAC decoder (this eliminates boundary check) X-Git-Url: https://git.nihav.org/?p=nihav.git;a=commitdiff_plain;h=14833a644657637b06a511e4bf6db0ec9ba0ad12 h264: use 6-bit state_idx in CABAC decoder (this eliminates boundary check) --- diff --git a/nihav-itu/src/codecs/h264/cabac_coder.rs b/nihav-itu/src/codecs/h264/cabac_coder.rs index 0e14809..baa8caf 100644 --- a/nihav-itu/src/codecs/h264/cabac_coder.rs +++ b/nihav-itu/src/codecs/h264/cabac_coder.rs @@ -131,7 +131,7 @@ impl<'a> CABAC<'a> { } pub fn decode_bit(&mut self, idx: usize) -> bool { let mut val_mps = (self.states[idx] & 0x80) != 0; - let state_idx = (self.states[idx] & 0x7F) as usize; + let state_idx = (self.states[idx] & 0x3F) as usize; let range_idx = ((self.cod_range >> 6) & 3) as usize; let range_lps = u16::from(RANGE_TBL_LPS[range_idx + state_idx * 4]); self.cod_range -= range_lps;