From: Kostya Shishkov Date: Sat, 5 Oct 2019 13:14:13 +0000 (+0200) Subject: vp56: move DCT coeffs base and probabilities to common X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=3f67638d8b7e163be9579e99a05f672f2ec4f144;p=nihav.git vp56: move DCT coeffs base and probabilities to common --- diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index 54c84a0..c626be8 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -381,17 +381,7 @@ fn map_mb_type(mbtype: VPMBType) -> usize { } } -pub const VP56_COEF_BASE: [i16; 6] = [ 5, 7, 11, 19, 35, 67 ]; pub fn expand_token_bc(bc: &mut BoolCoder, val_probs: &[u8; 11], token: u8, version: u8) -> i16 { - const COEF_ADD_PROBS: [[u8; 12]; 6] = [ - [ 159, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], - [ 165, 145, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], - [ 173, 148, 140, 128, 0, 0, 0, 0, 0, 0, 0, 0 ], - [ 176, 155, 140, 135, 128, 0, 0, 0, 0, 0, 0, 0 ], - [ 180, 157, 141, 134, 130, 128, 0, 0, 0, 0, 0, 0 ], - [ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 128 ], - ]; - let mut sign = false; let level; if token < TOKEN_LARGE { @@ -409,7 +399,7 @@ pub fn expand_token_bc(bc: &mut BoolCoder, val_probs: &[u8; 11], token: u8, vers sign = bc.read_bool(); } let mut add = 0i16; - let add_probs = &COEF_ADD_PROBS[cat]; + let add_probs = &VP56_COEF_ADD_PROBS[cat]; for prob in add_probs.iter() { if *prob == 128 { break; } add = (add << 1) | (bc.read_prob(*prob) as i16); diff --git a/nihav-duck/src/codecs/vpcommon.rs b/nihav-duck/src/codecs/vpcommon.rs index 0392a38..3caf569 100644 --- a/nihav-duck/src/codecs/vpcommon.rs +++ b/nihav-duck/src/codecs/vpcommon.rs @@ -70,6 +70,16 @@ impl VPShuffler { } } +pub const VP56_COEF_BASE: [i16; 6] = [ 5, 7, 11, 19, 35, 67 ]; +pub const VP56_COEF_ADD_PROBS: [[u8; 12]; 6] = [ + [ 159, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 165, 145, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 173, 148, 140, 128, 0, 0, 0, 0, 0, 0, 0, 0 ], + [ 176, 155, 140, 135, 128, 0, 0, 0, 0, 0, 0, 0 ], + [ 180, 157, 141, 134, 130, 128, 0, 0, 0, 0, 0, 0 ], + [ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 128 ], +]; + #[allow(dead_code)] pub struct BoolCoder<'a> { pub src: &'a [u8],