Add --enable-dist-8x8, rename existing '--tune' as '--tune-metric'

Added 'cdef-dist' and 'daala-dist' options to --tune-metric'.
(Actual bodies of the options will be added in later separate commits)

Also, if --tune=cdef-dist or --tune=daala-dist,
enable-dist-8x8 is automatically turned on.

This commit is a part of prep-work to remove DIST_8X8, CDEF_DIST,
and DAALA_DIST experimental flags.

Change-Id: I0790b9537dfaf166cb59741997ae27da10697a33
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index f670762..ddca3d5 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -58,6 +58,9 @@
   unsigned int qm_min;
   unsigned int qm_max;
 #endif
+#if CONFIG_DIST_8X8
+  unsigned int enable_dist_8x8;
+#endif
   unsigned int num_tg;
   unsigned int mtu_size;
 #if CONFIG_TEMPMV_SIGNALING
@@ -122,6 +125,9 @@
   DEFAULT_QM_FIRST,  // qm_min
   DEFAULT_QM_LAST,   // qm_max
 #endif
+#if CONFIG_DIST_8X8
+  0,
+#endif
   1,  // max number of tile groups
   0,  // mtu_size
 #if CONFIG_TEMPMV_SIGNALING
@@ -326,6 +332,14 @@
   if (extra_cfg->tuning == AOM_TUNE_SSIM)
     ERROR("Option --tune=ssim is not currently supported in AV1.");
 
+#if CONFIG_DIST_8X8
+  if (extra_cfg->tuning == AOM_TUNE_CDEF_DIST)
+    ERROR("Option --tune=cdef-dist is not currently supported in AV1.");
+
+  if (extra_cfg->tuning == AOM_TUNE_DAALA_DIST)
+    ERROR("Option --tune=daala-dist is not currently supported in AV1.");
+#endif  // CONFIG_DIST_8X8
+
   if (cfg->g_pass == AOM_RC_LAST_PASS) {
 #if !CONFIG_XIPHRC
     const size_t packet_sz = sizeof(FIRSTPASS_STATS);
@@ -480,7 +494,12 @@
   oxcf->qm_minlevel = extra_cfg->qm_min;
   oxcf->qm_maxlevel = extra_cfg->qm_max;
 #endif
-
+#if CONFIG_DIST_8X8
+  oxcf->using_dist_8x8 = extra_cfg->enable_dist_8x8;
+  if (extra_cfg->tuning == AOM_TUNE_CDEF_DIST ||
+      extra_cfg->tuning == AOM_TUNE_DAALA_DIST)
+    oxcf->using_dist_8x8 = 1;
+#endif
   oxcf->num_tile_groups = extra_cfg->num_tg;
 #if CONFIG_EXT_TILE
   // In large-scale tile encoding mode, num_tile_groups is always 1.
@@ -865,7 +884,14 @@
   return update_extra_cfg(ctx, &extra_cfg);
 }
 #endif
-
+#if CONFIG_DIST_8X8
+static aom_codec_err_t ctrl_set_enable_dist_8x8(aom_codec_alg_priv_t *ctx,
+                                                va_list args) {
+  struct av1_extracfg extra_cfg = ctx->extra_cfg;
+  extra_cfg.enable_dist_8x8 = CAST(AV1E_SET_ENABLE_DIST_8X8, args);
+  return update_extra_cfg(ctx, &extra_cfg);
+}
+#endif
 static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx,
                                        va_list args) {
   struct av1_extracfg extra_cfg = ctx->extra_cfg;
@@ -1547,6 +1573,9 @@
   { AV1E_SET_QM_MIN, ctrl_set_qm_min },
   { AV1E_SET_QM_MAX, ctrl_set_qm_max },
 #endif
+#if CONFIG_DIST_8X8
+  { AV1E_SET_ENABLE_DIST_8X8, ctrl_set_enable_dist_8x8 },
+#endif
   { AV1E_SET_NUM_TG, ctrl_set_num_tg },
   { AV1E_SET_MTU, ctrl_set_mtu },
 #if CONFIG_TEMPMV_SIGNALING