shithub: libvpx

Download patch

ref: bd775bfda96d8a3675859bda13cb860079b4daf4
parent: bb9511684f70a735b3b909712666021e178c93e7
author: Deepa K G <deepa.kg@ittiam.com>
date: Mon Jun 24 08:34:28 EDT 2019

Modify frame context index

Used separate frame contexts for non-boosted frames.
Adjusted the frame context index grouping for boosted
frames.

Change-Id: I7f6f83f53d46f66a83a6806c2b568bd833ce940d

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -822,8 +822,28 @@
   // layer ARF case as well.
   if (cpi->multi_layer_arf && !cpi->use_svc) {
     GF_GROUP *const gf_group = &cpi->twopass.gf_group;
-    cm->frame_context_idx = clamp(gf_group->layer_depth[gf_group->index] - 1, 0,
-                                  FRAME_CONTEXTS - 1);
+    const int gf_group_index = gf_group->index;
+    const int boost_frame =
+        !cpi->rc.is_src_frame_alt_ref &&
+        (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame);
+
+    // frame_context_idx           Frame Type
+    //        0              Intra only frame, base layer ARF
+    //        1              ARFs with layer depth = 2,3
+    //        2              ARFs with layer depth > 3
+    //        3              Non-boosted frames
+    if (frame_is_intra_only(cm)) {
+      cm->frame_context_idx = 0;
+    } else if (boost_frame) {
+      if (gf_group->rf_level[gf_group_index] == GF_ARF_STD)
+        cm->frame_context_idx = 0;
+      else if (gf_group->layer_depth[gf_group_index] <= 3)
+        cm->frame_context_idx = 1;
+      else
+        cm->frame_context_idx = 2;
+    } else {
+      cm->frame_context_idx = 3;
+    }
   }
 
   if (cm->frame_type == KEY_FRAME) {