shithub: libvpx

Download patch

ref: 3ff77503c935c105f5cab28bd7c508ba0a66080e
parent: a3c27960397354d796c268cbeefaa293759348fc
parent: d06839dd272514719591cf4615cce595b681ab3f
author: Jingning Han <[email protected]>
date: Tue Jul 31 00:11:45 EDT 2018

Merge changes Ibafb6157,Ibebced5d

* changes:
  Move frame pointer assignment outside block loop in tpl model
  Refactor tpl_model_store input parameters

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5661,27 +5661,29 @@
 }
 
 void tpl_model_store(TplDepStats *tpl_stats, int mi_row, int mi_col,
-                     BLOCK_SIZE bsize, int stride, int64_t intra_cost,
-                     int64_t inter_cost, int ref_frame_idx, int_mv mv) {
+                     BLOCK_SIZE bsize, int stride,
+                     const TplDepStats *src_stats) {
   const int mi_height = num_8x8_blocks_high_lookup[bsize];
   const int mi_width = num_8x8_blocks_wide_lookup[bsize];
   int idx, idy;
 
-  intra_cost = intra_cost / (mi_height * mi_width);
-  inter_cost = inter_cost / (mi_height * mi_width);
+  int64_t intra_cost = src_stats->intra_cost / (mi_height * mi_width);
+  int64_t inter_cost = src_stats->inter_cost / (mi_height * mi_width);
 
+  TplDepStats *tpl_ptr;
+
   intra_cost = VPXMAX(1, intra_cost);
   inter_cost = VPXMAX(1, inter_cost);
 
   for (idy = 0; idy < mi_height; ++idy) {
+    tpl_ptr = &tpl_stats[(mi_row + idy) * stride + mi_col];
     for (idx = 0; idx < mi_width; ++idx) {
-      TplDepStats *tpl_ptr =
-          &tpl_stats[(mi_row + idy) * stride + (mi_col + idx)];
       tpl_ptr->intra_cost = intra_cost;
       tpl_ptr->inter_cost = inter_cost;
       tpl_ptr->mc_dep_cost = tpl_ptr->intra_cost + tpl_ptr->mc_flow;
-      tpl_ptr->ref_frame_index = ref_frame_idx;
-      tpl_ptr->mv.as_int = mv.as_int;
+      tpl_ptr->ref_frame_index = src_stats->ref_frame_index;
+      tpl_ptr->mv.as_int = src_stats->mv.as_int;
+      ++tpl_ptr;
     }
   }
 }
@@ -5817,6 +5819,8 @@
   int mb_y_offset = mi_row * MI_SIZE * xd->cur_buf->y_stride + mi_col * MI_SIZE;
   MODE_INFO mi_above, mi_left;
 
+  memset(tpl_stats, 0, sizeof(*tpl_stats));
+
   xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
   xd->mb_to_bottom_edge = ((cm->mi_rows - 1 - mi_row) * MI_SIZE) * 8;
   xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8);
@@ -5975,6 +5979,7 @@
 
   xd->mi = cm->mi_grid_visible;
   xd->mi[0] = cm->mi;
+  xd->cur_buf = this_frame;
 
   // Get rd multiplier set up.
   rdmult =
@@ -5995,7 +6000,6 @@
         (cm->mi_rows - 1 - mi_row) * MI_SIZE + (17 - 2 * VP9_INTERP_EXTEND);
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col += mi_width) {
       TplDepStats tpl_stats;
-      xd->cur_buf = this_frame;
       mode_estimation(cpi, x, xd, &sf, gf_picture, frame_idx, src_diff, coeff,
                       qcoeff, dqcoeff, mi_row, mi_col, bsize, tx_size,
                       ref_frame, predictor, &recon_error, &sse, &tpl_stats);
@@ -6002,9 +6006,7 @@
 
       // Motion flow dependency dispenser.
       tpl_model_store(tpl_frame->tpl_stats_ptr, mi_row, mi_col, bsize,
-                      tpl_frame->stride, tpl_stats.intra_cost,
-                      tpl_stats.inter_cost, tpl_stats.ref_frame_index,
-                      tpl_stats.mv);
+                      tpl_frame->stride, &tpl_stats);
 
       tpl_model_update(cpi->tpl_stats, tpl_frame->tpl_stats_ptr, mi_row, mi_col,
                        bsize);