Use AOM_TUNE_IQ by default for YUV (#2830)
Enable TUNE_IQ by default starting with libaom v3.13.0.
Update avifenc --help.
Add CHANGELOG entry.
Co-authored-by: Vincent Rabaud <vrabaud@google.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1fce729..70de388 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,8 @@
* Set tuning before applying the user-provided specific aom codec options.
* Use AOM_TUNE_PSNR by default when encoding alpha with libaom because
AOM_TUNE_SSIM causes ringing for alpha.
+* Use AOM_TUNE_IQ by default when encoding still non-RGB color samples with
+ libaom v3.13.0 or later.
* Converting an image containing a gain map using avifenc with the --grid flag
now also splits the gain map into a grid.
diff --git a/apps/avifenc.c b/apps/avifenc.c
index ef3b615..82e7f94 100644
--- a/apps/avifenc.c
+++ b/apps/avifenc.c
@@ -321,7 +321,7 @@
printf(" end-usage=MODE : Rate control mode, one of 'vbr', 'cbr', 'cq', or 'q'\n");
printf(" sharpness=S : Bias towards block sharpness in rate-distortion optimization of transform coefficients in 0..7. (Default: 0)\n");
printf(" tune=METRIC : Tune the encoder for distortion metric, one of 'psnr', 'ssim' or 'iq'.\n");
- printf(" (Default for color: ssim, default for alpha: psnr)\n");
+ printf(" (Default for color: still non-RGB images (libaom v3.13.0+): iq, otherwise: ssim; default for alpha: psnr)\n");
printf(" film-grain-test=TEST : Film grain test vectors in 0..16. 0=none (default), 1=test1, 2=test2, ... 16=test16\n");
printf(" film-grain-table=FILENAME : Path to file containing film grain parameters\n");
printf("\n");
diff --git a/src/codec_aom.c b/src/codec_aom.c
index bcdabc7..97431fb 100644
--- a/src/codec_aom.c
+++ b/src/codec_aom.c
@@ -757,6 +757,20 @@
libavifDefaultTuneMetric = AOM_TUNE_PSNR;
} else {
libavifDefaultTuneMetric = AOM_TUNE_SSIM;
+#if defined(AOM_HAVE_TUNE_IQ)
+ // AOM_TUNE_IQ has been tuned for the YCbCr family of color spaces, and is favored for
+ // its low perceptual distortion. AOM_TUNE_IQ partially generalizes to, and benefits
+ // from other "YUV-like" spaces (e.g. YCgCo and ICtCp) including monochrome (luma only).
+ // AOM_TUNE_IQ sets --deltaq-mode=6 which can only be used in all intra mode.
+ // AOM_TUNE_IQ was introduced in libaom v3.12.0 but it has significantly different bit
+ // allocation characteristics compared to v3.13.0. AOM_TUNE_IQ is used by default
+ // starting with v3.13.0 for fewer behavior changes in libavif.
+ static const int aomVersion_3_13_0 = (3 << 16) | (13 << 8);
+ if (image->matrixCoefficients != AVIF_MATRIX_COEFFICIENTS_IDENTITY && aomUsage == AOM_USAGE_ALL_INTRA &&
+ aomVersion >= aomVersion_3_13_0) {
+ libavifDefaultTuneMetric = AOM_TUNE_IQ;
+ }
+#endif
}
}
}