Account for sub8x8 chroma intra boundary condition

Properly account for the intra boundary condition for sub8x8
chroma components in the modified chroma-2x2 framework. This fixes
a rare enc/dec mismatch issue when chroma-sub8x8 is turned on.

Change-Id: I058a2fb855a491bf604277f4c82169c1b55424fa
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 233e689..0acab96 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -585,6 +585,10 @@
 
   int up_available;
   int left_available;
+#if CONFIG_CHROMA_SUB8X8
+  int chroma_up_available;
+  int chroma_left_available;
+#endif
 
   const aom_prob (*partition_probs)[PARTITION_TYPES - 1];
 
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index bdb0667..7980bde 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -640,6 +640,14 @@
 #endif  // CONFIG_DEPENDENT_HORZTILES
 
   xd->left_available = (mi_col > tile->mi_col_start);
+#if CONFIG_CHROMA_SUB8X8
+  xd->chroma_up_available = xd->up_available;
+  xd->chroma_left_available = xd->left_available;
+  if (xd->plane[1].subsampling_x && bw < mi_size_wide[BLOCK_8X8])
+    xd->chroma_left_available = (mi_col - 1) > tile->mi_col_start;
+  if (xd->plane[1].subsampling_y && bh < mi_size_high[BLOCK_8X8])
+    xd->chroma_up_available = (mi_row - 1) > tile->mi_row_start;
+#endif
   if (xd->up_available) {
     xd->above_mi = xd->mi[-xd->mi_stride];
     // above_mi may be NULL in encoder's first pass.
diff --git a/av1/common/reconintra.c b/av1/common/reconintra.c
index ec2ac58..6e0ff52 100644
--- a/av1/common/reconintra.c
+++ b/av1/common/reconintra.c
@@ -2184,8 +2184,16 @@
   BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
   const struct macroblockd_plane *const pd = &xd->plane[plane];
   const int txw = tx_size_wide_unit[tx_size];
+#if CONFIG_CB4X4 && CONFIG_CHROMA_SUB8X8
+  const int have_top = row_off || (pd->subsampling_y ? xd->chroma_up_available
+                                                     : xd->up_available);
+  const int have_left =
+      col_off ||
+      (pd->subsampling_x ? xd->chroma_left_available : xd->left_available);
+#else
   const int have_top = row_off || xd->up_available;
   const int have_left = col_off || xd->left_available;
+#endif
   const int x = col_off << tx_size_wide_log2[0];
   const int y = row_off << tx_size_high_log2[0];
   const int mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);