Properly support monochrome in profile 0

Several assertions did not take into account that profile 0 supports
monochrome when input video is 4:4:4 but encodeing in monochrome.

BUG=aomedia:1580

Change-Id: Ifc8a749fe83d1fd87a8878083bc5e940b983d349
diff --git a/aomenc.c b/aomenc.c
index 2886c07..e1ea7ca 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -2045,8 +2045,10 @@
           case 0:
             if (input.bit_depth < 12 && (input.fmt == AOM_IMG_FMT_I444 ||
                                          input.fmt == AOM_IMG_FMT_I44416)) {
-              stream->config.cfg.g_profile = 1;
-              profile_updated = 1;
+              if (!stream->config.cfg.monochrome) {
+                stream->config.cfg.g_profile = 1;
+                profile_updated = 1;
+              }
             } else if (input.bit_depth == 12 || input.fmt == AOM_IMG_FMT_I422 ||
                        input.fmt == AOM_IMG_FMT_I42216) {
               stream->config.cfg.g_profile = 2;
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 500f52a..8c0de55 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -445,7 +445,8 @@
     case AOM_IMG_FMT_I42016: break;
     case AOM_IMG_FMT_I444:
     case AOM_IMG_FMT_I44416:
-      if (ctx->cfg.g_profile == (unsigned int)PROFILE_0) {
+      if (ctx->cfg.g_profile == (unsigned int)PROFILE_0 &&
+          !ctx->cfg.monochrome) {
         ERROR("Invalid image format. I444 images not supported in profile.");
       }
       break;
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 363a449..abdaf50 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -5370,7 +5370,7 @@
   aom_usec_timer_mark(&timer);
   cpi->time_receive_data += aom_usec_timer_elapsed(&timer);
 
-  if ((cm->profile == PROFILE_0) &&
+  if ((cm->profile == PROFILE_0) && !cm->seq_params.monochrome &&
       (subsampling_x != 1 || subsampling_y != 1)) {
     aom_internal_error(&cm->error, AOM_CODEC_INVALID_PARAM,
                        "Non-4:2:0 color format requires profile 1 or 2");