Commit e1466ad4 authored by Yaowu Xu's avatar Yaowu Xu

Fix encoder crash when --enable-daala-ec

Change-Id: I6855e18d92f693a9789eda7c91a3430566469bdd
parent 3c056790
...@@ -694,6 +694,9 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp, ...@@ -694,6 +694,9 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
aom_tree_index index = 0; aom_tree_index index = 0;
#if !CONFIG_RANS #if !CONFIG_RANS
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
...@@ -720,6 +723,34 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp, ...@@ -720,6 +723,34 @@ 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)
...@@ -741,6 +772,7 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp, ...@@ -741,6 +772,7 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
} }
} }
} }
#endif
#endif // CONFIG_RANS #endif // CONFIG_RANS
if (extra_bits_av1->base_val) { if (extra_bits_av1->base_val) {
......
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