Commit e063e2dd authored by Alex Converse's avatar Alex Converse

highbitdepth: deduplicate extrabits

Change-Id: Ib1777433c10e3b64f939c533c12a89dfc839bc6a
parent 74a77546
......@@ -37,26 +37,10 @@ const aom_prob av1_cat2_prob[] = { 165, 145 };
const aom_prob av1_cat3_prob[] = { 173, 148, 140 };
const aom_prob av1_cat4_prob[] = { 176, 155, 140, 135 };
const aom_prob av1_cat5_prob[] = { 180, 157, 141, 134, 130 };
const aom_prob av1_cat6_prob[] = { 254, 254, 254, 252, 249, 243, 230,
196, 177, 153, 140, 133, 130, 129 };
#if CONFIG_AOM_HIGHBITDEPTH
const aom_prob av1_cat1_prob_high10[] = { 159 };
const aom_prob av1_cat2_prob_high10[] = { 165, 145 };
const aom_prob av1_cat3_prob_high10[] = { 173, 148, 140 };
const aom_prob av1_cat4_prob_high10[] = { 176, 155, 140, 135 };
const aom_prob av1_cat5_prob_high10[] = { 180, 157, 141, 134, 130 };
const aom_prob av1_cat6_prob_high10[] = {
255, 255, 254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
const aom_prob av1_cat6_prob[] = {
255, 255, 255, 255, 254, 254, 254, 252, 249,
243, 230, 196, 177, 153, 140, 133, 130, 129
};
const aom_prob av1_cat1_prob_high12[] = { 159 };
const aom_prob av1_cat2_prob_high12[] = { 165, 145 };
const aom_prob av1_cat3_prob_high12[] = { 173, 148, 140 };
const aom_prob av1_cat4_prob_high12[] = { 176, 155, 140, 135 };
const aom_prob av1_cat5_prob_high12[] = { 180, 157, 141, 134, 130 };
const aom_prob av1_cat6_prob_high12[] = { 255, 255, 255, 255, 254, 254,
254, 252, 249, 243, 230, 196,
177, 153, 140, 133, 130, 129 };
#endif
const uint16_t band_count_table[TX_SIZES_ALL][8] = {
#if CONFIG_CB4X4
......
......@@ -97,22 +97,7 @@ DECLARE_ALIGNED(16, extern const uint8_t, av1_cat2_prob[2]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat3_prob[3]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat4_prob[4]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat5_prob[5]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat6_prob[14]);
#if CONFIG_AOM_HIGHBITDEPTH
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat1_prob_high10[1]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat2_prob_high10[2]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat3_prob_high10[3]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat4_prob_high10[4]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat5_prob_high10[5]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat6_prob_high10[16]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat1_prob_high12[1]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat2_prob_high12[2]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat3_prob_high12[3]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat4_prob_high12[4]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat5_prob_high12[5]);
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat6_prob_high12[18]);
#endif // CONFIG_AOM_HIGHBITDEPTH
DECLARE_ALIGNED(16, extern const uint8_t, av1_cat6_prob[18]);
#define EOB_MODEL_TOKEN 3
......@@ -125,10 +110,6 @@ typedef struct {
// indexed by token value
extern const av1_extra_bit av1_extra_bits[ENTROPY_TOKENS];
#if CONFIG_AOM_HIGHBITDEPTH
extern const av1_extra_bit av1_extra_bits_high10[ENTROPY_TOKENS];
extern const av1_extra_bit av1_extra_bits_high12[ENTROPY_TOKENS];
#endif // CONFIG_AOM_HIGHBITDEPTH
#define DCT_MAX_VALUE 16384
#if CONFIG_AOM_HIGHBITDEPTH
......
......@@ -108,12 +108,6 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
#if CONFIG_NEW_QUANT
const tran_low_t *dqv_val = &dq_val[0][0];
#endif // CONFIG_NEW_QUANT
const uint8_t *cat1_prob;
const uint8_t *cat2_prob;
const uint8_t *cat3_prob;
const uint8_t *cat4_prob;
const uint8_t *cat5_prob;
const uint8_t *cat6_prob;
(void)tx_type;
#if CONFIG_AOM_QM
(void)iqmatrix;
......@@ -127,40 +121,6 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
#endif
}
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->bd > AOM_BITS_8) {
if (xd->bd == AOM_BITS_10) {
cat1_prob = av1_cat1_prob_high10;
cat2_prob = av1_cat2_prob_high10;
cat3_prob = av1_cat3_prob_high10;
cat4_prob = av1_cat4_prob_high10;
cat5_prob = av1_cat5_prob_high10;
cat6_prob = av1_cat6_prob_high10;
} else {
cat1_prob = av1_cat1_prob_high12;
cat2_prob = av1_cat2_prob_high12;
cat3_prob = av1_cat3_prob_high12;
cat4_prob = av1_cat4_prob_high12;
cat5_prob = av1_cat5_prob_high12;
cat6_prob = av1_cat6_prob_high12;
}
} else {
cat1_prob = av1_cat1_prob;
cat2_prob = av1_cat2_prob;
cat3_prob = av1_cat3_prob;
cat4_prob = av1_cat4_prob;
cat5_prob = av1_cat5_prob;
cat6_prob = av1_cat6_prob;
}
#else
cat1_prob = av1_cat1_prob;
cat2_prob = av1_cat2_prob;
cat3_prob = av1_cat3_prob;
cat4_prob = av1_cat4_prob;
cat5_prob = av1_cat5_prob;
cat6_prob = av1_cat6_prob;
#endif
dq_shift = get_tx_scale(tx_size);
#if CONFIG_NEW_TOKENSET
......@@ -218,39 +178,30 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
case THREE_TOKEN:
case FOUR_TOKEN: val = token; break;
case CATEGORY1_TOKEN:
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
val = CAT1_MIN_VAL + read_coeff(av1_cat1_prob, 1, r);
break;
case CATEGORY2_TOKEN:
val = CAT2_MIN_VAL + read_coeff(cat2_prob, 2, r);
val = CAT2_MIN_VAL + read_coeff(av1_cat2_prob, 2, r);
break;
case CATEGORY3_TOKEN:
val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, r);
val = CAT3_MIN_VAL + read_coeff(av1_cat3_prob, 3, r);
break;
case CATEGORY4_TOKEN:
val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, r);
val = CAT4_MIN_VAL + read_coeff(av1_cat4_prob, 4, r);
break;
case CATEGORY5_TOKEN:
val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, r);
val = CAT5_MIN_VAL + read_coeff(av1_cat5_prob, 5, r);
break;
case CATEGORY6_TOKEN: {
const int skip_bits = TX_SIZES - 1 - txsize_sqr_up_map[tx_size];
const uint8_t *cat6p = cat6_prob + skip_bits;
#if CONFIG_AOM_HIGHBITDEPTH
switch (xd->bd) {
case AOM_BITS_8:
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
break;
case AOM_BITS_10:
val = CAT6_MIN_VAL + read_coeff(cat6p, 16 - skip_bits, r);
break;
case AOM_BITS_12:
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
break;
default: assert(0); return -1;
}
const int skip_bits =
TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - xd->bd);
#else
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
const int skip_bits =
TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - 8);
#endif
val = CAT6_MIN_VAL +
read_coeff(av1_cat6_prob + skip_bits, 18 - skip_bits, r);
} break;
}
......@@ -325,39 +276,30 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
case THREE_TOKEN:
case FOUR_TOKEN: val = token; break;
case CATEGORY1_TOKEN:
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
val = CAT1_MIN_VAL + read_coeff(av1_cat1_prob, 1, r);
break;
case CATEGORY2_TOKEN:
val = CAT2_MIN_VAL + read_coeff(cat2_prob, 2, r);
val = CAT2_MIN_VAL + read_coeff(av1_cat2_prob, 2, r);
break;
case CATEGORY3_TOKEN:
val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, r);
val = CAT3_MIN_VAL + read_coeff(av1_cat3_prob, 3, r);
break;
case CATEGORY4_TOKEN:
val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, r);
val = CAT4_MIN_VAL + read_coeff(av1_cat4_prob, 4, r);
break;
case CATEGORY5_TOKEN:
val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, r);
val = CAT5_MIN_VAL + read_coeff(av1_cat5_prob, 5, r);
break;
case CATEGORY6_TOKEN: {
const int skip_bits = TX_SIZES - 1 - txsize_sqr_up_map[tx_size];
const uint8_t *cat6p = cat6_prob + skip_bits;
#if CONFIG_AOM_HIGHBITDEPTH
switch (xd->bd) {
case AOM_BITS_8:
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
break;
case AOM_BITS_10:
val = CAT6_MIN_VAL + read_coeff(cat6p, 16 - skip_bits, r);
break;
case AOM_BITS_12:
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
break;
default: assert(0); return -1;
}
const int skip_bits =
TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - xd->bd);
#else
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
const int skip_bits =
TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - 8);
#endif
val = CAT6_MIN_VAL +
read_coeff(av1_cat6_prob + skip_bits, 18 - skip_bits, r);
} break;
}
#else // CONFIG_EC_MULTISYMBOL
......@@ -374,39 +316,30 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
case THREE_TOKEN:
case FOUR_TOKEN: val = token; break;
case CATEGORY1_TOKEN:
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
val = CAT1_MIN_VAL + read_coeff(av1_cat1_prob, 1, r);
break;
case CATEGORY2_TOKEN:
val = CAT2_MIN_VAL + read_coeff(cat2_prob, 2, r);
val = CAT2_MIN_VAL + read_coeff(av1_cat2_prob, 2, r);
break;
case CATEGORY3_TOKEN:
val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, r);
val = CAT3_MIN_VAL + read_coeff(av1_cat3_prob, 3, r);
break;
case CATEGORY4_TOKEN:
val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, r);
val = CAT4_MIN_VAL + read_coeff(av1_cat4_prob, 4, r);
break;
case CATEGORY5_TOKEN:
val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, r);
val = CAT5_MIN_VAL + read_coeff(av1_cat5_prob, 5, r);
break;
case CATEGORY6_TOKEN: {
const int skip_bits = TX_SIZES - 1 - txsize_sqr_up_map[tx_size];
const uint8_t *cat6p = cat6_prob + skip_bits;
#if CONFIG_AOM_HIGHBITDEPTH
switch (xd->bd) {
case AOM_BITS_8:
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
break;
case AOM_BITS_10:
val = CAT6_MIN_VAL + read_coeff(cat6p, 16 - skip_bits, r);
break;
case AOM_BITS_12:
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
break;
default: assert(0); return -1;
}
const int skip_bits =
TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - xd->bd);
#else
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
const int skip_bits =
TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - 8);
#endif
val = CAT6_MIN_VAL +
read_coeff(av1_cat6_prob + skip_bits, 18 - skip_bits, r);
break;
}
}
......
......@@ -819,20 +819,11 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
int count = 0;
const int seg_eob = tx_size_2d[tx_size];
#endif
#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
while (p < stop && p->token != EOSB_TOKEN) {
const int token = p->token;
aom_tree_index index = 0;
const av1_extra_bit *const extra_bits = &extra_bits_table[token];
const av1_extra_bit *const extra_bits = &av1_extra_bits[token];
if (token == BLOCK_Z_TOKEN) {
aom_write_symbol(w, 0, *p->head_cdf, HEAD_TOKENS + 1);
......@@ -855,9 +846,10 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
const int bit_string_length = extra_bits->len; // Length of extra bits to
// be written excluding
// the sign bit.
int skip_bits = (extra_bits->base_val == CAT6_MIN_VAL)
? TX_SIZES - 1 - txsize_sqr_up_map[tx_size]
: 0;
int skip_bits =
(extra_bits->base_val == CAT6_MIN_VAL)
? TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - bit_depth)
: 0;
if (bit_string_length > 0) {
const unsigned char *pb = extra_bits->prob;
......@@ -899,15 +891,6 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
int count = 0;
const int seg_eob = tx_size_2d[tx_size];
#endif
#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
while (p < stop && p->token != EOSB_TOKEN) {
const int token = p->token;
......@@ -917,7 +900,7 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
int coef_value = coef_encoding->value;
int coef_length = coef_encoding->len;
#endif // !CONFIG_EC_MULTISYMBOL
const av1_extra_bit *const extra_bits = &extra_bits_table[token];
const av1_extra_bit *const extra_bits = &av1_extra_bits[token];
#if CONFIG_EC_MULTISYMBOL
/* skip one or two nodes */
......@@ -960,10 +943,10 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
const int bit_string_length = extra_bits->len; // Length of extra bits to
// be written excluding
// the sign bit.
int skip_bits = (extra_bits->base_val == CAT6_MIN_VAL)
? TX_SIZES - 1 - txsize_sqr_up_map[tx_size]
: 0;
int skip_bits =
(extra_bits->base_val == CAT6_MIN_VAL)
? TX_SIZES - 1 - txsize_sqr_up_map[tx_size] + (12 - bit_depth)
: 0;
if (bit_string_length > 0) {
const unsigned char *pb = extra_bits->prob;
const int value = bit_string >> 1;
......
......@@ -271,41 +271,10 @@ const av1_extra_bit av1_extra_bits[ENTROPY_TOKENS] = {
{ av1_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost }, // CATEGORY3_TOKEN
{ av1_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost }, // CATEGORY4_TOKEN
{ av1_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost }, // CATEGORY5_TOKEN
{ av1_cat6_prob, 14, CAT6_MIN_VAL, 0 }, // CATEGORY6_TOKEN
{ av1_cat6_prob, 18, CAT6_MIN_VAL, 0 }, // CATEGORY6_TOKEN
{ 0, 0, 0, zero_cost } // EOB_TOKEN
};
#if CONFIG_AOM_HIGHBITDEPTH
const av1_extra_bit av1_extra_bits_high10[ENTROPY_TOKENS] = {
{ 0, 0, 0, zero_cost }, // ZERO
{ 0, 0, 1, sign_cost }, // ONE
{ 0, 0, 2, sign_cost }, // TWO
{ 0, 0, 3, sign_cost }, // THREE
{ 0, 0, 4, sign_cost }, // FOUR
{ av1_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost }, // CAT1
{ av1_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost }, // CAT2
{ av1_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost }, // CAT3
{ av1_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost }, // CAT4
{ av1_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost }, // CAT5
{ av1_cat6_prob_high10, 16, CAT6_MIN_VAL, 0 }, // CAT6
{ 0, 0, 0, zero_cost } // EOB
};
const av1_extra_bit av1_extra_bits_high12[ENTROPY_TOKENS] = {
{ 0, 0, 0, zero_cost }, // ZERO
{ 0, 0, 1, sign_cost }, // ONE
{ 0, 0, 2, sign_cost }, // TWO
{ 0, 0, 3, sign_cost }, // THREE
{ 0, 0, 4, sign_cost }, // FOUR
{ av1_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost }, // CAT1
{ av1_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost }, // CAT2
{ av1_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost }, // CAT3
{ av1_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost }, // CAT4
{ av1_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost }, // CAT5
{ av1_cat6_prob_high12, 18, CAT6_MIN_VAL, 0 }, // CAT6
{ 0, 0, 0, zero_cost } // EOB
};
#endif
#if !CONFIG_EC_MULTISYMBOL
const struct av1_token av1_coef_encodings[ENTROPY_TOKENS] = {
{ 2, 2 }, { 6, 3 }, { 28, 5 }, { 58, 6 }, { 59, 6 }, { 60, 6 },
......
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