]> git.nihav.org Git - nihav.git/commitdiff
codec_support/h263: pred_quant mode implies that AC coefficients should be predicted...
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 22 Dec 2020 11:22:56 +0000 (12:22 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 22 Dec 2020 11:22:56 +0000 (12:22 +0100)
nihav-codec-support/src/codecs/h263/decoder.rs

index 591840673f392214b3e3431139713004494d1559..6be437bd084e17906fcf238ee0f5018285251540 100644 (file)
@@ -295,6 +295,7 @@ impl H263BaseDecoder {
                 } else {
                     i16::from(binfo.get_q() * 2)
                 };
+            let qadd = (q + 1) >> 1;
             let quant_gray = 1024 / q;
             if apply_acpred && (binfo.acpred != ACPredMode::None) {
                 let has_b = (i == 1) || (i == 3) || !sstate.first_mb;
@@ -372,7 +373,19 @@ impl H263BaseDecoder {
                 for t in 0..8 { self.pred_coeffs[mb_pos].ver[i][t] = self.blk[i][t]; }
             }
             if apply_acpred {
-                self.blk[i][0] *= q;
+                let start = if binfo.get_q() < 8 {
+                        self.blk[i][0] <<= 3;
+                        1
+                    } else {
+                        0
+                    };
+                for el in self.blk[i].iter_mut().skip(start) {
+                    if *el > 0 {
+                        *el = *el * q + qadd;
+                    } else if *el < 0 {
+                        *el = *el * q - qadd;
+                    }
+                }
             }
             bdsp.idct(&mut self.blk[i]);
         }