]> granicus.if.org Git - libvpx/commitdiff
vp9-rtc: Add control to disable maxq on overshoot
authorMarco Paniconi <marpan@google.com>
Mon, 11 May 2020 19:22:19 +0000 (12:22 -0700)
committerMarco Paniconi <marpan@google.com>
Tue, 25 Aug 2020 20:06:41 +0000 (13:06 -0700)
Add encoder control to disable feature to increase Q
on overshoot detection, for CBR. Default (no usage
of the control) means the feature is internally enabled.

Add the control to the sample encoders, but keep it
disabled as default (set to 0, so feature is on).

Change-Id: Ia2237bc4aaea9770e5080dab20bfff9e3fd09199

examples/vp9_spatial_svc_encoder.c
examples/vpx_temporal_svc_encoder.c
vp9/encoder/vp9_ratectrl.c
vp9/encoder/vp9_ratectrl.h
vp9/encoder/vp9_speed_features.c
vp9/vp9_cx_iface.c
vpx/vp8cx.h

index f273c1208a1e4a19f159d3170aadd0da4d26aa10..5bb5a3183f39dd48e63e87b072e4e3b4100a8fee 100644 (file)
@@ -1053,6 +1053,8 @@ int main(int argc, const char **argv) {
 
   vpx_codec_control(&encoder, VP9E_SET_TUNE_CONTENT, app_input.tune_content);
 
+  vpx_codec_control(&encoder, VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, 0);
+
   svc_drop_frame.framedrop_mode = FULL_SUPERFRAME_DROP;
   for (sl = 0; sl < (unsigned int)svc_ctx.spatial_layers; ++sl)
     svc_drop_frame.framedrop_thresh[sl] = enc_cfg.rc_dropframe_thresh;
index 872751cefeeac54c358661aaff8de416064638cd..c5a3228b112b89d51eb621291ab4e298b7fd4a13 100644 (file)
@@ -831,6 +831,7 @@ int main(int argc, char **argv) {
   } else if (strncmp(encoder->name, "vp9", 3) == 0) {
     vpx_svc_extra_cfg_t svc_params;
     memset(&svc_params, 0, sizeof(svc_params));
+    vpx_codec_control(&codec, VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, 0);
     vpx_codec_control(&codec, VP8E_SET_CPUUSED, speed);
     vpx_codec_control(&codec, VP9E_SET_AQ_MODE, 3);
     vpx_codec_control(&codec, VP9E_SET_GF_CBR_BOOST_PCT, 0);
index 27a529914d6da5099a05a20238b7d72324284c56..4693309ce436c62c6bd24e30d686a7cff2eb887f 100644 (file)
@@ -441,6 +441,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
   rc->last_post_encode_dropped_scene_change = 0;
   rc->use_post_encode_drop = 0;
   rc->ext_use_post_encode_drop = 0;
+  rc->disable_overshoot_maxq_cbr = 0;
   rc->arf_active_best_quality_adjustment_factor = 1.0;
   rc->arf_increase_active_best_quality = 0;
   rc->preserve_arf_as_gld = 0;
index c5ffb153c8c2ba4c65404c22ec1a56df6f3d4985..0120f90a01d47dd67dce27b3976b1391c5641197 100644 (file)
@@ -195,7 +195,8 @@ typedef struct {
   int use_post_encode_drop;
   // External flag to enable post encode frame dropping, controlled by user.
   int ext_use_post_encode_drop;
-
+  // Flag to disable CBR feature to increase Q on overshoot detection.
+  int disable_overshoot_maxq_cbr;
   int damped_adjustment[RATE_FACTOR_LEVELS];
   double arf_active_best_quality_adjustment_factor;
   int arf_increase_active_best_quality;
index 5bbe54923689dfbf3fab41156d2a2635c60d2cba..585c9604c61e1704d9373089c146c469bfd759fe 100644 (file)
@@ -621,7 +621,7 @@ static void set_rt_speed_feature_framesize_independent(
     // increase in encoding time.
     if (cpi->use_svc && svc->spatial_layer_id > 0) sf->nonrd_keyframe = 1;
     if (cm->frame_type != KEY_FRAME && cpi->resize_state == ORIG &&
-        cpi->oxcf.rc_mode == VPX_CBR) {
+        cpi->oxcf.rc_mode == VPX_CBR && !cpi->rc.disable_overshoot_maxq_cbr) {
       if (cm->width * cm->height <= 352 * 288 && !cpi->use_svc &&
           cpi->oxcf.content != VP9E_CONTENT_SCREEN)
         sf->overshoot_detection_cbr_rt = RE_ENCODE_MAXQ;
@@ -668,7 +668,7 @@ static void set_rt_speed_feature_framesize_independent(
       sf->base_mv_aggressive = 1;
     }
     if (cm->frame_type != KEY_FRAME && cpi->resize_state == ORIG &&
-        cpi->oxcf.rc_mode == VPX_CBR)
+        cpi->oxcf.rc_mode == VPX_CBR && !cpi->rc.disable_overshoot_maxq_cbr)
       sf->overshoot_detection_cbr_rt = FAST_DETECTION_MAXQ;
   }
 
index 6caa4f7390c6d03ff6e86c6c8db7cbfc95c8cf90..172a248230d47519544a8bde849e60cc6dad6bf9 100644 (file)
@@ -1716,6 +1716,14 @@ static vpx_codec_err_t ctrl_set_postencode_drop(vpx_codec_alg_priv_t *ctx,
   return VPX_CODEC_OK;
 }
 
+static vpx_codec_err_t ctrl_set_disable_overshoot_maxq_cbr(
+    vpx_codec_alg_priv_t *ctx, va_list args) {
+  VP9_COMP *const cpi = ctx->cpi;
+  const unsigned int data = va_arg(args, unsigned int);
+  cpi->rc.disable_overshoot_maxq_cbr = data;
+  return VPX_CODEC_OK;
+}
+
 static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { VP8_COPY_REFERENCE, ctrl_copy_reference },
 
@@ -1760,6 +1768,7 @@ static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   { VP9E_SET_TARGET_LEVEL, ctrl_set_target_level },
   { VP9E_SET_ROW_MT, ctrl_set_row_mt },
   { VP9E_SET_POSTENCODE_DROP, ctrl_set_postencode_drop },
+  { VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, ctrl_set_disable_overshoot_maxq_cbr },
   { VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, ctrl_enable_motion_vector_unit_test },
   { VP9E_SET_SVC_INTER_LAYER_PRED, ctrl_set_svc_inter_layer_pred },
   { VP9E_SET_SVC_FRAME_DROP_LAYER, ctrl_set_svc_frame_drop_layer },
index dcdd710c0ba1a161ef8218bbc6fa5812f70d9ece..ed3e2516af6cf883d8ce5b1154ef591cc982f378 100644 (file)
@@ -684,6 +684,14 @@ enum vp8e_enc_control_id {
    * Supported in codecs: VP9
    */
   VP9E_SET_DELTA_Q_UV,
+
+  /*!\brief Codec control function to disable increase Q on overshoot in CBR.
+   *
+   * 0: On (default), 1: Disable.
+   *
+   * Supported in codecs: VP9
+   */
+  VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR,
 };
 
 /*!\brief vpx 1-D scaling mode
@@ -1034,6 +1042,8 @@ VPX_CTRL_USE_TYPE(VP9E_SET_POSTENCODE_DROP, unsigned int)
 VPX_CTRL_USE_TYPE(VP9E_SET_DELTA_Q_UV, int)
 #define VPX_CTRL_VP9E_SET_DELTA_Q_UV
 
+VPX_CTRL_USE_TYPE(VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR, int)
+#define VPX_CTRL_VP9E_SET_DISABLE_OVERSHOOT_MAXQ_CBR
 /*!\endcond */
 /*! @} - end defgroup vp8_encoder */
 #ifdef __cplusplus