shithub: libvpx

Download patch

ref: b5cd400e7640273d026cc7c33d4a76c4bef38074
parent: dfe4a7c88e1592ef84e21c35b8d58a2937ac7db8
author: Jingning Han <jingning@google.com>
date: Mon Nov 5 10:38:10 EST 2018

Refactor define_gf_group_structure()

Make it a standalone operation unit. Refactor to cut off unnecessary
dependency between define_gf_group_structure() and
allocate_gf_group_bits().

Change-Id: I954fd4e96152471a994f2ffd38a72061ab517ddd

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2176,7 +2176,7 @@
   }
 }
 
-static int define_gf_group_structure(VP9_COMP *cpi) {
+static void define_gf_group_structure(VP9_COMP *cpi) {
   RATE_CONTROL *const rc = &cpi->rc;
   TWO_PASS *const twopass = &cpi->twopass;
   GF_GROUP *const gf_group = &twopass->gf_group;
@@ -2219,7 +2219,8 @@
     gf_group->arf_src_offset[frame_index] = 0;
     gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
 
-    return frame_index;
+    gf_group->gf_group_size = frame_index;
+    return;
   }
 
   normal_frames =
@@ -2245,7 +2246,7 @@
   gf_group->arf_src_offset[frame_index] = 0;
   gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
 
-  return frame_index;
+  gf_group->gf_group_size = frame_index;
 }
 
 static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits,
@@ -2270,10 +2271,8 @@
   double this_frame_score = 1.0;
 
   // Define the GF structure and specify
-  int gop_frames = define_gf_group_structure(cpi);
+  int gop_frames = gf_group->gf_group_size;
 
-  gf_group->gf_group_size = gop_frames;
-
   key_frame = cpi->common.frame_type == KEY_FRAME;
 
   // For key frames the frame target rate is already set and it
@@ -2703,6 +2702,9 @@
 
   // Adjust KF group bits and error remaining.
   twopass->kf_group_error_left -= gf_group_err;
+
+  // Decide GOP structure.
+  define_gf_group_structure(cpi);
 
   // Allocate bits to each of the frames in the GF group.
   allocate_gf_group_bits(cpi, gf_group_bits, gf_arf_bits);