Commit 85901563 authored by Angie Chiang's avatar Angie Chiang

Change get_txb_skip_context to get_txb_ctx

Generate txb_ctx which contains both txb_skip_ctx and dc_ctx
directly

Change-Id: I5058b72e0b6431a9daf0536925c71da590cf7aeb
parent 57795a4c
......@@ -318,33 +318,34 @@ static INLINE int get_dc_sign_ctx(int dc_sign) {
return dc_sign_ctx;
}
static INLINE int get_txb_skip_context(BLOCK_SIZE bsize, TX_SIZE tx_size,
int plane, const ENTROPY_CONTEXT *a,
const ENTROPY_CONTEXT *l, int *dc_sign) {
static INLINE void get_txb_ctx(BLOCK_SIZE bsize, TX_SIZE tx_size, int plane,
const ENTROPY_CONTEXT *a,
const ENTROPY_CONTEXT *l, TXB_CTX *txb_ctx) {
const int tx_size_in_blocks = 1 << tx_size;
int ctx_offset = (plane == 0) ? 0 : 7;
int k;
if (bsize > txsize_to_bsize[tx_size]) ctx_offset += 3;
*dc_sign = 0;
int dc_sign = 0;
for (k = 0; k < tx_size_in_blocks; ++k) {
int sign = a[k] >> COEFF_CONTEXT_BITS;
if (sign == 1)
--*dc_sign;
--dc_sign;
else if (sign == 2)
++*dc_sign;
++dc_sign;
else if (sign != 0)
exit(0);
sign = l[k] >> 6;
if (sign == 1)
--*dc_sign;
--dc_sign;
else if (sign == 2)
++*dc_sign;
++dc_sign;
else if (sign != 0)
exit(0);
}
txb_ctx->dc_sign_ctx = get_dc_sign_ctx(dc_sign);
if (plane == 0) {
int top = 0;
......@@ -357,20 +358,20 @@ static INLINE int get_txb_skip_context(BLOCK_SIZE bsize, TX_SIZE tx_size,
left = AOMMIN(left, 255);
if (bsize == txsize_to_bsize[tx_size])
return 0;
txb_ctx->txb_skip_ctx = 0;
else if (top == 0 && left == 0)
return 1;
txb_ctx->txb_skip_ctx = 1;
else if (top == 0 || left == 0)
return 2 + (AOMMAX(top, left) > 3);
txb_ctx->txb_skip_ctx = 2 + (AOMMAX(top, left) > 3);
else if (AOMMAX(top, left) <= 3)
return 4;
txb_ctx->txb_skip_ctx = 4;
else if (AOMMIN(top, left) <= 3)
return 5;
txb_ctx->txb_skip_ctx = 5;
else
return 6;
txb_ctx->txb_skip_ctx = 6;
} else {
int ctx_base = get_entropy_context(tx_size, a, l);
return ctx_offset + ctx_base;
txb_ctx->txb_skip_ctx = ctx_offset + ctx_base;
}
}
#endif // AV1_COMMON_TXB_COMMON_H_
......@@ -435,10 +435,9 @@ static void update_and_record_txb_context(int plane, int block, int blk_row,
const uint8_t *const band = get_band_translate(tx_size);
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
int c, i;
int dc_sign;
int txb_skip_ctx = get_txb_skip_context(plane_bsize, tx_size, plane,
pd->above_context + blk_col,
pd->left_context + blk_row, &dc_sign);
TXB_CTX txb_ctx;
get_txb_ctx(plane_bsize, tx_size, plane, pd->above_context + blk_col,
pd->left_context + blk_row, &txb_ctx);
const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2;
int cul_level = 0;
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2];
......@@ -455,8 +454,8 @@ static void update_and_record_txb_context(int plane, int block, int blk_row,
(void)counts;
(void)band;
++td->counts->txb_skip[tx_size][txb_skip_ctx][eob == 0];
x->mbmi_ext->txb_skip_ctx[plane][block] = txb_skip_ctx;
++td->counts->txb_skip[tx_size][txb_ctx.txb_skip_ctx][eob == 0];
x->mbmi_ext->txb_skip_ctx[plane][block] = txb_ctx.txb_skip_ctx;
x->mbmi_ext->eobs[plane][block] = eob;
......@@ -498,7 +497,7 @@ static void update_and_record_txb_context(int plane, int block, int blk_row,
if (level == i + 1) {
++td->counts->coeff_base[tx_size][plane_type][i][ctx][1];
if (c == 0) {
int dc_sign_ctx = get_dc_sign_ctx(dc_sign);
int dc_sign_ctx = txb_ctx.dc_sign_ctx;
++td->counts->dc_sign[plane_type][dc_sign_ctx][v < 0];
x->mbmi_ext->dc_sign_ctx[plane][block] = dc_sign_ctx;
......@@ -521,7 +520,7 @@ static void update_and_record_txb_context(int plane, int block, int blk_row,
cul_level += level;
if (c == 0) {
int dc_sign_ctx = get_dc_sign_ctx(dc_sign);
int dc_sign_ctx = txb_ctx.dc_sign_ctx;
++td->counts->dc_sign[plane_type][dc_sign_ctx][v < 0];
x->mbmi_ext->dc_sign_ctx[plane][block] = dc_sign_ctx;
......
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