shithub: libvpx

Download patch

ref: 733d356fa77d9f0c9bf7a3070b53de3db961bfd8
parent: f216dba55792f772006ab4397b898a593ab492eb
author: angiebird <[email protected]>
date: Sun Nov 3 03:45:39 EST 2019

Add frame_rate param to vp9_get_encoder_config

Change-Id: I14a3d076d71240b4ed2436947418aa3177911fc1

--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1831,6 +1831,7 @@
 };
 
 static vpx_codec_enc_cfg_t get_enc_cfg(int frame_width, int frame_height,
+                                       vpx_rational_t frame_rate,
                                        int target_bitrate,
                                        vpx_enc_pass enc_pass) {
   vpx_codec_enc_cfg_t enc_cfg = encoder_usage_cfg_map[0].cfg;
@@ -1838,10 +1839,9 @@
   enc_cfg.g_h = frame_height;
   enc_cfg.rc_target_bitrate = target_bitrate;
   enc_cfg.g_pass = enc_pass;
-  // Use the same default setting as the one used in vpxenc.c
-  // The default unit time for the encoder is 1/1000 s.
-  enc_cfg.g_timebase.num = 1;
-  enc_cfg.g_timebase.den = 1000;
+  // g_timebase is the inverse of frame_rate
+  enc_cfg.g_timebase.num = frame_rate.den;
+  enc_cfg.g_timebase.den = frame_rate.num;
   return enc_cfg;
 }
 
@@ -1855,12 +1855,13 @@
 }
 
 VP9EncoderConfig vp9_get_encoder_config(int frame_width, int frame_height,
+                                        vpx_rational_t frame_rate,
                                         int target_bitrate,
                                         vpx_enc_pass enc_pass) {
   VP9EncoderConfig oxcf;
   vp9_extracfg extra_cfg = get_extra_cfg();
-  vpx_codec_enc_cfg_t enc_cfg =
-      get_enc_cfg(frame_width, frame_height, target_bitrate, enc_pass);
+  vpx_codec_enc_cfg_t enc_cfg = get_enc_cfg(
+      frame_width, frame_height, frame_rate, target_bitrate, enc_pass);
   set_encoder_config(&oxcf, &enc_cfg, &extra_cfg);
   return oxcf;
 }
--- a/vp9/vp9_cx_iface.h
+++ b/vp9/vp9_cx_iface.h
@@ -18,6 +18,7 @@
 #endif
 
 VP9EncoderConfig vp9_get_encoder_config(int frame_width, int frame_height,
+                                        vpx_rational_t frame_rate,
                                         int target_bitrate,
                                         vpx_enc_pass enc_pass);
 FRAME_INFO vp9_get_frame_info(const VP9EncoderConfig *oxcf);