]> granicus.if.org Git - libvpx/commitdiff
Update class0_fp_cdf and fp_cdf tables once per frame.
authorNathan E. Egge <negge@mozilla.com>
Thu, 8 Sep 2016 19:59:53 +0000 (15:59 -0400)
committerYaowu Xu <yaowu@google.com>
Fri, 21 Oct 2016 22:56:41 +0000 (22:56 +0000)
Move computing the class0_fp_cdf and fp_cdf tables per coded mv
 symbol to computing it only when the probabilities are updated.

Change-Id: Ib4957c8ab21e6189bcc3817a07b7681dfb343223

av1/common/entropymv.c
av1/common/entropymv.h
av1/decoder/decodeframe.c
av1/decoder/decodemv.c
av1/encoder/encodemv.c

index b96cc3157a69b30d2848c056e14a47b7da61accc..dfe798e1e6ee78bbce6d2f60613b5c35e5db16a0 100644 (file)
@@ -57,6 +57,10 @@ static const nmv_context default_nmv_context = {
         { 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 },  // bits
         { { 128, 128, 64 }, { 96, 112, 64 } },                 // class0_fp
         { 64, 96, 64 },                                        // fp
+#if CONFIG_DAALA_EC
+        { { 0 }, { 0 } },  // class0_fp_cdf is computed in av1_init_mv_probs()
+        { 0 },             // fp_cdf is computed from fp in av1_init_mv_probs()
+#endif
         160,                                                   // class0_hp bit
         128,                                                   // hp
     },
@@ -71,6 +75,10 @@ static const nmv_context default_nmv_context = {
         { 136, 140, 148, 160, 176, 192, 224, 234, 234, 240 },  // bits
         { { 128, 128, 64 }, { 96, 112, 64 } },                 // class0_fp
         { 64, 96, 64 },                                        // fp
+#if CONFIG_DAALA_EC
+        { { 0 }, { 0 } },  // class0_fp_cdf is computed in av1_init_mv_probs()
+        { 0 },             // fp_cdf is computed from fp in av1_init_mv_probs()
+#endif
         160,                                                   // class0_hp bit
         128,                                                   // hp
     } },
@@ -272,12 +280,21 @@ void av1_init_mv_probs(AV1_COMMON *cm) {
 #else
   cm->fc->nmvc = default_nmv_context;
 #if CONFIG_DAALA_EC
-  av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints,
-                  cm->fc->nmvc.joint_cdf);
-  av1_tree_to_cdf(av1_mv_class_tree, cm->fc->nmvc.comps[0].classes,
-                  cm->fc->nmvc.comps[0].class_cdf);
-  av1_tree_to_cdf(av1_mv_class_tree, cm->fc->nmvc.comps[1].classes,
-                  cm->fc->nmvc.comps[1].class_cdf);
+  {
+    int i, j;
+    av1_tree_to_cdf(av1_mv_joint_tree, cm->fc->nmvc.joints,
+                    cm->fc->nmvc.joint_cdf);
+    for (i = 0; i < 2; i++) {
+      av1_tree_to_cdf(av1_mv_class_tree, cm->fc->nmvc.comps[i].classes,
+                      cm->fc->nmvc.comps[i].class_cdf);
+      av1_tree_to_cdf(av1_mv_fp_tree, cm->fc->nmvc.comps[i].fp,
+                      cm->fc->nmvc.comps[i].fp_cdf);
+      for (j = 0; j < CLASS0_SIZE; j++) {
+        av1_tree_to_cdf(av1_mv_fp_tree, cm->fc->nmvc.comps[i].class0_fp[j],
+                        cm->fc->nmvc.comps[i].class0_fp_cdf[j]);
+      }
+    }
+  }
 #endif
 #endif
 #if CONFIG_GLOBAL_MOTION
index c68e6349d9250f5290844225e87dd5d3b8768d9d..f308ef3e96ed425b5e68b74b1f3de90bf3c239c7 100644 (file)
@@ -92,6 +92,10 @@ typedef struct {
   aom_prob bits[MV_OFFSET_BITS];
   aom_prob class0_fp[CLASS0_SIZE][MV_FP_SIZE - 1];
   aom_prob fp[MV_FP_SIZE - 1];
+#if CONFIG_DAALA_EC
+  aom_cdf_prob class0_fp_cdf[CLASS0_SIZE][MV_FP_SIZE];
+  aom_cdf_prob fp_cdf[MV_FP_SIZE];
+#endif
   aom_prob class0_hp;
   aom_prob hp;
 } nmv_component;
