[level map] simplified context derivation
This CL simplifies context derivation for nz and base level flags in
level map.
1. Reduce SIG_COEF_CONTEXTS from 58 to 42.
2. NZ and base level flags share the same context offsets derived from a
template of size 5 (down from 7).
In limited runs, compression performance seems neutral if not better.
Encoding time for a key frame on a local linux machine is reduced by about 25% or more.
Change-Id: Ibd93b21c839154bc5ae26b993f9e66537cbf5942
diff --git a/av1/decoder/decodetxb.c b/av1/decoder/decodetxb.c
index d0134f5..30330f0 100644
--- a/av1/decoder/decodetxb.c
+++ b/av1/decoder/decodetxb.c
@@ -174,10 +174,37 @@
levels[scan[c]] = is_nz;
if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
+
+#if USE_CAUSAL_BASE_CTX
+ if (is_nz) {
+ int k;
+ for (k = 0; k < NUM_BASE_LEVELS; ++k) {
+ int ctx = coeff_ctx;
+#if 0 // USE_CAUSAL_BASE_CTX read_coeffs
+ int is_k = av1_read_record_bit(counts, r, ACCT_STR);
+#else
+ int is_k = av1_read_record_bin(
+ counts, r, ec_ctx->coeff_base_cdf[txs_ctx][plane_type][k][ctx], 2,
+ ACCT_STR);
+ if (counts) ++counts->coeff_base[txs_ctx][plane_type][k][ctx][is_k];
+
+#endif
+ // is_k = 1 if level > (k+1)
+ if (is_k == 0) {
+ cul_level += k + 1;
+ break;
+ }
+ }
+ levels[scan[c]] = k + 1;
+ }
+#endif
}
*max_scan_line = *eob;
+#if USE_CAUSAL_BASE_CTX
+ update_eob = *eob - 1;
+#else
int i;
for (i = 0; i < NUM_BASE_LEVELS; ++i) {
update_eob = 0;
@@ -206,6 +233,7 @@
update_eob = AOMMAX(update_eob, c);
}
}
+#endif
// Loop to decode all signs in the transform block,
// starting with the sign of the DC (if applicable)