summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/vp9_ext_ratectrl_test.cc9
-rw-r--r--vp9/encoder/vp9_firstpass.c6
-rw-r--r--vpx/vpx_ext_ratectrl.h16
3 files changed, 24 insertions, 7 deletions
diff --git a/test/vp9_ext_ratectrl_test.cc b/test/vp9_ext_ratectrl_test.cc
index 66d423376..68703b7e9 100644
--- a/test/vp9_ext_ratectrl_test.cc
+++ b/test/vp9_ext_ratectrl_test.cc
@@ -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);
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index e121ac80e..4682cc003 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -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;
diff --git a/vpx/vpx_ext_ratectrl.h b/vpx/vpx_ext_ratectrl.h
index b57148c69..c3309b0f2 100644
--- a/vpx/vpx_ext_ratectrl.h
+++ b/vpx/vpx_ext_ratectrl.h
@@ -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,6 +287,10 @@ 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;
/*!
@@ -294,6 +298,16 @@ typedef struct vpx_rc_gop_info {
*/
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.
*/
int allow_alt_ref;