Move subsampling_x/y checking out of the decoding loop

Moved subsampling_x/y checking out of the decoding loop. This will
also partially resovle issue 2001.

BUG=aomedia:2001

Change-Id: Ic137a5afd1bcde6fbf36fc863091f092f8f4f157
diff --git a/av1/common/cfl.c b/av1/common/cfl.c
index ee19f0b..3e46bf4 100644
--- a/av1/common/cfl.c
+++ b/av1/common/cfl.c
@@ -18,14 +18,7 @@
 void cfl_init(CFL_CTX *cfl, AV1_COMMON *cm) {
   assert(block_size_wide[CFL_MAX_BLOCK_SIZE] == CFL_BUF_LINE);
   assert(block_size_high[CFL_MAX_BLOCK_SIZE] == CFL_BUF_LINE);
-  if (!(cm->subsampling_x == 0 && cm->subsampling_y == 0) &&
-      !(cm->subsampling_x == 1 && cm->subsampling_y == 1) &&
-      !(cm->subsampling_x == 1 && cm->subsampling_y == 0)) {
-    aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
-                       "Only 4:4:4, 4:2:2 and 4:2:0 are currently supported by "
-                       "CfL, %d %d subsampling is not supported.\n",
-                       cm->subsampling_x, cm->subsampling_y);
-  }
+
   memset(&cfl->recon_buf_q3, 0, sizeof(cfl->recon_buf_q3));
   memset(&cfl->ac_buf_q3, 0, sizeof(cfl->ac_buf_q3));
   cfl->subsampling_x = cm->subsampling_x;
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c
index 207065b..62ba69c 100644
--- a/av1/decoder/obu.c
+++ b/av1/decoder/obu.c
@@ -308,6 +308,14 @@
   read_sequence_header(cm, rb);
 
   av1_read_color_config(cm, rb, pbi->allow_lowbitdepth);
+  if (!(cm->subsampling_x == 0 && cm->subsampling_y == 0) &&
+      !(cm->subsampling_x == 1 && cm->subsampling_y == 1) &&
+      !(cm->subsampling_x == 1 && cm->subsampling_y == 0)) {
+    aom_internal_error(&cm->error, AOM_CODEC_UNSUP_BITSTREAM,
+                       "Only 4:4:4, 4:2:2 and 4:2:0 are currently supported by "
+                       "CfL, %d %d subsampling is not supported.\n",
+                       cm->subsampling_x, cm->subsampling_y);
+  }
 
   cm->film_grain_params_present = aom_rb_read_bit(rb);