Rework sub8x8 chroma reference check to support non-420 format

Make is_chroma_reference() account for all the YUV420, 444, and
422 formats.

Change-Id: Ia87e51894493dcea86843194a34e5de05799248a
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 68d68a7..fe1a9e9 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1692,7 +1692,8 @@
       }
     }
 #if CONFIG_CB4X4
-    if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col))
+    if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
+                            xd->plane[1].subsampling_y))
       write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
 #else  // !CONFIG_CB4X4
     write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
@@ -2042,7 +2043,8 @@
   }
 
 #if CONFIG_CB4X4
-  if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col))
+  if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
+                          xd->plane[1].subsampling_y))
     write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
 #else  // !CONFIG_CB4X4
   write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
@@ -2322,8 +2324,9 @@
     for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
 
 #if CONFIG_CB4X4
-      if (mbmi->sb_type < BLOCK_8X8 && plane &&
-          !is_chroma_reference(mi_row, mi_col)) {
+      if (!is_chroma_reference(mi_row, mi_col, mbmi->sb_type,
+                               xd->plane[plane].subsampling_x,
+                               xd->plane[plane].subsampling_y)) {
         (*tok)++;
         continue;
       }