[dist-8x8] Restore removed asserts

Reverts the commit 796d4e29f4d1e685adaf1ac4e43a4d6d77c4f3e5.
Then, put them behind DEBUG_DIST_8X8 compile time flag.

Change-Id: I8729abeca83a664d86188e21998d8d60b00120db
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index f57b216..5851845 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -3073,7 +3073,14 @@
 #if CONFIG_DIST_8X8
     if (x->using_dist_8x8 && reached_last_index &&
         sum_rdc.rdcost != INT64_MAX && bsize == BLOCK_8X8) {
-      sum_rdc.dist = dist_8x8_yuv(cpi, x, src_plane_8x8, dst_plane_8x8);
+      int64_t dist_8x8;
+      dist_8x8 = dist_8x8_yuv(cpi, x, src_plane_8x8, dst_plane_8x8);
+#ifdef DEBUG_DIST_8X8
+      // TODO(anyone): Fix dist-8x8 assert failure here when CFL is enabled
+      if (x->tune_metric == AOM_TUNE_PSNR && xd->bd == 8 && !CONFIG_CFL)
+        assert(sum_rdc.dist == dist_8x8);
+#endif  // DEBUG_DIST_8X8
+      sum_rdc.dist = dist_8x8;
       sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
     }
 #endif  // CONFIG_DIST_8X8
@@ -3168,7 +3175,14 @@
 #if CONFIG_DIST_8X8
       if (x->using_dist_8x8 && sum_rdc.rdcost != INT64_MAX &&
           bsize == BLOCK_8X8) {
-        sum_rdc.dist = dist_8x8_yuv(cpi, x, src_plane_8x8, dst_plane_8x8);
+        int64_t dist_8x8;
+        dist_8x8 = dist_8x8_yuv(cpi, x, src_plane_8x8, dst_plane_8x8);
+#ifdef DEBUG_DIST_8X8
+        // TODO(anyone): Fix dist-8x8 assert failure here when CFL is enabled
+        if (x->tune_metric == AOM_TUNE_PSNR && xd->bd == 8 && !CONFIG_CFL)
+          assert(sum_rdc.dist == dist_8x8);
+#endif  // DEBUG_DIST_8X8
+        sum_rdc.dist = dist_8x8;
         sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
       }
 #endif  // CONFIG_DIST_8X8
@@ -3261,7 +3275,14 @@
 #if CONFIG_DIST_8X8
       if (x->using_dist_8x8 && sum_rdc.rdcost != INT64_MAX &&
           bsize == BLOCK_8X8) {
-        sum_rdc.dist = dist_8x8_yuv(cpi, x, src_plane_8x8, dst_plane_8x8);
+        int64_t dist_8x8;
+        dist_8x8 = dist_8x8_yuv(cpi, x, src_plane_8x8, dst_plane_8x8);
+#ifdef DEBUG_DIST_8X8
+        // TODO(anyone): Fix dist-8x8 assert failure here when CFL is enabled
+        if (x->tune_metric == AOM_TUNE_PSNR && xd->bd == 8 && !CONFIG_CFL)
+          assert(sum_rdc.dist == dist_8x8);
+#endif  // DEBUG_DIST_8X8
+        sum_rdc.dist = dist_8x8;
         sum_rdc.rdcost = RDCOST(x->rdmult, sum_rdc.rate, sum_rdc.dist);
       }
 #endif  // CONFIG_DIST_8X8