From 667551d3d9e51cee457348ca2697a5fb8adbc84c Mon Sep 17 00:00:00 2001 From: "Nathan E. Egge" Date: Mon, 20 Jun 2016 13:44:22 -0400 Subject: [PATCH] Add API for writing trees using a CDF. 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 | 14 ++++++++++++++ aom_dsp/bitwriter.h | 14 ++++++++++++++ aom_dsp/daalaboolreader.h | 5 +++++ aom_dsp/daalaboolwriter.h | 5 +++++ 4 files changed, 38 insertions(+) diff --git a/aom_dsp/bitreader.h b/aom_dsp/bitreader.h index 74d529c5e..0b7930fdd 100644 --- a/aom_dsp/bitreader.h +++ b/aom_dsp/bitreader.h @@ -24,6 +24,7 @@ #include "aom_dsp/dkboolreader.h" #endif #include "aom_dsp/prob.h" +#include "av1/common/odintrin.h" #ifdef __cplusplus extern "C" { @@ -101,6 +102,19 @@ static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree, #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 diff --git a/aom_dsp/bitwriter.h b/aom_dsp/bitwriter.h index e650c97e6..da17f9cc5 100644 --- a/aom_dsp/bitwriter.h +++ b/aom_dsp/bitwriter.h @@ -12,6 +12,7 @@ #ifndef AOM_DSP_BITWRITER_H_ #define AOM_DSP_BITWRITER_H_ +#include #include "./aom_config.h" #if CONFIG_DAALA_EC #include "aom_dsp/daalaboolwriter.h" @@ -84,6 +85,19 @@ static INLINE void aom_write_tree(aom_writer *w, const aom_tree_index *tree, #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 diff --git a/aom_dsp/daalaboolreader.h b/aom_dsp/daalaboolreader.h index 3ccea1d00..f0a7e2542 100644 --- a/aom_dsp/daalaboolreader.h +++ b/aom_dsp/daalaboolreader.h @@ -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 diff --git a/aom_dsp/daalaboolwriter.h b/aom_dsp/daalaboolwriter.h index f9102f000..c71b12e74 100644 --- a/aom_dsp/daalaboolwriter.h +++ b/aom_dsp/daalaboolwriter.h @@ -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