Deduplicate code between HBD and LBD

Change-Id: I2e83419aecf6464fa76f091015597207a12bd478
diff --git a/aomenc.c b/aomenc.c
index ec1935a..9d06da7 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -1787,7 +1787,6 @@
           { stream->config.cfg.g_input_bit_depth = input.bit_depth; });
     }
 
-#if CONFIG_HIGHBITDEPTH
     FOREACH_STREAM({
       if (input.fmt != AOM_IMG_FMT_I420 && input.fmt != AOM_IMG_FMT_I42016) {
         /* Automatically upgrade if input is non-4:2:0 but a 4:2:0 profile
@@ -1824,31 +1823,11 @@
         }
       }
       if (stream->config.cfg.g_profile > 1) {
+#if CONFIG_HIGHBITDEPTH
         stream->config.use_16bit_internal = 1;
-      }
-      if (profile_updated && !global.quiet) {
-        fprintf(stderr,
-                "Warning: automatically upgrading to profile %d to "
-                "match input format.\n",
-                stream->config.cfg.g_profile);
-      }
-    });
 #else
-    FOREACH_STREAM({
-      if (input.fmt != AOM_IMG_FMT_I420 && input.fmt != AOM_IMG_FMT_I42016) {
-        /* Automatically upgrade if input is non-4:2:0 but a 4:2:0 profile
-           was selected. */
-        switch (stream->config.cfg.g_profile) {
-          case 0:
-            stream->config.cfg.g_profile = 1;
-            profile_updated = 1;
-            break;
-          case 2:
-            stream->config.cfg.g_profile = 3;
-            profile_updated = 1;
-            break;
-          default: break;
-        }
+        fatal("Unsupported profile.");
+#endif
       }
       if (profile_updated && !global.quiet) {
         fprintf(stderr,
@@ -1857,7 +1836,6 @@
                 stream->config.cfg.g_profile);
       }
     });
-#endif
 
     FOREACH_STREAM(set_stream_dimensions(stream, input.width, input.height));
     FOREACH_STREAM(validate_stream_config(stream, &global));