ref: d2c94ee1d8f4bc436d4cbb2632fc0b27d6966c62
parent: 4e22ef3a82e89c18927f3a810c7d585e5bd038a6
author: Luc Trudeau <[email protected]>
date: Mon Oct 7 15:53:26 EDT 2019
Don't backup pixels if next restoration unit is NONE
--- a/src/lr_apply_tmpl.c
+++ b/src/lr_apply_tmpl.c
@@ -236,9 +236,8 @@
const int shift_hor = 7 - ss_hor;
pixel pre_lr_border[2][128 + 8 /* maximum sbrow height is 128 + 8 rows offset */][4];
+ const Av1RestorationUnit *lr[2];
- int unit_w = unit_size, bit = 0;
-
enum LrEdgeFlags edges = (y > 0 ? LR_HAVE_TOP : 0) | LR_HAVE_RIGHT |
(row_h < h ? LR_HAVE_BOTTOM : 0);
@@ -248,26 +247,27 @@
aligned_unit_pos <<= ss_ver;
const int sb_idx = (aligned_unit_pos >> 7) * f->sr_sb128w;
const int unit_idx = ((aligned_unit_pos >> 6) & 1) << 1;
- for (int x = 0; x < w; x += unit_w, edges |= LR_HAVE_LEFT, bit ^= 1) {
- if (x + max_unit_size > w) {
- unit_w = w - x;
- edges &= ~LR_HAVE_RIGHT;
- }
-
- // Based on the position of the restoration unit, find the corresponding
- // AV1Filter unit.
- const int u_idx = unit_idx + ((x >> (shift_hor - 1)) & 1);
- const Av1RestorationUnit *const lr =
- &f->lf.lr_mask[sb_idx + (x >> shift_hor)].lr[plane][u_idx];
-
- // FIXME Don't backup if the next restoration unit is RESTORE_NONE
- if (edges & LR_HAVE_RIGHT) {
- backup4xU(pre_lr_border[bit], p + unit_w - 4, p_stride, row_h - y);
- }
- if (lr->type != DAV1D_RESTORATION_NONE) {
- lr_stripe(f, p, pre_lr_border[!bit], x, y, plane, unit_w, row_h, lr, edges);
- }
- p += unit_w;
+ lr[0] = &f->lf.lr_mask[sb_idx].lr[plane][unit_idx];
+ int restore = lr[0]->type != DAV1D_RESTORATION_NONE;
+ int x = 0, bit = 0;
+ for (; x + max_unit_size <= w; p += unit_size, edges |= LR_HAVE_LEFT, bit ^= 1) {
+ const int next_x = x + unit_size;
+ const int next_u_idx = unit_idx + ((next_x >> (shift_hor - 1)) & 1);
+ lr[!bit] =
+ &f->lf.lr_mask[sb_idx + (next_x >> shift_hor)].lr[plane][next_u_idx];
+ const int restore_next = lr[!bit]->type != DAV1D_RESTORATION_NONE;
+ if (restore_next)
+ backup4xU(pre_lr_border[bit], p + unit_size - 4, p_stride, row_h - y);
+ if (restore)
+ lr_stripe(f, p, pre_lr_border[!bit], x, y, plane, unit_size, row_h,
+ lr[bit], edges);
+ x = next_x;
+ restore = restore_next;
+ }
+ if (restore) {
+ edges &= ~LR_HAVE_RIGHT;
+ const int unit_w = w - x;
+ lr_stripe(f, p, pre_lr_border[!bit], x, y, plane, unit_w, row_h, lr[bit], edges);
}
}