Make `--tune=iq` use the all intra luma QM level formula Using the SSIMULACRA 2 luma QM formula can result in an image that can visually look too soft or blurry in some cases, especially at low to mid quality levels. `--tune=ssimulacra2` will continue using the SSIMULACRA 2 formula. Bug: aomedia:401234702 Change-Id: I60778359becf263b925468813be3de6c242c3f85
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index 79908ec..97bc198 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -1825,11 +1825,11 @@ // 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_iq() - // - aom_get_qmlevel_444_chroma_iq() + // - aom_get_qmlevel_luma_ssimulacra2() + // - aom_get_qmlevel_444_chroma() extra_cfg->enable_qm = 1; - extra_cfg->qm_min = QM_FIRST_IQ; - extra_cfg->qm_max = QM_LAST_IQ; + extra_cfg->qm_min = QM_FIRST_IQ_SSIMULACRA2; + extra_cfg->qm_max = QM_LAST_IQ_SSIMULACRA2; // We can turn on loop filter sharpness, as frames do not have to serve as // references to others. extra_cfg->sharpness = 7;
diff --git a/av1/common/quant_common.h b/av1/common/quant_common.h index 129c5c2..965a746 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_IQ 2 -#define QM_LAST_IQ 10 +#define QM_FIRST_IQ_SSIMULACRA2 2 +#define QM_LAST_IQ_SSIMULACRA2 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 image quality (IQ) +// Luma QM levels tuned for SSIMULACRA 2 // 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,7 +108,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_luma_iq(int qindex, int first, int last) { +static inline int aom_get_qmlevel_luma_ssimulacra2(int qindex, int first, + int last) { int qm_level = 0; if (qindex <= 40) { @@ -134,7 +135,7 @@ return clamp(qm_level, first, last); } -// Chroma QM levels for 4:4:4 subsampling tuned for image quality (IQ) +// Chroma QM levels for 4:4:4 subsampling used for SSIMULACRA 2 and IQ tunings // 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 @@ -146,8 +147,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_444_chroma_iq(int qindex, int first, - int last) { +static inline int aom_get_qmlevel_444_chroma(int qindex, int first, int last) { int chroma_qm_level = 0; if (qindex <= 12) {
diff --git a/av1/encoder/av1_quantize.c b/av1/encoder/av1_quantize.c index 0615224..1f962c3 100644 --- a/av1/encoder/av1_quantize.c +++ b/av1/encoder/av1_quantize.c
@@ -971,8 +971,12 @@ if (is_allintra) { if (tuning == AOM_TUNE_IQ || tuning == AOM_TUNE_SSIMULACRA2) { - // Use luma QM formula specifically tailored for tune IQ - get_luma_qmlevel = aom_get_qmlevel_luma_iq; + if (tuning == AOM_TUNE_SSIMULACRA2) { + // Use luma QM formula specifically tailored for tune SSIMULACRA2 + get_luma_qmlevel = aom_get_qmlevel_luma_ssimulacra2; + } else { + get_luma_qmlevel = aom_get_qmlevel_allintra; + } if (cm->seq_params->subsampling_x == 0 && cm->seq_params->subsampling_y == 0) { @@ -980,7 +984,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_iq; + get_chroma_qmlevel = aom_get_qmlevel_444_chroma; } else { // For all other chroma subsampling modes, use the all intra QM formula get_chroma_qmlevel = aom_get_qmlevel_allintra;