]> granicus.if.org Git - libvpx/commitdiff
Refactor vp9_update_rd_thresh_fact
authorJingning Han <jingning@google.com>
Thu, 30 Oct 2014 00:37:54 +0000 (17:37 -0700)
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>
Thu, 30 Oct 2014 18:09:40 +0000 (11:09 -0700)
Reduce the scope of function parameters.

Change-Id: Ifef2cfb559908a97498ffdbd6ea53da1cd45a73c

vp9/encoder/vp9_pickmode.c
vp9/encoder/vp9_rd.c
vp9/encoder/vp9_rd.h
vp9/encoder/vp9_rdopt.c

index 13564c3476b5d467339ba47008b6e78bf9da7e5d..9b7663fdeaf1f7b540c6d59b3a15edf2525dfc93 100644 (file)
@@ -836,10 +836,12 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
   }
 
   if (is_inter_block(mbmi))
-    vp9_update_rd_thresh_fact(cpi, tile_data, bsize,
+    vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact,
+                              cpi->sf.adaptive_rd_thresh, bsize,
                               mode_idx[ref_frame][INTER_OFFSET(mbmi->mode)]);
   else
-    vp9_update_rd_thresh_fact(cpi, tile_data, bsize,
+    vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact,
+                              cpi->sf.adaptive_rd_thresh, bsize,
                               mode_idx[ref_frame][mbmi->mode]);
 
   *rd_cost = best_rdc;
index 587ffad8d7bec07bd7215e084dc291d363f12c09..fa8482ff62a80cef05c3e208b963119c63460c96 100644 (file)
@@ -611,10 +611,9 @@ void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) {
       rd->thresh_mult_sub8x8[i] = INT_MAX;
 }
 
-// TODO(jingning) Refactor this function. Use targeted smaller struct as inputs.
-void vp9_update_rd_thresh_fact(VP9_COMP *cpi, TileDataEnc *tile_data,
+void vp9_update_rd_thresh_fact(int (*factor_buf)[MAX_MODES], int rd_thresh,
                                int bsize, int best_mode_index) {
-  if (cpi->sf.adaptive_rd_thresh > 0) {
+  if (rd_thresh > 0) {
     const int top_mode = bsize < BLOCK_8X8 ? MAX_REFS : MAX_MODES;
     int mode;
     for (mode = 0; mode < top_mode; ++mode) {
@@ -622,12 +621,12 @@ void vp9_update_rd_thresh_fact(VP9_COMP *cpi, TileDataEnc *tile_data,
       const BLOCK_SIZE max_size = MIN(bsize + 2, BLOCK_64X64);
       BLOCK_SIZE bs;
       for (bs = min_size; bs <= max_size; ++bs) {
-        int *const fact = &tile_data->thresh_freq_fact[bs][mode];
+        int *const fact = &factor_buf[bs][mode];
         if (mode == best_mode_index) {
           *fact -= (*fact >> 4);
         } else {
           *fact = MIN(*fact + RD_THRESH_INC,
-                      cpi->sf.adaptive_rd_thresh * RD_THRESH_MAX_FACT);
+                      rd_thresh * RD_THRESH_MAX_FACT);
         }
       }
     }
index aecca0b43c93d0a0250eb3eacb52af7e513e38d7..ebbe821d5be4412ccb5efe7bd0c860235cdcc962 100644 (file)
@@ -162,8 +162,7 @@ void vp9_set_rd_speed_thresholds(struct VP9_COMP *cpi);
 
 void vp9_set_rd_speed_thresholds_sub8x8(struct VP9_COMP *cpi);
 
-void vp9_update_rd_thresh_fact(struct VP9_COMP *cpi,
-                               struct TileDataEnc *tile_data,
+void vp9_update_rd_thresh_fact(int (*fact)[MAX_MODES], int rd_thresh,
                                int bsize, int best_mode_index);
 
 static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
index 795820b32c4f9c6572c76ae26f1be7049a15ba07..f6ed76ca9c5a181d58d63016962f6952d4c1ce48 100644 (file)
@@ -3397,7 +3397,8 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
          !is_inter_block(&best_mbmode));
 
   if (!cpi->rc.is_src_frame_alt_ref)
-    vp9_update_rd_thresh_fact(cpi, tile_data, bsize, best_mode_index);
+    vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact,
+                              sf->adaptive_rd_thresh, bsize, best_mode_index);
 
   // macroblock modes
   *mbmi = best_mbmode;
@@ -3552,7 +3553,8 @@ void vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi,
   assert((cm->interp_filter == SWITCHABLE) ||
          (cm->interp_filter == mbmi->interp_filter));
 
-  vp9_update_rd_thresh_fact(cpi, tile_data, bsize, THR_ZEROMV);
+  vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact,
+                            cpi->sf.adaptive_rd_thresh, bsize, THR_ZEROMV);
 
   vp9_zero(best_pred_diff);
   vp9_zero(best_filter_diff);
@@ -4127,7 +4129,8 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi,
          (cm->interp_filter == best_mbmode.interp_filter) ||
          !is_inter_block(&best_mbmode));
 
-  vp9_update_rd_thresh_fact(cpi, tile_data, bsize, best_ref_index);
+  vp9_update_rd_thresh_fact(tile_data->thresh_freq_fact,
+                            sf->adaptive_rd_thresh, bsize, best_ref_index);
 
   // macroblock modes
   *mbmi = best_mbmode;