Commit 061103dc authored by Alex Converse's avatar Alex Converse Committed by Gerrit Code Review

Merge "vp9: simplify extrabits encoding"

parents 8b55eafe 2f7f482c
......@@ -75,21 +75,6 @@ DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat6_prob_high12[18]);
#define EOB_MODEL_TOKEN 3
typedef struct {
const vpx_tree_index *tree;
const vpx_prob *prob;
int len;
int base_val;
const int16_t *cost;
} vp9_extra_bit;
// indexed by token value
extern const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS];
#if CONFIG_VP9_HIGHBITDEPTH
extern const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS];
extern const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS];
#endif // CONFIG_VP9_HIGHBITDEPTH
#define DCT_MAX_VALUE 16384
#if CONFIG_VP9_HIGHBITDEPTH
#define DCT_MAX_VALUE_HIGH10 65536
......
......@@ -176,12 +176,10 @@ static void pack_mb_tokens(vpx_writer *w,
const unsigned char *pb = b->prob;
int v = e >> 1;
int n = l; /* number of bits in v, assumed nonzero */
int i = 0;
do {
const int bb = (v >> --n) & 1;
vpx_write(w, bb, pb[i >> 1]);
i = b->tree[i + bb];
vpx_write(w, bb, *pb++);
} while (n);
}
......
......@@ -66,14 +66,6 @@ const vpx_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = {
-CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE
};
static const vpx_tree_index cat1[2] = {0, 0};
static const vpx_tree_index cat2[4] = {2, 2, 0, 0};
static const vpx_tree_index cat3[6] = {2, 2, 4, 4, 0, 0};
static const vpx_tree_index cat4[8] = {2, 2, 4, 4, 6, 6, 0, 0};
static const vpx_tree_index cat5[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0};
static const vpx_tree_index cat6[28] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12,
14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 0, 0};
static const int16_t zero_cost[] = {0};
static const int16_t one_cost[] = {255, 257};
static const int16_t two_cost[] = {255, 257};
......@@ -366,68 +358,49 @@ const int16_t vp9_cat6_high12_high_cost[2048] = {
};
#endif
#if CONFIG_VP9_HIGHBITDEPTH
static const vpx_tree_index cat1_high10[2] = {0, 0};
static const vpx_tree_index cat2_high10[4] = {2, 2, 0, 0};
static const vpx_tree_index cat3_high10[6] = {2, 2, 4, 4, 0, 0};
static const vpx_tree_index cat4_high10[8] = {2, 2, 4, 4, 6, 6, 0, 0};
static const vpx_tree_index cat5_high10[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0};
static const vpx_tree_index cat6_high10[32] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10,
12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28,
30, 30, 0, 0};
static const vpx_tree_index cat1_high12[2] = {0, 0};
static const vpx_tree_index cat2_high12[4] = {2, 2, 0, 0};
static const vpx_tree_index cat3_high12[6] = {2, 2, 4, 4, 0, 0};
static const vpx_tree_index cat4_high12[8] = {2, 2, 4, 4, 6, 6, 0, 0};
static const vpx_tree_index cat5_high12[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0};
static const vpx_tree_index cat6_high12[36] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10,
12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28,
30, 30, 32, 32, 34, 34, 0, 0};
#endif
const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = {
{0, 0, 0, 0, zero_cost}, // ZERO_TOKEN
{0, 0, 0, 1, one_cost}, // ONE_TOKEN
{0, 0, 0, 2, two_cost}, // TWO_TOKEN
{0, 0, 0, 3, three_cost}, // THREE_TOKEN
{0, 0, 0, 4, four_cost}, // FOUR_TOKEN
{cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL, cat1_cost}, // CATEGORY1_TOKEN
{cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL, cat2_cost}, // CATEGORY2_TOKEN
{cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost}, // CATEGORY3_TOKEN
{cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost}, // CATEGORY4_TOKEN
{cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost}, // CATEGORY5_TOKEN
{cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL, 0}, // CATEGORY6_TOKEN
{0, 0, 0, 0, zero_cost} // EOB_TOKEN
{0, 0, 0, zero_cost}, // ZERO_TOKEN
{0, 0, 1, one_cost}, // ONE_TOKEN
{0, 0, 2, two_cost}, // TWO_TOKEN
{0, 0, 3, three_cost}, // THREE_TOKEN
{0, 0, 4, four_cost}, // FOUR_TOKEN
{vp9_cat1_prob, 1, CAT1_MIN_VAL, cat1_cost}, // CATEGORY1_TOKEN
{vp9_cat2_prob, 2, CAT2_MIN_VAL, cat2_cost}, // CATEGORY2_TOKEN
{vp9_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost}, // CATEGORY3_TOKEN
{vp9_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost}, // CATEGORY4_TOKEN
{vp9_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost}, // CATEGORY5_TOKEN
{vp9_cat6_prob, 14, CAT6_MIN_VAL, 0}, // CATEGORY6_TOKEN
{0, 0, 0, zero_cost} // EOB_TOKEN
};
#if CONFIG_VP9_HIGHBITDEPTH
const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS] = {
{0, 0, 0, 0, zero_cost}, // ZERO
{0, 0, 0, 1, one_cost}, // ONE
{0, 0, 0, 2, two_cost}, // TWO
{0, 0, 0, 3, three_cost}, // THREE
{0, 0, 0, 4, four_cost}, // FOUR
{cat1_high10, vp9_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1
{cat2_high10, vp9_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2
{cat3_high10, vp9_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3
{cat4_high10, vp9_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4
{cat5_high10, vp9_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5
{cat6_high10, vp9_cat6_prob_high10, 16, CAT6_MIN_VAL, 0}, // CAT6
{0, 0, 0, 0, zero_cost} // EOB
{0, 0, 0, zero_cost}, // ZERO
{0, 0, 1, one_cost}, // ONE
{0, 0, 2, two_cost}, // TWO
{0, 0, 3, three_cost}, // THREE
{0, 0, 4, four_cost}, // FOUR
{vp9_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1
{vp9_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2
{vp9_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3
{vp9_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4
{vp9_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5
{vp9_cat6_prob_high10, 16, CAT6_MIN_VAL, 0}, // CAT6
{0, 0, 0, zero_cost} // EOB
};
const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS] = {
{0, 0, 0, 0, zero_cost}, // ZERO
{0, 0, 0, 1, one_cost}, // ONE
{0, 0, 0, 2, two_cost}, // TWO
{0, 0, 0, 3, three_cost}, // THREE
{0, 0, 0, 4, four_cost}, // FOUR
{cat1_high12, vp9_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1
{cat2_high12, vp9_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2
{cat3_high12, vp9_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3
{cat4_high12, vp9_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4
{cat5_high12, vp9_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5
{cat6_high12, vp9_cat6_prob_high12, 18, CAT6_MIN_VAL, 0}, // CAT6
{0, 0, 0, 0, zero_cost} // EOB
{0, 0, 0, zero_cost}, // ZERO
{0, 0, 1, one_cost}, // ONE
{0, 0, 2, two_cost}, // TWO
{0, 0, 3, three_cost}, // THREE
{0, 0, 4, four_cost}, // FOUR
{vp9_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1
{vp9_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2
{vp9_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3
{vp9_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4
{vp9_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5
{vp9_cat6_prob_high12, 18, CAT6_MIN_VAL, 0}, // CAT6
{0, 0, 0, zero_cost} // EOB
};
#endif
......
......@@ -54,6 +54,20 @@ struct ThreadData;
void vp9_tokenize_sb(struct VP9_COMP *cpi, struct ThreadData *td,
TOKENEXTRA **t, int dry_run, BLOCK_SIZE bsize);
typedef struct {
const vpx_prob *prob;
int len;
int base_val;
const int16_t *cost;
} vp9_extra_bit;
// indexed by token value
extern const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS];
#if CONFIG_VP9_HIGHBITDEPTH
extern const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS];
extern const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS];
#endif // CONFIG_VP9_HIGHBITDEPTH
extern const int16_t *vp9_dct_value_cost_ptr;
/* TODO: The Token field should be broken out into a separate char array to
* improve cache locality, since it's needed for costing when the rest of the
......
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