Implement update_txb_context for lv_map Change-Id: I6bedc3a1a40e551ce4b3989382b7706a589c08f2
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index bf0ad2a..a7e4e71 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c
@@ -378,14 +378,35 @@ BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) { TxbParams *const args = arg; + const AV1_COMP *cpi = args->cpi; + const AV1_COMMON *cm = &cpi->common; ThreadData *const td = args->td; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct macroblock_plane *p = &x->plane[plane]; struct macroblockd_plane *pd = &xd->plane[plane]; + const uint16_t eob = p->eobs[block]; + const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); + const PLANE_TYPE plane_type = pd->plane_type; + const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); + const SCAN_ORDER *const scan_order = + get_scan(cm, tx_size, tx_type, is_inter_block(mbmi)); + const int16_t *scan = scan_order->scan; (void)plane_bsize; - av1_set_contexts(xd, pd, plane, tx_size, p->eobs[block] > 0, blk_col, - blk_row); + + int cul_level = 0; + int c; + for (c = 0; c < eob; ++c) { + cul_level += abs(qcoeff[scan[c]]); + } + + cul_level = AOMMIN(COEFF_CONTEXT_MASK, cul_level); + + // DC value + set_dc_sign(&cul_level, qcoeff[0]); + + av1_set_contexts(xd, pd, plane, tx_size, cul_level, blk_col, blk_row); } static void update_and_record_txb_context(int plane, int block, int blk_row, @@ -508,7 +529,8 @@ // use 0-th order Golomb code to handle the residual level. } - cul_level = AOMMIN(63, cul_level); + + cul_level = AOMMIN(COEFF_CONTEXT_MASK, cul_level); // DC value set_dc_sign(&cul_level, tcoeff[0]);