]> git.nihav.org Git - nihav.git/commitdiff
vp7: fix intra prediction corner cases
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 6 Feb 2020 17:47:00 +0000 (18:47 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 6 Feb 2020 17:47:00 +0000 (18:47 +0100)
nihav-duck/src/codecs/vp7.rs

index 50fe5db8f983cae96cf3f4d8e5a1393c1bd8e581..59b1c22ea44e0e2d64390a90f5eebc0e88545cb3 100644 (file)
@@ -871,13 +871,14 @@ impl VP7Decoder {
                     }
                 }
             }
+            let tr_edge = if has_top { ydst[yoff - ystride + 15] } else { 0x80 };
             for y in 0..4 {
                 for x in 0..4 {
                     ipred_ctx_y.has_left = has_left || x > 0;
                     let bmode = self.ymodes[iidx + x];
                     let cur_yoff = yoff + x * 4;
-                    let has_tr = has_top && ((x < 3) || ((y == 0) && (mb_y < self.mb_w - 1)));
-                    let has_dl = ipred_ctx_y.has_left && (y < 3);
+                    let has_tr = ipred_ctx_y.has_top && ((x < 3) || ((y == 0) && (mb_y < self.mb_w - 1)));
+                    let has_dl = ipred_ctx_y.has_left && (x == 0) && (y < 3);
                     ipred_ctx_y.fill(ydst, cur_yoff, ystride,
                                      if has_tr { 8 } else { 4 },
                                      if has_dl { 8 } else { 4 });
@@ -890,6 +891,11 @@ impl VP7Decoder {
                             tr_save[x * 4 + i] = ipred_ctx_y.top[i + 4];
                         }
                     }
+                    if (mb_x == self.mb_w - 1) && has_top && (x == 3) {
+                        for i in 0..4 {
+                            ipred_ctx_y.top[i + 4] = tr_edge;
+                        }
+                    }
                     match bmode {
                         PredMode::DCPred => IPred4x4::ipred_dc(ydst, cur_yoff, ystride, ipred_ctx_y),
                         PredMode::TMPred => IPred4x4::ipred_tm(ydst, cur_yoff, ystride, ipred_ctx_y),