shithub: libvpx

Download patch

ref: 0d7a05ae0bda703fd00e2580f86966a9efe0a1cc
parent: ee8920732d1b1446799c5cb9195cfcb2df1fefe8
author: Jingning Han <jingning@google.com>
date: Tue Nov 6 11:35:44 EST 2018

Unify GOP structure layout setup

Refactor define_gf_group_structure() to unify the single-layer,
multi-layer ARF, and GF only GOP structure setup.

Change-Id: Iebbe9c3742fc58ae4e77b1072ebecb3ee7bd26b2

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2181,10 +2181,9 @@
   RATE_CONTROL *const rc = &cpi->rc;
   TWO_PASS *const twopass = &cpi->twopass;
   GF_GROUP *const gf_group = &twopass->gf_group;
-  int i;
   int frame_index = 0;
   int key_frame;
-  int normal_frames;
+  int layer_depth = 1;
 
   key_frame = cpi->common.frame_type == KEY_FRAME;
 
@@ -2191,6 +2190,7 @@
   gf_group->frame_start = cpi->common.current_video_frame;
   gf_group->frame_end = gf_group->frame_start + rc->baseline_gf_interval;
   gf_group->max_layer_depth = 0;
+  gf_group->allowed_max_layer_depth = 0;
 
   // For key frames the frame target rate is already set and it
   // is also the golden frame.
@@ -2204,51 +2204,24 @@
   if (rc->source_alt_ref_pending) {
     gf_group->update_type[frame_index] = ARF_UPDATE;
     gf_group->rf_level[frame_index] = GF_ARF_STD;
-    gf_group->layer_depth[frame_index] = 1;
+    gf_group->layer_depth[frame_index] = layer_depth;
     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;
     gf_group->max_layer_depth = 1;
     ++frame_index;
-  }
-
-  if (rc->source_alt_ref_pending && cpi->multi_layer_arf) {
+    ++layer_depth;
     gf_group->allowed_max_layer_depth = cpi->oxcf.enable_auto_arf;
-    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;
-
-    gf_group->gf_group_size = frame_index;
-    return;
   }
 
-  normal_frames =
-      rc->baseline_gf_interval - (key_frame || rc->source_alt_ref_pending);
+  find_arf_order(cpi, gf_group, &frame_index, layer_depth, 1,
+                 rc->baseline_gf_interval);
 
-  for (i = 0; i < normal_frames; ++i) {
-    if (twopass->stats_in >= twopass->stats_in_end) break;
-
-    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;
-  }
-
-  // Note:
-  // We need to configure the frame at the end of the sequence + 1 that will be
-  // the start frame for the next group. Otherwise prior to the call to
-  // vp9_rc_get_second_pass_params() the data will be undefined.
   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;
 
+  // Set the frame ops number.
   gf_group->gf_group_size = frame_index;
 }