X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-itu%2Fsrc%2Fcodecs%2Fh264%2Fcabac_coder.rs;h=baa8caff030757b11561eb2869ba021e1fd91c48;hb=14833a644657637b06a511e4bf6db0ec9ba0ad12;hp=453ebc9fcb1d140565efcddb3404f861ab3fe6f3;hpb=696e4e20bf7167121352f247893370cb83213d5c;p=nihav.git diff --git a/nihav-itu/src/codecs/h264/cabac_coder.rs b/nihav-itu/src/codecs/h264/cabac_coder.rs index 453ebc9..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; @@ -143,13 +143,13 @@ impl<'a> CABAC<'a> { val_mps }; self.states[idx] = if bit == val_mps { - TRANS_IDX_MPS[state_idx] + TRANS_IDX_MPS[state_idx] + (if val_mps { 0x80 } else { 0 }) } else { if state_idx == 0 { val_mps = !val_mps; } - TRANS_IDX_LPS[state_idx] - } + (if val_mps { 0x80 } else { 0 }); + TRANS_IDX_LPS[state_idx] + (if val_mps { 0x80 } else { 0 }) + }; self.renorm(); bit } @@ -188,7 +188,7 @@ impl<'a> CABAC<'a> { } self.cod_range <<= shift; self.cod_offset <<= shift; - self.cod_offset |= u16::from(self.bitbuf >> (16 - shift)); + self.cod_offset |= self.bitbuf >> (16 - shift); self.bitbuf <<= shift; self.bits -= shift; }