From: Kostya Shishkov Date: Wed, 8 Apr 2020 08:15:36 +0000 (+0200) Subject: intel263: fix quantisation X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=1032dfe16237d2cefa04e616d8202222af790401;p=nihav.git intel263: fix quantisation --- diff --git a/nihav-indeo/src/codecs/intel263.rs b/nihav-indeo/src/codecs/intel263.rs index 42d0380..b2e58cb 100644 --- a/nihav-indeo/src/codecs/intel263.rs +++ b/nihav-indeo/src/codecs/intel263.rs @@ -79,7 +79,11 @@ impl<'a> Intel263BR<'a> { level = code.get_level(); last = code.is_last(); if br.read_bool()? { level = -level; } - level = (level * q) + q_add; + if level > 0 { + level = (level * q) + q_add; + } else { + level = (level * q) - q_add; + } } else { last = br.read_bool()?; run = br.read(6)? as u8; @@ -89,7 +93,11 @@ impl<'a> Intel263BR<'a> { let top = br.read_s(6)? as i16; level = (top << 5) | low; } - level = (level * q) + q_add; + if level > 0 { + level = (level * q) + q_add; + } else { + level = (level * q) - q_add; + } if level < -2048 { level = -2048; } if level > 2047 { level = 2047; } }