index 4e0398f7d00e49f5afc1af0f516820a6bac0c438..1c453cdd6ab4a9dfd8c8839f09760533777bb380 100644 (file)
@@ -226,9 +226,17 @@ static void read_mv_probs(nmv_context *ctx, int allow_hp, aom_reader *r) {
 
   for (i = 0; i < 2; ++i) {
     nmv_component *const comp_ctx = &ctx->comps[i];
-    for (j = 0; j < CLASS0_SIZE; ++j)
+    for (j = 0; j < CLASS0_SIZE; ++j) {
       update_mv_probs(comp_ctx->class0_fp[j], MV_FP_SIZE - 1, r);
+#if CONFIG_DAALA_EC
+      av1_tree_to_cdf(av1_mv_fp_tree, comp_ctx->class0_fp[j],
+                      comp_ctx->class0_fp_cdf[j]);
+#endif
+    }
     update_mv_probs(comp_ctx->fp, MV_FP_SIZE - 1, r);
+#if CONFIG_DAALA_EC
+    av1_tree_to_cdf(av1_mv_fp_tree, comp_ctx->fp, comp_ctx->fp_cdf);
+#endif
   }
 
   if (allow_hp) {
index 692dc73b9411ba791652a3ad021cf4f6ea2e5d03..07c745da6977a874df316477fc7b1672f3d39e7e 100644 (file)
@@ -804,9 +804,14 @@ static int read_mv_component(aom_reader *r, const nmv_component *mvcomp,
     mag = CLASS0_SIZE << (mv_class + 2);
   }
 
-  // Fractional part
+// Fractional part
+#if CONFIG_DAALA_EC
+  fr = aom_read_symbol(r, class0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
+                       MV_FP_SIZE, ACCT_STR);
+#else
   fr = aom_read_tree(r, av1_mv_fp_tree,
                      class0 ? mvcomp->class0_fp[d] : mvcomp->fp, ACCT_STR);
+#endif
 
   // High precision part (if hp is not used, the default value of the hp is 1)
   hp = usehp ? aom_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp, ACCT_STR)
index 7e5179c7b310715d3a018223b4315c84a8a4e699..53dac124cbdd328aeb6acd81e6dce75e9dc99061 100644 (file)
@@ -62,10 +62,16 @@ static void encode_mv_component(aom_writer *w, int comp,
     for (i = 0; i < n; ++i) aom_write(w, (d >> i) & 1, mvcomp->bits[i]);
   }
 
-  // Fractional bits
+// Fractional bits
+#if CONFIG_DAALA_EC
+  aom_write_symbol(
+      w, fr, mv_class == MV_CLASS_0 ? mvcomp->class0_fp_cdf[d] : mvcomp->fp_cdf,
+      MV_FP_SIZE);
+#else
   av1_write_token(w, av1_mv_fp_tree,
                   mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp,
                   &mv_fp_encodings[fr]);
+#endif
 
   // High precision bit
   if (usehp)
@@ -217,12 +223,19 @@ void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
   }
 
   for (i = 0; i < 2; ++i) {
-    for (j = 0; j < CLASS0_SIZE; ++j)
+    for (j = 0; j < CLASS0_SIZE; ++j) {
       write_mv_update(av1_mv_fp_tree, mvc->comps[i].class0_fp[j],
                       counts->comps[i].class0_fp[j], MV_FP_SIZE, w);
-
+#if CONFIG_DAALA_EC
+      av1_tree_to_cdf(av1_mv_fp_tree, mvc->comps[i].class0_fp[j],
+                      mvc->comps[i].class0_fp_cdf[j]);
+#endif
+    }
     write_mv_update(av1_mv_fp_tree, mvc->comps[i].fp, counts->comps[i].fp,
                     MV_FP_SIZE, w);
+#if CONFIG_DAALA_EC
+    av1_tree_to_cdf(av1_mv_fp_tree, mvc->comps[i].fp, mvc->comps[i].fp_cdf);
+#endif
   }
 
   if (usehp) {