Rename tune=ssimulacra2 to tune=iq

We want tune=ssimulacra2 to mean a mode that maximizes the SSIMULACRA 2
metric. The current tune=ssimulacra2 mode increases image quality by
using the SSIMULACRA 2 metric as a guidance and validating with
subjective visual quality checks. Rename it tune=iq, which stands for
image quality or intra quality.

Bug: b:390668380
Change-Id: I6f1943395ffc186e9cc773e96d0d69c80d857641
diff --git a/aom/aomcx.h b/aom/aomcx.h
index 2534349..6bd8f50 100644
--- a/aom/aomcx.h
+++ b/aom/aomcx.h
@@ -1668,9 +1668,9 @@
  * Changes the encoder to tune for certain types of input material.
  *
  * \note
- * AOM_TUNE_SSIMULACRA2 is restricted to all intra mode (AOM_USAGE_ALL_INTRA).
- * Setting the tuning option to AOM_TUNE_SSIMULACRA2 causes the following
- * options to be set (expressed as command-line options):
+ * AOM_TUNE_IQ is restricted to all intra mode (AOM_USAGE_ALL_INTRA). Setting
+ * the tuning option to AOM_TUNE_IQ causes the following options to be set
+ * (expressed as command-line options):
  *   * --enable-qm=1
  *   * --qm-min=2
  *   * --qm-max=10
@@ -1690,14 +1690,13 @@
   AOM_TUNE_VMAF_NEG_MAX_GAIN = 7,
   AOM_TUNE_BUTTERAUGLI = 8,
   AOM_TUNE_VMAF_SALIENCY_MAP = 9,
-/*!\brief Allows detection of the presence of AOM_TUNE_SSIMULACRA2 at compile
- * time.
- */
-#define AOM_HAVE_TUNE_SSIMULACRA2 1
-  /* Increases image quality and consistency, guided by the SSIMULACRA2 metric
-   * and subjective quality checks. Shares the rdmult code with AOM_TUNE_SSIM.
+/*!\brief Allows detection of the presence of AOM_TUNE_IQ at compile time. */
+#define AOM_HAVE_TUNE_IQ 1
+  /* Image quality (or intra quality). Increases image quality and consistency,
+   * guided by the SSIMULACRA 2 metric and subjective quality checks. Shares
+   * the rdmult code with AOM_TUNE_SSIM.
    */
