From: Paul Wilkins Date: Thu, 28 Mar 2019 13:39:54 +0000 (+0000) Subject: Add GF group noise weighting in rd_variance_adjustment() X-Git-Tag: v1.8.1~147^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=247a28c280677b92537951f61b218d3c79ed3800;p=libvpx Add GF group noise weighting in rd_variance_adjustment() For film mode add a weighting to the thresholds used in rd_variance_adjustment() based on noise measured in the first pass. Change-Id: I83ca669bb55aa52f1d34f03a2268b79fba890770 --- diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index a01cf964d..eac5bc950 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -3140,6 +3140,7 @@ static void rd_variance_adjustment(VP9_COMP *cpi, MACROBLOCK *x, unsigned int absvar_diff = 0; unsigned int var_factor = 0; unsigned int adj_max; + unsigned int low_var_thresh = LOW_VAR_THRESH; const int bw = num_8x8_blocks_wide_lookup[bsize]; const int bh = num_8x8_blocks_high_lookup[bsize]; vp9e_tune_content content_type = cpi->oxcf.content; @@ -3164,12 +3165,23 @@ static void rd_variance_adjustment(VP9_COMP *cpi, MACROBLOCK *x, rec_variance /= (bw * bh); src_variance /= (bw * bh); + if (content_type == VP9E_CONTENT_FILM) { + if (cpi->oxcf.pass == 2) { + // Adjust low variance threshold based on estimated group noise enegry. + double noise_factor = + (double)cpi->twopass.gf_group.group_noise_energy / SECTION_NOISE_DEF; + low_var_thresh = (unsigned int)(low_var_thresh * noise_factor); + } + } else { + low_var_thresh = LOW_VAR_THRESH / 2; + } + // Lower of source (raw per pixel value) and recon variance. Note that // if the source per pixel is 0 then the recon value here will not be per // pixel (see above) so will likely be much larger. src_rec_min = VPXMIN(src_variance, rec_variance); - if (src_rec_min > LOW_VAR_THRESH) return; + if (src_rec_min > low_var_thresh) return; absvar_diff = (src_variance > rec_variance) ? (src_variance - rec_variance) : (rec_variance - src_variance); @@ -3183,7 +3195,7 @@ static void rd_variance_adjustment(VP9_COMP *cpi, MACROBLOCK *x, *this_rd += (*this_rd * var_factor) / 100; if (content_type == VP9E_CONTENT_FILM) { - if (src_rec_min <= LOW_VAR_THRESH / 2) { + if (src_rec_min <= low_var_thresh / 2) { if (ref_frame == INTRA_FRAME) { if (this_mode == DC_PRED) *this_rd *= 2;