striped_loop_restoration bug fixes

* The above/below buffers did not fit the extra replication pixels to the right and left
* The wiener filter stripe has to be at least 4 pixel high (because of the
  split into above/mid/below parts)

Change-Id: I360bef114c7ceb439e11b76bd4724af15e051348
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index ad994ae..67ad9f1 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -156,7 +156,7 @@
   for (p = 0; p < MAX_MB_PLANE; ++p) {
     int w = p == 0 ? width : ROUND_POWER_OF_TWO(width, cm->subsampling_x);
     int align_bits = 5;  // align for efficiency
-    int stride = ALIGN_POWER_OF_TWO(w, align_bits);
+    int stride = ALIGN_POWER_OF_TWO(w + 2 * RESTORATION_EXTRA_HORZ, align_bits);
     int num_stripes = (height + 63) / 64;
     // for each processing stripe: 2 lines above, 2 below
     int buf_size = num_stripes * 2 * stride;
@@ -186,6 +186,15 @@
     av1_free_restoration_struct(&cm->rst_info[p]);
   aom_free(cm->rst_tmpbuf);
   cm->rst_tmpbuf = NULL;
+#if CONFIG_STRIPED_LOOP_RESTORATION
+  for (p = 0; p < MAX_MB_PLANE; ++p) {
+    RestorationStripeBoundaries *boundaries = &cm->rst_info[p].boundaries;
+    aom_free(boundaries->stripe_boundary_above);
+    aom_free(boundaries->stripe_boundary_below);
+    boundaries->stripe_boundary_above = NULL;
+    boundaries->stripe_boundary_below = NULL;
+  }
+#endif
 }
 #endif  // CONFIG_LOOP_RESTORATION