summaryrefslogtreecommitdiff
path: root/vp10
diff options
context:
space:
mode:
authorhui su <huisu@google.com>2015-08-18 16:57:07 -0700
committerhui su <huisu@google.com>2015-08-21 09:53:37 -0700
commit5eed74e1d3179b7a6391d22edcab11def38aa2e6 (patch)
treecb87d124b4b38aebbdaf0bc1109db50dba301905 /vp10
parentb1339751b970b286f4019e62ea3eb583b8807326 (diff)
downloadlibvpx-5eed74e1d3179b7a6391d22edcab11def38aa2e6.tar
libvpx-5eed74e1d3179b7a6391d22edcab11def38aa2e6.tar.gz
libvpx-5eed74e1d3179b7a6391d22edcab11def38aa2e6.tar.bz2
libvpx-5eed74e1d3179b7a6391d22edcab11def38aa2e6.zip
Refactor get_tx_type and get_scan
This makes it easier to add new transform types and scan orders to VP10 in the future. Change-Id: I94874ddc9b19928d7820d57e94e2af04adf51efe
Diffstat (limited to 'vp10')
-rw-r--r--vp10/common/blockd.h20
-rw-r--r--vp10/common/scan.h12
-rw-r--r--vp10/decoder/decodeframe.c15
-rw-r--r--vp10/encoder/encodemb.c31
-rw-r--r--vp10/encoder/pickmode.c4
-rw-r--r--vp10/encoder/rdopt.c21
-rw-r--r--vp10/encoder/tokenize.c4
7 files changed, 47 insertions, 60 deletions
diff --git a/vp10/common/blockd.h b/vp10/common/blockd.h
index c9a10262b..26703d167 100644
--- a/vp10/common/blockd.h
+++ b/vp10/common/blockd.h
@@ -218,24 +218,16 @@ static const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES] = {
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);
diff --git a/vp10/common/scan.h b/vp10/common/scan.h
index f3c2a042e..f5a020f1e 100644
--- a/vp10/common/scan.h
+++ b/vp10/common/scan.h
@@ -38,16 +38,8 @@ static INLINE int get_coef_context(const int16_t *neighbors,
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
diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c
index 67f6909e4..22708c673 100644
--- a/vp10/decoder/decodeframe.c
+++ b/vp10/decoder/decodeframe.c
@@ -370,7 +370,9 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
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 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd,
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 @@ static int reconstruct_inter_block(MACROBLOCKD *const xd, vpx_reader *r,
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);
diff --git a/vp10/encoder/encodemb.c b/vp10/encoder/encodemb.c
index 55a96097f..00eb900db 100644
--- a/vp10/encoder/encodemb.c
+++ b/vp10/encoder/encodemb.c
@@ -104,7 +104,8 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
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 @@ void vp10_xform_quant_fp(MACROBLOCK *x, int plane, int block,
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 @@ void vp10_xform_quant(MACROBLOCK *x, int plane, int block,
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 @@ void vp10_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
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 @@ void vp10_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
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);
diff --git a/vp10/encoder/pickmode.c b/vp10/encoder/pickmode.c
index a730b99fa..ef1a06061 100644
--- a/vp10/encoder/pickmode.c
+++ b/vp10/encoder/pickmode.c
@@ -600,7 +600,9 @@ static void block_yrd(VP10_COMP *cpi, MACROBLOCK *x, int *rate, int64_t *dist,
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);
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 5f1ed365d..0272afc65 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -557,6 +557,7 @@ static void txfm_rd_in_plane(MACROBLOCK *x,
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 @@ static void txfm_rd_in_plane(MACROBLOCK *x,
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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
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 @@ static int64_t rd_pick_intra4x4block(VP10_COMP *cpi, MACROBLOCK *x,
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 @@ static int64_t encode_inter_mb_segment(VP10_COMP *cpi,
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];
diff --git a/vp10/encoder/tokenize.c b/vp10/encoder/tokenize.c
index ccfa2b51f..af915feed 100644
--- a/vp10/encoder/tokenize.c
+++ b/vp10/encoder/tokenize.c
@@ -507,7 +507,8 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
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 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
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;