Commit 46e84904 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

Use constrained tokenset with --enable-daala_ec.

Change-Id: Ia09edf92bf9f7ecacc65c232ac6e656cde236634
parent d8fdfaa4
...@@ -406,7 +406,7 @@ const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES] = { ...@@ -406,7 +406,7 @@ const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES] = {
{ 255, 246, 247, 255, 239, 255, 253, 255 }, { 255, 246, 247, 255, 239, 255, 253, 255 },
}; };
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
// Model obtained from a 2-sided zero-centered distribution derived // Model obtained from a 2-sided zero-centered distribution derived
// from a Pareto distribution. The cdf of the distribution is: // from a Pareto distribution. The cdf of the distribution is:
// cdf(x) = 0.5 + 0.5 * sgn(x) * [1 - {alpha/(alpha + |x|)} ^ beta] // cdf(x) = 0.5 + 0.5 * sgn(x) * [1 - {alpha/(alpha + |x|)} ^ beta]
...@@ -2803,7 +2803,7 @@ void av1_model_to_full_probs(const aom_prob *model, aom_prob *full) { ...@@ -2803,7 +2803,7 @@ void av1_model_to_full_probs(const aom_prob *model, aom_prob *full) {
extend_to_full_distribution(&full[UNCONSTRAINED_NODES], model[PIVOT_NODE]); extend_to_full_distribution(&full[UNCONSTRAINED_NODES], model[PIVOT_NODE]);
} }
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
static void build_token_cdfs(const aom_prob *pdf_model, static void build_token_cdfs(const aom_prob *pdf_model,
aom_cdf_prob cdf[ENTROPY_TOKENS]) { aom_cdf_prob cdf[ENTROPY_TOKENS]) {
int i, sum = 0; int i, sum = 0;
...@@ -2837,7 +2837,7 @@ void av1_default_coef_probs(AV1_COMMON *cm) { ...@@ -2837,7 +2837,7 @@ void av1_default_coef_probs(AV1_COMMON *cm) {
av1_copy(cm->fc->coef_probs[TX_16X16], default_coef_probs_16x16); av1_copy(cm->fc->coef_probs[TX_16X16], default_coef_probs_16x16);
av1_copy(cm->fc->coef_probs[TX_32X32], default_coef_probs_32x32); av1_copy(cm->fc->coef_probs[TX_32X32], default_coef_probs_32x32);
#endif // CONFIG_ENTROPY #endif // CONFIG_ENTROPY
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
av1_coef_pareto_cdfs(cm->fc); av1_coef_pareto_cdfs(cm->fc);
#endif // CONFIG_RANS #endif // CONFIG_RANS
} }
......
...@@ -190,12 +190,6 @@ static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) { ...@@ -190,12 +190,6 @@ static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) {
#define MODEL_NODES (ENTROPY_NODES - UNCONSTRAINED_NODES) #define MODEL_NODES (ENTROPY_NODES - UNCONSTRAINED_NODES)
extern const aom_tree_index av1_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)]; extern const aom_tree_index av1_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)];
extern const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES]; extern const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES];
#if CONFIG_RANS || CONFIG_DAALA_EC
typedef aom_cdf_prob coeff_cdf_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_TOKENS];
extern const aom_cdf_prob av1_pareto8_token_probs[COEFF_PROB_MODELS]
[ENTROPY_TOKENS - 2];
#endif // CONFIG_RANS
typedef aom_prob av1_coeff_probs_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] typedef aom_prob av1_coeff_probs_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[UNCONSTRAINED_NODES]; [UNCONSTRAINED_NODES];
...@@ -206,6 +200,15 @@ typedef unsigned int av1_coeff_count_model[REF_TYPES][COEF_BANDS] ...@@ -206,6 +200,15 @@ typedef unsigned int av1_coeff_count_model[REF_TYPES][COEF_BANDS]
void av1_model_to_full_probs(const aom_prob *model, aom_prob *full); void av1_model_to_full_probs(const aom_prob *model, aom_prob *full);
#if CONFIG_RANS || CONFIG_DAALA_EC
typedef aom_cdf_prob coeff_cdf_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]
[ENTROPY_TOKENS];
extern const aom_cdf_prob av1_pareto8_token_probs[COEFF_PROB_MODELS]
[ENTROPY_TOKENS - 2];
struct frame_contexts;
void av1_coef_pareto_cdfs(struct frame_contexts *fc);
#endif // CONFIG_RANS
typedef char ENTROPY_CONTEXT; typedef char ENTROPY_CONTEXT;
static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a, static INLINE int combine_entropy_contexts(ENTROPY_CONTEXT a,
......
...@@ -1919,7 +1919,7 @@ static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r) { ...@@ -1919,7 +1919,7 @@ static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r) {
TX_SIZE tx_size; TX_SIZE tx_size;
for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size) for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size)
read_coef_probs_common(fc->coef_probs[tx_size], r); read_coef_probs_common(fc->coef_probs[tx_size], r);
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
av1_coef_pareto_cdfs(fc); av1_coef_pareto_cdfs(fc);
#endif // CONFIG_RANS #endif // CONFIG_RANS
} }
......
...@@ -76,7 +76,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type, ...@@ -76,7 +76,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
const aom_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = const aom_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size_ctx][type][ref]; fc->coef_probs[tx_size_ctx][type][ref];
const aom_prob *prob; const aom_prob *prob;
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
const aom_cdf_prob(*const coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] = const aom_cdf_prob(*const coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
fc->coef_cdfs[tx_size_ctx][type][ref]; fc->coef_cdfs[tx_size_ctx][type][ref];
const aom_cdf_prob(*cdf)[ENTROPY_TOKENS]; const aom_cdf_prob(*cdf)[ENTROPY_TOKENS];
...@@ -169,7 +169,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type, ...@@ -169,7 +169,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
*max_scan_line = AOMMAX(*max_scan_line, scan[c]); *max_scan_line = AOMMAX(*max_scan_line, scan[c]);
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
cdf = &coef_cdfs[band][ctx]; cdf = &coef_cdfs[band][ctx];
token = ONE_TOKEN + token = ONE_TOKEN +
aom_read_symbol(r, *cdf, CATEGORY6_TOKEN - ONE_TOKEN + 1, ACCT_STR); aom_read_symbol(r, *cdf, CATEGORY6_TOKEN - ONE_TOKEN + 1, ACCT_STR);
......
...@@ -703,17 +703,14 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp, ...@@ -703,17 +703,14 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
while (p < stop && p->token != EOSB_TOKEN) { while (p < stop && p->token != EOSB_TOKEN) {
const int token = p->token; const int token = p->token;
aom_tree_index index = 0; aom_tree_index index = 0;
#if !CONFIG_RANS #if !CONFIG_RANS && !CONFIG_DAALA_EC
const struct av1_token *const coef_encoding = &av1_coef_encodings[token]; const struct av1_token *const coef_encoding = &av1_coef_encodings[token];
#if CONFIG_DAALA_EC
int i = 0;
#endif
int coef_value = coef_encoding->value; int coef_value = coef_encoding->value;
int coef_length = coef_encoding->len; int coef_length = coef_encoding->len;
#endif // !CONFIG_RANS #endif // !CONFIG_RANS
const av1_extra_bit *const extra_bits = &extra_bits_table[token]; const av1_extra_bit *const extra_bits = &extra_bits_table[token];
#if CONFIG_RANS #if CONFIG_RANS || CONFIG_DAALA_EC
/* skip one or two nodes */ /* skip one or two nodes */
if (!p->skip_eob_node) aom_write(w, token != EOB_TOKEN, p->context_tree[0]); if (!p->skip_eob_node) aom_write(w, token != EOB_TOKEN, p->context_tree[0]);
...@@ -725,34 +722,6 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp, ...@@ -725,34 +722,6 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
CATEGORY6_TOKEN - ONE_TOKEN + 1); CATEGORY6_TOKEN - ONE_TOKEN + 1);
} }
} }
#else
#if CONFIG_DAALA_EC
/* skip one or two nodes */
if (p->skip_eob_node) {
coef_length -= p->skip_eob_node;
i = 2 * p->skip_eob_node;
}
// TODO(jbb): expanding this can lead to big gains. It allows
// much better branch prediction and would enable us to avoid numerous
// lookups and compares.
// If we have a token that's in the constrained set, the coefficient tree
// is split into two treed writes. The first treed write takes care of the
// unconstrained nodes. The second treed write takes care of the
// constrained nodes.
if (token >= TWO_TOKEN && token < EOB_TOKEN) {
int len = UNCONSTRAINED_NODES - p->skip_eob_node;
int bits = coef_value >> (coef_length - len);
aom_write_tree_bits(w, av1_coef_tree, p->context_tree, bits, len, i);
coef_value &= (1 << (coef_length - len)) - 1;
aom_write_tree(w, av1_coef_con_tree,
av1_pareto8_full[p->context_tree[PIVOT_NODE] - 1],
coef_value, coef_length - len, 0);
} else {
aom_write_tree_bits(w, av1_coef_tree, p->context_tree, coef_value,
coef_length, i);
}
#else #else
/* skip one or two nodes */ /* skip one or two nodes */
if (p->skip_eob_node) if (p->skip_eob_node)
...@@ -774,7 +743,6 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp, ...@@ -774,7 +743,6 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
} }
} }
} }
#endif
#endif // CONFIG_RANS #endif // CONFIG_RANS
if (extra_bits->base_val) { if (extra_bits->base_val) {
......
...@@ -36,9 +36,9 @@ typedef struct { ...@@ -36,9 +36,9 @@ typedef struct {
typedef struct { typedef struct {
const aom_prob *context_tree; const aom_prob *context_tree;
#if CONFIG_ANS || CONFIG_DAALA_EC #if CONFIG_RANS || CONFIG_DAALA_EC
const aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS]; const aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS];
#endif // CONFIG_ANS #endif
EXTRABIT extra; EXTRABIT extra;
uint8_t token; uint8_t token;
uint8_t skip_eob_node; uint8_t skip_eob_node;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment