Refactor border treatment in loop restoration
Previously we were calling aom_extend_frame_borders to generate
extended pixels for use in loop-restoration. This generates quite a
large border, when we only need 3 pixels.
In addition, we were also calling extend_frame, which does the same
thing but with a smaller border, once (in the decoder) or multiple
times (in the encoder) per plane.
This patch tidies all of this up so that we only call extend_frame
once per plane, with the largest border size we need (3px).
It also adds two new #defines. RESTORATION_BORDER is the 3 pixel
border needed to do filtering for a processing
unit. RESTORATION_CTX_VERT is the number of rows saved for each stripe
when doing striped loop restoration.
Change-Id: I2c3ffcc19808f79db195f76d857e2f23da5d8a84
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index 26330d9..1d7c918 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -1137,20 +1137,6 @@
static const rest_unit_visitor_t funs[RESTORE_TYPES] = {
search_norestore, search_wiener, search_sgrproj, search_switchable
};
- static const int hborders[RESTORE_TYPES] = { 0, WIENER_HALFWIN,
- SGRPROJ_BORDER_HORZ, 0 };
- static const int vborders[RESTORE_TYPES] = { 0, WIENER_HALFWIN,
- SGRPROJ_BORDER_VERT, 0 };
-
- if (hborders[rtype] || vborders[rtype]) {
-#if CONFIG_HIGHBITDEPTH
- const int highbd = rsc->cm->use_highbitdepth;
-#else
- const int highbd = 0;
-#endif
- extend_frame(rsc->dgd_buffer, rsc->plane_width, rsc->plane_height,
- rsc->dgd_stride, hborders[rtype], vborders[rtype], highbd);
- }
reset_rsc(rsc);
av1_foreach_rest_unit_in_frame(rsc->cm, rsc->plane, rsc_on_tile, funs[rtype],
@@ -1186,6 +1172,15 @@
double best_cost = 0;
RestorationType best_rtype = RESTORE_NONE;
+#if CONFIG_HIGHBITDEPTH
+ const int highbd = rsc.cm->use_highbitdepth;
+#else
+ const int highbd = 0;
+#endif
+ extend_frame(rsc.dgd_buffer, rsc.plane_width, rsc.plane_height,
+ rsc.dgd_stride, RESTORATION_BORDER, RESTORATION_BORDER,
+ highbd);
+
for (RestorationType r = 0; r < num_rtypes; ++r) {
if ((force_restore_type != RESTORE_TYPES) && (r != RESTORE_NONE) &&
(r != force_restore_type))