[CFL] Sub8x8 Validation Code Rewrite

Sub8x8 Validation code is changed to be more robust. The scope of the
validation is narrowed to validating that all of the required content in
the storage buffer was stored between CfL predictions. The early
termination used in the current mode decision code does not allow to
validate more than that.

This change does not change encoder output

BUG=aomedia:925

Change-Id: I7f1ed84da5037dcfaaf5da9cf33b4b8d664d2352
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index f45f108..3f3169d 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2110,18 +2110,17 @@
                    tx_size, &this_rd_stats.dist, &this_rd_stats.sse,
                    OUTPUT_HAS_PREDICTED_PIXELS);
   }
+  rd = RDCOST(x->rdmult, 0, this_rd_stats.dist);
+  if (args->this_rd + rd > args->best_rd) {
+    args->exit_early = 1;
+    return;
+  }
 #if CONFIG_CFL
   if (plane == AOM_PLANE_Y && xd->cfl->store_y) {
     assert(!is_inter_block(mbmi) || plane_bsize < BLOCK_8X8);
     cfl_store_tx(xd, blk_row, blk_col, tx_size, plane_bsize);
   }
 #endif  // CONFIG_CFL
-  rd = RDCOST(x->rdmult, 0, this_rd_stats.dist);
-  if (args->this_rd + rd > args->best_rd) {
-    args->exit_early = 1;
-    return;
-  }
-
   const PLANE_TYPE plane_type = get_plane_type(plane);
   const TX_TYPE tx_type =
       av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);