]> granicus.if.org Git - libvpx/commitdiff
Add API for writing trees using a CDF.
authorNathan E. Egge <negge@mozilla.com>
Mon, 20 Jun 2016 17:44:22 +0000 (13:44 -0400)
committerYaowu Xu <yaowu@google.com>
Fri, 14 Oct 2016 21:59:27 +0000 (14:59 -0700)
Added aom_write_tree_cdf() and aom_read_tree_cdf() function calls to
 bitwriter.h and bitreader.h respectively.
These calls take a multisymbol CDF and an index and directly encode the
 symbol using the enabled entropy coder.
Currently only the daala entropy encoder supports this (enabled with
 --enable-daala_ec) and a compile error is thrown otherwise.

Change-Id: I2fa1e87af4352c94384e0cfdbfd170ac99cf3705

aom_dsp/bitreader.h
aom_dsp/bitwriter.h
aom_dsp/daalaboolreader.h
aom_dsp/daalaboolwriter.h

index 57626e7a52038459893b49aaa1bf5e55d66034fa..1a0cc45abcd14092fc04ff84f6b674d02c245a26 100644 (file)
@@ -26,6 +26,7 @@
 #include "aom_dsp/dkboolreader.h"
 #endif
 #include "aom_dsp/prob.h"
+#include "av1/common/odintrin.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -136,6 +137,19 @@ static INLINE int aom_read_symbol(aom_reader *r, const aom_cdf_prob *cdf,
 #endif
 }
 
+static INLINE int aom_read_tree_cdf(aom_reader *r, const uint16_t *cdf,
+                                    int nsymbs) {
+#if CONFIG_DAALA_EC
+  return daala_read_tree_cdf(r, cdf, nsymbs);
+#else
+  (void)r;
+  (void)cdf;
+  (void)nsymbs;
+  assert(0 && "Unsupported bitreader operation");
+  return -1;
+#endif
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index 86f97a3534d6e06f14ef6c2333030e7e72f43a09..d2569329a309bc05f4dff619073cda68da62a2bd 100644 (file)
@@ -116,6 +116,19 @@ static INLINE void aom_write_symbol(aom_writer *w, int symb,
 #endif
 }
 
+static INLINE void aom_write_tree_cdf(aom_writer *w, int symb,
+                                      const uint16_t *cdf, int nsymbs) {
+#if CONFIG_DAALA_EC
+  daala_write_tree_cdf(w, symb, cdf, nsymbs);
+#else
+  (void)w;
+  (void)symb;
+  (void)cdf;
+  (void)nsymbs;
+  assert(0 && "Unsupported bitwriter operation");
+#endif
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index 3ccea1d00c8096f70b69085a4465cb2a371456dd..f0a7e254270c1df5fbbb21b49a502a6fe6105a34 100644 (file)
@@ -66,6 +66,11 @@ static INLINE int daala_read_tree_bits(daala_reader *r,
   return -i;
 }
 
+static INLINE int daala_read_tree_cdf(daala_reader *r, const uint16_t *cdf,
+                                      int nsymbs) {
+  return od_ec_decode_cdf_q15(&r->ec, cdf, nsymbs, "aom");
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index f9102f000c3c9371a60140b7642081412557e653..c71b12e74952bdc0a27bf2ec058cd60589bd209b 100644 (file)
@@ -78,6 +78,11 @@ static INLINE void daala_write_tree_bits(daala_writer *w,
   } while (len);
 }
 
+static INLINE void daala_write_tree_cdf(daala_writer *w, int symb,
+                                        const uint16_t *cdf, int nsymbs) {
+  od_ec_encode_cdf_q15(&w->ec, symb, cdf, nsymbs);
+}
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif