shithub: libvpx

Download patch

ref: a646d7ff69bacdb75263360c991f1b86de257050
parent: c5d8c1e785f057458c9e6bbd8f6259279d5e689e
parent: 31e54bbf425fface54e952b015223bc05e49842b
author: Dmitry Kovalev <[email protected]>
date: Fri Aug 15 08:51:56 EDT 2014

Merge "Removing active_arnr_{strength, frames} from VP9_COMP."

--- a/vp9/encoder/vp9_encoder.h
+++ b/vp9/encoder/vp9_encoder.h
@@ -298,8 +298,6 @@
 
   int zbin_mode_boost;
   int zbin_mode_boost_enabled;
-  int active_arnr_frames;           // <= cpi->oxcf.arnr_max_frames
-  int active_arnr_strength;         // <= cpi->oxcf.arnr_max_strength
 
   int64_t last_time_stamp_seen;
   int64_t last_end_time_stamp_seen;
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -357,12 +357,14 @@
 
 // Apply buffer limits and context specific adjustments to arnr filter.
 static void adjust_arnr_filter(VP9_COMP *cpi,
-                               int distance, int group_boost) {
+                               int distance, int group_boost,
+                               int *arnr_frames, int *arnr_strength) {
+  const VP9EncoderConfig *const oxcf = &cpi->oxcf;
   const int frames_after_arf =
-            vp9_lookahead_depth(cpi->lookahead) - distance - 1;
+      vp9_lookahead_depth(cpi->lookahead) - distance - 1;
   int frames_fwd = (cpi->oxcf.arnr_max_frames - 1) >> 1;
   int frames_bwd;
-  int q;
+  int q, frames, strength;
 
   // Define the forward and backwards filter limits for this arnr group.
   if (frames_fwd > frames_after_arf)
@@ -375,10 +377,10 @@
   // For even length filter there is one more frame backward
   // than forward: e.g. len=6 ==> bbbAff, len=7 ==> bbbAfff.
   if (frames_bwd < distance)
-    frames_bwd += (cpi->oxcf.arnr_max_frames + 1) & 0x1;
+    frames_bwd += (oxcf->arnr_max_frames + 1) & 0x1;
 
   // Set the baseline active filter size.
-  cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd;
+  frames = frames_bwd + 1 + frames_fwd;
 
   // Adjust the strength based on active max q.
   if (cpi->common.current_video_frame > 1)
@@ -388,20 +390,21 @@
     q = ((int)vp9_convert_qindex_to_q(
         cpi->rc.avg_frame_qindex[KEY_FRAME]));
   if (q > 16) {
-    cpi->active_arnr_strength = cpi->oxcf.arnr_strength;
+    strength = oxcf->arnr_strength;
   } else {
-    cpi->active_arnr_strength = cpi->oxcf.arnr_strength - ((16 - q) / 2);
-    if (cpi->active_arnr_strength < 0)
-      cpi->active_arnr_strength = 0;
+    strength = oxcf->arnr_strength - ((16 - q) / 2);
+    if (strength < 0)
+      strength = 0;
   }
 
   // Adjust number of frames in filter and strength based on gf boost level.
-  if (cpi->active_arnr_frames > (group_boost / 150)) {
-    cpi->active_arnr_frames = (group_boost / 150);
-    cpi->active_arnr_frames += !(cpi->active_arnr_frames & 1);
+  if (frames > group_boost / 150) {
+    frames = group_boost / 150;
+    frames += !(frames & 1);
   }
-  if (cpi->active_arnr_strength > (group_boost / 300)) {
-    cpi->active_arnr_strength = (group_boost / 300);
+
+  if (strength > group_boost / 300) {
+    strength = group_boost / 300;
   }
 
   // Adjustments for second level arf in multi arf case.
@@ -408,9 +411,12 @@
   if (cpi->oxcf.pass == 2 && cpi->multi_arf_allowed) {
     const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
     if (gf_group->rf_level[gf_group->index] != GF_ARF_STD) {
-      cpi->active_arnr_strength >>= 1;
+      strength >>= 1;
     }
   }
+
+  *arnr_frames = frames;
+  *arnr_strength = strength;
 }
 
 void vp9_temporal_filter(VP9_COMP *cpi, int distance) {
@@ -425,9 +431,7 @@
   struct scale_factors sf;
 
   // Apply context specific adjustments to the arnr filter parameters.
-  adjust_arnr_filter(cpi, distance, rc->gfu_boost);
-  strength = cpi->active_arnr_strength;
-  frames_to_blur = cpi->active_arnr_frames;
+  adjust_arnr_filter(cpi, distance, rc->gfu_boost, &frames_to_blur, &strength);
   frames_to_blur_backward = (frames_to_blur / 2);
   frames_to_blur_forward = ((frames_to_blur - 1) / 2);
   start_frame = distance + frames_to_blur_forward;