]> granicus.if.org Git - libvpx/commitdiff
L2E: Distinguish fixed and active gf_interval
authorCheng Chen <chengchen@google.com>
Fri, 24 Jun 2022 18:57:42 +0000 (11:57 -0700)
committerCheng Chen <chengchen@google.com>
Mon, 27 Jun 2022 20:58:54 +0000 (13:58 -0700)
min/max_gf_interval is fixed and can be passed from the command line.
It must satisfy the level constraints.

active_min/max_gf_interval might be changing based on
min/max_gf_interval. It is determined per GOP.

Change-Id: If456c691c97a8b4c946859c05cedd39ca7defa9c

test/vp9_ext_ratectrl_test.cc
vp9/encoder/vp9_firstpass.c
vpx/vpx_ext_ratectrl.h

index 66d4233766c6c30104d657f9601b672ffe702251..68703b7e94ea3628dd001b58b4ee47d92257f6c8 100644 (file)
@@ -33,8 +33,7 @@ constexpr int kFixedGOPSize = 9;
 constexpr int kMaxLagInFrames = 25;
 constexpr int kDefaultMinGfInterval = 4;
 constexpr int kDefaultMaxGfInterval = 16;
-// The two pass rate control does not respect the input
-// min_gf_interval and max_gf_interval.
+// The active gf interval might change for each GOP
 // See function "get_active_gf_inverval_range".
 // The numbers below are from manual inspection.
 constexpr int kReadMinGfInterval = 5;
@@ -267,8 +266,10 @@ vpx_rc_status_t rc_get_gop_decision(vpx_rc_model_t rate_ctrl_model,
   ToyRateCtrl *toy_rate_ctrl = static_cast<ToyRateCtrl *>(rate_ctrl_model);
   EXPECT_EQ(toy_rate_ctrl->magic_number, kModelMagicNumber);
   EXPECT_EQ(gop_info->lag_in_frames, kMaxLagInFrames);
-  EXPECT_EQ(gop_info->min_gf_interval, kReadMinGfInterval);
-  EXPECT_EQ(gop_info->max_gf_interval, kReadMaxGfInterval);
+  EXPECT_EQ(gop_info->min_gf_interval, kDefaultMinGfInterval);
+  EXPECT_EQ(gop_info->max_gf_interval, kDefaultMaxGfInterval);
+  EXPECT_EQ(gop_info->active_min_gf_interval, kReadMinGfInterval);
+  EXPECT_EQ(gop_info->active_max_gf_interval, kReadMaxGfInterval);
   EXPECT_EQ(gop_info->allow_alt_ref, 1);
   if (gop_info->is_key_frame) {
     EXPECT_EQ(gop_info->last_gop_use_alt_ref, 0);
index e121ac80e1f78d33f2ea8f1c042a3bd804dfd8e7..4682cc00302e7ae46e317ac48bcde720c670486c 100644 (file)
@@ -2762,8 +2762,10 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) {
     vpx_codec_err_t codec_status;
     vpx_rc_gop_decision_t gop_decision;
     vpx_rc_gop_info_t gop_info;
-    gop_info.min_gf_interval = active_gf_interval.min;
-    gop_info.max_gf_interval = active_gf_interval.max;
+    gop_info.min_gf_interval = rc->min_gf_interval;
+    gop_info.max_gf_interval = rc->max_gf_interval;
+    gop_info.active_min_gf_interval = active_gf_interval.min;
+    gop_info.active_max_gf_interval = active_gf_interval.max;
     gop_info.allow_alt_ref = allow_alt_ref;
     gop_info.is_key_frame = is_key_frame;
     gop_info.last_gop_use_alt_ref = rc->source_alt_ref_active;
index b57148c69b347170c0e6a478ff5f3b484eba1948..c3309b0f264c176a9193b536bf3a2a4f84d49fd0 100644 (file)
@@ -25,7 +25,7 @@ extern "C" {
  * types, removing or reassigning enums, adding/removing/rearranging
  * fields to structures.
  */
-#define VPX_EXT_RATECTRL_ABI_VERSION (4)
+#define VPX_EXT_RATECTRL_ABI_VERSION (5)
 
 /*!\brief The control type of the inference API.
  * In VPX_RC_QP mode, the external rate control model determines the
@@ -287,12 +287,26 @@ typedef struct vpx_rc_config {
 typedef struct vpx_rc_gop_info {
   /*!
    * Minimum allowed gf interval, fixed for the whole clip.
+   * Note that it will be modified to match vp9's level constraints
+   * in the encoder.
+   * The level constraint is defined in vp9_encoder.c:
+   * const Vp9LevelSpec vp9_level_defs[VP9_LEVELS].
    */
   int min_gf_interval;
   /*!
    * Maximum allowed gf interval, fixed for the whole clip.
    */
   int max_gf_interval;
+  /*!
+   * Minimum allowed gf interval for the current GOP, determined
+   * by the encoder.
+   */
+  int active_min_gf_interval;
+  /*!
+   * Maximum allowed gf interval for the current GOP, determined
+   * by the encoder.
+   */
+  int active_max_gf_interval;
   /*!
    * Whether to allow the use of alt ref, can be changed per gop.
    */