Optimize Wiener filter selection

* Change the behaviour of search_wiener at borders to match
  the behaviour of the Wiener filter itself
* Reorder the calculation in compute_stats, saving ~5% of
  encode time at low bitrates (tested on bus_cif.y4m at 200kbps)

Change-Id: I5f649d77fd66584451aaf37697ce9c9af69524e4
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index f8884c8..e718807 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -105,7 +105,7 @@
                           &rst->nhtiles, &rst->nvtiles);
 }
 
-static void extend_frame(uint8_t *data, int width, int height, int stride) {
+void extend_frame(uint8_t *data, int width, int height, int stride) {
   uint8_t *data_p;
   int i;
   for (i = 0; i < height; ++i) {
@@ -842,8 +842,7 @@
 }
 
 #if CONFIG_AOM_HIGHBITDEPTH
-static void extend_frame_highbd(uint16_t *data, int width, int height,
-                                int stride) {
+void extend_frame_highbd(uint16_t *data, int width, int height, int stride) {
   uint16_t *data_p;
   int i, j;
   for (i = 0; i < height; ++i) {
diff --git a/av1/common/restoration.h b/av1/common/restoration.h
index cb1d11e..3a1d5ea 100644
--- a/av1/common/restoration.h
+++ b/av1/common/restoration.h
@@ -222,12 +222,14 @@
                                  int height);
 void av1_free_restoration_struct(RestorationInfo *rst_info);
 
+void extend_frame(uint8_t *data, int width, int height, int stride);
 void av1_selfguided_restoration(int32_t *dgd, int width, int height, int stride,
                                 int bit_depth, int r, int eps, int32_t *tmpbuf);
 void av1_domaintxfmrf_restoration(uint8_t *dgd, int width, int height,
                                   int stride, int param, uint8_t *dst,
                                   int dst_stride, int32_t *tmpbuf);
 #if CONFIG_AOM_HIGHBITDEPTH
+void extend_frame_highbd(uint16_t *data, int width, int height, int stride);
 void av1_domaintxfmrf_restoration_highbd(uint16_t *dgd, int width, int height,
                                          int stride, int param, int bit_depth,
                                          uint16_t *dst, int dst_stride,