]> granicus.if.org Git - libvpx/commitdiff
Improved auto_partition_range.
authorPaul Wilkins <paulwilkins@google.com>
Fri, 27 Sep 2013 11:59:06 +0000 (12:59 +0100)
committerPaul Wilkins <paulwilkins@google.com>
Mon, 30 Sep 2013 10:32:57 +0000 (11:32 +0100)
The code now takes into account temporal and spatial
information to determine the partition size range, but the
frequency counts have been removed.

The net effect is similar in quality but about 10% faster.

Change-Id: I39a513fb79cec9177b73b2a7218f0da70963ae95

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_onyx_if.c
vp9/encoder/vp9_onyx_int.h

index a2adcd386fc607f66f1162dd663cd714b34c6827..73b50c7639484a00b605a9beccc92d7fb4760e90 100644 (file)
@@ -507,8 +507,7 @@ static void set_offsets(VP9_COMP *cpi, int mi_row, int mi_col,
   // cannot be used.
   xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL;
 
-  xd->this_mi =
-  xd->mi_8x8[0] = cm->mi + idx_str;
+  xd->this_mi = xd->mi_8x8[0] = cm->mi + idx_str;
 
   mbmi = &xd->this_mi->mbmi;
 
@@ -1261,63 +1260,64 @@ static void get_sb_partition_size_range(VP9_COMP *cpi, MODE_INFO ** mi_8x8,
 static void rd_auto_partition_range(VP9_COMP *cpi, int row, int col,
                                     BLOCK_SIZE *min_block_size,
                                     BLOCK_SIZE *max_block_size) {
+  VP9_COMMON * const cm = &cpi->common;
   MACROBLOCKD *const xd = &cpi->mb.e_mbd;
   MODE_INFO ** mi_8x8 = xd->mi_8x8;
+  MODE_INFO ** prev_mi_8x8 = xd->prev_mi_8x8;
+
   const int left_in_image = xd->left_available && mi_8x8[-1];
   const int above_in_image = xd->up_available &&
                              mi_8x8[-xd->mode_info_stride];
   MODE_INFO ** above_sb64_mi_8x8;
   MODE_INFO ** left_sb64_mi_8x8;
 
-  // Frequency check
-  if (cpi->sf.auto_min_max_partition_count <= 0) {
-    cpi->sf.auto_min_max_partition_count =
-      cpi->sf.auto_min_max_partition_interval;
+  int row8x8_remaining = cm->cur_tile_mi_row_end - row;
+  int col8x8_remaining = cm->cur_tile_mi_col_end - col;
+  int bh, bw;
+
+  // Trap case where we do not have a prediction.
+  if (!left_in_image && !above_in_image &&
+      ((cm->frame_type == KEY_FRAME) || !cm->prev_mi)) {
     *min_block_size = BLOCK_4X4;
     *max_block_size = BLOCK_64X64;
   } else {
-    --cpi->sf.auto_min_max_partition_count;
-
-    // Set default values if no left or above neighbour
-    if (!left_in_image && !above_in_image) {
-      *min_block_size = BLOCK_4X4;
-      *max_block_size = BLOCK_64X64;
-    } else {
-      VP9_COMMON *const cm = &cpi->common;
-      int row8x8_remaining = cm->cur_tile_mi_row_end - row;
-      int col8x8_remaining = cm->cur_tile_mi_col_end - col;
-      int bh, bw;
-
-      // Default "min to max" and "max to min"
-      *min_block_size = BLOCK_64X64;
-      *max_block_size = BLOCK_4X4;
-
-      // Find the min and max partition sizes used in the left SB64
-      if (left_in_image) {
-        left_sb64_mi_8x8 = &mi_8x8[-MI_BLOCK_SIZE];
-        get_sb_partition_size_range(cpi, left_sb64_mi_8x8,
-                                    min_block_size, max_block_size);
-      }
-
-      // Find the min and max partition sizes used in the above SB64 taking
-      // the values found for left as a starting point.
-      if (above_in_image) {
-        above_sb64_mi_8x8 = &mi_8x8[-xd->mode_info_stride * MI_BLOCK_SIZE];
-        get_sb_partition_size_range(cpi, above_sb64_mi_8x8,
-                                    min_block_size, max_block_size);
-      }
+    // Default "min to max" and "max to min"
+    *min_block_size = BLOCK_64X64;
+    *max_block_size = BLOCK_4X4;
+
+    // NOTE: each call to get_sb_partition_size_range() uses the previous
+    // passed in values for min and max as a starting point.
+    //
+    // Find the min and max partition used in previous frame at this location
+    if (cm->prev_mi && (cm->frame_type != KEY_FRAME)) {
+      get_sb_partition_size_range(cpi, prev_mi_8x8,
+                                  min_block_size, max_block_size);
+    }
 
-      // Give a bit of leaway either side of the observed min and max
-      *min_block_size = min_partition_size[*min_block_size];
-      *max_block_size = max_partition_size[*max_block_size];
+    // Find the min and max partition sizes used in the left SB64
+    if (left_in_image) {
+      left_sb64_mi_8x8 = &mi_8x8[-MI_BLOCK_SIZE];
+      get_sb_partition_size_range(cpi, left_sb64_mi_8x8,
+                                  min_block_size, max_block_size);
+    }
 
-      // Check border cases where max and min from neighbours may not be legal.
-      *max_block_size = find_partition_size(*max_block_size,
-                                            row8x8_remaining, col8x8_remaining,
-                                            &bh, &bw);
-      *min_block_size = MIN(*min_block_size, *max_block_size);
+    // Find the min and max partition sizes used in the above SB64.
+    if (above_in_image) {
+      above_sb64_mi_8x8 = &mi_8x8[-xd->mode_info_stride * MI_BLOCK_SIZE];
+      get_sb_partition_size_range(cpi, above_sb64_mi_8x8,
+                                  min_block_size, max_block_size);
     }
   }
+
+  // Give a bit of leaway either side of the observed min and max
+  *min_block_size = min_partition_size[*min_block_size];
+  *max_block_size = max_partition_size[*max_block_size];
+
+  // Check border cases where max and min from neighbours may not be legal.
+  *max_block_size = find_partition_size(*max_block_size,
+                                        row8x8_remaining, col8x8_remaining,
+                                        &bh, &bw);
+  *min_block_size = MIN(*min_block_size, *max_block_size);
 }
 
 static void compute_fast_motion_search_level(VP9_COMP *cpi, BLOCK_SIZE bsize) {
@@ -1895,13 +1895,11 @@ static void encode_frame_internal(VP9_COMP *cpi) {
 
   xd->mi_8x8 = cm->mi_grid_visible;
   // required for vp9_frame_init_quantizer
-  xd->this_mi =
-  xd->mi_8x8[0] = cm->mi;
+  xd->this_mi = xd->mi_8x8[0] = cm->mi;
   xd->mic_stream_ptr = cm->mi;
 
   xd->last_mi = cm->prev_mi;
 
-
   vp9_zero(cpi->NMVcount);
   vp9_zero(cpi->coef_counts);
   vp9_zero(cm->counts.eob_branch);
index 16e83f1931bf9acaae92cd273710b033064a8b28..70a8fb314fcd6aa9b41e2a731cda04fd15cc6304 100644 (file)
@@ -707,8 +707,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
   sf->less_rectangular_check = 0;
   sf->use_square_partition_only = 0;
   sf->auto_min_max_partition_size = 0;
-  sf->auto_min_max_partition_interval = 0;
-  sf->auto_min_max_partition_count = 0;
   sf->max_partition_size = BLOCK_64X64;
   sf->min_partition_size = BLOCK_4X4;
   sf->adjust_partitioning_from_last_frame = 0;
@@ -773,7 +771,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
         sf->auto_mv_step_size = 1;
 
         sf->auto_min_max_partition_size = 1;
-        sf->auto_min_max_partition_interval = 1;
         // FIXME(jingning): temporarily turn off disable_split_var_thresh
         // during refactoring process. will get this back after finishing
         // the main framework of partition search type.
@@ -818,7 +815,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
         sf->subpel_iters_per_step = 1;
         sf->use_fast_lpf_pick = 1;
         sf->auto_min_max_partition_size = 1;
-        sf->auto_min_max_partition_interval = 2;
         sf->disable_split_var_thresh = 32;
         sf->disable_filter_search_var_thresh = 32;
         sf->use_fast_coef_updates = 2;
@@ -856,7 +852,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
         sf->subpel_iters_per_step = 1;
         sf->use_fast_lpf_pick = 1;
         sf->auto_min_max_partition_size = 1;
-        sf->auto_min_max_partition_interval = 2;
         sf->disable_split_var_thresh = 64;
         sf->disable_filter_search_var_thresh = 64;
         sf->use_fast_coef_updates = 2;
index 1002ff756d930b7cef4c36268775c5c7da194179..7d31f1dd2651714c1954ad2c2f2f1759c8ef16cf 100644 (file)
@@ -257,8 +257,6 @@ typedef struct {
   int reference_masking;
   BLOCK_SIZE always_this_block_size;
   int auto_min_max_partition_size;
-  int auto_min_max_partition_interval;
-  int auto_min_max_partition_count;
   BLOCK_SIZE min_partition_size;
   BLOCK_SIZE max_partition_size;
   int adjust_partitioning_from_last_frame;