-  AOM_TUNE_SSIMULACRA2 = 10,
+  AOM_TUNE_IQ = 10,
 } aom_tune_metric;
 
 /*!\brief Distortion metric to use for RD optimization.
diff --git a/av1/arg_defs.c b/av1/arg_defs.c
index 6fdfc79..114c773 100644
--- a/av1/arg_defs.c
+++ b/av1/arg_defs.c
@@ -48,7 +48,7 @@
   { "vmaf_neg", AOM_TUNE_VMAF_NEG_MAX_GAIN },
   { "butteraugli", AOM_TUNE_BUTTERAUGLI },
   { "vmaf_saliency_map", AOM_TUNE_VMAF_SALIENCY_MAP },
-  { "ssimulacra2", AOM_TUNE_SSIMULACRA2 },
+  { "iq", AOM_TUNE_IQ },
   { NULL, 0 }
 };
 
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 971dd7b..47ce04b 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -850,7 +850,7 @@
   }
 #endif
 
-  RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR, AOM_TUNE_SSIMULACRA2);
+  RANGE_CHECK(extra_cfg, tuning, AOM_TUNE_PSNR, AOM_TUNE_IQ);
 
   RANGE_CHECK(extra_cfg, dist_metric, AOM_DIST_METRIC_PSNR,
               AOM_DIST_METRIC_QM_PSNR);
@@ -1786,22 +1786,22 @@
 
 static aom_codec_err_t handle_tuning(aom_codec_alg_priv_t *ctx,
                                      struct av1_extracfg *extra_cfg) {
-  if (extra_cfg->tuning == AOM_TUNE_SSIMULACRA2) {
+  if (extra_cfg->tuning == AOM_TUNE_IQ) {
     if (ctx->cfg.g_usage != AOM_USAGE_ALL_INTRA) return AOM_CODEC_INCAPABLE;
     // Enable QMs as they've been found to be beneficial for images, when used
     // with alternative QM formulas:
     // - aom_get_qmlevel_allintra()
-    // - aom_get_qmlevel_luma_ssimulacra2()
-    // - aom_get_qmlevel_444_chroma_ssimulacra2()
+    // - aom_get_qmlevel_luma_iq()
+    // - aom_get_qmlevel_444_chroma_iq()
     extra_cfg->enable_qm = 1;
-    extra_cfg->qm_min = QM_FIRST_SSIMULACRA2;
-    extra_cfg->qm_max = QM_LAST_SSIMULACRA2;
+    extra_cfg->qm_min = QM_FIRST_IQ;
+    extra_cfg->qm_max = QM_LAST_IQ;
     // We can turn on loop filter sharpness, as frames do not have to serve as
     // references to others.
     extra_cfg->sharpness = 7;
     // Using the QM-PSNR metric was found to be beneficial for images (over the
     // default PSNR metric), as it correlates better with subjective image
-    // quality consistency and better SSIMULACRA2 scores.
+    // quality consistency and better SSIMULACRA 2 scores.
     extra_cfg->dist_metric = AOM_DIST_METRIC_QM_PSNR;
     // CDEF_ALL has been found to blur images at medium and high quality
     // qindexes, so let's use a version that adapts CDEF strength on frame
diff --git a/av1/common/quant_common.h b/av1/common/quant_common.h
index b21412f..129c5c2 100644
--- a/av1/common/quant_common.h
+++ b/av1/common/quant_common.h
@@ -38,8 +38,8 @@
 #define DEFAULT_QM_LAST 9
 #define DEFAULT_QM_FIRST_ALLINTRA 4
 #define DEFAULT_QM_LAST_ALLINTRA 10
-#define QM_FIRST_SSIMULACRA2 2
-#define QM_LAST_SSIMULACRA2 10
+#define QM_FIRST_IQ 2
+#define QM_LAST_IQ 10
 #define LOSSLESS_Q_STEP 4  // this should equal to dc/ac_qlookup_QTX[0]
 
 struct AV1Common;
@@ -96,7 +96,7 @@
   return clamp(qm_level, first, last);
 }
 
-// Luma QM levels tuned for SSIMULACRA 2 tune
+// Luma QM levels tuned for image quality (IQ)
 // This formula was empirically derived by encoding Daala's subset1 validation
 // testset for each QP/QM tuple, and building a convex hull that maximizes
 // SSIMULACRA 2 scores, and a final subjective visual quality pass as a quick
@@ -108,8 +108,7 @@
 // both set below or above this range.
 // For more information on quantization matrices, please refer to
 // https://arxiv.org/pdf/2008.06091, section F.
-static inline int aom_get_qmlevel_luma_ssimulacra2(int qindex, int first,
-                                                   int last) {
+static inline int aom_get_qmlevel_luma_iq(int qindex, int first, int last) {
   int qm_level = 0;
 
   if (qindex <= 40) {
@@ -135,7 +134,7 @@
   return clamp(qm_level, first, last);
 }
 
-// Chroma QM levels for 4:4:4 subsampling tuned for SSIMULACRA 2 tune
+// Chroma QM levels for 4:4:4 subsampling tuned for image quality (IQ)
 // This formula was empirically derived by encoding Daala's subset1 validation
 // testset for each QP/QM tuple, and building a convex hull that maximizes
 // SSIMULACRA 2 scores, and a final subjective visual quality pass as a quick
@@ -147,8 +146,8 @@
 // both set below or above this range.
 // For more information on quantization matrices, please refer to
 // https://arxiv.org/pdf/2008.06091, section F.
-static inline int aom_get_qmlevel_444_chroma_ssimulacra2(int qindex, int first,
-                                                         int last) {
+static inline int aom_get_qmlevel_444_chroma_iq(int qindex, int first,
+                                                int last) {
   int chroma_qm_level = 0;
 
   if (qindex <= 12) {
diff --git a/av1/encoder/allintra_vis.c b/av1/encoder/allintra_vis.c
index e9a493b..b9398e4 100644
--- a/av1/encoder/allintra_vis.c
+++ b/av1/encoder/allintra_vis.c
@@ -1105,7 +1105,7 @@
   // Determine the SB's delta_q boost by computing an (unscaled) delta_q from
   // the base and target q values, then scale that delta_q according to the
   // frame's base qindex.
-  // The scaling coefficients were chosen empirically to maximize SSIMULACRA2
+  // The scaling coefficients were chosen empirically to maximize SSIMULACRA 2
   // scores, 10th percentile scores, and subjective quality. Boosts become
   // smaller (for a given variance) the lower the base qindex.
   int boost = (int)round((base_qindex + 544.0) * (base_qindex - target_qindex) /
diff --git a/av1/encoder/av1_quantize.c b/av1/encoder/av1_quantize.c
index 3ddedce..323bc2f 100644
--- a/av1/encoder/av1_quantize.c
+++ b/av1/encoder/av1_quantize.c
@@ -873,7 +873,7 @@
   quant_params->y_dc_delta_q = 0;
 
   if (enable_chroma_deltaq) {
-    if (is_allintra && tuning == AOM_TUNE_SSIMULACRA2) {
+    if (is_allintra && tuning == AOM_TUNE_IQ) {
       int chroma_dc_delta_q = 0;
       int chroma_ac_delta_q = 0;
 
@@ -968,9 +968,9 @@
   int (*get_chroma_qmlevel)(int, int, int);
 
   if (is_allintra) {
-    if (tuning == AOM_TUNE_SSIMULACRA2) {
-      // Use luma QM formula specifically tailored for tune SSIMULACRA 2
-      get_luma_qmlevel = aom_get_qmlevel_luma_ssimulacra2;
+    if (tuning == AOM_TUNE_IQ) {
+      // Use luma QM formula specifically tailored for tune IQ
+      get_luma_qmlevel = aom_get_qmlevel_luma_iq;
 
       if (cm->seq_params->subsampling_x == 0 &&
           cm->seq_params->subsampling_y == 0) {
@@ -978,7 +978,7 @@
         // compared to 4:2:0 (2x on each dimension). This means the encoder
         // should use lower chroma QM levels that more closely match the scaling
         // of an equivalent 4:2:0 chroma QM.
-        get_chroma_qmlevel = aom_get_qmlevel_444_chroma_ssimulacra2;
+        get_chroma_qmlevel = aom_get_qmlevel_444_chroma_iq;
       } else {
         // For all other chroma subsampling modes, use the all intra QM formula
         get_chroma_qmlevel = aom_get_qmlevel_allintra;
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index d66cb93..d339bed 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -46,7 +46,7 @@
   // to 4.8323^1024 and exceed DBL_MAX, resulting in data overflow.
   assert(bsize_base >= BLOCK_8X8);
   assert(cpi->oxcf.tune_cfg.tuning == AOM_TUNE_SSIM ||
-         cpi->oxcf.tune_cfg.tuning == AOM_TUNE_SSIMULACRA2);
+         cpi->oxcf.tune_cfg.tuning == AOM_TUNE_IQ);
 
   for (row = mi_row / num_mi_w;
        row < num_rows && row < mi_row / num_mi_w + num_brows; ++row) {
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 44c92e5..31d8853 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3774,7 +3774,7 @@
   }
 
   if (oxcf->tune_cfg.tuning == AOM_TUNE_SSIM ||
-      oxcf->tune_cfg.tuning == AOM_TUNE_SSIMULACRA2) {
+      oxcf->tune_cfg.tuning == AOM_TUNE_IQ) {
     av1_set_mb_ssim_rdmult_scaling(cpi);
   }
 #if CONFIG_SALIENCY_MAP
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 27fd1eb..53c14fc 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -616,7 +616,7 @@
 #endif  // !CONFIG_REALTIME_ONLY
 
   if (cpi->oxcf.tune_cfg.tuning == AOM_TUNE_SSIM ||
-      cpi->oxcf.tune_cfg.tuning == AOM_TUNE_SSIMULACRA2) {
+      cpi->oxcf.tune_cfg.tuning == AOM_TUNE_IQ) {
     av1_set_ssim_rdmult(cpi, &x->errorperbit, bsize, mi_row, mi_col,
                         &x->rdmult);
   }
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 2c26688..b3eef0b 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -400,7 +400,7 @@
     rdmult = (int64_t)((double)rdmult * def_rd_q_mult);
   }
 
-  if (tuning == AOM_TUNE_SSIMULACRA2) {
+  if (tuning == AOM_TUNE_IQ) {
     // Further multiply rdmult (by up to 200/128 = 1.5625) to improve image
     // quality. The most noticeable effect is a mild bias towards choosing
     // larger transform sizes (e.g. one 16x16 transform instead of 4 8x8
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index a70f0c9..103c8e0 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -1376,9 +1376,9 @@
   const int base_qindex =
       cpi->use_ducky_encode ? gf_group->q_val[frame_idx] : pframe_qindex;
   // The TPL model is only meant to be run in inter mode, so ensure that we are
-  // not running in all intra mode, which implies we are not tuning for
-  // SSIMULACRA 2.
-  assert(cpi->oxcf.tune_cfg.tuning != AOM_TUNE_SSIMULACRA2 &&
+  // not running in all intra mode, which implies we are not tuning for image
+  // quality (IQ).
+  assert(cpi->oxcf.tune_cfg.tuning != AOM_TUNE_IQ &&
          cpi->oxcf.mode != ALLINTRA);
   // Get rd multiplier set up.
   rdmult = av1_compute_rd_mult(
diff --git a/av1/encoder/txb_rdopt.c b/av1/encoder/txb_rdopt.c
index 9c77012..95a0289 100644
--- a/av1/encoder/txb_rdopt.c
+++ b/av1/encoder/txb_rdopt.c
@@ -336,13 +336,13 @@
   const LV_MAP_EOB_COST *txb_eob_costs =
       &coeff_costs->eob_costs[eob_multi_size][plane_type];
 
-  // For the SSIMULACRA 2 tune, increase rshift from 2 to 4.
+  // For the IQ tune, increase rshift from 2 to 4.
   // This biases trellis quantization towards keeping more coefficients, and
-  // together with the SSIMULACRA2 rdmult adjustment in
+  // together with the IQ rdmult adjustment in
   // av1_compute_rd_mult_based_on_qindex(), this helps preserve image
   // features (like repeating patterns and camera noise/film grain), which
   // improves SSIMULACRA 2 scores.
-  const int rshift = cpi->oxcf.tune_cfg.tuning == AOM_TUNE_SSIMULACRA2 ? 4 : 2;
+  const int rshift = cpi->oxcf.tune_cfg.tuning == AOM_TUNE_IQ ? 4 : 2;
 
   const int64_t rdmult = ROUND_POWER_OF_TWO(
       (int64_t)x->rdmult *
diff --git a/test/encode_api_test.cc b/test/encode_api_test.cc
index 8d6803d..5f053b3 100644
--- a/test/encode_api_test.cc
+++ b/test/encode_api_test.cc
@@ -109,7 +109,7 @@
   EXPECT_EQ(AOM_CODEC_OK, aom_codec_destroy(&enc));
 }
 
-TEST(EncodeAPI, TuneSsimulacra2NotAllIntra) {
+TEST(EncodeAPI, TuneIqNotAllIntra) {
   aom_codec_iface_t *iface = aom_codec_av1_cx();
   aom_codec_enc_cfg_t cfg;
   ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_REALTIME),
@@ -118,7 +118,7 @@
   aom_codec_ctx_t enc;
   ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, 0), AOM_CODEC_OK);
 
-  ASSERT_EQ(aom_codec_control(&enc, AOME_SET_TUNING, AOM_TUNE_SSIMULACRA2),
+  ASSERT_EQ(aom_codec_control(&enc, AOME_SET_TUNING, AOM_TUNE_IQ),
             AOM_CODEC_INCAPABLE);
 
   ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
@@ -986,7 +986,7 @@
   ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
 }
 
-TEST(EncodeAPI, AllIntraAndTuneSsimulacra2) {
+TEST(EncodeAPI, AllIntraAndTuneIq) {
   aom_codec_iface_t *iface = aom_codec_av1_cx();
   aom_codec_enc_cfg_t cfg;
   ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_ALL_INTRA),
@@ -995,7 +995,7 @@
   aom_codec_ctx_t enc;
   ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, 0), AOM_CODEC_OK);
 
-  ASSERT_EQ(aom_codec_control(&enc, AOME_SET_TUNING, AOM_TUNE_SSIMULACRA2),
+  ASSERT_EQ(aom_codec_control(&enc, AOME_SET_TUNING, AOM_TUNE_IQ),
             AOM_CODEC_OK);
 
   aom_image_t *image = CreateGrayImage(AOM_IMG_FMT_I420, cfg.g_w, cfg.g_h);