ref: c398d5a77046ced168bfb7e37443852c5cb58b3b
parent: 4fc3dadb3223d6d68878502b4e80d0a0e1dd3f5a
author: Hui Su <[email protected]>
date: Mon Jun 25 06:58:33 EDT 2018
Turn on ML partition search breakout on speed 0 Enable ML based partition search breakout on speed 0 when frame resolution is less then 720p and bitdepth is 8. Compression performance change is neutral. Tested encoding speed over 20 480p sequences: Speed gain(%) QP=30 QP=40 QP=50 QP=60 max 14.4 18.6 17.8 24.4 average 4.6 9.0 8.0 13.2 Change-Id: Ia0d2947030ac774dc1533eb27ffc57f5b788a6ce
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -3662,33 +3662,7 @@
best_rdc = this_rdc;
if (bsize >= BLOCK_8X8) pc_tree->partitioning = PARTITION_NONE;
- if (!cpi->sf.ml_partition_search_early_termination) {
- // If all y, u, v transform blocks in this partition are skippable,
- // and the dist & rate are within the thresholds, the partition search
- // is terminated for current branch of the partition search tree.
- if (!x->e_mbd.lossless && ctx->skippable) {
- int use_ml_based_breakout =
- cpi->sf.use_ml_partition_search_breakout &&
- cm->base_qindex >= 100;
-#if CONFIG_VP9_HIGHBITDEPTH
- if (x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
- use_ml_based_breakout = 0;
-#endif // CONFIG_VP9_HIGHBITDEPTH
- if (use_ml_based_breakout) {
- if (ml_predict_breakout(cpi, bsize, x, &this_rdc)) {
- do_split = 0;
- do_rect = 0;
- }
- } else {
- if ((best_rdc.dist < (dist_breakout_thr >> 2)) ||
- (best_rdc.dist < dist_breakout_thr &&
- best_rdc.rate < rate_breakout_thr)) {
- do_split = 0;
- do_rect = 0;
- }
- }
- }
- } else {
+ if (cpi->sf.ml_partition_search_early_termination) {
// Currently, the machine-learning based partition search early
// termination is only used while bsize is 16x16, 32x32 or 64x64,
// VPXMIN(cm->width, cm->height) >= 480, and speed = 0.
@@ -3698,6 +3672,31 @@
if (ml_pruning_partition(cm, xd, ctx, mi_row, mi_col, bsize)) {
do_split = 0;
do_rect = 0;
+ }
+ }
+ }
+
+ if ((do_split || do_rect) && !x->e_mbd.lossless && ctx->skippable) {
+ int use_ml_based_breakout =
+ cpi->sf.use_ml_partition_search_breakout &&
+ cm->base_qindex >= 100;
+#if CONFIG_VP9_HIGHBITDEPTH
+ if (x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+ use_ml_based_breakout = 0;
+#endif // CONFIG_VP9_HIGHBITDEPTH
+ if (use_ml_based_breakout) {
+ if (ml_predict_breakout(cpi, bsize, x, &this_rdc)) {
+ do_split = 0;
+ do_rect = 0;
+ }
+ } else {
+ if (!cpi->sf.ml_partition_search_early_termination) {
+ if ((best_rdc.dist < (dist_breakout_thr >> 2)) ||
+ (best_rdc.dist < dist_breakout_thr &&
+ best_rdc.rate < rate_breakout_thr)) {
+ do_split = 0;
+ do_rect = 0;
+ }
}
}
}
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -61,6 +61,9 @@
SPEED_FEATURES *sf,
int speed) {
VP9_COMMON *const cm = &cpi->common;
+ const int is_480p_or_larger = VPXMIN(cm->width, cm->height) >= 480;
+ const int is_720p_or_larger = VPXMIN(cm->width, cm->height) >= 720;
+ const int is_2160p_or_larger = VPXMIN(cm->width, cm->height) >= 2160;
// speed 0 features
sf->partition_search_breakout_thr.dist = (1 << 20);
@@ -68,14 +71,21 @@
// Currently, the machine-learning based partition search early termination
// is only used while VPXMIN(cm->width, cm->height) >= 480 and speed = 0.
- if (VPXMIN(cm->width, cm->height) >= 480) {
+ if (is_480p_or_larger) {
sf->ml_partition_search_early_termination = 1;
}
+ if (!is_720p_or_larger) {
+ sf->use_ml_partition_search_breakout = 1;
+ sf->ml_partition_search_breakout_thresh[0] = 2.5f;
+ sf->ml_partition_search_breakout_thresh[1] = 1.5f;
+ sf->ml_partition_search_breakout_thresh[2] = 1.5f;
+ }
+
if (speed >= 1) {
sf->ml_partition_search_early_termination = 0;
- if (VPXMIN(cm->width, cm->height) >= 720) {
+ if (is_720p_or_larger) {
sf->disable_split_mask =
cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT;
sf->partition_search_breakout_thr.dist = (1 << 23);
@@ -82,7 +92,6 @@
} else {
sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
sf->partition_search_breakout_thr.dist = (1 << 21);
- sf->use_ml_partition_search_breakout = 1;
sf->ml_partition_search_breakout_thresh[0] = 0.0f;
sf->ml_partition_search_breakout_thresh[1] = 0.0f;
sf->ml_partition_search_breakout_thresh[2] = 0.0f;
@@ -90,7 +99,7 @@
}
if (speed >= 2) {
- if (VPXMIN(cm->width, cm->height) >= 720) {
+ if (is_720p_or_larger) {
sf->disable_split_mask =
cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT;
sf->adaptive_pred_interp_filter = 0;
@@ -107,7 +116,7 @@
sf->rd_auto_partition_min_limit = set_partition_min_limit(cm);
// Use a set of speed features for 4k videos.
- if (VPXMIN(cm->width, cm->height) >= 2160) {
+ if (is_2160p_or_larger) {
sf->use_square_partition_only = 1;
sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC;
@@ -120,7 +129,7 @@
if (speed >= 3) {
sf->use_ml_partition_search_breakout = 0;
- if (VPXMIN(cm->width, cm->height) >= 720) {
+ if (is_720p_or_larger) {
sf->disable_split_mask = DISABLE_ALL_SPLIT;
sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0;
sf->partition_search_breakout_thr.dist = (1 << 25);
@@ -145,7 +154,7 @@
if (speed >= 4) {
sf->partition_search_breakout_thr.rate = 300;
- if (VPXMIN(cm->width, cm->height) >= 720) {
+ if (is_720p_or_larger) {
sf->partition_search_breakout_thr.dist = (1 << 26);
} else {
sf->partition_search_breakout_thr.dist = (1 << 24);