cb4x4: Fix reset_skip_context() without chroma_2x2

reset_skip_context() was always clearing the entropy contexts for
all three color planes, using a block size that corresponded with
the luma plane.

However, when chroma_2x2 is disabled, then for sub-8x8 luma block
sizes, the corresponding chroma block size is always 4x4, and the
skip flag only affects the chroma blocks corresponding to the
upper-left luma block.

This patch makes reset_skip_context() reset the contexts that
actually correspond to the chroma blocks that are skipped (if any).
It also moves reset_skip_context() to av1_reset_skip_context() in
blockd.c, because blockd.h gets included before onyx_int.h, which
declares the required is_chroma_reference() function.
reset_skip_context() was too large and used in too many places to
be a reasonable candidate for inlining, anyway.

AWCY results on objective-1-fast:

cb4x4-fix-base@2017-05-11T06:26:50.159Z -> cb4x4-fix-reset_skip@2017-05-11T06:28:45.482Z
  PSNR | PSNR Cb | PSNR Cr | PSNR HVS |   SSIM | MS SSIM | CIEDE 2000
0.0301 |  0.1068 |  0.1463 |   0.0359 | 0.0260 |  0.0347 |     0.0479

A regression (near the noise range), but without this fix, the line
buffer size required by the entropy contexts will be doubled.

Change-Id: I12fa6e60d9c1c7c85927742775a346ea22b3193f
diff --git a/av1/common/blockd.c b/av1/common/blockd.c
index 4eb6f01..602cef4 100644
--- a/av1/common/blockd.c
+++ b/av1/common/blockd.c
@@ -259,6 +259,36 @@
 }
 #endif
 
+void av1_reset_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col,
+                            BLOCK_SIZE bsize) {
+  int i;
+  int nplanes;
+#if CONFIG_CB4X4
+  int chroma_ref;
+  chroma_ref =
+      is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
+                          xd->plane[1].subsampling_y);
+  nplanes = 1 + (MAX_MB_PLANE - 1) * chroma_ref;
+#else
+  (void)mi_row;
+  (void)mi_col;
+  nplanes = MAX_MB_PLANE;
+#endif
+  for (i = 0; i < nplanes; i++) {
+    struct macroblockd_plane *const pd = &xd->plane[i];
+#if CONFIG_CHROMA_2X2 || !CONFIG_CB4X4
+    const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
+#else
+    const BLOCK_SIZE plane_bsize =
+        AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
+#endif
+    const int txs_wide = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
+    const int txs_high = block_size_high[plane_bsize] >> tx_size_high_log2[0];
+    memset(pd->above_context, 0, sizeof(ENTROPY_CONTEXT) * txs_wide);
+    memset(pd->left_context, 0, sizeof(ENTROPY_CONTEXT) * txs_high);
+  }
+}
+
 void av1_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y) {
   int i;