Add a flag to disable ml-based coding block partition features Runtime flag: --disable-ml-partition-speed-features OFF(0) by default. Change-Id: I6108685c1c8358ad1074a5e00a7f34fec2d3cb98
diff --git a/aom/aom_encoder.h b/aom/aom_encoder.h index 6e7589d..bf42dc7 100644 --- a/aom/aom_encoder.h +++ b/aom/aom_encoder.h
@@ -234,6 +234,10 @@ * */ unsigned int enable_1to4_partitions; + /*!\brief disable ml-based speed-up for partition search + * + */ + unsigned int disable_ml_partition_speed_features; #if CONFIG_SDP /*!\brief enable Semi-decoupled partitioning *
diff --git a/aom/aomcx.h b/aom/aomcx.h index db2a744..92c5514 100644 --- a/aom/aomcx.h +++ b/aom/aomcx.h
@@ -1307,6 +1307,14 @@ /*!\brief Control to get frame info */ AV1E_GET_FRAME_INFO = 165, + + /*!\brief Codec control function to disable ML based partition search speed + * features. + * + * - 0 = off (default) + * - 1 = on + */ + AV1E_SET_DISABLE_ML_PARTITION_SPEED_FEATURES = 166, }; /*!\brief aom 1-D scaling mode @@ -1571,6 +1579,9 @@ AOM_CTRL_USE_TYPE(AV1E_SET_TIMING_INFO_TYPE, int) /* aom_timing_info_type_t */ #define AOM_CTRL_AV1E_SET_TIMING_INFO_TYPE +AOM_CTRL_USE_TYPE(AV1E_SET_DISABLE_ML_PARTITION_SPEED_FEATURES, int) +#define AOM_CTRL_AV1E_SET_DISABLE_ML_PARTITION_SPEED_FEATURES + AOM_CTRL_USE_TYPE(AV1E_SET_ENABLE_RECT_PARTITIONS, int) #define AOM_CTRL_AV1E_SET_ENABLE_RECT_PARTITIONS
diff --git a/apps/aomenc.c b/apps/aomenc.c index 29c0358..06a1079 100644 --- a/apps/aomenc.c +++ b/apps/aomenc.c
@@ -118,115 +118,118 @@ return 0; } -static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED, - AOME_SET_ENABLEAUTOALTREF, - AOME_SET_SHARPNESS, - AOME_SET_STATIC_THRESHOLD, - AV1E_SET_ROW_MT, - AV1E_SET_TILE_COLUMNS, - AV1E_SET_TILE_ROWS, - AV1E_SET_ENABLE_TPL_MODEL, - AV1E_SET_ENABLE_KEYFRAME_FILTERING, - AOME_SET_ARNR_MAXFRAMES, - AOME_SET_ARNR_STRENGTH, - AOME_SET_TUNING, - AOME_SET_QP, - AOME_SET_MAX_INTRA_BITRATE_PCT, - AV1E_SET_MAX_INTER_BITRATE_PCT, - AV1E_SET_GF_CBR_BOOST_PCT, - AV1E_SET_LOSSLESS, - AV1E_SET_ENABLE_DEBLOCKING, - AV1E_SET_ENABLE_CDEF, - AV1E_SET_ENABLE_RESTORATION, - AV1E_SET_ENABLE_RECT_PARTITIONS, - AV1E_SET_ENABLE_AB_PARTITIONS, - AV1E_SET_ENABLE_1TO4_PARTITIONS, - AV1E_SET_MIN_PARTITION_SIZE, - AV1E_SET_MAX_PARTITION_SIZE, +static const int av1_arg_ctrl_map[] = { + AOME_SET_CPUUSED, + AOME_SET_ENABLEAUTOALTREF, + AOME_SET_SHARPNESS, + AOME_SET_STATIC_THRESHOLD, + AV1E_SET_ROW_MT, + AV1E_SET_TILE_COLUMNS, + AV1E_SET_TILE_ROWS, + AV1E_SET_ENABLE_TPL_MODEL, + AV1E_SET_ENABLE_KEYFRAME_FILTERING, + AOME_SET_ARNR_MAXFRAMES, + AOME_SET_ARNR_STRENGTH, + AOME_SET_TUNING, + AOME_SET_QP, + AOME_SET_MAX_INTRA_BITRATE_PCT, + AV1E_SET_MAX_INTER_BITRATE_PCT, + AV1E_SET_GF_CBR_BOOST_PCT, + AV1E_SET_LOSSLESS, + AV1E_SET_ENABLE_DEBLOCKING, + AV1E_SET_ENABLE_CDEF, + AV1E_SET_ENABLE_RESTORATION, + AV1E_SET_DISABLE_ML_PARTITION_SPEED_FEATURES, + AV1E_SET_ENABLE_RECT_PARTITIONS, + AV1E_SET_ENABLE_AB_PARTITIONS, + AV1E_SET_ENABLE_1TO4_PARTITIONS, + AV1E_SET_MIN_PARTITION_SIZE, + AV1E_SET_MAX_PARTITION_SIZE, #if !CONFIG_REMOVE_DUAL_FILTER - AV1E_SET_ENABLE_DUAL_FILTER, + AV1E_SET_ENABLE_DUAL_FILTER, #endif // !CONFIG_REMOVE_DUAL_FILTER - AV1E_SET_ENABLE_CHROMA_DELTAQ, - AV1E_SET_ENABLE_INTRA_EDGE_FILTER, - AV1E_SET_ENABLE_ORDER_HINT, - AV1E_SET_ENABLE_TX64, - AV1E_SET_ENABLE_FLIP_IDTX, + AV1E_SET_ENABLE_CHROMA_DELTAQ, + AV1E_SET_ENABLE_INTRA_EDGE_FILTER, + AV1E_SET_ENABLE_ORDER_HINT, + AV1E_SET_ENABLE_TX64, + AV1E_SET_ENABLE_FLIP_IDTX, #if !CONFIG_REMOVE_DIST_WTD_COMP - AV1E_SET_ENABLE_DIST_WTD_COMP, + AV1E_SET_ENABLE_DIST_WTD_COMP, #endif // !CONFIG_REMOVE_DIST_WTD_COMP - AV1E_SET_ENABLE_MASKED_COMP, - AV1E_SET_ENABLE_ONESIDED_COMP, - AV1E_SET_ENABLE_INTERINTRA_COMP, - AV1E_SET_ENABLE_SMOOTH_INTERINTRA, - AV1E_SET_ENABLE_DIFF_WTD_COMP, - AV1E_SET_ENABLE_INTERINTER_WEDGE, - AV1E_SET_ENABLE_INTERINTRA_WEDGE, - AV1E_SET_ENABLE_GLOBAL_MOTION, - AV1E_SET_ENABLE_WARPED_MOTION, - AV1E_SET_ENABLE_FILTER_INTRA, - AV1E_SET_ENABLE_SMOOTH_INTRA, - AV1E_SET_ENABLE_PAETH_INTRA, - AV1E_SET_ENABLE_CFL_INTRA, - AV1E_SET_FORCE_VIDEO_MODE, - AV1E_SET_ENABLE_OBMC, - AV1E_SET_ENABLE_OVERLAY, - AV1E_SET_ENABLE_PALETTE, - AV1E_SET_ENABLE_INTRABC, - AV1E_SET_ENABLE_ANGLE_DELTA, - AV1E_SET_ENABLE_TRELLIS_QUANT, - AV1E_SET_ENABLE_QM, - AV1E_SET_QM_MIN, - AV1E_SET_QM_MAX, - AV1E_SET_REDUCED_TX_TYPE_SET, - AV1E_SET_INTRA_DCT_ONLY, - AV1E_SET_INTER_DCT_ONLY, - AV1E_SET_INTRA_DEFAULT_TX_ONLY, - AV1E_SET_QUANT_B_ADAPT, - AV1E_SET_COEFF_COST_UPD_FREQ, - AV1E_SET_MODE_COST_UPD_FREQ, - AV1E_SET_MV_COST_UPD_FREQ, - AV1E_SET_FRAME_PARALLEL_DECODING, - AV1E_SET_ERROR_RESILIENT_MODE, - AV1E_SET_AQ_MODE, - AV1E_SET_DELTAQ_MODE, - AV1E_SET_DELTALF_MODE, - AV1E_SET_FRAME_PERIODIC_BOOST, - AV1E_SET_NOISE_SENSITIVITY, - AV1E_SET_TUNE_CONTENT, - AV1E_SET_CDF_UPDATE_MODE, - AV1E_SET_COLOR_PRIMARIES, - AV1E_SET_TRANSFER_CHARACTERISTICS, - AV1E_SET_MATRIX_COEFFICIENTS, - AV1E_SET_CHROMA_SAMPLE_POSITION, - AV1E_SET_MIN_GF_INTERVAL, - AV1E_SET_MAX_GF_INTERVAL, - AV1E_SET_GF_MIN_PYRAMID_HEIGHT, - AV1E_SET_GF_MAX_PYRAMID_HEIGHT, - AV1E_SET_SUPERBLOCK_SIZE, - AV1E_SET_NUM_TG, - AV1E_SET_MTU, - AV1E_SET_TIMING_INFO_TYPE, - AV1E_SET_FILM_GRAIN_TEST_VECTOR, - AV1E_SET_FILM_GRAIN_TABLE, + AV1E_SET_ENABLE_MASKED_COMP, + AV1E_SET_ENABLE_ONESIDED_COMP, + AV1E_SET_ENABLE_INTERINTRA_COMP, + AV1E_SET_ENABLE_SMOOTH_INTERINTRA, + AV1E_SET_ENABLE_DIFF_WTD_COMP, + AV1E_SET_ENABLE_INTERINTER_WEDGE, + AV1E_SET_ENABLE_INTERINTRA_WEDGE, + AV1E_SET_ENABLE_GLOBAL_MOTION, + AV1E_SET_ENABLE_WARPED_MOTION, + AV1E_SET_ENABLE_FILTER_INTRA, + AV1E_SET_ENABLE_SMOOTH_INTRA, + AV1E_SET_ENABLE_PAETH_INTRA, + AV1E_SET_ENABLE_CFL_INTRA, + AV1E_SET_FORCE_VIDEO_MODE, + AV1E_SET_ENABLE_OBMC, + AV1E_SET_ENABLE_OVERLAY, + AV1E_SET_ENABLE_PALETTE, + AV1E_SET_ENABLE_INTRABC, + AV1E_SET_ENABLE_ANGLE_DELTA, + AV1E_SET_ENABLE_TRELLIS_QUANT, + AV1E_SET_ENABLE_QM, + AV1E_SET_QM_MIN, + AV1E_SET_QM_MAX, + AV1E_SET_REDUCED_TX_TYPE_SET, + AV1E_SET_INTRA_DCT_ONLY, + AV1E_SET_INTER_DCT_ONLY, + AV1E_SET_INTRA_DEFAULT_TX_ONLY, + AV1E_SET_QUANT_B_ADAPT, + AV1E_SET_COEFF_COST_UPD_FREQ, + AV1E_SET_MODE_COST_UPD_FREQ, + AV1E_SET_MV_COST_UPD_FREQ, + AV1E_SET_FRAME_PARALLEL_DECODING, + AV1E_SET_ERROR_RESILIENT_MODE, + AV1E_SET_AQ_MODE, + AV1E_SET_DELTAQ_MODE, + AV1E_SET_DELTALF_MODE, + AV1E_SET_FRAME_PERIODIC_BOOST, + AV1E_SET_NOISE_SENSITIVITY, + AV1E_SET_TUNE_CONTENT, + AV1E_SET_CDF_UPDATE_MODE, + AV1E_SET_COLOR_PRIMARIES, + AV1E_SET_TRANSFER_CHARACTERISTICS, + AV1E_SET_MATRIX_COEFFICIENTS, + AV1E_SET_CHROMA_SAMPLE_POSITION, + AV1E_SET_MIN_GF_INTERVAL, + AV1E_SET_MAX_GF_INTERVAL, + AV1E_SET_GF_MIN_PYRAMID_HEIGHT, + AV1E_SET_GF_MAX_PYRAMID_HEIGHT, + AV1E_SET_SUPERBLOCK_SIZE, + AV1E_SET_NUM_TG, + AV1E_SET_MTU, + AV1E_SET_TIMING_INFO_TYPE, + AV1E_SET_FILM_GRAIN_TEST_VECTOR, + AV1E_SET_FILM_GRAIN_TABLE, #if CONFIG_DENOISE - AV1E_SET_DENOISE_NOISE_LEVEL, - AV1E_SET_DENOISE_BLOCK_SIZE, + AV1E_SET_DENOISE_NOISE_LEVEL, + AV1E_SET_DENOISE_BLOCK_SIZE, #endif // CONFIG_DENOISE - AV1E_SET_MAX_REFERENCE_FRAMES, - AV1E_SET_REDUCED_REFERENCE_SET, - AV1E_SET_ENABLE_REF_FRAME_MVS, - AV1E_SET_TARGET_SEQ_LEVEL_IDX, - AV1E_SET_TIER_MASK, - AV1E_SET_MIN_CR, - AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, - AV1E_SET_CHROMA_SUBSAMPLING_X, - AV1E_SET_CHROMA_SUBSAMPLING_Y, + AV1E_SET_MAX_REFERENCE_FRAMES, + AV1E_SET_REDUCED_REFERENCE_SET, + AV1E_SET_ENABLE_REF_FRAME_MVS, + AV1E_SET_TARGET_SEQ_LEVEL_IDX, + AV1E_SET_TIER_MASK, + AV1E_SET_MIN_CR, + AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, + AV1E_SET_CHROMA_SUBSAMPLING_X, + AV1E_SET_CHROMA_SUBSAMPLING_Y, #if CONFIG_TUNE_VMAF - AV1E_SET_VMAF_MODEL_PATH, + AV1E_SET_VMAF_MODEL_PATH, #endif - AV1E_SET_SUBGOP_CONFIG_STR, - AV1E_SET_SUBGOP_CONFIG_PATH, - 0 }; + AV1E_SET_SUBGOP_CONFIG_STR, + AV1E_SET_SUBGOP_CONFIG_PATH, + 0 +}; const arg_def_t *main_args[] = { &g_av1_codec_arg_defs.help, &g_av1_codec_arg_defs.use_cfg, @@ -338,6 +341,7 @@ &g_av1_codec_arg_defs.enable_deblocking, &g_av1_codec_arg_defs.enable_cdef, &g_av1_codec_arg_defs.enable_restoration, + &g_av1_codec_arg_defs.disable_ml_partition_speed_features, &g_av1_codec_arg_defs.enable_rect_partitions, &g_av1_codec_arg_defs.enable_ab_partitions, &g_av1_codec_arg_defs.enable_1to4_partitions,
diff --git a/av1/arg_defs.c b/av1/arg_defs.c index ff2ea3d..c381ac9 100644 --- a/av1/arg_defs.c +++ b/av1/arg_defs.c
@@ -333,6 +333,10 @@ "Enable cross component sample offset (0: false " "1: true)"), #endif + .disable_ml_partition_speed_features = + ARG_DEF(NULL, "disable-ml-partition-speed-features", 1, + "Disable ML partition speed features " + "(0: false (default), 1: true)"), .enable_rect_partitions = ARG_DEF(NULL, "enable-rect-partitions", 1, "Enable rectangular partitions " "(0: false, 1: true (default))"),
diff --git a/av1/arg_defs.h b/av1/arg_defs.h index 5e9d244..60a1ff6 100644 --- a/av1/arg_defs.h +++ b/av1/arg_defs.h
@@ -134,6 +134,7 @@ #if CONFIG_CCSO arg_def_t enable_ccso; #endif + arg_def_t disable_ml_partition_speed_features; arg_def_t enable_rect_partitions; arg_def_t enable_ab_partitions; arg_def_t enable_1to4_partitions;
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index 9c3c69f..35651e5 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -109,6 +109,7 @@ const char *film_grain_table_filename; unsigned int motion_vector_unit_test; unsigned int cdf_update_mode; + int disable_ml_partition_speed_features; int enable_rect_partitions; // enable rectangular partitions for sequence int enable_ab_partitions; // enable AB partitions for sequence int enable_1to4_partitions; // enable 1:4 and 4:1 partitions for sequence @@ -384,6 +385,7 @@ 0, // film_grain_table_filename 0, // motion_vector_unit_test 1, // CDF update mode + 0, // disable ML based partition speed up features 1, // enable rectangular partitions 1, // enable ab shape partitions 1, // enable 1:4 and 4:1 partitions @@ -834,6 +836,8 @@ cfg->enable_dual_filter = extra_cfg->enable_dual_filter; #endif // !CONFIG_REMOVE_DUAL_FILTER cfg->enable_angle_delta = extra_cfg->enable_angle_delta; + cfg->disable_ml_partition_speed_features = + extra_cfg->disable_ml_partition_speed_features; cfg->enable_rect_partitions = extra_cfg->enable_rect_partitions; cfg->enable_ab_partitions = extra_cfg->enable_ab_partitions; cfg->enable_1to4_partitions = extra_cfg->enable_1to4_partitions; @@ -1344,6 +1348,8 @@ (extra_cfg->allow_warped_motion & extra_cfg->enable_warped_motion); // Set partition related configuration. + part_cfg->disable_ml_partition_speed_features = + extra_cfg->disable_ml_partition_speed_features; part_cfg->enable_rect_partitions = extra_cfg->enable_rect_partitions; part_cfg->enable_ab_partitions = extra_cfg->enable_ab_partitions; part_cfg->enable_1to4_partitions = extra_cfg->enable_1to4_partitions; @@ -1875,6 +1881,14 @@ return update_extra_cfg(ctx, &extra_cfg); } +static aom_codec_err_t ctrl_set_disable_ml_partition_speed_features( + aom_codec_alg_priv_t *ctx, va_list args) { + struct av1_extracfg extra_cfg = ctx->extra_cfg; + extra_cfg.disable_ml_partition_speed_features = + CAST(AV1E_SET_DISABLE_ML_PARTITION_SPEED_FEATURES, args); + return update_extra_cfg(ctx, &extra_cfg); +} + static aom_codec_err_t ctrl_set_enable_rect_partitions( aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; @@ -3523,6 +3537,12 @@ &g_av1_codec_arg_defs.enable_1to4_partitions, argv, err_string)) { extra_cfg.enable_1to4_partitions = arg_parse_int_helper(&arg, err_string); + } else if (arg_match_helper( + &arg, + &g_av1_codec_arg_defs.disable_ml_partition_speed_features, + argv, err_string)) { + extra_cfg.disable_ml_partition_speed_features = + arg_parse_int_helper(&arg, err_string); #if CONFIG_SDP } else if (arg_match_helper(&arg, &g_av1_codec_arg_defs.enable_sdp, argv, err_string)) { @@ -3781,6 +3801,8 @@ { AV1E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode }, { AV1E_SET_ERROR_RESILIENT_MODE, ctrl_set_error_resilient_mode }, { AV1E_SET_S_FRAME_MODE, ctrl_set_s_frame_mode }, + { AV1E_SET_DISABLE_ML_PARTITION_SPEED_FEATURES, + ctrl_set_disable_ml_partition_speed_features }, { AV1E_SET_ENABLE_RECT_PARTITIONS, ctrl_set_enable_rect_partitions }, { AV1E_SET_ENABLE_AB_PARTITIONS, ctrl_set_enable_ab_partitions }, { AV1E_SET_ENABLE_1TO4_PARTITIONS, ctrl_set_enable_1to4_partitions }, @@ -3948,7 +3970,7 @@ 0, // use_fixed_qp_offsets { -1, -1, -1, -1, -1, -1 }, // fixed_qp_offsets { - 0, 128, 128, 4, 1, 1, 1, + 0, 128, 128, 4, 1, 1, 1, 0, #if CONFIG_SDP 1, #endif // CONFIG_SDP
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index 903c8d7..9c3f4c2 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -201,6 +201,11 @@ */ typedef struct { /*! + * Flag to indicate if ml-based speed-up for partition search should be + * disabled. + */ + bool disable_ml_partition_speed_features; + /*! * Flag to indicate if rectanguar partitions should be enabled. */ bool enable_rect_partitions;
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c index 52e8b87..067986b 100644 --- a/av1/encoder/speed_features.c +++ b/av1/encoder/speed_features.c
@@ -883,6 +883,23 @@ lpf_sf->disable_lr_filter = 0; } +static void av1_disable_ml_based_partition_sf( + PARTITION_SPEED_FEATURES *const part_sf) { + part_sf->ml_prune_4_partition = 0; + part_sf->ml_prune_ab_partition = 0; + part_sf->ml_prune_rect_partition = 0; + part_sf->ml_early_term_after_part_split_level = 0; + part_sf->auto_max_partition_based_on_simple_motion = NOT_IN_USE; + part_sf->intra_cnn_split = 0; + part_sf->simple_motion_search_split = 0; + part_sf->simple_motion_search_prune_rect = 0; + part_sf->simple_motion_search_early_term_none = 0; + + for (int i = 0; i < PARTITION_BLOCK_SIZES; ++i) { + part_sf->ml_partition_search_breakout_thresh[i] = -1; + } +} + void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi, int speed) { SPEED_FEATURES *const sf = &cpi->sf; const AV1EncoderConfig *const oxcf = &cpi->oxcf; @@ -896,6 +913,9 @@ cpi->mv_search_params.find_fractional_mv_step = av1_return_max_sub_pixel_mv; else if (cpi->oxcf.unit_test_cfg.motion_vector_unit_test == 2) cpi->mv_search_params.find_fractional_mv_step = av1_return_min_sub_pixel_mv; + + if (oxcf->part_cfg.disable_ml_partition_speed_features) + av1_disable_ml_based_partition_sf(&sf->part_sf); } void av1_set_speed_features_framesize_independent(AV1_COMP *cpi, int speed) {
diff --git a/common/args.c b/common/args.c index b4d2715..6c8e401 100644 --- a/common/args.c +++ b/common/args.c
@@ -80,6 +80,7 @@ GET_PARAMS(enable_ab_partitions); GET_PARAMS(enable_rect_partitions); GET_PARAMS(enable_1to4_partitions); + GET_PARAMS(disable_ml_partition_speed_features); #if CONFIG_SDP GET_PARAMS(enable_sdp); #endif