From 1032dfe16237d2cefa04e616d8202222af790401 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Wed, 8 Apr 2020 10:15:36 +0200 Subject: [PATCH] intel263: fix quantisation --- nihav-indeo/src/codecs/intel263.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; } } -- 2.39.5