rtc: Allow for color_sensitivity for speed 11

For speed 11 camera mode: when fixed partition
is being used, the color_sensitivity[] is unset (0)
and this leads to bad artifacts in color content.

Fix is to set a flag (x->force_color_check_block_level) for
the superblock and use it the nonrd_pickmode to indicate
that block level color setting should be done.

This reduces artifacts, on rtc set:
bdrate gain ~2%, IC slowdown ~1.4%.

Change-Id: Id3663f8b5b82357d5fe8008a9f2430ba1a36c3b0
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 4e62312..267541b 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -1328,6 +1328,10 @@
   //! Threshold on the number of colors for testing palette mode.
   int color_palette_thresh;
 
+  //! Used in REALTIME coding mode: flag to indicate if the color_sensitivity
+  // should be checked at the coding block level.
+  int force_color_check_block_level;
+
   //! The buffer used by search_tx_type() to swap dqcoeff in macroblockd_plane
   // so we can keep dqcoeff of the best tx_type.
   tran_low_t *dqcoeff_buf;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 5456d5a..fb694be 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -548,6 +548,8 @@
       bsize_select = cm->seq_params->sb_size;
     }
     const BLOCK_SIZE bsize = seg_skip ? sb_size : bsize_select;
+    if (x->content_state_sb.source_sad_nonrd > kZeroSad)
+      x->force_color_check_block_level = 1;
     av1_set_fixed_partitioning(cpi, tile_info, mi, mi_row, mi_col, bsize);
   } else if (sf->part_sf.partition_search_type == VAR_BASED_PARTITION) {
     // set a variance-based partition
@@ -1215,6 +1217,7 @@
     x->sb_me_mv.as_int = 0;
     x->sb_force_fixed_part = 1;
     x->color_palette_thresh = 64;
+    x->force_color_check_block_level = 0;
     x->nonrd_prune_ref_frame_search =
         cpi->sf.rt_sf.nonrd_prune_ref_frame_search;
 
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 2034425..6161031 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -1975,11 +1975,13 @@
   const int subsampling_y = cpi->common.seq_params->subsampling_y;
   const int source_sad_nonrd = x->content_state_sb.source_sad_nonrd;
   const int high_res = cpi->common.width * cpi->common.height >= 640 * 360;
-  if (bsize == cpi->common.seq_params->sb_size) {
+  if (bsize == cpi->common.seq_params->sb_size &&
+      !x->force_color_check_block_level) {
     // At superblock level color_sensitivity is already set to 0, 1, or 2.
     // 2 is middle/uncertain level. To avoid additional sad
     // computations when bsize = sb_size force level 2 to 1 (certain color)
-    // for motion areas.
+    // for motion areas. Avoid this shortcut if x->force_color_check_block_level
+    // is set.
     if (x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_U)] == 2) {
       x->color_sensitivity[COLOR_SENS_IDX(AOM_PLANE_U)] =
           source_sad_nonrd >= kMedSad ? 1 : 0;
@@ -2035,8 +2037,10 @@
   for (int plane = AOM_PLANE_U; plane < num_planes; ++plane) {
     // Always check if level = 2. If level = 0 check again for
     // motion areas for higher resolns, where color artifacts
-    // are more noticeable.
+    // are more noticeable. Always check if
+    // x->force_color_check_block_level is set.
     if (x->color_sensitivity[COLOR_SENS_IDX(plane)] == 2 ||
+        x->force_color_check_block_level ||
         (x->color_sensitivity[COLOR_SENS_IDX(plane)] == 0 &&
          source_sad_nonrd >= kMedSad && high_res)) {
       struct macroblock_plane *const p = &x->plane[plane];