[CFL] Asserts for chroma_sub8x8

When Chroma from Luma is combined with chroma_sub8x8, the prediction
used for sub8x8 blocks originates from multiple luma blocks. Extra
asserts are added to validate that the prediction buffer contains all
the required information.

Change-Id: I305c46ce9b8292697e1d5b181d123461026da11c
diff --git a/av1/common/cfl.c b/av1/common/cfl.c
index f0f6981..f9b7d26 100644
--- a/av1/common/cfl.c
+++ b/av1/common/cfl.c
@@ -26,6 +26,9 @@
   cfl->subsampling_y = cm->subsampling_y;
   cfl->are_parameters_computed = 0;
   cfl->store_y = 0;
+#if CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
+  cfl_clear_sub8x8_val(cfl);
+#endif  // CONFIG_CHROMA_SUB8X8 && CONFIG_DEBUG
 }
 
 // Load from the CfL pixel buffer into output
@@ -311,10 +314,21 @@
       assert(col == 0);
       col++;
     }
+#if CONFIG_DEBUG
+    for (int unit_r = 0; unit_r < tx_size_high_unit[tx_size]; unit_r++) {
+      assert(row + unit_r < 2);
+      int row_off = (row + unit_r) * 2;
+      for (int unit_c = 0; unit_c < tx_size_wide_unit[tx_size]; unit_c++) {
+        assert(col + unit_c < 2);
+        assert(cfl->sub8x8_val[row_off + col + unit_c] == 0);
+        cfl->sub8x8_val[row_off + col + unit_c] = 1;
+      }
+    }
+#endif  // CONFIG_DEBUG
   }
 #else
   (void)bsize;
-#endif
+#endif  // CONFIG_CHROMA_SUB8X8
 
   // Invalidate current parameters
   cfl->are_parameters_computed = 0;
@@ -357,6 +371,20 @@
 #if CONFIG_CHROMA_SUB8X8
   const BLOCK_SIZE plane_bsize = AOMMAX(
       BLOCK_4X4, get_plane_block_size(mbmi->sb_type, &xd->plane[AOM_PLANE_U]));
+#if CONFIG_DEBUG
+  if (mbmi->sb_type < BLOCK_8X8) {
+    const int val_high =
+        block_size_high[BLOCK_8X8] / block_size_high[BLOCK_4X4];
+    const int val_wide =
+        block_size_wide[BLOCK_8X8] / block_size_wide[BLOCK_4X4];
+    for (int val_r = 0; val_r < val_high; val_r++) {
+      for (int val_c = 0; val_c < val_wide; val_c++) {
+        assert(cfl->sub8x8_val[(val_r * val_wide) + val_c] == 1);
+      }
+    }
+    cfl_clear_sub8x8_val(cfl);
+  }
+#endif  // CONFIG_DEBUG
 #else
   const BLOCK_SIZE plane_bsize =
       get_plane_block_size(mbmi->sb_type, &xd->plane[AOM_PLANE_U]);