Refactor pruning of sgr based on wiener results

Refactored the pruning logic of speed feature
'prune_sgr_based_on_wiener'.This patch will faciliate extending the
speed feature for higher quality presets.

Change-Id: I44d73c740bb81b1877788cede449ba421894ceeb
diff --git a/av1/encoder/pickrst.c b/av1/encoder/pickrst.c
index e0a4d69..e371b0e 100644
--- a/av1/encoder/pickrst.c
+++ b/av1/encoder/pickrst.c
@@ -98,6 +98,10 @@
   // The rtype to use for this unit given a frame rtype as
   // index. Indices: WIENER, SGRPROJ, SWITCHABLE.
   RestorationType best_rtype[RESTORE_TYPES - 1];
+
+  // This flag will be set based on the speed feature
+  // 'prune_sgr_based_on_wiener'. 0 implies no pruning and 1 implies pruning.
+  uint8_t skip_sgr_eval;
 } RestUnitSearchInfo;
 
 typedef struct {
@@ -860,8 +864,7 @@
   const int64_t bits_none = x->sgrproj_restore_cost[0];
   // Prune evaluation of RESTORE_SGRPROJ if RESTORE_NONE was the winner (no loop
   // restoration)
-  if (rsc->sf->prune_sgr_based_on_wiener &&
-      rusi->best_rtype[RESTORE_WIENER - 1] == RESTORE_NONE) {
+  if (rusi->skip_sgr_eval) {
     rsc->bits += bits_none;
     rsc->sse += rusi->sse[RESTORE_NONE];
     rusi->best_rtype[RESTORE_SGRPROJ - 1] = RESTORE_NONE;
@@ -1475,6 +1478,7 @@
     rsc->sse += rusi->sse[RESTORE_NONE];
     rusi->best_rtype[RESTORE_WIENER - 1] = RESTORE_NONE;
     rusi->sse[RESTORE_WIENER] = INT64_MAX;
+    if (rsc->sf->prune_sgr_based_on_wiener) rusi->skip_sgr_eval = 1;
     return;
   }
 
@@ -1493,6 +1497,7 @@
     rsc->sse += rusi->sse[RESTORE_NONE];
     rusi->best_rtype[RESTORE_WIENER - 1] = RESTORE_NONE;
     rusi->sse[RESTORE_WIENER] = INT64_MAX;
+    if (rsc->sf->prune_sgr_based_on_wiener) rusi->skip_sgr_eval = 1;
     return;
   }
 
@@ -1523,6 +1528,10 @@
       (cost_wiener < cost_none) ? RESTORE_WIENER : RESTORE_NONE;
   rusi->best_rtype[RESTORE_WIENER - 1] = rtype;
 
+  if (rsc->sf->prune_sgr_based_on_wiener) {
+    rusi->skip_sgr_eval = rusi->best_rtype[RESTORE_WIENER - 1] == RESTORE_NONE;
+  }
+
   rsc->sse += rusi->sse[rtype];
   rsc->bits += (cost_wiener < cost_none) ? bits_wiener : bits_none;
   if (cost_wiener < cost_none) rsc->wiener = rusi->wiener;