Add the speed feature structure for codec dev This commit re-structures the speed feature setup for the codec development purpose. Instead of progressively reducing encoder complexity at the expense of incremental coding loss, we allow a separate set of speed features, each corresponds to a certain category of coding units: 1 << 0: transform coding 1 << 1: inter prediction 1 << 2: intra prediction 1 << 3: block partition 1 << 4: loop filters 1 << 5: rd early skip [6 - 7] are left open for next adjustment. It is constructed to facilitate the codec development purpose. When working on a coding functions, one could choose to turn on one or more less related coding units to speed up the evaluation process. For example, to test a transform related experiment, one could set --dev-sf=2, 6, or 22 which corresponds to turning on: 2 - inter prediction speed features, 6 - both inter / intra speed features, 22 - inter / intra, and loop filter features. The goal is to allow faster experimental verification during the development process. With the experiment in a stable state, we can evaluate its performance in speed 0 at higher confidence level. Change-Id: Ib46c7dea2d2a60204c399dc01f10262c976adf0d
diff --git a/aom/aomcx.h b/aom/aomcx.h index 2f9bafd..f8c7168 100644 --- a/aom/aomcx.h +++ b/aom/aomcx.h
@@ -153,6 +153,10 @@ */ AOME_SET_CPUUSED = 13, + /*!\brief Speed features for codec development + */ + AOME_SET_DEVSF, + /*!\brief Codec control function to enable automatic set and use alf frames. */ AOME_SET_ENABLEAUTOALTREF, @@ -692,6 +696,8 @@ AOM_CTRL_USE_TYPE(AOME_SET_CPUUSED, int) #define AOM_CTRL_AOME_SET_CPUUSED +AOM_CTRL_USE_TYPE(AOME_SET_DEVSF, int) +#define AOM_CTRL_AOME_SET_DEVSF AOM_CTRL_USE_TYPE(AOME_SET_ENABLEAUTOALTREF, unsigned int) #define AOM_CTRL_AOME_SET_ENABLEAUTOALTREF
diff --git a/aomenc.c b/aomenc.c index 6071e38..9438023 100644 --- a/aomenc.c +++ b/aomenc.c
@@ -412,6 +412,8 @@ #if CONFIG_AV1_ENCODER static const arg_def_t cpu_used_av1 = ARG_DEF(NULL, "cpu-used", 1, "CPU Used (0..8)"); +static const arg_def_t dev_sf_av1 = + ARG_DEF(NULL, "dev-sf", 1, "Dev Speed (0..255)"); #if CONFIG_EXT_TILE static const arg_def_t single_tile_decoding = ARG_DEF(NULL, "single-tile-decoding", 1, @@ -559,6 +561,7 @@ #endif // CONFIG_EXT_PARTITION static const arg_def_t *av1_args[] = { &cpu_used_av1, + &dev_sf_av1, &auto_altref, &sharpness, &static_thresh, @@ -617,6 +620,7 @@ #endif // CONFIG_HIGHBITDEPTH NULL }; static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED, + AOME_SET_DEVSF, AOME_SET_ENABLEAUTOALTREF, AOME_SET_SHARPNESS, AOME_SET_STATIC_THRESHOLD,
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c index e55625d..09dd3a2 100644 --- a/av1/av1_cx_iface.c +++ b/av1/av1_cx_iface.c
@@ -31,6 +31,7 @@ struct av1_extracfg { int cpu_used; // available cpu percentage in 1/16 + int dev_sf; unsigned int enable_auto_alt_ref; unsigned int enable_auto_bwd_ref; unsigned int noise_sensitivity; @@ -95,6 +96,7 @@ static struct av1_extracfg default_extra_cfg = { 0, // cpu_used + 0, // dev_sf 1, // enable_auto_alt_ref 0, // enable_auto_bwd_ref 0, // noise_sensitivity @@ -279,6 +281,7 @@ RANGE_CHECK_HI(extra_cfg, enable_auto_alt_ref, 2); RANGE_CHECK_HI(extra_cfg, enable_auto_bwd_ref, 2); RANGE_CHECK(extra_cfg, cpu_used, 0, 8); + RANGE_CHECK(extra_cfg, dev_sf, 0, UINT8_MAX); RANGE_CHECK_HI(extra_cfg, noise_sensitivity, 6); RANGE_CHECK(extra_cfg, superblock_size, AOM_SUPERBLOCK_SIZE_64X64, AOM_SUPERBLOCK_SIZE_DYNAMIC); @@ -572,6 +575,7 @@ oxcf->key_freq = cfg->kf_max_dist; oxcf->speed = extra_cfg->cpu_used; + oxcf->dev_sf = extra_cfg->dev_sf; oxcf->enable_auto_arf = extra_cfg->enable_auto_alt_ref; oxcf->enable_auto_brf = extra_cfg->enable_auto_bwd_ref; oxcf->noise_sensitivity = extra_cfg->noise_sensitivity; @@ -750,6 +754,12 @@ return update_extra_cfg(ctx, &extra_cfg); } +static aom_codec_err_t ctrl_set_devsf(aom_codec_alg_priv_t *ctx, va_list args) { + struct av1_extracfg extra_cfg = ctx->extra_cfg; + extra_cfg.dev_sf = CAST(AOME_SET_DEVSF, args); + return update_extra_cfg(ctx, &extra_cfg); +} + static aom_codec_err_t ctrl_set_enable_auto_alt_ref(aom_codec_alg_priv_t *ctx, va_list args) { struct av1_extracfg extra_cfg = ctx->extra_cfg; @@ -1588,6 +1598,7 @@ { AOME_SET_ACTIVEMAP, ctrl_set_active_map }, { AOME_SET_SCALEMODE, ctrl_set_scale_mode }, { AOME_SET_CPUUSED, ctrl_set_cpuused }, + { AOME_SET_DEVSF, ctrl_set_devsf }, { AOME_SET_ENABLEAUTOALTREF, ctrl_set_enable_auto_alt_ref }, { AOME_SET_ENABLEAUTOBWDREF, ctrl_set_enable_auto_bwd_ref }, { AOME_SET_SHARPNESS, ctrl_set_sharpness },
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h index e1ddd73..84dcb27 100644 --- a/av1/encoder/encoder.h +++ b/av1/encoder/encoder.h
@@ -153,6 +153,7 @@ int noise_sensitivity; // pre processing blur: recommendation 0 int sharpness; // sharpening output: recommendation 0: int speed; + int dev_sf; // maximum allowed bitrate for any intra frame in % of bitrate target. unsigned int rc_max_intra_bitrate_pct; // maximum allowed bitrate for any inter frame in % of bitrate target.
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c index 8833a7b..e81732c 100644 --- a/av1/encoder/speed_features.c +++ b/av1/encoder/speed_features.c
@@ -363,6 +363,52 @@ cpi->find_fractional_mv_step = av1_return_min_sub_pixel_mv; } +static void set_dev_sf(AV1_COMP *cpi, SPEED_FEATURES *sf, int speed) { + AV1_COMMON *const cm = &cpi->common; + + if (speed & TXFM_CODING_SF) { + sf->tx_size_search_init_depth_rect = 1; + sf->tx_size_search_init_depth_sqr = 1; + sf->tx_size_search_method = USE_FAST_RD; + sf->tx_type_search.fast_intra_tx_type_search = 1; + sf->tx_type_search.fast_inter_tx_type_search = 1; + } + + if (speed & INTER_PRED_SF) { + sf->selective_ref_frame = 2; + sf->adaptive_motion_search = 1; + sf->mv.auto_mv_step_size = 1; + sf->adaptive_rd_thresh = 1; + sf->mv.subpel_iters_per_step = 1; + sf->adaptive_pred_interp_filter = 1; + } + + if (speed & INTRA_PRED_SF) { + sf->max_intra_bsize = BLOCK_32X32; + } + + if (speed & PARTITION_SF) { + if ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) || + av1_internal_image_edge(cpi)) { + sf->use_square_partition_only = !frame_is_boosted(cpi); + } else { + sf->use_square_partition_only = !frame_is_intra_only(cm); + } + sf->less_rectangular_check = 1; +#if CONFIG_EXT_PARTITION_TYPES + sf->prune_ext_partition_types_search = 1; +#endif // CONFIG_EXT_PARTITION_TYPES + } + + if (speed & LOOP_FILTER_SF) { + sf->fast_cdef_search = 1; + } + + if (speed & RD_SKIP_SF) { + sf->use_rd_breakout = 1; + } +} + void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) { AV1_COMMON *const cm = &cpi->common; SPEED_FEATURES *const sf = &cpi->sf; @@ -458,6 +504,8 @@ sf->gm_search_type = GM_FULL_SEARCH; sf->use_fast_interpolation_filter_search = 0; + set_dev_sf(cpi, sf, oxcf->dev_sf); + if (oxcf->mode == GOOD #if CONFIG_XIPHRC || oxcf->pass == 1
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h index fedefaa..9f0a7a1 100644 --- a/av1/encoder/speed_features.h +++ b/av1/encoder/speed_features.h
@@ -95,6 +95,17 @@ }; typedef enum { + TXFM_CODING_SF = 1, + INTER_PRED_SF = 2, + INTRA_PRED_SF = 4, + PARTITION_SF = 8, + LOOP_FILTER_SF = 16, + RD_SKIP_SF = 32, + RESERVE_2_SF = 64, + RESERVE_3_SF = 128, +} DEV_SPEED_FEATURES; + +typedef enum { DIAMOND = 0, NSTEP = 1, HEX = 2,