Separate dc coeff decoding form others
BUG=aomedia:1369
Change-Id: Ibe104cfbc969728b2d5a2ffa38e954bce7fa98bc
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h
index 8443900..9c37324 100644
--- a/av1/common/txb_common.h
+++ b/av1/common/txb_common.h
@@ -360,6 +360,7 @@
static INLINE int get_br_ctx_2d(const uint8_t *const levels,
const int c, // raster order
const int bwl) {
+ assert(c > 0);
const int row = c >> bwl;
const int col = c - (row << bwl);
const int stride = (1 << bwl) + TX_PAD_HOR;
@@ -369,7 +370,6 @@
AOMMIN(levels[pos + stride], COEFF_BASE_RANGE + NUM_BASE_LEVELS + 1) +
AOMMIN(levels[pos + 1 + stride], COEFF_BASE_RANGE + NUM_BASE_LEVELS + 1);
mag = AOMMIN((mag + 1) >> 1, 6);
- if (c == 0) return mag;
if ((row < 2) && (col < 2)) return mag + 7;
return mag + 14;
}
@@ -537,6 +537,7 @@
static INLINE int get_lower_levels_ctx_2d(const uint8_t *levels, int coeff_idx,
int bwl, TX_SIZE tx_size) {
+ assert(coeff_idx > 0);
int mag;
// Note: AOMMIN(level, 3) is useless for decoder since level < 3.
levels = levels + get_padded_idx(coeff_idx, bwl);
@@ -547,13 +548,9 @@
mag += AOMMIN(levels[(2 << bwl) + (2 << TX_PAD_HOR_LOG2)], 3); // { 2, 0 }
const int ctx = AOMMIN((mag + 1) >> 1, 4);
- if (!coeff_idx) {
- return 0;
- } else {
- const int row = coeff_idx >> bwl;
- const int col = coeff_idx - (row << bwl);
- return ctx + av1_nz_map_ctx_offset[tx_size][AOMMIN(row, 4)][AOMMIN(col, 4)];
- }
+ const int row = coeff_idx >> bwl;
+ const int col = coeff_idx - (row << bwl);
+ return ctx + av1_nz_map_ctx_offset[tx_size][AOMMIN(row, 4)][AOMMIN(col, 4)];
}
static INLINE int get_lower_levels_ctx(const uint8_t *levels, int coeff_idx,
int bwl, TX_SIZE tx_size,
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c
index acc2145..5f92a11 100644
--- a/av1/decoder/decodetxb.c
+++ b/av1/decoder/decodetxb.c
@@ -260,16 +260,20 @@
}
levels[get_padded_idx(pos, bwl)] = level;
}
- base_cdf_arr base_cdf = ec_ctx->coeff_base_cdf[txs_ctx][plane_type];
- br_cdf_arr br_cdf =
- ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_32X32)][plane_type];
- const TX_CLASS tx_class = tx_type_to_class[tx_type];
- if (tx_class == TX_CLASS_2D) {
- read_coeffs_reverse_2d(r, tx_size, 0, *eob - 1 - 1, scan, bwl, levels,
- base_cdf, br_cdf);
- } else {
- read_coeffs_reverse(r, tx_size, tx_type, 0, *eob - 1 - 1, scan, bwl, levels,
- base_cdf, br_cdf);
+ if (*eob > 1) {
+ base_cdf_arr base_cdf = ec_ctx->coeff_base_cdf[txs_ctx][plane_type];
+ br_cdf_arr br_cdf =
+ ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_32X32)][plane_type];
+ const TX_CLASS tx_class = tx_type_to_class[tx_type];
+ if (tx_class == TX_CLASS_2D) {
+ read_coeffs_reverse_2d(r, tx_size, 1, *eob - 1 - 1, scan, bwl, levels,
+ base_cdf, br_cdf);
+ read_coeffs_reverse(r, tx_size, tx_type, 0, 0, scan, bwl, levels,
+ base_cdf, br_cdf);
+ } else {
+ read_coeffs_reverse(r, tx_size, tx_type, 0, *eob - 1 - 1, scan, bwl,
+ levels, base_cdf, br_cdf);
+ }
}
// Loop to decode all signs in the transform block,