]> granicus.if.org Git - libvpx/commitdiff
Add vpxenc control to turn on/off tpl model
authorJingning Han <jingning@google.com>
Mon, 13 Aug 2018 21:47:54 +0000 (14:47 -0700)
committerJingning Han <jingning@google.com>
Tue, 14 Aug 2018 15:54:48 +0000 (08:54 -0700)
The default is set to turn on the temporal dependency model at
speed 0. Use --enable-tpl to control turning it on/off when calling
vpxenc.

Change-Id: I61614cd8100ae57dc01fd46b2a69c5b67287f18a

vp9/encoder/vp9_encoder.h
vp9/encoder/vp9_speed_features.c
vp9/vp9_cx_iface.c
vpx/vp8cx.h
vpxenc.c

index 038413a96efe67c4ef15cc6d77d887ad32d70c6c..6a825800da497a74ef68d52c2955d95a97c44856 100644 (file)
@@ -248,6 +248,8 @@ typedef struct VP9EncoderConfig {
   int tile_columns;
   int tile_rows;
 
+  int enable_tpl_model;
+
   int max_threads;
 
   unsigned int target_level;
index d522a623bcc006f2ff40c72ffcdd05f7a13dc054..dca47924e3908f7fcbedf9948ab0e203b9186558 100644 (file)
@@ -849,9 +849,9 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) {
   sf->allow_acl = 1;
 #if CONFIG_VP9_HIGHBITDEPTH
   // TODO(jingning): Make the model support high bit-depth route.
-  sf->enable_tpl_model = !cm->use_highbitdepth;
+  sf->enable_tpl_model = !cm->use_highbitdepth && oxcf->enable_tpl_model;
 #else
-  sf->enable_tpl_model = 1;
+  sf->enable_tpl_model = oxcf->enable_tpl_model;
 #endif
   sf->prune_ref_frame_for_rect_partitions = 0;
 
index 3da8758d973b5240fd20c0bc0d1c4153cafd887f..45a8464593a198994a3d5560ff47bea28d522ddc 100644 (file)
@@ -30,6 +30,7 @@ struct vp9_extracfg {
   unsigned int static_thresh;
   unsigned int tile_columns;
   unsigned int tile_rows;
+  unsigned int enable_tpl_model;
   unsigned int arnr_max_frames;
   unsigned int arnr_strength;
   unsigned int min_gf_interval;
@@ -63,6 +64,7 @@ static struct vp9_extracfg default_extra_cfg = {
   0,                     // static_thresh
   6,                     // tile_columns
   0,                     // tile_rows
+  1,                     // enable_tpl_model
   7,                     // arnr_max_frames
   5,                     // arnr_strength
   0,                     // min_gf_interval; 0 -> default decision
@@ -544,6 +546,8 @@ static vpx_codec_err_t set_encoder_config(
 
   oxcf->tile_columns = extra_cfg->tile_columns;
 
+  oxcf->enable_tpl_model = extra_cfg->enable_tpl_model;
+
   // TODO(yunqing): The dependencies between row tiles cause error in multi-
   // threaded encoding. For now, tile_rows is forced to be 0 in this case.
   // The further fix can be done by adding synchronizations after a tile row
@@ -740,6 +744,13 @@ static vpx_codec_err_t ctrl_set_tile_rows(vpx_codec_alg_priv_t *ctx,
   return update_extra_cfg(ctx, &extra_cfg);
 }
 
+static vpx_codec_err_t ctrl_set_tpl_model(vpx_codec_alg_priv_t *ctx,
+                                          va_list args) {
+  struct vp9_extracfg extra_cfg = ctx->extra_cfg;
+  extra_cfg.enable_tpl_model = CAST(VP9E_SET_TPL, args);
+  return update_extra_cfg(ctx, &extra_cfg);
+}
+
 static vpx_codec_err_t ctrl_set_arnr_max_frames(vpx_codec_alg_priv_t *ctx,
                                                 va_list args) {
   struct vp9_extracfg extra_cfg = ctx->extra_cfg;
@@ -1618,6 +1629,7 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { VP8E_SET_STATIC_THRESHOLD, ctrl_set_static_thresh },
   { VP9E_SET_TILE_COLUMNS, ctrl_set_tile_columns },
   { VP9E_SET_TILE_ROWS, ctrl_set_tile_rows },
+  { VP9E_SET_TPL, ctrl_set_tpl_model },
   { VP8E_SET_ARNR_MAXFRAMES, ctrl_set_arnr_max_frames },
   { VP8E_SET_ARNR_STRENGTH, ctrl_set_arnr_strength },
   { VP8E_SET_ARNR_TYPE, ctrl_set_arnr_type },
index ea720cfb34aa2206ad53087d090b0de6bd2ee92a..5ede91a2097cc585323ace0086b28d614f800dea 100644 (file)
@@ -652,6 +652,14 @@ enum vp8e_enc_control_id {
    * Supported in codecs: VP9
    */
   VP9E_SET_SVC_SPATIAL_LAYER_SYNC,
+
+  /*!\brief Codec control function to enable temporal dependency model.
+   *
+   * Vp9 allows the encoder to run temporal dependency model and use it to
+   * improve the compression performance. To enable, set this parameter to be
+   * 1. The default value is set to be 1.
+   */
+  VP9E_SET_TPL,
 };
 
 /*!\brief vpx 1-D scaling mode
@@ -897,6 +905,9 @@ VPX_CTRL_USE_TYPE(VP9E_SET_TILE_COLUMNS, int)
 VPX_CTRL_USE_TYPE(VP9E_SET_TILE_ROWS, int)
 #define VPX_CTRL_VP9E_SET_TILE_ROWS
 
+VPX_CTRL_USE_TYPE(VP9E_SET_TPL, int)
+#define VPX_CTRL_VP9E_SET_TPL
+
 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER, int *)
 #define VPX_CTRL_VP8E_GET_LAST_QUANTIZER
 VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
index 3d8d95940f5a4e5400059c31b71fffb3cbdd51c7..770a91762be790f9ba2802891e0895fc2d639c92 100644 (file)
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -412,6 +412,10 @@ static const arg_def_t tile_cols =
 static const arg_def_t tile_rows =
     ARG_DEF(NULL, "tile-rows", 1,
             "Number of tile rows to use, log2 (set to 0 while threads > 1)");
+
+static const arg_def_t enable_tpl_model =
+    ARG_DEF(NULL, "enable-tpl", 1, "Enable temporal dependency model");
+
 static const arg_def_t lossless =
     ARG_DEF(NULL, "lossless", 1, "Lossless mode (0: false (default), 1: true)");
 static const arg_def_t frame_parallel_decoding = ARG_DEF(
@@ -497,6 +501,7 @@ static const arg_def_t *vp9_args[] = { &cpu_used_vp9,
                                        &static_thresh,
                                        &tile_cols,
                                        &tile_rows,
+                                       &enable_tpl_model,
                                        &arnr_maxframes,
                                        &arnr_strength,
                                        &arnr_type,
@@ -528,6 +533,7 @@ static const int vp9_arg_ctrl_map[] = { VP8E_SET_CPUUSED,
                                         VP8E_SET_STATIC_THRESHOLD,
                                         VP9E_SET_TILE_COLUMNS,
                                         VP9E_SET_TILE_ROWS,
+                                        VP9E_SET_TPL,
                                         VP8E_SET_ARNR_MAXFRAMES,
                                         VP8E_SET_ARNR_STRENGTH,
                                         VP8E_SET_ARNR_TYPE,