Add codec control function for enabling frame_periodic_boost.
authorMarco Paniconi <marpan@google.com>
Thu, 3 Apr 2014 22:49:03 +0000 (15:49 -0700)
committerMarco Paniconi <marpan@google.com>
Thu, 3 Apr 2014 22:49:03 +0000 (15:49 -0700)
Change-Id: I6371ef7301c6bc3138552bd349e9bd154dee3e08

examples/vpx_temporal_scalable_patterns.c
vp9/encoder/vp9_onyx_int.h
vp9/encoder/vp9_ratectrl.c
vp9/encoder/vp9_speed_features.c
vp9/encoder/vp9_speed_features.h
vp9/vp9_cx_iface.c
vpx/vp8cx.h
vpxenc.c

index 3a4f05b92cb2b0bb1d6a0618cca6fb6b5bbf41a0..5cb4ee9cf2e314834aa3ff845e5bf72e4b4a5a4d 100644 (file)
@@ -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");
index 9a2bafc3e5284d2aeddd054a689d650ec0c3d9ef..d9dbd53da4ad5b56da9a18135fc734505edf6353 100644 (file)
@@ -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;
index 21f4230435864f9e0934ac31f953c955914421e6..eb4db1a33345a2a3463437bcdafd568d14f15b38 100644 (file)
@@ -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)
index 0d9007b94b6c62ff29b09efda3a42566ee11ffd3..14328293ba35c208459289b501fd6205a94bd1af 100644 (file)
@@ -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;
+  }
 }
index 27b11c84e074c14bc251e1da1f3331ab4bb4cf8d..826043910799cc3eea8700e81e5a19cad893e56a 100644 (file)
@@ -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;
index a9fd8c11e992b61a947cd7dc56d6534a03e1ea8e..37a214e0536593d6e3a1ee240fcc71618f387cd1 100644 (file)
@@ -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},
index 0b637d42f936cd0b10ea7f80fc7e304bd690dde2..8944a26647466664f451a9e59f0412f7ef266bee 100644 (file)
@@ -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"
index 1cd5e92325233351445d72d8cb5d7effc4101ee0..c4d77f1455d3d43a77b4e75f31f84146f7cd988d 100644 (file)
--- 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