Rework txfm_above and txfm_left context offset Make the txfm_above and txfm_left be processed in the unit of miniumum transform block size. Scale the transform block step size with respect to the mode_info step size. Change-Id: Iee4421e005db742cd4ff7899215560063e5f68e5
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 0a6e83c..2525c4c 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c
@@ -362,22 +362,22 @@ const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0); - int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, + int ctx = txfm_partition_context(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, mbmi->sb_type, tx_size); if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (depth == MAX_VARTX_DEPTH) { - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, tx_size, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, tx_size, tx_size); return; } if (tx_size == mbmi->inter_tx_size[tx_row][tx_col]) { aom_write(w, 0, cm->fc->txfm_partition_prob[ctx]); - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, tx_size, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, tx_size, tx_size); } else { const TX_SIZE sub_txs = sub_tx_size_map[tx_size]; const int bsl = tx_size_wide_unit[sub_txs]; @@ -386,8 +386,8 @@ aom_write(w, 1, cm->fc->txfm_partition_prob[ctx]); if (tx_size == TX_8X8) { - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, sub_txs, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, sub_txs, tx_size); return; } @@ -2282,9 +2282,10 @@ mi_row, mi_col, w); } else { #if CONFIG_VAR_TX - xd->above_txfm_context = cm->above_txfm_context + mi_col; - xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->above_txfm_context = + cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2); + xd->left_txfm_context = xd->left_txfm_context_buffer + + ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2); #endif #if CONFIG_DUAL_FILTER // has_subpel_mv_component needs the ref frame buffers set up to look
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index b2917c6..0465ba8 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -275,9 +275,10 @@ set_mode_info_offsets(cpi, x, xd, mi_row, mi_col); set_skip_context(xd, mi_row, mi_col); #if CONFIG_VAR_TX - xd->above_txfm_context = cm->above_txfm_context + mi_col; - xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->above_txfm_context = + cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2); + xd->left_txfm_context = xd->left_txfm_context_buffer + + ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2); xd->max_tx_size = max_txsize_lookup[bsize]; #endif @@ -1761,8 +1762,8 @@ #if CONFIG_VAR_TX TXFM_CONTEXT *p_ta; TXFM_CONTEXT *p_tl; - TXFM_CONTEXT ta[MAX_MIB_SIZE]; - TXFM_CONTEXT tl[MAX_MIB_SIZE]; + TXFM_CONTEXT ta[2 * MAX_MIB_SIZE]; + TXFM_CONTEXT tl[2 * MAX_MIB_SIZE]; #endif } RD_SEARCH_MACROBLOCK_CONTEXT; @@ -1803,9 +1804,9 @@ xd->above_txfm_context = ctx->p_ta; xd->left_txfm_context = ctx->p_tl; memcpy(xd->above_txfm_context, ctx->ta, - sizeof(*xd->above_txfm_context) * mi_width); + sizeof(*xd->above_txfm_context) * (mi_width << TX_UNIT_WIDE_LOG2)); memcpy(xd->left_txfm_context, ctx->tl, - sizeof(*xd->left_txfm_context) * mi_height); + sizeof(*xd->left_txfm_context) * (mi_height << TX_UNIT_HIGH_LOG2)); #endif #if CONFIG_PVQ od_encode_rollback(&x->daala_enc, rdo_buf); @@ -1848,9 +1849,9 @@ sizeof(xd->left_seg_context[0]) * mi_height); #if CONFIG_VAR_TX memcpy(ctx->ta, xd->above_txfm_context, - sizeof(*xd->above_txfm_context) * mi_width); + sizeof(*xd->above_txfm_context) * (mi_width << TX_UNIT_WIDE_LOG2)); memcpy(ctx->tl, xd->left_txfm_context, - sizeof(*xd->left_txfm_context) * mi_height); + sizeof(*xd->left_txfm_context) * (mi_height << TX_UNIT_HIGH_LOG2)); ctx->p_ta = xd->above_txfm_context; ctx->p_tl = xd->left_txfm_context; #endif @@ -2265,9 +2266,10 @@ pc_tree->partitioning = partition; #if CONFIG_VAR_TX - xd->above_txfm_context = cm->above_txfm_context + mi_col; - xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->above_txfm_context = + cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2); + xd->left_txfm_context = xd->left_txfm_context_buffer + + ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2); #endif #if !CONFIG_PVQ save_context(x, &x_ctx, mi_row, mi_col, bsize); @@ -3281,9 +3283,10 @@ } #if CONFIG_VAR_TX - xd->above_txfm_context = cm->above_txfm_context + mi_col; - xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->above_txfm_context = + cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2); + xd->left_txfm_context = xd->left_txfm_context_buffer + + ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2); #endif #if !CONFIG_PVQ save_context(x, &x_ctx, mi_row, mi_col, bsize); @@ -5245,8 +5248,8 @@ const int tx_col = blk_col >> 1; const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0); - int ctx = txfm_partition_context(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, + int ctx = txfm_partition_context(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, mbmi->sb_type, tx_size); const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col]; @@ -5255,8 +5258,8 @@ if (tx_size == plane_tx_size) { ++counts->txfm_partition[ctx][0]; mbmi->tx_size = tx_size; - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, tx_size, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, tx_size, tx_size); } else { const TX_SIZE sub_txs = sub_tx_size_map[tx_size]; const int bs = tx_size_wide_unit[sub_txs]; @@ -5268,8 +5271,8 @@ if (tx_size == TX_8X8) { mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4; mbmi->tx_size = TX_4X4; - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, TX_4X4, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, TX_4X4, tx_size); return; } @@ -5293,9 +5296,10 @@ const int bw = tx_size_wide_unit[max_tx_size]; int idx, idy; - xd->above_txfm_context = cm->above_txfm_context + mi_col; - xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->above_txfm_context = + cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2); + xd->left_txfm_context = xd->left_txfm_context_buffer + + ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2); for (idy = 0; idy < mi_height; idy += bh) for (idx = 0; idx < mi_width; idx += bw) @@ -5316,8 +5320,8 @@ if (tx_size == plane_tx_size) { mbmi->tx_size = tx_size; - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, tx_size, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, tx_size, tx_size); } else { const TX_SIZE sub_txs = sub_tx_size_map[tx_size]; @@ -5327,8 +5331,8 @@ if (tx_size == TX_8X8) { mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4; mbmi->tx_size = TX_4X4; - txfm_partition_update(xd->above_txfm_context + tx_col, - xd->left_txfm_context + tx_row, TX_4X4, tx_size); + txfm_partition_update(xd->above_txfm_context + blk_col, + xd->left_txfm_context + blk_row, TX_4X4, tx_size); return; } @@ -5351,9 +5355,10 @@ const int bw = tx_size_wide_unit[max_tx_size]; int idx, idy; - xd->above_txfm_context = cm->above_txfm_context + mi_col; - xd->left_txfm_context = - xd->left_txfm_context_buffer + (mi_row & MAX_MIB_MASK); + xd->above_txfm_context = + cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2); + xd->left_txfm_context = xd->left_txfm_context_buffer + + ((mi_row & MAX_MIB_MASK) << TX_UNIT_HIGH_LOG2); for (idy = 0; idy < mi_height; idy += bh) for (idx = 0; idx < mi_width; idx += bw)
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 561e425..2a02d76 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -4046,9 +4046,8 @@ ENTROPY_CONTEXT *pta = ta + blk_col; ENTROPY_CONTEXT *ptl = tl + blk_row; int coeff_ctx, i; - int ctx = - txfm_partition_context(tx_above + (blk_col >> 1), - tx_left + (blk_row >> 1), mbmi->sb_type, tx_size); + int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row, + mbmi->sb_type, tx_size); int64_t sum_rd = INT64_MAX; int tmp_eob = 0; int zero_blk_rate; @@ -4152,8 +4151,8 @@ int idx, idy; for (i = 0; i < tx_size_wide_unit[tx_size]; ++i) pta[i] = !(tmp_eob == 0); for (i = 0; i < tx_size_high_unit[tx_size]; ++i) ptl[i] = !(tmp_eob == 0); - txfm_partition_update(tx_above + (blk_col >> 1), tx_left + (blk_row >> 1), - tx_size, tx_size); + txfm_partition_update(tx_above + blk_col, tx_left + blk_row, tx_size, + tx_size); inter_tx_size[0][0] = tx_size; for (idy = 0; idy < tx_size_high_unit[tx_size] / 2; ++idy) for (idx = 0; idx < tx_size_wide_unit[tx_size] / 2; ++idx) @@ -4192,17 +4191,15 @@ int step = tx_size_wide_unit[max_tx_size] * tx_size_high_unit[max_tx_size]; ENTROPY_CONTEXT ctxa[2 * MAX_MIB_SIZE]; ENTROPY_CONTEXT ctxl[2 * MAX_MIB_SIZE]; - TXFM_CONTEXT tx_above[MAX_MIB_SIZE]; - TXFM_CONTEXT tx_left[MAX_MIB_SIZE]; + TXFM_CONTEXT tx_above[MAX_MIB_SIZE * 2]; + TXFM_CONTEXT tx_left[MAX_MIB_SIZE * 2]; RD_STATS pn_rd_stats; av1_init_rd_stats(&pn_rd_stats); av1_get_entropy_contexts(bsize, 0, pd, ctxa, ctxl); - memcpy(tx_above, xd->above_txfm_context, - sizeof(TXFM_CONTEXT) * (mi_width >> 1)); - memcpy(tx_left, xd->left_txfm_context, - sizeof(TXFM_CONTEXT) * (mi_height >> 1)); + memcpy(tx_above, xd->above_txfm_context, sizeof(TXFM_CONTEXT) * mi_width); + memcpy(tx_left, xd->left_txfm_context, sizeof(TXFM_CONTEXT) * mi_height); for (idy = 0; idy < mi_height; idy += bh) { for (idx = 0; idx < mi_width; idx += bw) {