aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2020-12-22 12:22:56 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2020-12-22 12:22:56 +0100
commit72a12906b921436dad6ff68326ad8b3e526fbe11 (patch)
treee17541b45876c9637b7b348c9e5d8d3be1f65e45
parent06480aad139b943f8fcef979b16af72036dd604a (diff)
downloadnihav-72a12906b921436dad6ff68326ad8b3e526fbe11.tar.gz
codec_support/h263: pred_quant mode implies that AC coefficients should be predicted before quantisation too
-rw-r--r--nihav-codec-support/src/codecs/h263/decoder.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/nihav-codec-support/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs
index 5918406..6be437b 100644
--- a/nihav-codec-support/src/codecs/h263/decoder.rs
+++ b/nihav-codec-support/src/codecs/h263/decoder.rs
@@ -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]);
}