]> granicus.if.org Git - libvpx/commitdiff
Add frame_gop_index to GF_GROUP
authorJingning Han <jingning@google.com>
Mon, 15 Oct 2018 18:48:39 +0000 (11:48 -0700)
committerJingning Han <jingning@google.com>
Mon, 15 Oct 2018 21:58:08 +0000 (14:58 -0700)
Add frame_gop_index to track the frame offset within a group of
picture. This reworks the GOP frame offset calculation and use
case. The coding stats remain identical.

Change-Id: I94d0957bcc327f6bbeac6e84157635663c36b953

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_firstpass.h

index 7c9d61ab2232d6f6521a5d0929e6577e31b7bbae..a2550d1d193162d814651f350136eb8816c3f849 100644 (file)
@@ -5416,8 +5416,9 @@ void init_gop_frames(VP9_COMP *cpi, GF_PICTURE *gf_picture,
 
   // Initialize P frames
   for (frame_idx = 2; frame_idx < MAX_LAG_BUFFERS; ++frame_idx) {
+    const int frame_gop_offset = gf_group->frame_gop_index[frame_idx];
     struct lookahead_entry *buf =
-        vp9_lookahead_peek(cpi->lookahead, frame_idx - 2);
+        vp9_lookahead_peek(cpi->lookahead, frame_gop_offset - 1);
 
     if (buf == NULL) break;
 
index 58c3a435d9fc119b0501dd315641176fb64253ac..318dd21b70fdf2816a4ae2a7e2b3e2f722240080 100644 (file)
@@ -2124,6 +2124,7 @@ static void find_arf_order(VP9_COMP *cpi, GF_GROUP *gf_group,
     for (idx = start; idx < end; ++idx) {
       gf_group->update_type[*index_counter] = LF_UPDATE;
       gf_group->arf_src_offset[*index_counter] = 0;
+      gf_group->frame_gop_index[*index_counter] = idx;
       gf_group->rf_level[*index_counter] = INTER_NORMAL;
       gf_group->layer_depth[*index_counter] = depth;
       ++(*index_counter);
@@ -2137,6 +2138,7 @@ static void find_arf_order(VP9_COMP *cpi, GF_GROUP *gf_group,
   gf_group->layer_depth[*index_counter] = depth;
   gf_group->update_type[*index_counter] = ARF_UPDATE;
   gf_group->arf_src_offset[*index_counter] = mid - start;
+  gf_group->frame_gop_index[*index_counter] = mid;
   gf_group->rf_level[*index_counter] = GF_ARF_LOW;
 
   for (idx = 0; idx <= mid; ++idx)
@@ -2153,6 +2155,7 @@ static void find_arf_order(VP9_COMP *cpi, GF_GROUP *gf_group,
 
   gf_group->update_type[*index_counter] = USE_BUF_FRAME;
   gf_group->arf_src_offset[*index_counter] = 0;
+  gf_group->frame_gop_index[*index_counter] = mid;
   gf_group->rf_level[*index_counter] = INTER_NORMAL;
   gf_group->layer_depth[*index_counter] = depth;
   ++(*index_counter);
@@ -2203,17 +2206,18 @@ static int define_gf_group_structure(VP9_COMP *cpi) {
     gf_group->layer_depth[frame_index] = 1;
     gf_group->arf_src_offset[frame_index] =
         (unsigned char)(rc->baseline_gf_interval - 1);
+    gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
     ++frame_index;
   }
 
   if (rc->source_alt_ref_pending && cpi->multi_layer_arf) {
-    find_arf_order(cpi, gf_group, &frame_index, 2, 0,
-                   rc->baseline_gf_interval - 1);
+    find_arf_order(cpi, gf_group, &frame_index, 2, 1, rc->baseline_gf_interval);
 
     set_gf_overlay_frame_type(gf_group, frame_index,
                               rc->source_alt_ref_pending);
 
     gf_group->arf_src_offset[frame_index] = 0;
+    gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
 
     return frame_index;
   }
@@ -2227,6 +2231,7 @@ static int define_gf_group_structure(VP9_COMP *cpi) {
     gf_group->update_type[frame_index] = LF_UPDATE;
     gf_group->rf_level[frame_index] = INTER_NORMAL;
     gf_group->arf_src_offset[frame_index] = 0;
+    gf_group->frame_gop_index[frame_index] = i + 1;
     gf_group->layer_depth[frame_index] = MAX_ARF_LAYERS - 1;
 
     ++frame_index;
@@ -2247,6 +2252,7 @@ static int define_gf_group_structure(VP9_COMP *cpi) {
     gf_group->rf_level[frame_index] = GF_ARF_STD;
   }
   gf_group->arf_src_offset[frame_index] = 0;
+  gf_group->frame_gop_index[frame_index] = rc->baseline_gf_interval;
 
   return frame_index;
 }
index 9bd0a9e04a11320a7e7baf9fb44a07c929157295..9d1e9355a47f46f8b224427471234e938893c19d 100644 (file)
@@ -129,6 +129,7 @@ typedef struct {
   FRAME_UPDATE_TYPE update_type[MAX_STATIC_GF_GROUP_LENGTH + 2];
   unsigned char arf_src_offset[MAX_STATIC_GF_GROUP_LENGTH + 2];
   unsigned char layer_depth[MAX_STATIC_GF_GROUP_LENGTH + 2];
+  unsigned char frame_gop_index[MAX_STATIC_GF_GROUP_LENGTH + 2];
   int bit_allocation[MAX_STATIC_GF_GROUP_LENGTH + 2];
   int gfu_boost[MAX_STATIC_GF_GROUP_LENGTH + 2];