shithub: libvpx

Download patch

ref: 159cc3b33c718d90a1a3bae87682d1d21d4af480
parent: f217049dbe0df053a60c3cabaef85bbbe613338b
author: Marco <[email protected]>
date: Fri Jan 13 06:21:33 EST 2017

vp9: Add speed feature flag for computing average source sad.

If enabled will compute source_sad for every superblock on every frame,
prior to encoding. Off by default, only on for speed=8 when
copy_partition is set.

Change-Id: Iab7903180a23dad369135e8234b7f896f20e1231

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3165,7 +3165,7 @@
   if (cpi->oxcf.pass == 0 && cpi->oxcf.mode == REALTIME &&
       cpi->oxcf.speed >= 5 && cpi->resize_state == 0 &&
       (cpi->oxcf.content == VP9E_CONTENT_SCREEN ||
-       cpi->oxcf.rc_mode == VPX_VBR || cpi->sf.copy_partition_flag) &&
+       cpi->oxcf.rc_mode == VPX_VBR || cpi->sf.use_source_sad) &&
       cm->show_frame)
     vp9_avg_source_sad(cpi);
 
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -2254,8 +2254,8 @@
         for (sbi_row = 0; sbi_row < sb_rows; ++sbi_row) {
           for (sbi_col = 0; sbi_col < sb_cols; ++sbi_col) {
             // Checker-board pattern, ignore boundary.
-            // If the partition copy is on, compute for every superblock.
-            if (cpi->sf.copy_partition_flag ||
+            // If the use_source_sad is on, compute for every superblock.
+            if (cpi->sf.use_source_sad ||
                 ((sbi_row > 0 && sbi_col > 0) &&
                  (sbi_row < sb_rows - 1 && sbi_col < sb_cols - 1) &&
                  ((sbi_row % 2 == 0 && sbi_col % 2 == 0) ||
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -312,6 +312,7 @@
   sf->exhaustive_searches_thresh = INT_MAX;
   sf->allow_acl = 0;
   sf->copy_partition_flag = 0;
+  sf->use_source_sad = 0;
 
   if (speed >= 1) {
     sf->allow_txfm_domain_distortion = 1;
@@ -502,6 +503,7 @@
         !cpi->external_resize)
       sf->copy_partition_flag = 1;
     if (sf->copy_partition_flag) {
+      sf->use_source_sad = 1;
       if (cpi->prev_partition == NULL) {
         cpi->prev_partition = (BLOCK_SIZE *)vpx_calloc(
             cm->mi_stride * cm->mi_rows, sizeof(BLOCK_SIZE));
--- a/vp9/encoder/vp9_speed_features.h
+++ b/vp9/encoder/vp9_speed_features.h
@@ -478,6 +478,10 @@
 
   // Global flag to enable partition copy from the previous frame.
   int copy_partition_flag;
+
+  // Compute the source sad for every superblock of the frame,
+  // prior to encoding the frame, to be used to bypass some encoder decisions.
+  int use_source_sad;
 } SPEED_FEATURES;
 
 struct VP9_COMP;