shithub: libvpx

Download patch

ref: e56e8dcd6fc9e2b04316be5144c18ca6772f6263
parent: 5b63f0f821e94f8072eb483014cfc33b05978bb9
author: Angie Chiang <angiebird@google.com>
date: Tue Nov 17 12:25:31 EST 2020

Add gop_index to vpx_ext_ratectrl.h

Bug: webm:1707

Change-Id: I48826d5f3a7cc292825a7f1e30ac6d0f57adc569

--- a/test/vp9_ext_ratectrl_test.cc
+++ b/test/vp9_ext_ratectrl_test.cc
@@ -73,6 +73,7 @@
   EXPECT_EQ(encode_frame_info->coding_index, toy_rate_ctrl->coding_index);
 
   if (encode_frame_info->coding_index == 0) {
+    EXPECT_EQ(encode_frame_info->gop_index, 0);
     EXPECT_EQ(encode_frame_info->frame_type, 0 /*kFrameTypeKey*/);
     EXPECT_EQ(encode_frame_info->ref_frame_valid_list[0],
               0);  // kRefFrameTypeLast
@@ -83,6 +84,7 @@
   }
 
   if (encode_frame_info->coding_index == 1) {
+    EXPECT_EQ(encode_frame_info->gop_index, 1);
     EXPECT_EQ(encode_frame_info->frame_type, 2 /*kFrameTypeAltRef*/);
     EXPECT_EQ(encode_frame_info->ref_frame_valid_list[0],
               1);  // kRefFrameTypeLast
@@ -96,10 +98,13 @@
 
   if (encode_frame_info->coding_index >= 2 &&
       encode_frame_info->coding_index < 5) {
+    // In the first group of pictures, coding_index and gop_index are equal.
+    EXPECT_EQ(encode_frame_info->gop_index, encode_frame_info->coding_index);
     EXPECT_EQ(encode_frame_info->frame_type, 1 /*kFrameTypeInter*/);
   }
 
   if (encode_frame_info->coding_index == 5) {
+    EXPECT_EQ(encode_frame_info->gop_index, 0);
     EXPECT_EQ(encode_frame_info->frame_type, 3 /*kFrameTypeOverlay*/);
     EXPECT_EQ(encode_frame_info->ref_frame_valid_list[0],
               1);  // kRefFrameTypeLast
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4511,8 +4511,8 @@
       get_ref_frame_bufs(cpi, ref_frame_bufs);
       vp9_extrc_get_encodeframe_decision(
           &cpi->ext_ratectrl, cm->current_video_frame,
-          cm->current_frame_coding_index, update_type, ref_frame_bufs,
-          ref_frame_flags, &encode_frame_decision);
+          cm->current_frame_coding_index, gf_group->index, update_type,
+          ref_frame_bufs, ref_frame_flags, &encode_frame_decision);
       q = encode_frame_decision.q_index;
     }
 
--- a/vp9/encoder/vp9_ext_ratectrl.c
+++ b/vp9/encoder/vp9_ext_ratectrl.c
@@ -103,7 +103,7 @@
 }
 
 void vp9_extrc_get_encodeframe_decision(
-    EXT_RATECTRL *ext_ratectrl, int show_index, int coding_index,
+    EXT_RATECTRL *ext_ratectrl, int show_index, int coding_index, int gop_index,
     FRAME_UPDATE_TYPE update_type,
     RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int ref_frame_flags,
     vpx_rc_encodeframe_decision_t *encode_frame_decision) {
@@ -111,6 +111,7 @@
     vpx_rc_encodeframe_info_t encode_frame_info;
     encode_frame_info.show_index = show_index;
     encode_frame_info.coding_index = coding_index;
+    encode_frame_info.gop_index = gop_index;
     encode_frame_info.frame_type = extrc_get_frame_type(update_type);
 
     vp9_get_ref_frame_info(update_type, ref_frame_flags, ref_frame_bufs,
--- a/vp9/encoder/vp9_ext_ratectrl.h
+++ b/vp9/encoder/vp9_ext_ratectrl.h
@@ -33,7 +33,7 @@
                                     const FIRST_PASS_INFO *first_pass_info);
 
 void vp9_extrc_get_encodeframe_decision(
-    EXT_RATECTRL *ext_ratectrl, int show_index, int coding_index,
+    EXT_RATECTRL *ext_ratectrl, int show_index, int coding_index, int gop_index,
     FRAME_UPDATE_TYPE update_type,
     RefCntBuffer *ref_frame_bufs[MAX_INTER_REF_FRAMES], int ref_frame_flags,
     vpx_rc_encodeframe_decision_t *encode_frame_decision);
--- a/vpx/vpx_encoder.h
+++ b/vpx/vpx_encoder.h
@@ -30,6 +30,7 @@
 #endif
 
 #include "./vpx_codec.h"
+#include "./vpx_ext_ratectrl.h"
 
 /*! Temporal Scalability: Maximum length of the sequence defining frame
  * layer membership
@@ -57,7 +58,8 @@
  * fields to structures
  */
 #define VPX_ENCODER_ABI_VERSION \
-  (14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
+  (14 + VPX_CODEC_ABI_VERSION + \
+   VPX_EXT_RATECTRL_ABI_VERSION) /**<\hideinitializer*/
 
 /*! \brief Encoder capabilities bitfield
  *
--- a/vpx/vpx_ext_ratectrl.h
+++ b/vpx/vpx_ext_ratectrl.h
@@ -17,6 +17,16 @@
 
 #include "./vpx_integer.h"
 
+/*!\brief Current ABI version number
+ *
+ * \internal
+ * If this file is altered in any way that changes the ABI, this value
+ * must be bumped. Examples include, but are not limited to, changing
+ * types, removing or reassigning enums, adding/removing/rearranging
+ * fields to structures.
+ */
+#define VPX_EXT_RATECTRL_ABI_VERSION (1)
+
 /*!\brief Abstract rate control model handler
  *
  * The encoder will receive the model handler from create_model() defined in
@@ -48,8 +58,12 @@
    * 4: Golden frame
    */
   int frame_type;
-  int show_index;                  /**< display index, starts from zero*/
-  int coding_index;                /**< coding index, starts from zero*/
+  int show_index;   /**< display index, starts from zero*/
+  int coding_index; /**< coding index, starts from zero*/
+  /*!
+   * index in group of picture, starts from zero.
+   */
+  int gop_index;
   int ref_frame_coding_indexes[3]; /**< three reference frames' coding indices*/
   /*!
    * The validity of the three reference frames.