EC_MULTISYMBOL: always send the EOB_TOKEN after a non-zero value. This will allow EOB_TOKEN to be merged with that value. Change-Id: I82ba5e8d38e235d07894e43b5fec53968f84ab6c
diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c index b39c5ad..9c5c7a7 100644 --- a/av1/decoder/detokenize.c +++ b/av1/decoder/detokenize.c
@@ -191,7 +191,7 @@ *max_scan_line = AOMMAX(*max_scan_line, scan[c]); token_cache[scan[c]] = av1_pt_energy_class[token]; - ctx_eob = get_coef_context(nb, token_cache, c + 1); + ctx_eob = get_coef_context(nb, token_cache, AOMMIN(c + 1, max_eob - 1)); band_eob = c < max_eob - 1 ? *band_translate : band_eob; prob_eob = coef_probs[band_eob][ctx_eob]; @@ -260,7 +260,7 @@ if (v) dqcoeff[scan[c]] = aom_read_bit(r, ACCT_STR) ? -v : v; #endif // CONFIG_COEFFICIENT_RANGE_CHECKING - if (c + 1 < max_eob && token) { + if (token) { if (counts) ++eob_branch_count[band_eob][ctx_eob]; if (!aom_read(r, prob_eob[EOB_CONTEXT_NODE], ACCT_STR)) { // INCREMENT_COUNT(EOB_MODEL_TOKEN);
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c index 87f8d2f..52d4996 100644 --- a/av1/encoder/tokenize.c +++ b/av1/encoder/tokenize.c
@@ -480,11 +480,12 @@ ec_ctx->coef_tail_cdfs[tx_size][type][ref]; unsigned int(*const blockz_count)[2] = td->counts->blockz_count[txsize_sqr_map[tx_size]][type][ref]; + int c2; #endif + const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size); unsigned int(*const eob_branch)[COEFF_CONTEXTS] = td->counts->eob_branch[txsize_sqr_map[tx_size]][type][ref]; 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 skip_eob = 0; int16_t token; EXTRABIT extra; @@ -509,15 +510,13 @@ token_cache[scan[c]] = av1_pt_energy_class[token]; ++c; - pt = get_coef_context(nb, token_cache, c); + pt = get_coef_context(nb, token_cache, AOMMIN(c, seg_eob - 1)); skip_eob = (token == ZERO_TOKEN); } - if (c < seg_eob) { - assert(!skip_eob); // The last token must be non-zero. - add_token(&t, coef_probs[band[c]][pt], NULL, NULL, 0, EOB_TOKEN, 0, - counts[band[c]][pt]); - ++eob_branch[band[c]][pt]; - } + c2 = AOMMIN(c, seg_eob - 1); + add_token(&t, coef_probs[band[c2]][pt], NULL, NULL, 0, EOB_TOKEN, 0, + counts[band[c2]][pt]); + ++eob_branch[band[c2]][pt]; #else while (c < eob) { const int v = qcoeff[scan[c]];