]> granicus.if.org Git - libvpx/commitdiff
Update switchable_interp_cdf once per frame.
authorNathan E. Egge <negge@mozilla.com>
Tue, 26 Apr 2016 15:37:06 +0000 (11:37 -0400)
committerYaowu Xu <yaowu@google.com>
Mon, 17 Oct 2016 15:44:57 +0000 (08:44 -0700)
Move from computing the switchable_interp_cdf per symbol to
 computing once per frame when the probabilities are adapted.

Change-Id: I6571126239f0327e22bb09ee8bad94114291683e

av1/common/entropymode.c
av1/common/entropymode.h
av1/decoder/decodeframe.c
av1/decoder/decodemv.c
av1/decoder/decoder.c
av1/encoder/bitstream.c

index 84843d8cf76e60e7adc070c921a6919dbd4a3d97..a6965338d0adaf2769b150f125b548bf468cba1a 100644 (file)
@@ -1380,8 +1380,17 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
 #if CONFIG_LOOP_RESTORATION
   av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
 #endif  // CONFIG_LOOP_RESTORATION
+#if CONFIG_DAALA_EC
+  av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
+                     fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
+#endif
 }
 
+#if CONFIG_DAALA_EC
+int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
+int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
+#endif
+
 #if CONFIG_EXT_INTERP
 const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
     {
index 1caf31904d76ba94ca0a035fa7f971804cb250e8..262a2a111c37316a8812615ed4e54cc87040d672 100644 (file)
@@ -131,6 +131,10 @@ typedef struct frame_contexts {
 #if CONFIG_LOOP_RESTORATION
   aom_prob switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1];
 #endif  // CONFIG_LOOP_RESTORATION
+#if CONFIG_DAALA_EC
+  uint16_t switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
+                                [SWITCHABLE_FILTERS];
+#endif
 } FRAME_CONTEXT;
 
 typedef struct FRAME_COUNTS {
@@ -278,6 +282,10 @@ extern const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)];
 extern const aom_tree_index
     av1_switchable_restore_tree[TREE_SIZE(RESTORE_SWITCHABLE_TYPES)];
 #endif  // CONFIG_LOOP_RESTORATION
+#if CONFIG_DAALA_EC
+extern int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
+extern int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
+#endif
 
 void av1_setup_past_independence(struct AV1Common *cm);
 
index 000757f07ecb4c7917170a518ffc5ff66852fa1e..49954ce49083808b9dc0dae5c8e5525255e00790 100644 (file)
@@ -107,9 +107,14 @@ static TX_MODE read_tx_mode(struct aom_read_bit_buffer *rb) {
 
 static void read_switchable_interp_probs(FRAME_CONTEXT *fc, aom_reader *r) {
   int i, j;
-  for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
+  for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
     for (i = 0; i < SWITCHABLE_FILTERS - 1; ++i)
       av1_diff_update_prob(r, &fc->switchable_interp_prob[j][i]);
+#if CONFIG_DAALA_EC
+    av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
+                    fc->switchable_interp_cdf[j]);
+#endif
+  }
 }
 
 static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
index 3ede7e062f168561ef8f612448e48846b593913b..ef9596c4ee044ce9ccdaa58ed92a25e7ca9a5303 100644 (file)
@@ -867,8 +867,14 @@ static INLINE InterpFilter read_interp_filter(AV1_COMMON *const cm,
     const int ctx = av1_get_pred_context_switchable_interp(xd);
 #endif
     FRAME_COUNTS *counts = xd->counts;
+#if CONFIG_DAALA_EC
+    const InterpFilter type =
+        (InterpFilter)av1_switchable_interp_inv[aom_read_tree_cdf(
+            r, cm->fc->switchable_interp_cdf[ctx], SWITCHABLE_FILTERS)];
+#else
     const InterpFilter type = (InterpFilter)aom_read_tree(
         r, av1_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx]);
+#endif
     if (counts) ++counts->switchable_interp[ctx][type];
     return type;
   }
index e6c8f9043880c986adf6fb9347bc68221f3bc1ae..6882d82d39d4858773642a409b0062a5492a7373 100644 (file)
@@ -47,6 +47,10 @@ static void initialize_dec(void) {
     av1_init_wedge_masks();
 #endif  // CONFIG_EXT_INTER
     init_done = 1;
+#if CONFIG_DAALA_EC
+    av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
+                          SWITCHABLE_FILTERS, av1_switchable_interp_tree);
+#endif
   }
 }
 
index e31fa6757029f8ec9e4e61301e917ff8b798b1fc..22268a872f6d5d210adbc22c02a18e13fdc31aba 100644 (file)
@@ -189,6 +189,14 @@ void av1_encode_token_init(void) {
   av1_tokens_from_tree(switchable_restore_encodings,
                        av1_switchable_restore_tree);
 #endif  // CONFIG_LOOP_RESTORATION
+
+#if CONFIG_DAALA_EC
+  /* This hack is necessary when CONFIG_EXT_INTERP is enabled because the five
+      SWITCHABLE_FILTERS are not consecutive, e.g., 0, 1, 2, 3, 4, when doing
+      an in-order traversal of the av1_switchable_interp_tree structure. */
+  av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
+                        SWITCHABLE_FILTERS, av1_switchable_interp_tree);
+#endif
 }
 
 static void write_intra_mode(aom_writer *w, PREDICTION_MODE mode,
@@ -486,10 +494,16 @@ static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
 static void update_switchable_interp_probs(AV1_COMMON *cm, aom_writer *w,
                                            FRAME_COUNTS *counts) {
   int j;
-  for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
+  for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
     prob_diff_update(av1_switchable_interp_tree,
                      cm->fc->switchable_interp_prob[j],
                      counts->switchable_interp[j], SWITCHABLE_FILTERS, w);
+#if CONFIG_DAALA_EC
+    av1_tree_to_cdf(av1_switchable_interp_tree,
+                    cm->fc->switchable_interp_prob[j],
+                    cm->fc->switchable_interp_cdf[j]);
+#endif
+  }
 }
 
 #if CONFIG_EXT_TX
@@ -963,9 +977,15 @@ static void write_switchable_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
 #else
     {
       const int ctx = av1_get_pred_context_switchable_interp(xd);
+#if CONFIG_DAALA_EC
+      aom_write_tree_cdf(w, av1_switchable_interp_ind[mbmi->interp_filter],
+                         cm->fc->switchable_interp_cdf[ctx],
+                         SWITCHABLE_FILTERS);
+#else
       av1_write_token(w, av1_switchable_interp_tree,
                       cm->fc->switchable_interp_prob[ctx],
                       &switchable_interp_encodings[mbmi->interp_filter]);
+#endif
       ++cpi->interp_filter_selected[0][mbmi->interp_filter];
     }
 #endif