diff options
Diffstat (limited to 'third_party/aom/av1/decoder/decodetxb.c')
-rw-r--r-- | third_party/aom/av1/decoder/decodetxb.c | 90 |
1 files changed, 48 insertions, 42 deletions
diff --git a/third_party/aom/av1/decoder/decodetxb.c b/third_party/aom/av1/decoder/decodetxb.c index 90685a18d..6e38427b3 100644 --- a/third_party/aom/av1/decoder/decodetxb.c +++ b/third_party/aom/av1/decoder/decodetxb.c @@ -42,14 +42,14 @@ static int read_golomb(MACROBLOCKD *xd, aom_reader *r) { } uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, - aom_reader *r, int block, int plane, - tran_low_t *tcoeffs, TXB_CTX *txb_ctx, - int16_t *max_scan_line, int *eob) { + aom_reader *r, int blk_row, int blk_col, int block, + int plane, tran_low_t *tcoeffs, TXB_CTX *txb_ctx, + TX_SIZE tx_size, int16_t *max_scan_line, int *eob) { FRAME_COUNTS *counts = xd->counts; - TX_SIZE tx_size = get_tx_size(plane, xd); + TX_SIZE txs_ctx = get_txsize_context(tx_size); PLANE_TYPE plane_type = get_plane_type(plane); - aom_prob *nz_map = cm->fc->nz_map[tx_size][plane_type]; - aom_prob *eob_flag = cm->fc->eob_flag[tx_size][plane_type]; + aom_prob *nz_map = cm->fc->nz_map[txs_ctx][plane_type]; + aom_prob *eob_flag = cm->fc->eob_flag[txs_ctx][plane_type]; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int seg_eob = tx_size_2d[tx_size]; int c = 0; @@ -57,40 +57,47 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, const int16_t *const dequant = xd->plane[plane].seg_dequant[mbmi->segment_id]; const int shift = av1_get_tx_scale(tx_size); const int bwl = b_width_log2_lookup[txsize_to_bsize[tx_size]] + 2; + const int height = tx_size_high[tx_size]; int cul_level = 0; unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2]; - uint8_t txb_mask[32 * 32] = { 0 }; - nz_map_count = (counts) ? &counts->nz_map[tx_size][plane_type] : NULL; + nz_map_count = (counts) ? &counts->nz_map[txs_ctx][plane_type] : NULL; memset(tcoeffs, 0, sizeof(*tcoeffs) * seg_eob); int all_zero = - aom_read(r, cm->fc->txb_skip[tx_size][txb_ctx->txb_skip_ctx], ACCT_STR); + aom_read(r, cm->fc->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx], ACCT_STR); if (xd->counts) - ++xd->counts->txb_skip[tx_size][txb_ctx->txb_skip_ctx][all_zero]; + ++xd->counts->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx][all_zero]; *eob = 0; if (all_zero) { *max_scan_line = 0; +#if CONFIG_TXK_SEL + if (plane == 0) mbmi->txk_type[(blk_row << 4) + blk_col] = DCT_DCT; +#endif return 0; } + (void)blk_row; + (void)blk_col; #if CONFIG_TXK_SEL - av1_read_tx_type(cm, xd, block, plane, r); + av1_read_tx_type(cm, xd, blk_row, blk_col, block, plane, + get_min_tx_size(tx_size), r); #endif - 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 TX_TYPE tx_type = + av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size); + const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const int16_t *scan = scan_order->scan; + const int16_t *iscan = scan_order->iscan; for (c = 0; c < seg_eob; ++c) { int is_nz; - int coeff_ctx = get_nz_map_ctx(tcoeffs, txb_mask, scan[c], bwl); - int eob_ctx = get_eob_ctx(tcoeffs, scan[c], bwl); + 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) - is_nz = aom_read(r, nz_map[coeff_ctx], tx_size); + is_nz = aom_read(r, nz_map[coeff_ctx], ACCT_STR); else is_nz = 1; @@ -105,11 +112,10 @@ 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) { - int is_eob = aom_read(r, eob_flag[eob_ctx], tx_size); - if (counts) ++counts->eob_flag[tx_size][plane_type][eob_ctx][is_eob]; + int is_eob = aom_read(r, eob_flag[eob_ctx], ACCT_STR); + if (counts) ++counts->eob_flag[txs_ctx][plane_type][eob_ctx][is_eob]; if (is_eob) break; } - txb_mask[scan[c]] = 1; } *eob = AOMMIN(seg_eob, c + 1); @@ -117,7 +123,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, int i; for (i = 0; i < NUM_BASE_LEVELS; ++i) { - aom_prob *coeff_base = cm->fc->coeff_base[tx_size][plane_type][i]; + aom_prob *coeff_base = cm->fc->coeff_base[txs_ctx][plane_type][i]; update_eob = 0; for (c = *eob - 1; c >= 0; --c) { @@ -127,17 +133,18 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, if (*v <= i) continue; - ctx = get_base_ctx(tcoeffs, scan[c], bwl, i + 1); + ctx = get_base_ctx(tcoeffs, scan[c], bwl, height, i + 1); - if (aom_read(r, coeff_base[ctx], tx_size)) { + if (aom_read(r, coeff_base[ctx], ACCT_STR)) { *v = i + 1; cul_level += i + 1; - if (counts) ++counts->coeff_base[tx_size][plane_type][i][ctx][1]; + if (counts) ++counts->coeff_base[txs_ctx][plane_type][i][ctx][1]; if (c == 0) { int dc_sign_ctx = txb_ctx->dc_sign_ctx; - sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], tx_size); + sign = + aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR); if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign]; } else { sign = aom_read_bit(r, ACCT_STR); @@ -146,7 +153,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, continue; } *v = i + 2; - if (counts) ++counts->coeff_base[tx_size][plane_type][i][ctx][0]; + if (counts) ++counts->coeff_base[txs_ctx][plane_type][i][ctx][0]; // update the eob flag for coefficients with magnitude above 1. update_eob = AOMMAX(update_eob, c); @@ -163,26 +170,26 @@ 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; - sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], tx_size); + sign = aom_read(r, cm->fc->dc_sign[plane_type][dc_sign_ctx], ACCT_STR); if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][sign]; } else { sign = aom_read_bit(r, ACCT_STR); } - ctx = get_br_ctx(tcoeffs, scan[c], bwl); + ctx = get_br_ctx(tcoeffs, scan[c], bwl, height); - if (cm->fc->coeff_lps[tx_size][plane_type][ctx] == 0) exit(0); + 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[tx_size][plane_type][ctx], tx_size)) { + if (aom_read(r, cm->fc->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR)) { *v = (idx + 1 + NUM_BASE_LEVELS); if (sign) *v = -(*v); cul_level += abs(*v); - if (counts) ++counts->coeff_lps[tx_size][plane_type][ctx][1]; + if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][1]; break; } - if (counts) ++counts->coeff_lps[tx_size][plane_type][ctx][0]; + if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][0]; } if (idx < COEFF_BASE_RANGE) continue; @@ -211,32 +218,31 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, uint8_t av1_read_coeffs_txb_facade(AV1_COMMON *cm, MACROBLOCKD *xd, aom_reader *r, int row, int col, int block, int plane, tran_low_t *tcoeffs, - int16_t *max_scan_line, int *eob) { + TX_SIZE tx_size, int16_t *max_scan_line, + int *eob) { MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct macroblockd_plane *pd = &xd->plane[plane]; const BLOCK_SIZE bsize = mbmi->sb_type; -#if CONFIG_CB4X4 -#if CONFIG_CHROMA_2X2 - const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); -#else +#if CONFIG_CHROMA_SUB8X8 const BLOCK_SIZE plane_bsize = AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd)); -#endif // CONFIG_CHROMA_2X2 +#elif CONFIG_CB4X4 + const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); #else // CONFIG_CB4X4 const BLOCK_SIZE plane_bsize = get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd); #endif // CONFIG_CB4X4 - TX_SIZE tx_size = get_tx_size(plane, xd); TXB_CTX txb_ctx; get_txb_ctx(plane_bsize, tx_size, plane, pd->above_context + col, pd->left_context + row, &txb_ctx); - uint8_t cul_level = av1_read_coeffs_txb(cm, xd, r, block, plane, tcoeffs, - &txb_ctx, max_scan_line, eob); + uint8_t cul_level = + av1_read_coeffs_txb(cm, xd, r, row, col, block, plane, tcoeffs, &txb_ctx, + tx_size, max_scan_line, eob); #if CONFIG_ADAPT_SCAN PLANE_TYPE plane_type = get_plane_type(plane); - TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); + TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, row, col, block, tx_size); if (xd->counts && *eob > 0) av1_update_scan_count_facade(cm, xd->counts, tx_size, tx_type, pd->dqcoeff, *eob); |