From 29a41206910e665f8195eddfa87d64698eb4882b Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Wed, 5 Apr 2017 11:53:32 -0700 Subject: [PATCH] Make var-tx work with the re-designed cb4x4 Resolve tokenization and bit-stream packing issues in var-tx when the re-designed cb4x4 is enabled. Change-Id: I651f776104679eb7d4d0681f428490f668dc806a --- av1/encoder/bitstream.c | 8 ++++++++ av1/encoder/tokenize.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 5c5599f70..e958d41ff 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c @@ -2333,7 +2333,12 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile, const struct macroblockd_plane *const pd = &xd->plane[plane]; BLOCK_SIZE bsize = mbmi->sb_type; #if CONFIG_CB4X4 +#if CONFIG_CHROMA_2X2 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); +#else + const BLOCK_SIZE plane_bsize = + AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd)); +#endif #else const BLOCK_SIZE plane_bsize = get_plane_block_size(AOMMAX(bsize, BLOCK_8X8), pd); @@ -2374,6 +2379,9 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile, #endif // CONFIG_RD_DEBUG } else { TX_SIZE tx = get_tx_size(plane, xd); +#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 + tx = AOMMAX(TX_4X4, tx); +#endif const int bkw = tx_size_wide_unit[tx]; const int bkh = tx_size_high_unit[tx]; for (row = 0; row < num_4x4_h; row += bkh) { diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c index 44b09e8c3..f14410e63 100644 --- a/av1/encoder/tokenize.c +++ b/av1/encoder/tokenize.c @@ -710,8 +710,24 @@ void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t, *t = t_backup; for (plane = 0; plane < MAX_MB_PLANE; ++plane) { +#if CONFIG_CB4X4 + if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) { +#if !CONFIG_PVQ + if (!dry_run) { + (*t)->token = EOSB_TOKEN; + (*t)++; + } +#endif + continue; + } +#endif const struct macroblockd_plane *const pd = &xd->plane[plane]; +#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 + const BLOCK_SIZE plane_bsize = + AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd)); +#else const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); +#endif const int mi_width = block_size_wide[plane_bsize] >> tx_size_wide_log2[0]; const int mi_height = block_size_high[plane_bsize] >> tx_size_wide_log2[0]; const TX_SIZE max_tx_size = max_txsize_rect_lookup[plane_bsize];