From c20dc8ebc2a2313caa0de00bf8af03e29bf31be9 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Fri, 17 Feb 2017 15:37:28 -0800 Subject: [PATCH] Sync sub8x8 chroma component decoding process Process sub8x8 chroma component decoding in the unit of 4x4 block. Change-Id: I02e149f6076cdb5942b8a0a0b9ac2d833b1a7e49 --- av1/common/onyxc_int.h | 3 +++ av1/common/reconinter.c | 5 +++++ av1/decoder/decodeframe.c | 17 +++++++++++++++-- av1/encoder/bitstream.c | 9 +++++++++ av1/encoder/tokenize.c | 10 ++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h index f29a232ad..fd70332bf 100644 --- a/av1/common/onyxc_int.h +++ b/av1/common/onyxc_int.h @@ -584,6 +584,9 @@ static INLINE void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh) { xd->plane[i].width = (bw * MI_SIZE) >> xd->plane[i].subsampling_x; xd->plane[i].height = (bh * MI_SIZE) >> xd->plane[i].subsampling_y; + + xd->plane[i].width = AOMMAX(xd->plane[i].width, 4); + xd->plane[i].height = AOMMAX(xd->plane[i].height, 4); } } diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c index f7143cb6e..cae92a605 100644 --- a/av1/common/reconinter.c +++ b/av1/common/reconinter.c @@ -1085,6 +1085,11 @@ static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize, const int bw = pd->width; const int bh = pd->height; +#if CONFIG_CB4X4 + if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) + continue; +#endif + if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8 && !unify_bsize) { const PARTITION_TYPE bp = bsize - xd->mi[0]->mbmi.sb_type; const int have_vsplit = bp != PARTITION_HORZ; diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index d791ac8ae..b9cb37a5e 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c @@ -1659,7 +1659,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, const int stepr = tx_size_high_unit[tx_size]; const int stepc = tx_size_wide_unit[tx_size]; #if CONFIG_CB4X4 - const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); + const BLOCK_SIZE plane_bsize = + AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd)); #else const BLOCK_SIZE plane_bsize = get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd); @@ -1668,6 +1669,11 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane); +#if CONFIG_CB4X4 + if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) + continue; +#endif + for (row = 0; row < max_blocks_high; row += stepr) for (col = 0; col < max_blocks_wide; col += stepc) predict_and_reconstruct_intra_block(cm, xd, r, mbmi, plane, row, col, @@ -1738,7 +1744,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, for (plane = 0; plane < MAX_MB_PLANE; ++plane) { const struct macroblockd_plane *const pd = &xd->plane[plane]; #if CONFIG_CB4X4 - const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); + const BLOCK_SIZE plane_bsize = + AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd)); #else const BLOCK_SIZE plane_bsize = get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd); @@ -1746,6 +1753,12 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane); int row, col; + +#if CONFIG_CB4X4 + if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) + continue; +#endif + #if CONFIG_VAR_TX const TX_SIZE max_tx_size = max_txsize_rect_lookup[plane_bsize]; const int bh_var_tx = tx_size_high_unit[max_tx_size]; diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 410686042..7830ba912 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c @@ -2151,6 +2151,15 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile, assert(*tok < tok_end); for (plane = 0; plane < MAX_MB_PLANE; ++plane) { MB_MODE_INFO *mbmi = &m->mbmi; + +#if CONFIG_CB4X4 + if (mbmi->sb_type < BLOCK_8X8 && plane && + !is_chroma_reference(mi_row, mi_col)) { + (*tok)++; + continue; + } +#endif + #if CONFIG_VAR_TX const struct macroblockd_plane *const pd = &xd->plane[plane]; BLOCK_SIZE bsize = mbmi->sb_type; diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c index d05dff595..bf0dff9fd 100644 --- a/av1/encoder/tokenize.c +++ b/av1/encoder/tokenize.c @@ -816,6 +816,16 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t, td->counts->skip[ctx][0] += skip_inc; for (plane = 0; plane < MAX_MB_PLANE; ++plane) { +#if CONFIG_CB4X4 + if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) { + (*t)->token = EOSB_TOKEN; + (*t)++; + continue; + } +#else + (void)mi_row; + (void)mi_col; +#endif av1_foreach_transformed_block_in_plane(xd, bsize, plane, tokenize_b, &arg); (*t)->token = EOSB_TOKEN; -- GitLab