]> git.nihav.org Git - nihav.git/commitdiff
intel263: fix quantisation
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 8 Apr 2020 08:15:36 +0000 (10:15 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 8 Apr 2020 08:15:36 +0000 (10:15 +0200)
nihav-indeo/src/codecs/intel263.rs

index 42d0380a573d06f8855a000b81597da5b34b0300..b2e58cbfdadf75df3eba76b091ae6a0584fe97e9 100644 (file)
@@ -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; }
             }