Add a speed feature for using best rd in partition search
In the current encoder partition search, partition search uses
best rdcost so far to help skip some mode search / transform search.
It is a search feature and has been turned on by default but not
guarded by any speed feature.
Here we add a speed feature to control it.
BUG=aomedia:3003
Change-Id: Idf9072bf6d338d11efe1a8dc68d471df4dc05639
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 69c2ac1..c5bfaf6 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -74,6 +74,7 @@
part_sf->simple_motion_search_rect_split = 0;
part_sf->reuse_prev_rd_results_for_part_ab = 0;
part_sf->reuse_best_prediction_for_part_ab = 0;
+ part_sf->use_best_rd_for_pruning = 0;
}
static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
@@ -635,7 +636,7 @@
RD_STATS *rd_cost, PARTITION_TYPE partition,
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
RD_STATS best_rd) {
- if (best_rd.rdcost < 0) {
+ if (cpi->sf.part_sf.use_best_rd_for_pruning && best_rd.rdcost < 0) {
ctx->rd_stats.rdcost = INT64_MAX;
ctx->rd_stats.skip_txfm = 0;
av1_invalid_rd_stats(rd_cost);
@@ -718,6 +719,13 @@
av1_set_error_per_bit(&x->errorperbit, x->rdmult);
av1_rd_cost_update(x->rdmult, &best_rd);
+ // If set best_rd.rdcost to INT64_MAX, the encoder will not use any previous
+ // rdcost information for the following mode search.
+ // Disabling the feature could get some coding gain, with encoder slowdown.
+ if (!cpi->sf.part_sf.use_best_rd_for_pruning) {
+ av1_invalid_rd_stats(&best_rd);
+ }
+
// Find best coding mode & reconstruct the MB so it is available
// as a predictor for MBs that follow in the SB
if (frame_is_intra_only(cm)) {
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index b0ec555..abd3a7e 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -304,6 +304,7 @@
sf->part_sf.simple_motion_search_prune_rect = 1;
sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3;
sf->part_sf.reuse_prev_rd_results_for_part_ab = 1;
+ sf->part_sf.use_best_rd_for_pruning = 1;
sf->intra_sf.intra_pruning_with_hog = 1;
sf->intra_sf.dv_cost_upd_level = INTERNAL_COST_UPD_OFF;
@@ -741,6 +742,7 @@
sf->part_sf.simple_motion_search_prune_rect = 1;
sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3;
sf->part_sf.reuse_prev_rd_results_for_part_ab = 1;
+ sf->part_sf.use_best_rd_for_pruning = 1;
// TODO(debargha): Test, tweak and turn on either 1 or 2
sf->inter_sf.inter_mode_rd_model_estimation = 1;
@@ -1185,6 +1187,7 @@
sf->part_sf.ml_prune_partition = 1;
sf->part_sf.prune_ext_partition_types_search_level = 1;
sf->part_sf.reuse_prev_rd_results_for_part_ab = 1;
+ sf->part_sf.use_best_rd_for_pruning = 1;
// TODO(debargha): Test, tweak and turn on either 1 or 2
sf->inter_sf.inter_mode_rd_model_estimation = 0;
@@ -1565,6 +1568,7 @@
part_sf->simple_motion_search_rect_split = 0;
part_sf->reuse_prev_rd_results_for_part_ab = 0;
part_sf->reuse_best_prediction_for_part_ab = 0;
+ part_sf->use_best_rd_for_pruning = 0;
}
static AOM_INLINE void init_mv_sf(MV_SPEED_FEATURES *mv_sf) {
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index a15f2c1..8588e25 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -591,6 +591,16 @@
// Reuse the best prediction modes found in PARTITION_SPLIT and PARTITION_RECT
// when encoding PARTITION_AB.
int reuse_best_prediction_for_part_ab;
+
+ // The current partition search records the best rdcost so far and uses it
+ // in mode search and transform search to early skip when some criteria is
+ // met. For example, when the current rdcost is larger than the best rdcost,
+ // or the model rdcost is larger than the best rdcost times some thresholds.
+ // By default, this feature is turned on to speed up the encoder partition
+ // search.
+ // If disabling it, at speed 0, 30 frames, we could get
+ // about -0.25% quality gain (psnr, ssim, vmaf), with about 13% slowdown.
+ int use_best_rd_for_pruning;
} PARTITION_SPEED_FEATURES;
typedef struct MV_SPEED_FEATURES {