Commit ba72ccde authored by Alex Converse's avatar Alex Converse

Refactor extrabits packing

- Eliminate the awkward _av1 suffix/infix in local variable names.
- Lift bitdepth selection out of the token loop.

Change-Id: I26d3397464f7808e0481a804033a93ca4f01f5d5
parent 21f7e0dc
......@@ -324,6 +324,15 @@ static void pack_mb_tokens(aom_writer *w, TOKENEXTRA **tp,
const TOKENEXTRA *const stop,
aom_bit_depth_t bit_depth, const TX_SIZE tx) {
TOKENEXTRA *p = *tp;
#if CONFIG_AOM_HIGHBITDEPTH
const av1_extra_bit *const extra_bits_table =
(bit_depth == AOM_BITS_12)
? av1_extra_bits_high12
: (bit_depth == AOM_BITS_10) ? av1_extra_bits_high10 : av1_extra_bits;
#else
const av1_extra_bit *const extra_bits_table = av1_extra_bits;
(void)bit_depth;
#endif // CONFIG_AOM_HIGHBITDEPTH
#if !CONFIG_MISC_FIXES
(void)tx;
#endif
......@@ -336,16 +345,7 @@ static void pack_mb_tokens(aom_writer *w, TOKENEXTRA **tp,
int coef_value = coef_encoding->value;
int coef_length = coef_encoding->len;
#endif // !CONFIG_RANS
#if CONFIG_AOM_HIGHBITDEPTH
const av1_extra_bit *const extra_bits_av1 =
(bit_depth == AOM_BITS_12)
? &av1_extra_bits_high12[token]
: (bit_depth == AOM_BITS_10) ? &av1_extra_bits_high10[token]
: &av1_extra_bits[token];
#else
const av1_extra_bit *const extra_bits_av1 = &av1_extra_bits[token];
(void)bit_depth;
#endif // CONFIG_AOM_HIGHBITDEPTH
const av1_extra_bit *const extra_bits = &extra_bits_table[token];
#if CONFIG_RANS
if (!p->skip_eob_node) aom_write(w, token != EOB_TOKEN, p->context_tree[0]);
......@@ -390,20 +390,22 @@ static void pack_mb_tokens(aom_writer *w, TOKENEXTRA **tp,
}
#endif // CONFIG_RANS
if (extra_bits_av1->base_val) {
const int extra_bits = p->extra;
const int extra_bits_av1_length = extra_bits_av1->len;
if (extra_bits->base_val) {
const int bit_string = p->extra;
const int bit_string_length = extra_bits->len; // Length of extra bits to
// be written excluding
// the sign bit.
#if CONFIG_MISC_FIXES
int skip_bits =
(extra_bits_av1->base_val == CAT6_MIN_VAL) ? TX_SIZES - 1 - tx : 0;
(extra_bits->base_val == CAT6_MIN_VAL) ? TX_SIZES - 1 - tx : 0;
#else
int skip_bits = 0;
#endif
if (extra_bits_av1_length > 0) {
const unsigned char *pb = extra_bits_av1->prob;
const int value = extra_bits >> 1;
const int num_bits = extra_bits_av1_length; // number of bits in value
if (bit_string_length > 0) {
const unsigned char *pb = extra_bits->prob;
const int value = bit_string >> 1;
const int num_bits = bit_string_length; // number of bits in value
assert(num_bits > 0);
for (index = 0; index < num_bits; ++index) {
......@@ -418,7 +420,7 @@ static void pack_mb_tokens(aom_writer *w, TOKENEXTRA **tp,
}
}
aom_write_bit(w, extra_bits & 1);
aom_write_bit(w, bit_string & 1);
}
++p;
}
......
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