shithub: libvpx

Download patch

ref: e407b1a616aaec55f0dd2957e23026b0375b5d64
parent: 6bc958713f8bc114157ae29c733548a22976e8c0
parent: 740083a97bb3ef0a11e45977611402a047099cfb
author: Jingning Han <jingning@google.com>
date: Tue Sep 11 00:04:14 EDT 2018

Merge "Separate frame context index for GOP layers"

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -780,6 +780,7 @@
 
 static void setup_frame(VP9_COMP *cpi) {
   VP9_COMMON *const cm = &cpi->common;
+  GF_GROUP *const gf_group = &cpi->twopass.gf_group;
   // Set up entropy context depending on frame type. The decoder mandates
   // the use of the default context, index 0, for keyframes and inter
   // frames where the error_resilient_mode or intra_only flag is set. For
@@ -790,6 +791,13 @@
   } else {
     if (!cpi->use_svc) cm->frame_context_idx = cpi->refresh_alt_ref_frame;
   }
+
+  // TODO(jingning): Overwrite the frame_context_idx index in multi-layer ARF
+  // case. Need some further investigation on if we could apply this to single
+  // layer ARF case as well.
+  if (cpi->multi_layer_arf && !cpi->use_svc)
+    cm->frame_context_idx = clamp(gf_group->layer_depth[gf_group->index] - 1, 0,
+                                  FRAME_CONTEXTS - 1);
 
   if (cm->frame_type == KEY_FRAME) {
     cpi->refresh_golden_frame = 1;
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2413,6 +2413,7 @@
     }
     gf_group->arf_update_idx[frame_index] = arf_buffer_indices[0];
     gf_group->arf_ref_idx[frame_index] = arf_buffer_indices[0];
+    gf_group->layer_depth[frame_index] = MAX_ARF_LAYERS - 1;
   }
 
   ++frame_index;