From 0eb88c9064c9e5e163d0771dac974c1ea321c3eb Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Thu, 3 Apr 2014 15:49:03 -0700 Subject: [PATCH] Add codec control function for enabling frame_periodic_boost. Change-Id: I6371ef7301c6bc3138552bd349e9bd154dee3e08 --- examples/vpx_temporal_scalable_patterns.c | 1 + vp9/encoder/vp9_onyx_int.h | 3 +++ vp9/encoder/vp9_ratectrl.c | 2 +- vp9/encoder/vp9_speed_features.c | 8 ++++++-- vp9/encoder/vp9_speed_features.h | 2 +- vp9/vp9_cx_iface.c | 8 +++++++- vpx/vp8cx.h | 3 +++ vpxenc.c | 9 +++++++-- 8 files changed, 29 insertions(+), 7 deletions(-) diff --git a/examples/vpx_temporal_scalable_patterns.c b/examples/vpx_temporal_scalable_patterns.c index 3a4f05b92..5cb4ee9cf 100644 --- a/examples/vpx_temporal_scalable_patterns.c +++ b/examples/vpx_temporal_scalable_patterns.c @@ -575,6 +575,7 @@ int main(int argc, char **argv) { } else if (strncmp(encoder->name, "vp9", 3) == 0) { vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed); vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3); + vpx_codec_control(&codec, VP9E_SET_FRAME_PERIODIC_BOOST, 0); vpx_codec_control(&codec, VP8E_SET_NOISE_SENSITIVITY, 0); if (vpx_codec_control(&codec, VP9E_SET_SVC, 1)) { die_codec(&codec, "Failed to set SVC"); diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index 9a2bafc3e..d9dbd53da 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -232,6 +232,9 @@ typedef struct { int lossless; AQ_MODE aq_mode; // Adaptive Quantization mode + // Enable feature to reduce the frame quantization every x frames. + int frame_periodic_boost; + // two pass datarate control int two_pass_vbrbias; // two pass datarate control tweaks int two_pass_vbrmin_section; diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 21f423043..eb4db1a33 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -982,7 +982,7 @@ int vp9_rc_pick_q_and_bounds(const VP9_COMP *cpi, if (cpi->sf.use_nonrd_pick_mode) { if (q == 0) q++; - if (cpi->sf.force_ref_frame == 1) + if (cpi->sf.force_frame_boost == 1) q -= cpi->sf.max_delta_qindex; if (q < *bottom_index) diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c index 0d9007b94..14328293b 100644 --- a/vp9/encoder/vp9_speed_features.c +++ b/vp9/encoder/vp9_speed_features.c @@ -244,7 +244,7 @@ static void set_rt_speed_feature(VP9_COMMON *cm, sf->min_partition_size = BLOCK_8X8; sf->partition_check = (cm->current_video_frame % sf->last_partitioning_redo_frequency == 1); - sf->force_ref_frame = cm->frame_type == KEY_FRAME || + sf->force_frame_boost = cm->frame_type == KEY_FRAME || (cm->current_video_frame % (sf->last_partitioning_redo_frequency << 1) == 1); sf->max_delta_qindex = (cm->frame_type == KEY_FRAME) ? 20 : 15; @@ -300,7 +300,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { sf->last_partitioning_redo_frequency = 4; sf->disable_split_mask = 0; sf->mode_search_skip_flags = 0; - sf->force_ref_frame = 0; + sf->force_frame_boost = 0; sf->max_delta_qindex = 0; sf->disable_split_var_thresh = 0; sf->disable_filter_search_var_thresh = 0; @@ -368,4 +368,8 @@ void vp9_set_speed_features(VP9_COMP *cpi) { if (sf->disable_split_mask == DISABLE_ALL_SPLIT) sf->adaptive_pred_interp_filter = 0; + + if (!cpi->oxcf.frame_periodic_boost) { + sf->max_delta_qindex = 0; + } } diff --git a/vp9/encoder/vp9_speed_features.h b/vp9/encoder/vp9_speed_features.h index 27b11c84e..826043910 100644 --- a/vp9/encoder/vp9_speed_features.h +++ b/vp9/encoder/vp9_speed_features.h @@ -254,7 +254,7 @@ typedef struct { // Use finer quantizer in every other few frames that run variable block // partition type search. - int force_ref_frame; + int force_frame_boost; // Maximally allowed base quantization index fluctuation. int max_delta_qindex; diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index a9fd8c11e..37a214e05 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -37,6 +37,7 @@ struct vp9_extracfg { unsigned int lossless; unsigned int frame_parallel_decoding_mode; AQ_MODE aq_mode; + unsigned int frame_periodic_boost; }; struct extraconfig_map { @@ -65,6 +66,7 @@ static const struct extraconfig_map extracfg_map[] = { 0, // lossless 0, // frame_parallel_decoding_mode NO_AQ, // aq_mode + 0, // frame_periodic_delta_q } } }; @@ -150,7 +152,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, RANGE_CHECK_HI(cfg, rc_min_quantizer, cfg->rc_max_quantizer); RANGE_CHECK_BOOL(extra_cfg, lossless); RANGE_CHECK(extra_cfg, aq_mode, 0, AQ_MODE_COUNT - 1); - + RANGE_CHECK(extra_cfg, frame_periodic_boost, 0, 1); RANGE_CHECK_HI(cfg, g_threads, 64); RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); RANGE_CHECK(cfg, rc_end_usage, VPX_VBR, VPX_Q); @@ -360,6 +362,8 @@ static vpx_codec_err_t set_vp9e_config(VP9_CONFIG *oxcf, oxcf->aq_mode = extra_cfg->aq_mode; + oxcf->frame_periodic_boost = extra_cfg->frame_periodic_boost; + oxcf->ss_number_layers = cfg->ss_number_layers; if (oxcf->ss_number_layers > 1) { @@ -484,6 +488,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, int ctrl_id, MAP(VP9E_SET_FRAME_PARALLEL_DECODING, extra_cfg.frame_parallel_decoding_mode); MAP(VP9E_SET_AQ_MODE, extra_cfg.aq_mode); + MAP(VP9E_SET_FRAME_PERIODIC_BOOST, extra_cfg.frame_periodic_boost); } res = validate_config(ctx, &ctx->cfg, &extra_cfg); @@ -1094,6 +1099,7 @@ static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = { {VP9E_SET_LOSSLESS, set_param}, {VP9E_SET_FRAME_PARALLEL_DECODING, set_param}, {VP9E_SET_AQ_MODE, set_param}, + {VP9E_SET_FRAME_PERIODIC_BOOST, set_param}, {VP9_GET_REFERENCE, get_reference}, {VP9E_SET_SVC, vp9e_set_svc}, {VP9E_SET_SVC_PARAMETERS, vp9e_set_svc_parameters}, diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h index 0b637d42f..8944a2664 100644 --- a/vpx/vp8cx.h +++ b/vpx/vp8cx.h @@ -192,6 +192,7 @@ enum vp8e_enc_control_id { VP9E_SET_TILE_ROWS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, + VP9E_SET_FRAME_PERIODIC_BOOST, VP9E_SET_SVC, VP9E_SET_SVC_PARAMETERS, @@ -364,6 +365,8 @@ VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int) VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int) +VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PERIODIC_BOOST, unsigned int) + /*! @} - end defgroup vp8_encoder */ #ifdef __cplusplus } // extern "C" diff --git a/vpxenc.c b/vpxenc.c index 1cd5e9232..c4d77f145 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -400,13 +400,17 @@ static const arg_def_t frame_parallel_decoding = ARG_DEF( NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); static const arg_def_t aq_mode = ARG_DEF( NULL, "aq-mode", 1, - "Adaptive q mode (0: off (by default), 1: variance 2: complexity)"); + "Adaptive q mode (0: off (by default), 1: variance 2: complexity, " + "3: cyclic refresh)"); +static const arg_def_t frame_periodic_boost = ARG_DEF( + NULL, "frame_boost", 1, + "Enable frame periodic boost (0: off (by default), 1: on)"); static const arg_def_t *vp9_args[] = { &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, &tune_ssim, &cq_level, &max_intra_rate_pct, &lossless, - &frame_parallel_decoding, &aq_mode, + &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, NULL }; static const int vp9_arg_ctrl_map[] = { @@ -416,6 +420,7 @@ static const int vp9_arg_ctrl_map[] = { VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, + VP9E_SET_FRAME_PERIODIC_BOOST, 0 }; #endif -- 2.40.0