ref: cd14e03196d3f01e57618c3d1c12d6ce597c8980
parent: e0425bc0ef6013f6f6c0151338905d25019e985d
parent: 5eed74e1d3179b7a6391d22edcab11def38aa2e6
author: Hui Su <[email protected]>
date: Fri Aug 21 19:21:04 EDT 2015
Merge "Refactor get_tx_type and get_scan"
--- a/vp10/common/blockd.h
+++ b/vp10/common/blockd.h
@@ -218,24 +218,16 @@
ADST_ADST, // TM
};
-static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type,
- const MACROBLOCKD *xd) {
- const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-
- if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi))
- return DCT_DCT;
-
- return intra_mode_to_tx_type_lookup[mbmi->mode];
-}
-
-static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
- const MACROBLOCKD *xd, int ib) {
+static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, const MACROBLOCKD *xd,
+ int block_idx) {
const MODE_INFO *const mi = xd->mi[0];
+ const MB_MODE_INFO *const mbmi = &mi->mbmi;
- if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi))
+ if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi) ||
+ mbmi->tx_size >= TX_32X32)
return DCT_DCT;
- return intra_mode_to_tx_type_lookup[get_y_mode(mi, ib)];
+ return intra_mode_to_tx_type_lookup[get_y_mode(mi, block_idx)];
}
void vp10_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y);
--- a/vp10/common/scan.h
+++ b/vp10/common/scan.h
@@ -38,16 +38,8 @@
token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 1;
}
-static INLINE const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size,
- PLANE_TYPE type, int block_idx) {
- const MODE_INFO *const mi = xd->mi[0];
-
- if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless) {
- return &vp10_default_scan_orders[tx_size];
- } else {
- const PREDICTION_MODE mode = get_y_mode(mi, block_idx);
- return &vp10_scan_orders[tx_size][intra_mode_to_tx_type_lookup[mode]];
- }
+static INLINE const scan_order *get_scan(TX_SIZE tx_size, TX_TYPE tx_type) {
+ return &vp10_scan_orders[tx_size][tx_type];
}
#ifdef __cplusplus
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -370,7 +370,9 @@
TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
PREDICTION_MODE mode = (plane == 0) ? mbmi->mode : mbmi->uv_mode;
+ PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
uint8_t *dst;
+ int block_idx = (row << 1) + col;
dst = &pd->dst.buf[4 * row * pd->dst.stride + 4 * col];
if (mbmi->sb_type < BLOCK_8X8)
@@ -382,12 +384,10 @@
col, row, plane);
if (!mbmi->skip) {
- const TX_TYPE tx_type = (plane || xd->lossless) ?
- DCT_DCT : intra_mode_to_tx_type_lookup[mode];
- const scan_order *sc = (plane || xd->lossless) ?
- &vp10_default_scan_orders[tx_size] : &vp10_scan_orders[tx_size][tx_type];
+ TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx);
+ const scan_order *sc = get_scan(tx_size, tx_type);
const int eob = vp10_decode_block_tokens(xd, plane, sc, col, row, tx_size,
- r, mbmi->segment_id);
+ r, mbmi->segment_id);
inverse_transform_block_intra(xd, plane, tx_type, tx_size,
dst, pd->dst.stride, eob);
}
@@ -397,7 +397,10 @@
MB_MODE_INFO *const mbmi, int plane,
int row, int col, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
- const scan_order *sc = &vp10_default_scan_orders[tx_size];
+ PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ int block_idx = (row << 1) + col;
+ TX_TYPE tx_type = get_tx_type(plane_type, xd, block_idx);
+ const scan_order *sc = get_scan(tx_size, tx_type);
const int eob = vp10_decode_block_tokens(xd, plane, sc, col, row, tx_size, r,
mbmi->segment_id);
--- a/vp10/encoder/encodemb.c
+++ b/vp10/encoder/encodemb.c
@@ -104,7 +104,8 @@
const int mul = 1 + (tx_size == TX_32X32);
const int16_t *dequant_ptr = pd->dequant;
const uint8_t *const band_translate = get_band_translate(tx_size);
- const scan_order *const so = get_scan(xd, tx_size, type, block);
+ TX_TYPE tx_type = get_tx_type(type, xd, block);
+ const scan_order *const so = get_scan(tx_size, tx_type);
const int16_t *const scan = so->scan;
const int16_t *const nb = so->neighbors;
int next = eob, sz = 0;
@@ -327,7 +328,9 @@
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
- const scan_order *const scan_order = &vp10_default_scan_orders[tx_size];
+ PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+ const scan_order *const scan_order = get_scan(tx_size, tx_type);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
@@ -498,7 +501,9 @@
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
const struct macroblockd_plane *const pd = &xd->plane[plane];
- const scan_order *const scan_order = &vp10_default_scan_orders[tx_size];
+ PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+ const scan_order *const scan_order = get_scan(tx_size, tx_type);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
@@ -772,8 +777,9 @@
tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
- const scan_order *scan_order;
- TX_TYPE tx_type = DCT_DCT;
+ PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+ const scan_order *const scan_order = get_scan(tx_size, tx_type);
PREDICTION_MODE mode;
const int bwl = b_width_log2_lookup[plane_bsize];
const int diff_stride = 4 * (1 << bwl);
@@ -788,20 +794,7 @@
src = &p->src.buf[4 * (j * src_stride + i)];
src_diff = &p->src_diff[4 * (j * diff_stride + i)];
- if (tx_size == TX_4X4) {
- tx_type = get_tx_type_4x4(pd->plane_type, xd, block);
- scan_order = &vp10_scan_orders[TX_4X4][tx_type];
- mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode;
- } else {
- mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
- if (tx_size == TX_32X32) {
- scan_order = &vp10_default_scan_orders[TX_32X32];
- } else {
- tx_type = get_tx_type(pd->plane_type, xd);
- scan_order = &vp10_scan_orders[tx_size][tx_type];
- }
- }
-
+ mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode;
vp10_predict_intra_block(xd, bwl, tx_size, mode, x->skip_encode ? src : dst,
x->skip_encode ? src_stride : dst_stride,
dst, dst_stride, i, j, plane);
--- a/vp10/encoder/pickmode.c
+++ b/vp10/encoder/pickmode.c
@@ -600,7 +600,9 @@
for (r = 0; r < max_blocks_high; r += block_step) {
for (c = 0; c < num_4x4_w; c += block_step) {
if (c < max_blocks_wide) {
- const scan_order *const scan_order = &vp10_default_scan_orders[tx_size];
+ PLANE_TYPE plane_type = (plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV;
+ TX_TYPE tx_type = get_tx_type(plane_type, xd, block);
+ const scan_order *const scan_order = get_scan(tx_size, tx_type);
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
tran_low_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -557,6 +557,7 @@
int use_fast_coef_casting) {
MACROBLOCKD *const xd = &x->e_mbd;
const struct macroblockd_plane *const pd = &xd->plane[plane];
+ TX_TYPE tx_type;
struct rdcost_block_args args;
vp10_zero(args);
args.x = x;
@@ -569,7 +570,8 @@
vp10_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left);
- args.so = get_scan(xd, tx_size, pd->plane_type, 0);
+ tx_type = get_tx_type(pd->plane_type, xd, 0);
+ args.so = get_scan(tx_size, tx_type);
vp10_foreach_transformed_block_in_plane(xd, bsize, plane,
block_rd_txfm, &args);
@@ -795,7 +797,8 @@
vpx_highbd_subtract_block(4, 4, src_diff, 8, src, src_stride,
dst, dst_stride, xd->bd);
if (xd->lossless) {
- const scan_order *so = &vp10_default_scan_orders[TX_4X4];
+ TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+ const scan_order *so = get_scan(TX_4X4, tx_type);
vp10_highbd_fwht4x4(src_diff, coeff, 8);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
@@ -808,8 +811,8 @@
p->eobs[block], xd->bd);
} else {
int64_t unused;
- const TX_TYPE tx_type = get_tx_type_4x4(PLANE_TYPE_Y, xd, block);
- const scan_order *so = &vp10_scan_orders[TX_4X4][tx_type];
+ TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+ const scan_order *so = get_scan(TX_4X4, tx_type);
if (tx_type == DCT_DCT)
vpx_highbd_fdct4x4(src_diff, coeff, 8);
else
@@ -897,7 +900,8 @@
vpx_subtract_block(4, 4, src_diff, 8, src, src_stride, dst, dst_stride);
if (xd->lossless) {
- const scan_order *so = &vp10_default_scan_orders[TX_4X4];
+ TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+ const scan_order *so = get_scan(TX_4X4, tx_type);
vp10_fwht4x4(src_diff, coeff, 8);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
@@ -909,8 +913,8 @@
p->eobs[block]);
} else {
int64_t unused;
- const TX_TYPE tx_type = get_tx_type_4x4(PLANE_TYPE_Y, xd, block);
- const scan_order *so = &vp10_scan_orders[TX_4X4][tx_type];
+ TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, block);
+ const scan_order *so = get_scan(TX_4X4, tx_type);
vp10_fht4x4(src_diff, coeff, 8, tx_type);
vp10_regular_quantize_b_4x4(x, 0, block, so->scan, so->iscan);
ratey += cost_coeffs(x, 0, block, tempa + idx, templ + idy, TX_4X4,
@@ -1301,7 +1305,8 @@
pd->dst.stride)];
int64_t thisdistortion = 0, thissse = 0;
int thisrate = 0, ref;
- const scan_order *so = &vp10_default_scan_orders[TX_4X4];
+ TX_TYPE tx_type = get_tx_type(PLANE_TYPE_Y, xd, i);
+ const scan_order *so = get_scan(TX_4X4, tx_type);
const int is_compound = has_second_ref(&mi->mbmi);
const InterpKernel *kernel = vp10_filter_kernels[mi->mbmi.interp_filter];
--- a/vp10/encoder/tokenize.c
+++ b/vp10/encoder/tokenize.c
@@ -507,7 +507,8 @@
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
const int segment_id = mbmi->segment_id;
const int16_t *scan, *nb;
- const scan_order *so;
+ const TX_TYPE tx_type = get_tx_type(type, xd, block);
+ const scan_order *const so = get_scan(tx_size, tx_type);
const int ref = is_inter_block(mbmi);
unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
td->rd_counts.coef_counts[tx_size][type][ref];
@@ -524,7 +525,6 @@
pt = get_entropy_context(tx_size, pd->above_context + aoff,
pd->left_context + loff);
- so = get_scan(xd, tx_size, type, block);
scan = so->scan;
nb = so->neighbors;
c = 0;