shithub: libvpx

Download patch

ref: 2c8c1f53703e503f146aee61539b1a42d7913c69
parent: 833ad89f721c0bea15b2114b72cd940a2d4279d4
author: Dmitry Kovalev <dkovalev@google.com>
date: Wed Apr 16 14:31:42 EDT 2014

Replacing cpu_used with speed in VP9_CONFIG.

Change-Id: I86b85b5c11388e84a48f8936330c0d920df5d1f0

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -911,7 +911,7 @@
     const int num_mbs = cpi->common.MBs;
     const double section_err = stats->coded_error / stats->count;
     const double err_per_mb = section_err / num_mbs;
-    const double speed_term = 1.0 + 0.04 * cpi->speed;
+    const double speed_term = 1.0 + 0.04 * cpi->oxcf.speed;
     const int target_norm_bits_per_mb = ((uint64_t)section_target_bandwidth <<
                                             BPER_MB_NORMBITS) / num_mbs;
     int q;
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -38,8 +38,8 @@
 
   // Further step/diamond searches as necessary
   int step_param = cpi->sf.reduce_first_step_size +
-      (cpi->speed < 8 ? (cpi->speed > 5 ? 1 : 0) : 2);
-  step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2));
+                       (cpi->oxcf.speed > 5 ? 1 : 0);
+  step_param = MIN(step_param, cpi->sf.max_step_search_steps - 2);
 
   vp9_set_mv_search_range(x, ref_mv);
 
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -705,14 +705,10 @@
 
   cpi->oxcf = *oxcf;
 
-  if (cpi->oxcf.cpu_used == -6)
-    cpi->oxcf.play_alternate = 0;
-
   switch (cpi->oxcf.mode) {
       // Real time and one pass deprecated in test code base
     case ONE_PASS_GOOD:
       cpi->pass = 0;
-      cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5);
       break;
 
     case ONE_PASS_BEST:
@@ -725,7 +721,6 @@
 
     case TWO_PASS_SECOND_GOOD:
       cpi->pass = 2;
-      cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5);
       break;
 
     case TWO_PASS_SECOND_BEST:
@@ -734,6 +729,7 @@
 
     case REALTIME:
       cpi->pass = 0;
+      cpi->oxcf.play_alternate = 0;
       break;
   }
 
@@ -832,8 +828,6 @@
     vp9_update_layer_context_change_config(cpi,
                                            (int)cpi->oxcf.target_bandwidth);
   }
-
-  cpi->speed = abs(cpi->oxcf.cpu_used);
 
 #if CONFIG_MULTIPLE_ARF
   vp9_zero(cpi->alt_ref_source);
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -196,7 +196,7 @@
 
   int noise_sensitivity;  // pre processing blur: recommendation 0
   int sharpness;  // sharpening output: recommendation 0:
-  int cpu_used;
+  int speed;
   unsigned int rc_max_intra_bitrate_pct;
 
   MODE mode;
@@ -402,10 +402,6 @@
   int mbgraph_n_frames;             // number of frames filled in the above
   int static_mb_pct;                // % forced skip mbs by segmentation
 
-  // for real time encoding
-  int speed;
-
-  int cpu_used;
   int pass;
 
   int ref_frame_flags;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -451,7 +451,7 @@
       x->pred_sse[ref] = sse;
 
     // Fast approximate the modelling function.
-    if (cpi->speed > 4) {
+    if (cpi->oxcf.speed > 4) {
       int64_t rate;
       int64_t dist;
       int64_t square_error = sse;
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -289,7 +289,6 @@
   SPEED_FEATURES *const sf = &cpi->sf;
   VP9_COMMON *const cm = &cpi->common;
   const VP9_CONFIG *const oxcf = &cpi->oxcf;
-  const int speed = cpi->speed < 0 ? -cpi->speed : cpi->speed;
   int i;
 
   // best quality defaults
@@ -360,10 +359,10 @@
     case TWO_PASS_FIRST:
     case ONE_PASS_GOOD:
     case TWO_PASS_SECOND_GOOD:
-      set_good_speed_feature(cpi, cm, sf, speed);
+      set_good_speed_feature(cpi, cm, sf, oxcf->speed);
       break;
     case REALTIME:
-      set_rt_speed_feature(cm, sf, speed);
+      set_rt_speed_feature(cm, sf, oxcf->speed);
       break;
   }
 
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -151,12 +151,8 @@
   xd->plane[0].pre[0].buf = frame_ptr_buf;
   xd->plane[0].pre[0].stride = stride;
 
-  // Further step/diamond searches as necessary
-  if (cpi->speed < 8)
-    step_param = cpi->sf.reduce_first_step_size + ((cpi->speed > 5) ? 1 : 0);
-  else
-    step_param = cpi->sf.reduce_first_step_size + 2;
-  step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2));
+  step_param = cpi->sf.reduce_first_step_size + (cpi->oxcf.speed > 5 ? 1 : 0);
+  step_param = MIN(step_param, cpi->sf.max_step_search_steps - 2);
 
   /*cpi->sf.search_method == HEX*/
   // Ignore mv costing by sending NULL pointer instead of cost arrays
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -356,7 +356,7 @@
 
   oxcf->key_freq               = cfg->kf_max_dist;
 
-  oxcf->cpu_used               =  extra_cfg->cpu_used;
+  oxcf->speed                  =  clamp(abs(extra_cfg->cpu_used), 0, 7);
   oxcf->encode_breakout        =  extra_cfg->static_thresh;
   oxcf->play_alternate         =  extra_cfg->enable_auto_alt_ref;
   oxcf->noise_sensitivity      =  extra_cfg->noise_sensitivity;