Revert "aomenc: remove config control of "allow_screen_content_tools""

This reverts commit 1b5328e05cfdbfcf24ec7fab2c1718215155644c.

This commit has some pretty negative consequences with block copy. I
need to be able to force block copy on for arbitrary sequences while it
is still in development, and I need to be able to keep the palette
enable status between block copy and non-block copy runs.

Change If815a1eff2f9419117477f14cda143dd669c87c6 will prevent
allow_screen_content_tools from getting clobbered and still allow us to
force it on.
BUG=aomedia:656

Change-Id: I7a2f4207b5d2da35aec7870250e8b330c58a0e13
diff --git a/aomenc.c b/aomenc.c
index 0e384d6..74fb60c 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -513,7 +513,6 @@
                  chroma_sample_position_enum);
 #endif
 
-// TODO(huisu): remove "tune-content" control flag.
 static const struct arg_enum_list tune_content_enum[] = {
   { "default", AOM_CONTENT_DEFAULT },
   { "screen", AOM_CONTENT_SCREEN },
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 7a57f22..540d154 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -5082,10 +5082,8 @@
   av1_zero(rdc->coef_counts);
   av1_zero(rdc->comp_pred_diff);
 
-#if CONFIG_PALETTE || CONFIG_INTRABC
-  // 'allow_screen_content_tools' is assigned at intra-only frame, and will
-  // remain unchanged till the next intra-only frame.
-  if (frame_is_intra_only(cm)) {
+#if CONFIG_PALETTE
+  if (cpi->auto_tune_content && frame_is_intra_only(cm)) {
     cm->allow_screen_content_tools = is_screen_content(
         cpi->source->y_buffer,
 #if CONFIG_HIGHBITDEPTH
@@ -5093,7 +5091,7 @@
 #endif  // CONFIG_HIGHBITDEPTH
         cpi->source->y_stride, cpi->source->y_width, cpi->source->y_height);
   }
-#endif  // CONFIG_PALETTE || CONFIG_INTRABC
+#endif  // CONFIG_PALETTE
 
 #if CONFIG_GLOBAL_MOTION
   av1_zero(rdc->global_motion_used);
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 6003b58..cd4adbe 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2198,6 +2198,11 @@
   cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
 
 #if CONFIG_PALETTE || CONFIG_INTRABC
+  if (frame_is_intra_only(cm)) {
+    cm->allow_screen_content_tools = (cpi->oxcf.content == AOM_CONTENT_SCREEN);
+    // Automatically decide if screen content tools should be enabled.
+    cpi->auto_tune_content = (cpi->oxcf.content == AOM_CONTENT_DEFAULT);
+  }
   if (x->palette_buffer == 0) {
     CHECK_MEM_ERROR(cm, x->palette_buffer,
                     aom_memalign(16, sizeof(*x->palette_buffer)));
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index c7bef26..87f2ea3 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -655,6 +655,12 @@
 #if CONFIG_SPEED_REFS
   int sb_scanning_pass_idx;
 #endif  // CONFIG_SPEED_REFS
+
+#if CONFIG_PALETTE || CONFIG_INTRABC
+  // Specify if encoder does automatic classification of source video as
+  // screen content or not.
+  int auto_tune_content;
+#endif  // CONFIG_PALETTE || CONFIG_INTRABC
 } AV1_COMP;
 
 void av1_initialize_enc(void);