From 14833a644657637b06a511e4bf6db0ec9ba0ad12 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 12 May 2021 18:29:34 +0200 Subject: [PATCH] h264: use 6-bit state_idx in CABAC decoder (this eliminates boundary check) --- nihav-itu/src/codecs/h264/cabac_coder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.5