shithub: libvpx

Download patch

ref: 69a4ed0dd448ba51c6b23240594a3fb71f0e8d0e
parent: ca97594a8adbbc3d4e3be835d96e16945fd09bee
parent: 4d3275f865488bb6dc4c7a25e12cc6efa358ef7b
author: Jingning Han <jingning@google.com>
date: Mon Oct 15 23:49:52 EDT 2018

Merge "Add frame_gop_index to GF_GROUP"

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5416,8 +5416,9 @@
 
   // 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;
 
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2124,6 +2124,7 @@
     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 @@
   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 @@
 
   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 @@
     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 @@
     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 @@
     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;
 }
--- a/vp9/encoder/vp9_firstpass.h
+++ b/vp9/encoder/vp9_firstpass.h
@@ -129,6 +129,7 @@
   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];