From: “Michael Date: Tue, 9 Apr 2019 21:28:06 +0000 (-0500) Subject: Add fast-adapt mechanism for VNR X-Git-Tag: v1.8.1~130 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32d633ba17aa5ceb8cb12fa2c665747239b3593a;p=libvpx Add fast-adapt mechanism for VNR Change-Id: Ia1d9cde418cc981ee08dc94a2e375d6cb4542250 --- diff --git a/vp9/encoder/vp9_noise_estimate.c b/vp9/encoder/vp9_noise_estimate.c index 2ed192ab6..9696529c5 100644 --- a/vp9/encoder/vp9_noise_estimate.c +++ b/vp9/encoder/vp9_noise_estimate.c @@ -46,6 +46,7 @@ void vp9_noise_estimate_init(NOISE_ESTIMATE *const ne, int width, int height) { ne->thresh = 115; } ne->num_frames_estimate = 15; + ne->adapt_thresh = (3 * ne->thresh) >> 1; } static int enable_noise_estimation(VP9_COMP *const cpi) { @@ -277,7 +278,12 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) { // Scale by 40 to work with existing thresholds ne->value = (int)((3 * ne->value + max_bin * 40) >> 2); - ne->count++; + // Quickly increase VNR strength when the noise level increases suddenly. + if (ne->level < kMedium && ne->value > ne->adapt_thresh) { + ne->count = ne->num_frames_estimate; + } else { + ne->count++; + } if (ne->count == ne->num_frames_estimate) { // Reset counter and check noise level condition. ne->num_frames_estimate = 30; diff --git a/vp9/encoder/vp9_noise_estimate.h b/vp9/encoder/vp9_noise_estimate.h index e30ad3151..7fc94ff8c 100644 --- a/vp9/encoder/vp9_noise_estimate.h +++ b/vp9/encoder/vp9_noise_estimate.h @@ -32,6 +32,7 @@ typedef struct noise_estimate { NOISE_LEVEL level; int value; int thresh; + int adapt_thresh; int count; int last_w; int last_h;