summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDebargha Mukherjee <debargha@google.com>2016-09-01 16:46:32 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-09-01 16:46:32 +0000
commita6bc3dfb0f8e46017d7823985f8383a8dc6cc68b (patch)
treedc8aefe0472c3d339209efa2befd15b3a538b6e4 /vp9
parent009116cb6f7a75645c7c3092f97a5fa4cd42d15b (diff)
parente6446b4b60c7dd3cdeb6cfc3694f9a81df596764 (diff)
downloadlibvpx-a6bc3dfb0f8e46017d7823985f8383a8dc6cc68b.tar
libvpx-a6bc3dfb0f8e46017d7823985f8383a8dc6cc68b.tar.gz
libvpx-a6bc3dfb0f8e46017d7823985f8383a8dc6cc68b.tar.bz2
libvpx-a6bc3dfb0f8e46017d7823985f8383a8dc6cc68b.zip
Merge "Refactor uv tx size with lookup arrays"
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_blockd.h17
-rw-r--r--vp9/common/vp9_common_data.c96
-rw-r--r--vp9/common/vp9_common_data.h1
-rw-r--r--vp9/common/vp9_loopfilter.c4
-rw-r--r--vp9/decoder/vp9_decodeframe.c13
-rw-r--r--vp9/encoder/vp9_rdopt.c8
6 files changed, 110 insertions, 29 deletions
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index 69ba4dc63..780b29208 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -228,20 +228,13 @@ static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
void vp9_setup_block_planes(MACROBLOCKD *xd, int ss_x, int ss_y);
-static INLINE TX_SIZE get_uv_tx_size_impl(TX_SIZE y_tx_size, BLOCK_SIZE bsize,
- int xss, int yss) {
- if (bsize < BLOCK_8X8) {
- return TX_4X4;
- } else {
- const BLOCK_SIZE plane_bsize = ss_size_lookup[bsize][xss][yss];
- return VPXMIN(y_tx_size, max_txsize_lookup[plane_bsize]);
- }
-}
-
static INLINE TX_SIZE get_uv_tx_size(const MODE_INFO *mi,
const struct macroblockd_plane *pd) {
- return get_uv_tx_size_impl(mi->tx_size, mi->sb_type, pd->subsampling_x,
- pd->subsampling_y);
+ assert(mi->sb_type < BLOCK_8X8 ||
+ ss_size_lookup[mi->sb_type][pd->subsampling_x][pd->subsampling_y] !=
+ BLOCK_INVALID);
+ return uv_txsize_lookup[mi->sb_type][mi->tx_size][pd->subsampling_x]
+ [pd->subsampling_y];
}
static INLINE BLOCK_SIZE
diff --git a/vp9/common/vp9_common_data.c b/vp9/common/vp9_common_data.c
index 673072b61..4a1083322 100644
--- a/vp9/common/vp9_common_data.c
+++ b/vp9/common/vp9_common_data.c
@@ -125,6 +125,102 @@ const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = {
{ { BLOCK_64X64, BLOCK_64X32 }, { BLOCK_32X64, BLOCK_32X32 } },
};
+const TX_SIZE uv_txsize_lookup[BLOCK_SIZES][TX_SIZES][2][2] = {
+ // ss_x == 0 ss_x == 0 ss_x == 1 ss_x == 1
+ // ss_y == 0 ss_y == 1 ss_y == 0 ss_y == 1
+ {
+ // BLOCK_4X4
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ },
+ {
+ // BLOCK_4X8
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ },
+ {
+ // BLOCK_8X4
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ },
+ {
+ // BLOCK_8X8
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ },
+ {
+ // BLOCK_8X16
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_4X4, TX_4X4 } },
+ },
+ {
+ // BLOCK_16X8
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_4X4 }, { TX_8X8, TX_4X4 } },
+ { { TX_8X8, TX_4X4 }, { TX_8X8, TX_8X8 } },
+ { { TX_8X8, TX_4X4 }, { TX_8X8, TX_8X8 } },
+ },
+ {
+ // BLOCK_16X16
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ },
+ {
+ // BLOCK_16X32
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_16X16 }, { TX_8X8, TX_8X8 } },
+ },
+ {
+ // BLOCK_32X16
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+ { { TX_16X16, TX_8X8 }, { TX_16X16, TX_8X8 } },
+ },
+ {
+ // BLOCK_32X32
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
+ { { TX_32X32, TX_16X16 }, { TX_16X16, TX_16X16 } },
+ },
+ {
+ // BLOCK_32X64
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
+ { { TX_32X32, TX_32X32 }, { TX_16X16, TX_16X16 } },
+ },
+ {
+ // BLOCK_64X32
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
+ { { TX_32X32, TX_16X16 }, { TX_32X32, TX_16X16 } },
+ },
+ {
+ // BLOCK_64X64
+ { { TX_4X4, TX_4X4 }, { TX_4X4, TX_4X4 } },
+ { { TX_8X8, TX_8X8 }, { TX_8X8, TX_8X8 } },
+ { { TX_16X16, TX_16X16 }, { TX_16X16, TX_16X16 } },
+ { { TX_32X32, TX_32X32 }, { TX_32X32, TX_32X32 } },
+ },
+};
+
// Generates 4 bit field in which each bit set to 1 represents
// a blocksize partition 1111 means we split 64x64, 32x32, 16x16
// and 8x8. 1000 means we just split the 64x64 to 32x32
diff --git a/vp9/common/vp9_common_data.h b/vp9/common/vp9_common_data.h
index 0ae24dad5..5c6a7e8ff 100644
--- a/vp9/common/vp9_common_data.h
+++ b/vp9/common/vp9_common_data.h
@@ -33,6 +33,7 @@ extern const TX_SIZE max_txsize_lookup[BLOCK_SIZES];
extern const BLOCK_SIZE txsize_to_bsize[TX_SIZES];
extern const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES];
extern const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2];
+extern const TX_SIZE uv_txsize_lookup[BLOCK_SIZES][TX_SIZES][2][2];
#if CONFIG_BETTER_HW_COMPATIBILITY && CONFIG_VP9_HIGHBITDEPTH
extern const uint8_t need_top_left[INTRA_MODES];
#endif // CONFIG_BETTER_HW_COMPATIBILITY && CONFIG_VP9_HIGHBITDEPTH
diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c
index 4c06d92cc..d796d7161 100644
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -655,7 +655,7 @@ static void build_masks(const loop_filter_info_n *const lfi_n,
const int shift_uv, LOOP_FILTER_MASK *lfm) {
const BLOCK_SIZE block_size = mi->sb_type;
const TX_SIZE tx_size_y = mi->tx_size;
- const TX_SIZE tx_size_uv = get_uv_tx_size_impl(tx_size_y, block_size, 1, 1);
+ const TX_SIZE tx_size_uv = uv_txsize_lookup[block_size][tx_size_y][1][1];
const int filter_level = get_filter_level(lfi_n, mi);
uint64_t *const left_y = &lfm->left_y[tx_size_y];
uint64_t *const above_y = &lfm->above_y[tx_size_y];
@@ -1524,7 +1524,7 @@ void vp9_build_mask(VP9_COMMON *cm, const MODE_INFO *mi, int mi_row, int mi_col,
const TX_SIZE tx_size_y = mi->tx_size;
const loop_filter_info_n *const lfi_n = &cm->lf_info;
const int filter_level = get_filter_level(lfi_n, mi);
- const TX_SIZE tx_size_uv = get_uv_tx_size_impl(tx_size_y, block_size, 1, 1);
+ const TX_SIZE tx_size_uv = uv_txsize_lookup[block_size][tx_size_y][1][1];
LOOP_FILTER_MASK *const lfm = get_lfm(&cm->lf, mi_row, mi_col);
uint64_t *const left_y = &lfm->left_y[tx_size_y];
uint64_t *const above_y = &lfm->above_y[tx_size_y];
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index 66dbbc62c..af2c900e6 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -712,13 +712,6 @@ static void dec_build_inter_predictors_sb(VP9Decoder *const pbi,
}
}
-static INLINE TX_SIZE dec_get_uv_tx_size(const MODE_INFO *mi, int n4_wl,
- int n4_hl) {
- // get minimum log2 num4x4s dimension
- const int x = VPXMIN(n4_wl, n4_hl);
- return VPXMIN(mi->tx_size, x);
-}
-
static INLINE void dec_reset_skip_context(MACROBLOCKD *xd) {
int i;
for (i = 0; i < MAX_MB_PLANE; i++) {
@@ -799,8 +792,7 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
- const TX_SIZE tx_size =
- plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl) : mi->tx_size;
+ const TX_SIZE tx_size = plane ? get_uv_tx_size(mi, pd) : mi->tx_size;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int step = (1 << tx_size);
@@ -833,8 +825,7 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
- const TX_SIZE tx_size =
- plane ? dec_get_uv_tx_size(mi, pd->n4_wl, pd->n4_hl) : mi->tx_size;
+ const TX_SIZE tx_size = plane ? get_uv_tx_size(mi, pd) : mi->tx_size;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int step = (1 << tx_size);
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 50b365e5d..27d4e9d6d 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2848,8 +2848,8 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost,
return;
}
}
- max_uv_tx_size = get_uv_tx_size_impl(
- xd->mi[0]->tx_size, bsize, pd[1].subsampling_x, pd[1].subsampling_y);
+ max_uv_tx_size = uv_txsize_lookup[bsize][xd->mi[0]->tx_size]
+ [pd[1].subsampling_x][pd[1].subsampling_y];
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv, &rate_uv_tokenonly, &dist_uv,
&uv_skip, VPXMAX(BLOCK_8X8, bsize), max_uv_tx_size);
@@ -3344,8 +3344,8 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, TileDataEnc *tile_data,
best_rd);
if (rate_y == INT_MAX) continue;
- uv_tx = get_uv_tx_size_impl(mi->tx_size, bsize, pd->subsampling_x,
- pd->subsampling_y);
+ uv_tx = uv_txsize_lookup[bsize][mi->tx_size][pd->subsampling_x]
+ [pd->subsampling_y];
if (rate_uv_intra[uv_tx] == INT_MAX) {
choose_intra_uv_mode(cpi, x, ctx, bsize, uv_tx, &rate_uv_intra[uv_tx],
&rate_uv_tokenonly[uv_tx], &dist_uv[uv_tx],