Commit bb72cafa authored by Jingning Han's avatar Jingning Han
Browse files

Make lv-map decoding support per symbol cdf update

Support the per symbol cdf update at the level map syntax element
decoding process.

Change-Id: Id58bf86fb1c7c72dd14ddaa3781caaa27f446ef7
parent fdaa55ed
......@@ -20,6 +20,7 @@
#endif
#if CONFIG_LV_MAP
#include "av1/common/txb_common.h"
const aom_prob default_txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS] = {
#if CONFIG_CHROMA_2X2
{ 252, 71, 126, 184, 178, 218, 251, 49, 133, 221, 27, 92, 197 },
......
......@@ -48,8 +48,10 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
FRAME_COUNTS *counts = xd->counts;
TX_SIZE txs_ctx = get_txsize_context(tx_size);
PLANE_TYPE plane_type = get_plane_type(plane);
#if !LV_MAP_PROB
aom_prob *nz_map = cm->fc->nz_map[txs_ctx][plane_type];
aom_prob *eob_flag = cm->fc->eob_flag[txs_ctx][plane_type];
#endif
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const int seg_eob = tx_size_2d[tx_size];
int c = 0;
......@@ -65,8 +67,13 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
memset(tcoeffs, 0, sizeof(*tcoeffs) * seg_eob);
#if LV_MAP_PROB
int all_zero = aom_read_symbol(
r, cm->fc->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2, ACCT_STR);
#else
int all_zero =
aom_read(r, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx], ACCT_STR);
#endif
if (xd->counts)
++xd->counts->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx][all_zero];
......@@ -96,10 +103,16 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
int coeff_ctx = get_nz_map_ctx(tcoeffs, scan[c], bwl, height, iscan);
int eob_ctx = get_eob_ctx(tcoeffs, scan[c], txs_ctx);
if (c < seg_eob - 1)
if (c < seg_eob - 1) {
#if LV_MAP_PROB
is_nz = aom_read_symbol(
r, cm->fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2, ACCT_STR);
#else
is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR);
else
#endif
} else {
is_nz = 1;
}
// set non-zero coefficient map.
tcoeffs[scan[c]] = is_nz;
......@@ -112,7 +125,12 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (counts) ++(*nz_map_count)[coeff_ctx][is_nz];
if (is_nz) {
#if LV_MAP_PROB
int is_eob = aom_read_symbol(
r, cm->fc->eob_flag_cdf[txs_ctx][plane_type][eob_ctx], 2, ACCT_STR);
#else
int is_eob = aom_read(r, eob_flag[eob_ctx], ACCT_STR);
#endif
if (counts) ++counts->eob_flag[txs_ctx][plane_type][eob_ctx][is_eob];
if (is_eob) break;
}
......@@ -123,8 +141,9 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
int i;
for (i = 0; i < NUM_BASE_LEVELS; ++i) {
#if !LV_MAP_PROB
aom_prob *coeff_base = cm->fc->coeff_base[txs_ctx][plane_type][i];
#endif
update_eob = 0;
for (c = *eob - 1; c >= 0; --c) {
tran_low_t *v = &tcoeffs[scan[c]];
......@@ -135,7 +154,14 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
ctx = get_base_ctx(tcoeffs, scan[c], bwl, height, i + 1);
if (aom_read(r, coeff_base[ctx], ACCT_STR)) {
#if LV_MAP_PROB
if (aom_read_symbol(r,
cm->fc->coeff_base_cdf[txs_ctx][plane_type][i][ctx],
2, ACCT_STR))
#else
if (aom_read(r, coeff_base[ctx], ACCT_STR))
#endif
{
*v = i + 1;
cul_level += i + 1;
......@@ -143,8 +169,13 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (c == 0) {
int dc_sign_ctx = txb_ctx->dc_sign_ctx;
#if LV_MAP_PROB
sign = aom_read_symbol(
r, cm->fc->dc_sign_cdf[plane_type][dc_sign_ctx], 2, ACCT_STR);
#else
sign =
aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
#endif
if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign];
} else {
sign = aom_read_bit(r, ACCT_STR);
......@@ -170,7 +201,12 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (c == 0) {
int dc_sign_ctx = txb_ctx->dc_sign_ctx;
#if LV_MAP_PROB
sign = aom_read_symbol(r, cm->fc->dc_sign_cdf[plane_type][dc_sign_ctx], 2,
ACCT_STR);
#else
sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
#endif
if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign];
} else {
sign = aom_read_bit(r, ACCT_STR);
......@@ -181,7 +217,13 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (cm->fc->coeff_lps[txs_ctx][plane_type][ctx] == 0) exit(0);
for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
if (aom_read(r, cm->fc->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR)) {
#if LV_MAP_PROB
if (aom_read_symbol(r, cm->fc->coeff_lps_cdf[txs_ctx][plane_type][ctx], 2,
ACCT_STR))
#else
if (aom_read(r, cm->fc->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR))
#endif
{
*v = (idx + 1 + NUM_BASE_LEVELS);
if (sign) *v = -(*v);
cul_level += abs(*v);
......@@ -283,6 +325,11 @@ void av1_read_txb_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, aom_reader *r) {
const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode];
TX_SIZE tx_size;
int ctx, plane;
#if LV_MAP_PROB
return;
#endif
for (plane = 0; plane < PLANE_TYPES; ++plane)
for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx)
av1_diff_update_prob(r, &fc->dc_sign[plane][ctx], ACCT_STR);
......
......@@ -1762,6 +1762,10 @@ void av1_write_txb_probs(AV1_COMP *cpi, aom_writer *w) {
TX_SIZE tx_size;
int ctx, plane;
#if LV_MAP_PROB
return;
#endif
for (plane = 0; plane < PLANE_TYPES; ++plane)
for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx)
av1_cond_prob_diff_update(w, &cpi->common.fc->dc_sign[plane][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