vp9: Denoiser speed-up: increase partition and ac skip thresholds.
authorMarco <marpan@google.com>
Tue, 7 Feb 2017 01:02:28 +0000 (17:02 -0800)
committerMarco <marpan@google.com>
Tue, 7 Feb 2017 18:33:13 +0000 (10:33 -0800)
Add factor to increase varianace partition and ac skip thresholds,
under certain conditions (noise level and sum_diff), to increase
denoiser speed.

Change-Id: I7671140ef3598bf5f114a72623d68792bcd7b77b

vp9/encoder/vp9_denoiser.c
vp9/encoder/vp9_denoiser.h
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_pickmode.c

index a505d41..afc66d0 100644 (file)
@@ -564,6 +564,25 @@ void vp9_denoiser_set_noise_level(VP9_DENOISER *denoiser, int noise_level) {
   denoiser->prev_denoising_level = denoiser->denoising_level;
 }
 
+// Scale/increase the partition threshold for denoiser speed-up.
+int64_t vp9_scale_part_thresh(int64_t threshold,
+                              VP9_DENOISER_LEVEL noise_level) {
+  if (noise_level >= kDenLow)
+    return ((5 * threshold) >> 2);
+  else
+    return threshold;
+}
+
+//  Scale/increase the ac skip threshold for denoiser speed-up.
+int64_t vp9_scale_acskip_thresh(int64_t threshold,
+                                VP9_DENOISER_LEVEL noise_level,
+                                int abs_sumdiff) {
+  if (noise_level >= kDenLow && abs_sumdiff < 5)
+    return threshold *= (noise_level == kDenLow) ? 2 : 6;
+  else
+    return threshold;
+}
+
 #ifdef OUTPUT_YUV_DENOISED
 static void make_grayscale(YV12_BUFFER_CONFIG *yuv) {
   int r, c;
index fcfaa50..a029339 100644 (file)
@@ -97,6 +97,13 @@ void vp9_denoiser_free(VP9_DENOISER *denoiser);
 
 void vp9_denoiser_set_noise_level(VP9_DENOISER *denoiser, int noise_level);
 
+int64_t vp9_scale_part_thresh(int64_t threshold,
+                              VP9_DENOISER_LEVEL noise_level);
+
+int64_t vp9_scale_acskip_thresh(int64_t threshold,
+                                VP9_DENOISER_LEVEL noise_level,
+                                int abs_sumdiff);
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index a62f4b4..1bbdeec 100644 (file)
@@ -488,8 +488,16 @@ static void set_vbp_thresholds(VP9_COMP *cpi, int64_t thresholds[], int q) {
       else if (noise_level < kLow)
         threshold_base = (7 * threshold_base) >> 3;
     }
+#if CONFIG_VP9_TEMPORAL_DENOISING
+    if (cpi->oxcf.noise_sensitivity > 0)
+      threshold_base =
+          vp9_scale_part_thresh(threshold_base, cpi->denoiser.denoising_level);
+    else if (cpi->oxcf.speed >= 8 && cm->width <= 640 && cm->height <= 480)
+      threshold_base = (5 * threshold_base) >> 2;
+#else
     if (cpi->oxcf.speed >= 8 && cm->width <= 640 && cm->height <= 480)
       threshold_base = (5 * threshold_base) >> 2;
+#endif
     thresholds[0] = threshold_base;
     thresholds[2] = threshold_base << cpi->oxcf.speed;
     if (cm->width <= 352 && cm->height <= 288) {
index de1546a..8126a0a 100644 (file)
@@ -353,8 +353,17 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
   *var_y = var;
   *sse_y = sse;
 
+#if CONFIG_VP9_TEMPORAL_DENOISING
+  if (cpi->oxcf.noise_sensitivity > 0)
+    ac_thr = vp9_scale_acskip_thresh(ac_thr, cpi->denoiser.denoising_level,
+                                     (abs(sum) >> (bw + bh)));
+  else
+    ac_thr *= ac_thr_factor(cpi->oxcf.speed, cpi->common.width,
+                            cpi->common.height, abs(sum) >> (bw + bh));
+#else
   ac_thr *= ac_thr_factor(cpi->oxcf.speed, cpi->common.width,
                           cpi->common.height, abs(sum) >> (bw + bh));
+#endif
 
   if (cpi->common.tx_mode == TX_MODE_SELECT) {
     if (sse > (var << 2))