diff options
author | Nathan E. Egge <negge@mozilla.com> | 2016-03-06 13:41:53 -0500 |
---|---|---|
committer | Yaowu Xu <yaowu@google.com> | 2016-10-14 14:59:27 -0700 |
commit | 43acafdee2cc90a837dcad2f5e402ae3abe5cb4e (patch) | |
tree | 234b234899cf4a9f8e91dd4abc5cd66026d4f836 /aom_dsp/daalaboolwriter.h | |
parent | 0435f0eae6ec8470a146ceea799a4b770b192895 (diff) |
Use Daala entropy coder to code trees.
When building with --enable-daala_ec, calls to aom_write_tree() and
aom_read_tree() will convert a aom_tree_index structure with associated
aom_prob probabilities into a CDF on the fly for use with the
od_ec_encode_cdf_q15().
The number of symbols in the CDF is capped at 16, and trees that contain
more than 16 leaf nodes are handled by splitting the most likely, e.g.,
highest probability symbols, first and coding multiple symbols if
necessary.
ntt-short-1:
MEDIUM (%) HIGH (%)
PSNR 0.000227 0.000213
PSNRHVS 0.000215 0.000205
SSIM 0.000229 0.000209
FASTSSIM 0.000229 0.000214
subset1:
RATE (%) DSNR (dB)
PSNR -0.00026 0.00002
PSNRHVS -0.00026 0.00002
SSIM -0.00026 0.00001
FASTSSIM -0.00026 0.00001
Change-Id: Icb1a8cb854fd81fdd88fbe4bc6761c7eb4757dfe
Diffstat (limited to 'aom_dsp/daalaboolwriter.h')
-rw-r--r-- | aom_dsp/daalaboolwriter.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/aom_dsp/daalaboolwriter.h b/aom_dsp/daalaboolwriter.h index 250ec62b9..f9102f000 100644 --- a/aom_dsp/daalaboolwriter.h +++ b/aom_dsp/daalaboolwriter.h @@ -13,6 +13,7 @@ #define AOM_DSP_DAALABOOLWRITER_H_ #include "aom_dsp/entenc.h" +#include "aom_dsp/prob.h" #ifdef __cplusplus extern "C" { @@ -38,6 +39,45 @@ static INLINE void aom_daala_write(daala_writer *w, int bit, int prob) { } } +static INLINE void daala_write_tree_bits(daala_writer *w, + const aom_tree_index *tree, + const aom_prob *probs, int bits, + int len, aom_tree_index i) { + aom_tree_index root; + root = i; + do { + uint16_t cdf[16]; + aom_tree_index index[16]; + int path[16]; + int dist[16]; + int nsymbs; + int symb; + int j; + /* Compute the CDF of the binary tree using the given probabilities. */ + nsymbs = tree_to_cdf(tree, probs, root, cdf, index, path, dist); + /* Find the symbol to code. */ + symb = -1; + for (j = 0; j < nsymbs; j++) { + /* If this symbol codes a leaf node, */ + if (index[j] <= 0) { + if (len == dist[j] && path[j] == bits) { + symb = j; + break; + } + } else { + if (len > dist[j] && path[j] == bits >> (len - dist[j])) { + symb = j; + break; + } + } + } + OD_ASSERT(symb != -1); + od_ec_encode_cdf_q15(&w->ec, symb, cdf, nsymbs); + bits &= (1 << (len - dist[symb])) - 1; + len -= dist[symb]; + } while (len); +} + #ifdef __cplusplus } // extern "C" #endif |