]> granicus.if.org Git - libvpx/commitdiff
Allow user to set rc_mode and cq_level in SimpleEncode
authorAngie Chiang <angiebird@google.com>
Fri, 20 Nov 2020 03:55:33 +0000 (19:55 -0800)
committerAngie Chiang <angiebird@google.com>
Sat, 21 Nov 2020 01:40:04 +0000 (17:40 -0800)
Change-Id: If3f56837e2c78a8b0fe7e0040f297c3f3ddb9c8b

vp9/simple_encode.cc
vp9/simple_encode.h

index afda6e2035c65623fbcaa16db0fe27dbc1421b09..d4eb0c669d71426933bc84bd7bd24b69a9d6fcee 100644 (file)
@@ -765,6 +765,16 @@ static void UpdateEncodeConfig(const EncodeConfig &config,
   SET_STRUCT_VALUE(config, oxcf, ret, encode_breakout);
   SET_STRUCT_VALUE(config, oxcf, ret, enable_tpl_model);
   SET_STRUCT_VALUE(config, oxcf, ret, enable_auto_arf);
+  if (strcmp(config.name, "rc_mode") == 0) {
+    int rc_mode = atoi(config.value);
+    if (rc_mode >= VPX_VBR && rc_mode <= VPX_Q) {
+      oxcf->rc_mode = (enum vpx_rc_mode)rc_mode;
+      ret = 1;
+    } else {
+      fprintf(stderr, "Invalid rc_mode value: %d\n", rc_mode);
+    }
+  }
+  SET_STRUCT_VALUE(config, oxcf, ret, cq_level);
   if (ret == 0) {
     fprintf(stderr, "Ignored unsupported encode_config %s\n", config.name);
   }
index 380e8118fc0d497ba83f00e3c09ece57c057bfe7..e3ef3cea95a2e2fdfc65d80f2993ac1d749a6f32 100644 (file)
@@ -361,21 +361,32 @@ class SimpleEncode {
   // The following configs in VP9EncoderConfig are allowed to change in this
   // function. See https://ffmpeg.org/ffmpeg-codecs.html#libvpx for each
   // config's meaning.
-  // Configs in VP9EncoderConfig:      Equivalent configs in ffmpeg:
-  // 1  key_freq                       -g
-  // 2  two_pass_vbrmin_section        -minrate * 100LL / bit_rate
-  // 3  two_pass_vbrmax_section        -maxrate * 100LL / bit_rate
-  // 4  under_shoot_pct                -undershoot-pct
-  // 5  over_shoot_pct                 -overshoot-pct
-  // 6  max_threads                    -threads
-  // 7  frame_parallel_decoding_mode   -frame-parallel
-  // 8  tile_column                    -tile-columns
-  // 9  arnr_max_frames                -arnr-maxframes
-  // 10 arnr_strength                  -arnr-strength
-  // 11 lag_in_frames                  -rc_lookahead
-  // 12 encode_breakout                -static-thresh
-  // 13 enable_tpl_model               -enable-tpl
-  // 14 enable_auto_arf                -auto-alt-ref
+  // Configs in VP9EncoderConfig:          Equivalent configs in ffmpeg:
+  // 1  key_freq                           -g
+  // 2  two_pass_vbrmin_section            -minrate * 100LL / bit_rate
+  // 3  two_pass_vbrmax_section            -maxrate * 100LL / bit_rate
+  // 4  under_shoot_pct                    -undershoot-pct
+  // 5  over_shoot_pct                     -overshoot-pct
+  // 6  max_threads                        -threads
+  // 7  frame_parallel_decoding_mode       -frame-parallel
+  // 8  tile_column                        -tile-columns
+  // 9  arnr_max_frames                    -arnr-maxframes
+  // 10 arnr_strength                      -arnr-strength
+  // 11 lag_in_frames                      -rc_lookahead
+  // 12 encode_breakout                    -static-thresh
+  // 13 enable_tpl_model                   -enable-tpl
+  // 14 enable_auto_arf                    -auto-alt-ref
+  // 15 rc_mode
+  //    Possible Settings:
+  //      0 - Variable Bit Rate (VPX_VBR)  -b:v <bit_rate>
+  //      1 - Constant Bit Rate (VPX_CBR)  -b:v <bit_rate> -minrate <bit_rate>
+  //                                        -maxrate <bit_rate>
+  //        two_pass_vbrmin_section == 100   i.e. bit_rate == minrate == maxrate
+  //        two_pass_vbrmax_section == 100
+  //      2 - Constrained Quality (VPX_CQ) -crf <cq_level> -b:v bit_rate
+  //      3 - Constant Quality (VPX_Q)     -crf <cq_level> -b:v 0
+  //    See https://trac.ffmpeg.org/wiki/Encode/VP9 for more details.
+  // 16 cq_level                          see rc_mode for details.
   StatusCode SetEncodeConfig(const char *name, const char *value);
 
   // A debug function that dumps configs from VP9EncoderConfig