Remove RestorationInternal from AV1_COMMON
The bits needed by striped loop restoration are now in
RestorationInfo (which also gets rid of a rather ugly extra
index).
The scratch buffer that's used for self-guided restoration has been
moved up to its own variable (rst_tmpbuf).
All the rest of the fields are now safely hidden inside restoration.c
This patch also does a big cleanup of the initialisation code in
loop_restoration_rows: it doesn't need to be as repetitive now that
the fields of YV12_BUFFER_CONFIG can be accessed by plane index.
Change-Id: Iba7edc0f94041fa053cdeb3d6cf35d84a05dbfaf
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index a6f949d..e03d832 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4294,19 +4294,34 @@
cm->subsampling_x, cm->subsampling_y, cm->rst_info);
for (int i = 0; i < MAX_MB_PLANE; ++i)
cm->rst_info[i].frame_restoration_type = RESTORE_NONE;
- av1_alloc_restoration_buffers(cm);
- for (int i = 0; i < MAX_MB_PLANE; ++i) {
- cpi->rst_search[i].restoration_tilesize =
- cm->rst_info[i].restoration_tilesize;
- cpi->rst_search[i].procunit_width = cm->rst_info[i].procunit_width;
- cpi->rst_search[i].procunit_height = cm->rst_info[i].procunit_height;
- av1_alloc_restoration_struct(cm, &cpi->rst_search[i],
+
#if CONFIG_FRAME_SUPERRES
- cm->superres_upscaled_width,
- cm->superres_upscaled_height);
+ const int frame_width = cm->superres_upscaled_width;
+ const int frame_height = cm->superres_upscaled_height;
#else
- cm->width, cm->height);
-#endif // CONFIG_FRAME_SUPERRES
+ const int frame_width = cm->width;
+ const int frame_height = cm->height;
+#endif
+
+ av1_alloc_restoration_buffers(cm);
+
+ // Set up the rst_search RestorationInfo structures. These are the same as
+ // the rst_info ones except need their own arrays of types and coefficients,
+ // allocated in av1_alloc_restoration_struct.
+ for (int i = 0; i < MAX_MB_PLANE; ++i) {
+ RestorationInfo *search = &cpi->rst_search[i];
+ RestorationInfo *rsi = &cm->rst_info[i];
+
+ search->restoration_tilesize = rsi->restoration_tilesize;
+ search->procunit_width = rsi->procunit_width;
+ search->procunit_height = rsi->procunit_height;
+ av1_alloc_restoration_struct(cm, search, frame_width, frame_height);
+#if CONFIG_STRIPED_LOOP_RESTORATION
+ // We can share boundary buffers between the search info and the main one
+ search->stripe_boundary_above = rsi->stripe_boundary_above;
+ search->stripe_boundary_below = rsi->stripe_boundary_below;
+ search->stripe_boundary_stride = rsi->stripe_boundary_stride;
+#endif
}
#endif // CONFIG_LOOP_RESTORATION
alloc_util_frame_buffers(cpi); // TODO(afergs): Remove? Gets called anyways.