Implement Variance Boost strength Use the existing AV1E_SET_DELTAQ_STRENGTH codec control to specify Variance Boost strength. The provided value is specified as a percentage. For example, to make Variance Boost 25% stronger, use `--deltaq-strength=125`. Bug: aomedia:401234702 Change-Id: I74c75d3d1e71a3ec68681681c1b123202b5f1927
diff --git a/av1/arg_defs.c b/av1/arg_defs.c index eccaea9..81d00c4 100644 --- a/av1/arg_defs.c +++ b/av1/arg_defs.c
@@ -560,7 +560,7 @@ "Variance Boost all intra); requires --enable-tpl-model=1"), .deltaq_strength = ARG_DEF(NULL, "deltaq-strength", 1, "Deltaq strength for" - " --deltaq-mode=4 (%)"), + " --deltaq-mode=4 and --deltaq-mode=6 (%)"), .deltalf_mode = ARG_DEF(NULL, "delta-lf-mode", 1, "Enable delta-lf-mode (0: off (default), 1: on)"), .frame_periodic_boost =
diff --git a/av1/encoder/allintra_vis.c b/av1/encoder/allintra_vis.c index b9398e4..50e0ba2 100644 --- a/av1/encoder/allintra_vis.c +++ b/av1/encoder/allintra_vis.c
@@ -1077,11 +1077,15 @@ // Variance Boost only supports 64x64 SBs. assert(cm->seq_params->sb_size == BLOCK_64X64); - // Strength is currently hard-coded and optimized for still pictures. In the - // future, we might want to expose this as a parameter that can be fine-tuned - // by the caller. - const int strength = 3; unsigned int variance = av1_get_variance_boost_block_variance(cpi, x); + // Compute Variance Boost strength from the deltaq_strength value. + double strength = (cpi->oxcf.q_cfg.deltaq_strength / 100.0) * 3.0; + + // Clamp strength to a reasonable range. + // deltaq_strength can go up to 1000%, which is too strong for the Variance + // Boost scaling. Testing revealed strengths as high as 6 (200%) are still + // reasonable for some specific scenarios. + strength = fclamp(strength, 0.0, 6.0); // Variance = 0 areas are either completely flat patches or have very fine // gradients. Boost these blocks as if they have a variance of 1. @@ -1092,8 +1096,6 @@ // Compute a boost based on a fast-growing formula. // High and medium variance SBs essentially get no boost, while lower variance // SBs get increasingly stronger boosts. - assert(strength >= 1 && strength <= 4); - // Still picture curve, with variance crossover point at 1024. double qstep_ratio = 0.15 * strength * (-log2((double)variance) + 10.0) + 1.0; qstep_ratio = fclamp(qstep_ratio, 1.0, VAR_BOOST_MAX_BOOST);