From c1d64b86f13df45af447a348fcd9d2ed1471ab14 Mon Sep 17 00:00:00 2001 From: Yannis Date: Wed, 18 Jun 2025 15:46:36 +0200 Subject: [PATCH 1/2] Use AOM_TUNE_IQ by default Enable TUNE_IQ by default starting with libaom v3.13.0. Update avifenc --help. Add CHANGELOG entry. Co-authored-by: Vincent Rabaud --- CHANGELOG.md | 2 ++ apps/avifenc.c | 2 +- src/codec_aom.c | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fce729568..70de388fb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ The changes are relative to the previous release, unless the baseline is specifi * 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 ef3b615ec8..82e7f9423a 100644 --- a/apps/avifenc.c +++ b/apps/avifenc.c @@ -321,7 +321,7 @@ static void syntaxLong(void) 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 8947edffc0..2a2e4c3d75 100644 --- a/src/codec_aom.c +++ b/src/codec_aom.c @@ -758,6 +758,20 @@ static avifResult aomCodecEncodeImage(avifCodec * codec, } 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 } } From 3e96351308199a1d2caa93eec99ef7c279d2ac6e Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Thu, 26 Feb 2026 09:24:32 +0100 Subject: [PATCH 2/2] Move TUNE_IQ block into non-alpha else --- src/codec_aom.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/codec_aom.c b/src/codec_aom.c index 2a2e4c3d75..030f2e75bf 100644 --- a/src/codec_aom.c +++ b/src/codec_aom.c @@ -757,21 +757,21 @@ static avifResult aomCodecEncodeImage(avifCodec * codec, 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; - } + // 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 + } } }