shithub: libvpx

Download patch

ref: 2337285a2e27a7acdfaa94bba50030c8b49d11e7
parent: d2828f773fd034fb6c44f544e6c2db6e22ca4dc9
parent: bb01ac96ecee7aa62e4ef1fbf1bdf9518e72e687
author: Jingning Han <jingning@google.com>
date: Fri Mar 15 12:47:43 EDT 2019

Merge "Setup frame segmentation for perceptual quality target"

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -5873,6 +5873,20 @@
       cpi->rd.r0 = (double)intra_cost_base / mc_dep_cost_base;
   }
 
+  // Frame segmentation
+  if (cpi->sf.enable_wiener_variance && cm->show_frame) {
+    int mi_row, mi_col;
+    cpi->kmeans_data_size = 0;
+    cpi->kmeans_ctr_num = 5;
+
+    for (mi_row = 0; mi_row < cm->mi_rows; mi_row += MI_BLOCK_SIZE)
+      for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE)
+        wiener_var_rdmult(cpi, BLOCK_64X64, mi_row, mi_col, cpi->rd.RDMULT);
+
+    vp9_kmeans(cpi->kmeans_ctr_ls, cpi->kmeans_boundary_ls, cpi->kmeans_ctr_num,
+               cpi->kmeans_data_arr, cpi->kmeans_data_size);
+  }
+
   {
     struct vpx_usec_timer emr_timer;
     vpx_usec_timer_start(&emr_timer);
@@ -5884,11 +5898,6 @@
     }
 #endif
 
-    if (cpi->sf.enable_wiener_variance && cm->show_frame) {
-      cpi->kmeans_data_size = 0;
-      cpi->kmeans_ctr_num = 5;
-    }
-
     if (!cpi->row_mt) {
       cpi->row_mt_sync_read_ptr = vp9_row_mt_sync_read_dummy;
       cpi->row_mt_sync_write_ptr = vp9_row_mt_sync_write_dummy;
@@ -5902,12 +5911,6 @@
       cpi->row_mt_sync_read_ptr = vp9_row_mt_sync_read;
       cpi->row_mt_sync_write_ptr = vp9_row_mt_sync_write;
       vp9_encode_tiles_row_mt(cpi);
-    }
-
-    if (cpi->sf.enable_wiener_variance && cm->show_frame) {
-      vp9_kmeans(cpi->kmeans_ctr_ls, cpi->kmeans_boundary_ls,
-                 cpi->kmeans_ctr_num, cpi->kmeans_data_arr,
-                 cpi->kmeans_data_size);
     }
 
     vpx_usec_timer_mark(&emr_timer);