From: Kostya Shishkov Date: Sun, 26 Nov 2017 17:53:38 +0000 (+0100) Subject: rv20: use proper DC quant in AIC mode X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=de919937c067ff7ba0e0f138d5c9bd524dbcaff4;p=nihav.git rv20: use proper DC quant in AIC mode --- diff --git a/src/codecs/h263/data.rs b/src/codecs/h263/data.rs index 98c0a81..928b1cf 100644 --- a/src/codecs/h263/data.rs +++ b/src/codecs/h263/data.rs @@ -4,6 +4,10 @@ use io::codebook::CodebookDescReader; pub const H263_SCALES: &[u8] = &[ 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15 ]; +#[allow(dead_code)] +pub const H263_DC_SCALES: &[u8] = &[ + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62 ]; + pub const H263_ZIGZAG: &[usize] = &[ 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, diff --git a/src/codecs/h263/rv20.rs b/src/codecs/h263/rv20.rs index 753a166..6836759 100644 --- a/src/codecs/h263/rv20.rs +++ b/src/codecs/h263/rv20.rs @@ -137,7 +137,11 @@ impl<'a> RealVideo20BR<'a> { level = code.get_level(); last = code.is_last(); if br.read_bool().unwrap() { level = -level; } - level = (level * q) + q_add; + if (idx != 0) || !sstate.is_iframe { + level = (level * q) + q_add; + } else { + level = level * (H263_DC_SCALES[quant as usize] as i16); + } } else { last = br.read_bool().unwrap(); run = br.read(6).unwrap() as u8; @@ -147,7 +151,11 @@ impl<'a> RealVideo20BR<'a> { let top = br.read_s(6).unwrap() as i16; level = (top << 5) | low; } - level = (level * q) + q_add; + if (idx != 0) || !sstate.is_iframe { + level = (level * q) + q_add; + } else { + level = level * (H263_DC_SCALES[quant as usize] as i16); + } if level < -2048 { level = -2048; } if level > 2047 { level = 2047; } } @@ -487,6 +495,6 @@ mod test { use test::dec_video::test_file_decoding; #[test] fn test_rv20() { - test_file_decoding("realmedia", "assets/RV/rv20_cook_640x352_realproducer_plus_8.51.rm", /*None*/Some(1000), true, false, Some("rv20")); + test_file_decoding("realmedia", "assets/RV/rv20_cook_640x352_realproducer_plus_8.51.rm", /*None*/Some(1000), true, false, Some("rv20")); } }