From: Hui Su Date: Mon, 25 Jun 2018 17:58:33 +0000 (-0700) Subject: Turn on ML partition search breakout on speed 0 X-Git-Tag: v1.8.0~575^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c398d5a77046ced168bfb7e37443852c5cb58b3b;p=libvpx 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 --- diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index d7faa4be9..bfe34ac45 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -3662,33 +3662,7 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td, 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. @@ -3702,6 +3676,31 @@ static void rd_pick_partition(VP9_COMP *cpi, ThreadData *td, } } + 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; + } + } + } + } + #if CONFIG_FP_MB_STATS // Check if every 16x16 first pass block statistics has zero // motion and the corresponding first pass residue is small enough. diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index b9f8055bc..75401131f 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -61,6 +61,9 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, 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,21 +71,27 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, // 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); } 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 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, } 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 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, 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 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, 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 @@ static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi, 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);