Refactor tx_size use case in the RD loop Use table access to replace the enum arithmetic computations. Change-Id: I573c301b16f30eb9fa147b3b3ec02af5cdad7444
diff --git a/av1/encoder/encodemb.c b/av1/encoder/encodemb.c index bc1c521..1178282 100644 --- a/av1/encoder/encodemb.c +++ b/av1/encoder/encodemb.c
@@ -928,7 +928,7 @@ const int src_stride = p->src.stride; const int dst_stride = pd->dst.stride; - int tx1d_size = get_tx1d_size(tx_size); + int tx1d_size = tx_size_1d[tx_size]; FWD_TXFM_PARAM fwd_txfm_param; fwd_txfm_param.tx_type = tx_type;
diff --git a/av1/encoder/hybrid_fwd_txfm.h b/av1/encoder/hybrid_fwd_txfm.h index 5afd05f..9cd8c11 100644 --- a/av1/encoder/hybrid_fwd_txfm.h +++ b/av1/encoder/hybrid_fwd_txfm.h
@@ -60,16 +60,6 @@ } #endif // CONFIG_AOM_HIGHBITDEPTH -static INLINE int get_tx1d_size(TX_SIZE tx_size) { - switch (tx_size) { - case TX_32X32: return 32; - case TX_16X16: return 16; - case TX_8X8: return 8; - case TX_4X4: return 4; - default: assert(0); return -1; - } -} - #ifdef __cplusplus } // extern "C" #endif
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index 2f2b598..e7cb214 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -471,7 +471,7 @@ static void dist_block(MACROBLOCK *x, int plane, int block, TX_SIZE tx_size, int64_t *out_dist, int64_t *out_sse) { - const int ss_txfrm_size = tx_size << 1; + const int ss_txfrm_size = 1 << (tx_size_1d_log2[tx_size] << 1); MACROBLOCKD *const xd = &x->e_mbd; const struct macroblock_plane *const p = &x->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane]; @@ -481,12 +481,12 @@ tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); #if CONFIG_AOM_HIGHBITDEPTH const int bd = (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) ? xd->bd : 8; - *out_dist = av1_highbd_block_error(coeff, dqcoeff, 16 << ss_txfrm_size, - &this_sse, bd) >> - shift; + *out_dist = + av1_highbd_block_error(coeff, dqcoeff, ss_txfrm_size, &this_sse, bd) >> + shift; #else *out_dist = - av1_block_error(coeff, dqcoeff, 16 << ss_txfrm_size, &this_sse) >> shift; + av1_block_error(coeff, dqcoeff, ss_txfrm_size, &this_sse) >> shift; #endif // CONFIG_AOM_HIGHBITDEPTH *out_sse = this_sse >> shift; } @@ -517,19 +517,23 @@ &b_args); dist_block(x, plane, block, tx_size, &dist, &sse); } else if (max_txsize_lookup[plane_bsize] == tx_size) { - if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == + if (x->skip_txfm[(plane << 2) + + (block >> (tx_size_1d_in_unit_log2[tx_size] * 2))] == SKIP_TXFM_NONE) { // full forward transform and quantization av1_xform_quant(x, plane, block, blk_row, blk_col, plane_bsize, tx_size); dist_block(x, plane, block, tx_size, &dist, &sse); - } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == - SKIP_TXFM_AC_ONLY) { + } else if (x->skip_txfm[(plane << 2) + + (block >> (tx_size_1d_in_unit_log2[tx_size] * + 2))] == SKIP_TXFM_AC_ONLY) { // compute DC coefficient tran_low_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block); tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block); av1_xform_quant_dc(x, plane, block, blk_row, blk_col, plane_bsize, tx_size); - sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; + sse = x->bsse[(plane << 2) + + (block >> (tx_size_1d_in_unit_log2[tx_size] * 2))] + << 4; dist = sse; if (x->plane[plane].eobs[block]) { const int64_t orig_sse = (int64_t)coeff[0] * coeff[0]; @@ -546,7 +550,9 @@ // SKIP_TXFM_AC_DC // skip forward transform x->plane[plane].eobs[block] = 0; - sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4; + sse = x->bsse[(plane << 2) + + (block >> (tx_size_1d_in_unit_log2[tx_size] * 2))] + << 4; dist = sse; } } else {