Commit 8c576368 authored by Debargha Mukherjee's avatar Debargha Mukherjee Committed by Yue Chen
Browse files

Revert "Optimize get_txb_ctx()"

This reverts commit 4ab9a5dc.

Reason for revert: Breaks encoding/decoding

Change-Id: I9db6bd36688eb182365a31a2976257fb23a2c9c8
parent 8746b60c
...@@ -550,87 +550,81 @@ static INLINE void set_dc_sign(int *cul_level, tran_low_t v) { ...@@ -550,87 +550,81 @@ static INLINE void set_dc_sign(int *cul_level, tran_low_t v) {
*cul_level += 2 << COEFF_CONTEXT_BITS; *cul_level += 2 << COEFF_CONTEXT_BITS;
} }
static INLINE void get_txb_ctx(const BLOCK_SIZE plane_bsize, static INLINE int get_dc_sign_ctx(int dc_sign) {
const TX_SIZE tx_size, const int plane, int dc_sign_ctx = 0;
const ENTROPY_CONTEXT *const a, if (dc_sign < 0)
const ENTROPY_CONTEXT *const l, dc_sign_ctx = 1;
TXB_CTX *const txb_ctx) { else if (dc_sign > 0)
#define MAX_TX_SIZE_UNIT 16 dc_sign_ctx = 2;
static const int8_t signs[3] = { 0, -1, 1 };
static const int8_t dc_sign_contexts[2 * MAX_TX_SIZE_UNIT + 1] = { return dc_sign_ctx;
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, }
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
}; static INLINE void get_txb_ctx(BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
int plane, const ENTROPY_CONTEXT *a,
const ENTROPY_CONTEXT *l, TXB_CTX *txb_ctx) {
const int txb_w_unit = tx_size_wide_unit[tx_size]; const int txb_w_unit = tx_size_wide_unit[tx_size];
const int txb_h_unit = tx_size_high_unit[tx_size]; const int txb_h_unit = tx_size_high_unit[tx_size];
int dc_sign = 0; int ctx_offset = (plane == 0) ? 0 : 7;
int k = 0;
do { if (num_pels_log2_lookup[plane_bsize] >
const unsigned int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS; num_pels_log2_lookup[txsize_to_bsize[tx_size]])
assert(sign <= 2); ctx_offset += 3;
dc_sign += signs[sign];
} while (++k < txb_w_unit);
k = 0; int dc_sign = 0;
do { for (int k = 0; k < txb_w_unit; ++k) {
const unsigned int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS; int sign = ((uint8_t)a[k]) >> COEFF_CONTEXT_BITS;
assert(sign <= 2); if (sign == 1)
dc_sign += signs[sign]; --dc_sign;
} while (++k < txb_h_unit); else if (sign == 2)
++dc_sign;
else if (sign != 0)
assert(0);
}
txb_ctx->dc_sign_ctx = dc_sign_contexts[dc_sign + MAX_TX_SIZE_UNIT]; for (int k = 0; k < txb_h_unit; ++k) {
int sign = ((uint8_t)l[k]) >> COEFF_CONTEXT_BITS;
if (sign == 1)
--dc_sign;
else if (sign == 2)
++dc_sign;
else if (sign != 0)
assert(0);
}
txb_ctx->dc_sign_ctx = get_dc_sign_ctx(dc_sign);
if (plane == 0) { if (plane == 0) {
if (plane_bsize == txsize_to_bsize[tx_size]) { int top = 0;
txb_ctx->txb_skip_ctx = 0; int left = 0;
} else {
static const uint8_t skip_contexts[5][5] = { { 1, 2, 2, 2, 3 },
{ 1, 4, 4, 4, 5 },
{ 1, 4, 4, 4, 5 },
{ 1, 4, 4, 4, 5 },
{ 1, 4, 4, 4, 6 } };
int top = 0;
int left = 0;
k = 0;
do {
top |= a[k];
} while (++k < txb_w_unit);
top &= COEFF_CONTEXT_MASK;
k = 0;
do {
left |= l[k];
} while (++k < txb_h_unit);
left &= COEFF_CONTEXT_MASK;
const int max = AOMMIN(top | left, 4);
const int min = AOMMIN(AOMMIN(top, left), 4);
#if 0 for (int k = 0; k < txb_w_unit; ++k) {
// This is the algorithm to generate table skip_contexts[]. top = AOMMAX(top, ((uint8_t)a[k] & COEFF_CONTEXT_MASK));
if (!max) }
txb_ctx->txb_skip_ctx = 1;
else if (!min) for (int k = 0; k < txb_h_unit; ++k) {
txb_ctx->txb_skip_ctx = 2 + (max > 3); left = AOMMAX(left, ((uint8_t)l[k] & COEFF_CONTEXT_MASK));
else if (max <= 3)
txb_ctx->txb_skip_ctx = 4;
else if (min <= 3)
txb_ctx->txb_skip_ctx = 5;
else
txb_ctx->txb_skip_ctx = 6;
#endif
txb_ctx->txb_skip_ctx = skip_contexts[min][max];
} }
top = AOMMIN(top, 255);
left = AOMMIN(left, 255);
if (plane_bsize == txsize_to_bsize[tx_size])
txb_ctx->txb_skip_ctx = 0;
else if (top == 0 && left == 0)
txb_ctx->txb_skip_ctx = 1;
else if (top == 0 || left == 0)
txb_ctx->txb_skip_ctx = 2 + (AOMMAX(top, left) > 3);
else if (AOMMAX(top, left) <= 3)
txb_ctx->txb_skip_ctx = 4;
else if (AOMMIN(top, left) <= 3)
txb_ctx->txb_skip_ctx = 5;
else
txb_ctx->txb_skip_ctx = 6;
} else { } else {
const int ctx_base = get_entropy_context(tx_size, a, l); int ctx_base = get_entropy_context(tx_size, a, l);
const int ctx_offset = (num_pels_log2_lookup[plane_bsize] > txb_ctx->txb_skip_ctx = ctx_offset + ctx_base;
num_pels_log2_lookup[txsize_to_bsize[tx_size]])
? 10
: 7;
txb_ctx->txb_skip_ctx = ctx_base + ctx_offset;
} }
#undef MAX_TX_SIZE_UNIT
} }
void av1_init_txb_probs(FRAME_CONTEXT *fc); void av1_init_txb_probs(FRAME_CONTEXT *fc);
......
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