Misc. clean ups / refactor of speed 1

With this patch, and the speed settings turned on for speed 1,
the coding efficiency of speed 1 in default configuration should be
only a little worse than speed 0, but it should roughly run at
double the speed.

Specifically, this patch makes various changes to make sure that
speed 1 behaves exactly the same as speed 0 except for speed settings
turned on or off in speed_features.c.

This will change the bitstream generated a little for speeds
1 or higher because of the following reasons:
1. Removes a hacky speed setting correction factor in firstpass.c
2. Fast cdef search is moved from speed 1+ to 2+, and a new speed
feature is added to control that.
3. Mesh search settings are pushed down one level so that speeds 0
and 1 use the same settings.
4. A disable_split_mask feature for animated content previously
turned on speeds 1+ is moved down to speeds 2+.

Change-Id: I0ec36556f157bdc42c5daa0cfb9518cf7ff65f6b
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 6fb96e5..ef23d56 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4594,7 +4594,7 @@
   } else {
     // Find CDEF parameters
     av1_cdef_search(cm->frame_to_show, cpi->source, cm, xd,
-                    cpi->oxcf.speed > 0);
+                    cpi->sf.fast_cdef_search);
 
     // Apply the filter
     av1_cdef_frame(cm->frame_to_show, cm, xd);
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index d6cf18a..16dbf65 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -1151,7 +1151,7 @@
                             : cpi->common.MBs;
     const int active_mbs = AOMMAX(1, num_mbs - (int)(num_mbs * inactive_zone));
     const double av_err_per_mb = section_err / active_mbs;
-    const double speed_term = 1.0 + 0.04 * oxcf->speed;
+    const double speed_term = 1.0;
     double ediv_size_correction;
     const int target_norm_bits_per_mb =
         (int)((uint64_t)section_target_bandwidth << BPER_MB_NORMBITS) /
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index da38f4c..69e17fc 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -28,7 +28,7 @@
       { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } },
     };
 static unsigned char good_quality_max_mesh_pct[MAX_MESH_SPEED + 1] = {
-  50, 25, 15, 5, 1, 1
+  50, 50, 25, 15, 5, 1
 };
 
 #if CONFIG_INTRABC
@@ -36,11 +36,11 @@
 // each speed setting
 static MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = {
   { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } },
+  { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } },
   { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } },
-  { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } },
 };
 static uint8_t intrabc_max_mesh_pct[MAX_MESH_SPEED + 1] = { 100, 100, 100,
                                                             25,  25,  10 };
@@ -110,9 +110,9 @@
   }
 
   // If this is a two pass clip that fits the criteria for animated or
-  // graphics content then reset disable_split_mask for speeds 1-4.
+  // graphics content then reset disable_split_mask for speeds 2+.
   // Also if the image edge is internal to the coded area.
-  if ((speed >= 1) && (cpi->oxcf.pass == 2) &&
+  if ((speed >= 2) && (cpi->oxcf.pass == 2) &&
       ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
        (av1_internal_image_edge(cpi)))) {
     sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
@@ -156,6 +156,9 @@
     } else {
       sf->use_square_partition_only = !frame_is_intra_only(cm);
     }
+#if CONFIG_CDEF
+    sf->fast_cdef_search = 1;
+#endif  // CONFIG_CDEF
 
     sf->less_rectangular_check = 1;
 
@@ -445,6 +448,9 @@
 #if CONFIG_EXT_PARTITION_TYPES
   sf->prune_ext_partition_types_search = 0;
 #endif  // CONFIG_EXT_PARTITION_TYPES
+#if CONFIG_CDEF
+  sf->fast_cdef_search = 0;
+#endif  // CONFIG_CDEF
 
   // Set this at the appropriate speed levels
   sf->use_transform_domain_distortion = 0;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index fc3c8e0..a33c7bc 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -343,6 +343,10 @@
   int prune_ext_partition_types_search;
 #endif  // CONFIG_EXT_PARTITION_TYPES
 
+#if CONFIG_CDEF
+  int fast_cdef_search;
+#endif  // CONFIG_CDEF
+
   // Skip rectangular partition test when partition type none gives better
   // rd than partition type split.
   int less_rectangular_check;