Commit 6957e7a0 authored by Deb Mukherjee's avatar Deb Mukherjee

Some extra bit probability cleanups

Refactoring to remove some duplication of probability
tables between tokenization and detokenization.

Change-Id: I2fc6a6497f9c0410021a9b41f828bc58a864e466
parent a75d55df
...@@ -15,6 +15,14 @@ ...@@ -15,6 +15,14 @@
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx/vpx_integer.h" #include "vpx/vpx_integer.h"
const vp9_prob vp9_cat1_prob[] = { 159 };
const vp9_prob vp9_cat2_prob[] = { 165, 145 };
const vp9_prob vp9_cat3_prob[] = { 173, 148, 140 };
const vp9_prob vp9_cat4_prob[] = { 176, 155, 140, 135 };
const vp9_prob vp9_cat5_prob[] = { 180, 157, 141, 134, 130 };
const vp9_prob vp9_cat6_prob[] = {
254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
};
const uint8_t vp9_coefband_trans_8x8plus[1024] = { const uint8_t vp9_coefband_trans_8x8plus[1024] = {
0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
......
...@@ -43,6 +43,21 @@ extern "C" { ...@@ -43,6 +43,21 @@ extern "C" {
DECLARE_ALIGNED(16, extern const uint8_t, vp9_pt_energy_class[ENTROPY_TOKENS]); DECLARE_ALIGNED(16, extern const uint8_t, vp9_pt_energy_class[ENTROPY_TOKENS]);
#define CAT1_MIN_VAL 5
#define CAT2_MIN_VAL 7
#define CAT3_MIN_VAL 11
#define CAT4_MIN_VAL 19
#define CAT5_MIN_VAL 35
#define CAT6_MIN_VAL 67
// Extra bit probabilities.
DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat1_prob[1]);
DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat2_prob[2]);
DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat3_prob[3]);
DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat4_prob[4]);
DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat5_prob[5]);
DECLARE_ALIGNED(16, extern const uint8_t, vp9_cat6_prob[14]);
#define EOB_MODEL_TOKEN 3 #define EOB_MODEL_TOKEN 3
extern const vp9_tree_index vp9_coefmodel_tree[]; extern const vp9_tree_index vp9_coefmodel_tree[];
......
...@@ -28,35 +28,6 @@ ...@@ -28,35 +28,6 @@
#define CAT_THREE_CONTEXT_NODE 6 #define CAT_THREE_CONTEXT_NODE 6
#define CAT_FIVE_CONTEXT_NODE 7 #define CAT_FIVE_CONTEXT_NODE 7
#define CAT1_MIN_VAL 5
#define CAT2_MIN_VAL 7
#define CAT3_MIN_VAL 11
#define CAT4_MIN_VAL 19
#define CAT5_MIN_VAL 35
#define CAT6_MIN_VAL 67
#define CAT1_PROB0 159
#define CAT2_PROB0 145
#define CAT2_PROB1 165
#define CAT3_PROB0 140
#define CAT3_PROB1 148
#define CAT3_PROB2 173
#define CAT4_PROB0 135
#define CAT4_PROB1 140
#define CAT4_PROB2 155
#define CAT4_PROB3 176
#define CAT5_PROB0 130
#define CAT5_PROB1 134
#define CAT5_PROB2 141
#define CAT5_PROB3 157
#define CAT5_PROB4 180
static const vp9_prob cat6_prob[15] = {
254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0
};
#define INCREMENT_COUNT(token) \ #define INCREMENT_COUNT(token) \
do { \ do { \
if (!cm->frame_parallel_decoding_mode) \ if (!cm->frame_parallel_decoding_mode) \
...@@ -96,7 +67,6 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, PLANE_TYPE type, ...@@ -96,7 +67,6 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, PLANE_TYPE type,
unsigned int (*eob_branch_count)[COEFF_CONTEXTS] = unsigned int (*eob_branch_count)[COEFF_CONTEXTS] =
counts->eob_branch[tx_size][type][ref]; counts->eob_branch[tx_size][type][ref];
uint8_t token_cache[32 * 32]; uint8_t token_cache[32 * 32];
const uint8_t *cat6;
const uint8_t *band_translate = get_band_translate(tx_size); const uint8_t *band_translate = get_band_translate(tx_size);
const int dq_shift = (tx_size == TX_32X32); const int dq_shift = (tx_size == TX_32X32);
int v; int v;
...@@ -148,44 +118,55 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, PLANE_TYPE type, ...@@ -148,44 +118,55 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, PLANE_TYPE type,
if (!vp9_read(r, prob[HIGH_LOW_CONTEXT_NODE])) { if (!vp9_read(r, prob[HIGH_LOW_CONTEXT_NODE])) {
if (!vp9_read(r, prob[CAT_ONE_CONTEXT_NODE])) { if (!vp9_read(r, prob[CAT_ONE_CONTEXT_NODE])) {
val = CAT1_MIN_VAL; val = CAT1_MIN_VAL;
ADJUST_COEF(CAT1_PROB0, 0); ADJUST_COEF(vp9_cat1_prob[0], 0);
WRITE_COEF_CONTINUE(val, CATEGORY1_TOKEN); WRITE_COEF_CONTINUE(val, CATEGORY1_TOKEN);
} }
val = CAT2_MIN_VAL; val = CAT2_MIN_VAL;
ADJUST_COEF(CAT2_PROB1, 1); ADJUST_COEF(vp9_cat2_prob[0], 1);
ADJUST_COEF(CAT2_PROB0, 0); ADJUST_COEF(vp9_cat2_prob[1], 0);
WRITE_COEF_CONTINUE(val, CATEGORY2_TOKEN); WRITE_COEF_CONTINUE(val, CATEGORY2_TOKEN);
} }
if (!vp9_read(r, prob[CAT_THREEFOUR_CONTEXT_NODE])) { if (!vp9_read(r, prob[CAT_THREEFOUR_CONTEXT_NODE])) {
if (!vp9_read(r, prob[CAT_THREE_CONTEXT_NODE])) { if (!vp9_read(r, prob[CAT_THREE_CONTEXT_NODE])) {
val = CAT3_MIN_VAL; val = CAT3_MIN_VAL;
ADJUST_COEF(CAT3_PROB2, 2); ADJUST_COEF(vp9_cat3_prob[0], 2);
ADJUST_COEF(CAT3_PROB1, 1); ADJUST_COEF(vp9_cat3_prob[1], 1);
ADJUST_COEF(CAT3_PROB0, 0); ADJUST_COEF(vp9_cat3_prob[2], 0);
WRITE_COEF_CONTINUE(val, CATEGORY3_TOKEN); WRITE_COEF_CONTINUE(val, CATEGORY3_TOKEN);
} }
val = CAT4_MIN_VAL; val = CAT4_MIN_VAL;
ADJUST_COEF(CAT4_PROB3, 3); ADJUST_COEF(vp9_cat4_prob[0], 3);
ADJUST_COEF(CAT4_PROB2, 2); ADJUST_COEF(vp9_cat4_prob[1], 2);
ADJUST_COEF(CAT4_PROB1, 1); ADJUST_COEF(vp9_cat4_prob[2], 1);
ADJUST_COEF(CAT4_PROB0, 0); ADJUST_COEF(vp9_cat4_prob[3], 0);
WRITE_COEF_CONTINUE(val, CATEGORY4_TOKEN); WRITE_COEF_CONTINUE(val, CATEGORY4_TOKEN);
} }
if (!vp9_read(r, prob[CAT_FIVE_CONTEXT_NODE])) { if (!vp9_read(r, prob[CAT_FIVE_CONTEXT_NODE])) {
val = CAT5_MIN_VAL; val = CAT5_MIN_VAL;
ADJUST_COEF(CAT5_PROB4, 4); ADJUST_COEF(vp9_cat5_prob[0], 4);
ADJUST_COEF(CAT5_PROB3, 3); ADJUST_COEF(vp9_cat5_prob[1], 3);
ADJUST_COEF(CAT5_PROB2, 2); ADJUST_COEF(vp9_cat5_prob[2], 2);
ADJUST_COEF(CAT5_PROB1, 1); ADJUST_COEF(vp9_cat5_prob[3], 1);
ADJUST_COEF(CAT5_PROB0, 0); ADJUST_COEF(vp9_cat5_prob[4], 0);
WRITE_COEF_CONTINUE(val, CATEGORY5_TOKEN); WRITE_COEF_CONTINUE(val, CATEGORY5_TOKEN);
} }
val = 0; val = 0;
cat6 = cat6_prob; val = (val << 1) | vp9_read(r, vp9_cat6_prob[0]);
while (*cat6) val = (val << 1) | vp9_read(r, vp9_cat6_prob[1]);
val = (val << 1) | vp9_read(r, *cat6++); val = (val << 1) | vp9_read(r, vp9_cat6_prob[2]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[3]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[4]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[5]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[6]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[7]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[8]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[9]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[10]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[11]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[12]);
val = (val << 1) | vp9_read(r, vp9_cat6_prob[13]);
val += CAT6_MIN_VAL; val += CAT6_MIN_VAL;
WRITE_COEF_CONTINUE(val, CATEGORY6_TOKEN); WRITE_COEF_CONTINUE(val, CATEGORY6_TOKEN);
......
...@@ -55,15 +55,6 @@ const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = { ...@@ -55,15 +55,6 @@ const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = {
-CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE
}; };
static const vp9_prob Pcat1[] = { 159};
static const vp9_prob Pcat2[] = { 165, 145};
static const vp9_prob Pcat3[] = { 173, 148, 140};
static const vp9_prob Pcat4[] = { 176, 155, 140, 135};
static const vp9_prob Pcat5[] = { 180, 157, 141, 134, 130};
static const vp9_prob Pcat6[] = {
254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129
};
static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[28]; static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[28];
static void init_bit_tree(vp9_tree_index *p, int n) { static void init_bit_tree(vp9_tree_index *p, int n) {
...@@ -87,18 +78,18 @@ static void init_bit_trees() { ...@@ -87,18 +78,18 @@ static void init_bit_trees() {
} }
const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = { const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = {
{0, 0, 0, 0}, // ZERO_TOKEN {0, 0, 0, 0}, // ZERO_TOKEN
{0, 0, 0, 1}, // ONE_TOKEN {0, 0, 0, 1}, // ONE_TOKEN
{0, 0, 0, 2}, // TWO_TOKEN {0, 0, 0, 2}, // TWO_TOKEN
{0, 0, 0, 3}, // THREE_TOKEN {0, 0, 0, 3}, // THREE_TOKEN
{0, 0, 0, 4}, // FOUR_TOKEN {0, 0, 0, 4}, // FOUR_TOKEN
{cat1, Pcat1, 1, 5}, // CATEGORY1_TOKEN {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN
{cat2, Pcat2, 2, 7}, // CATEGORY2_TOKEN {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN
{cat3, Pcat3, 3, 11}, // CATEGORY3_TOKEN {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN
{cat4, Pcat4, 4, 19}, // CATEGORY4_TOKEN {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN
{cat5, Pcat5, 5, 35}, // CATEGORY5_TOKEN {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN
{cat6, Pcat6, 14, 67}, // CATEGORY6_TOKEN {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL}, // CATEGORY6_TOKEN
{0, 0, 0, 0} // EOB_TOKEN {0, 0, 0, 0} // EOB_TOKEN
}; };
struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS]; struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS];
......
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