Commit 19b5c8fa authored by Jingning Han's avatar Jingning Han
Browse files

Rework txk_type indexing system for chroma component

Use the row and column indexes to fetch txk_type, which allows the
chroma components to derive the tx type from the corresponding luma
components. It improves the coding performance of txk-sel by 0.18%.

Change-Id: I3f4bca5839e13ae95e51053e76cd86fe58202ac9
parent a5378e73
...@@ -1114,11 +1114,12 @@ static INLINE TX_TYPE get_default_tx_type(PLANE_TYPE plane_type, ...@@ -1114,11 +1114,12 @@ static INLINE TX_TYPE get_default_tx_type(PLANE_TYPE plane_type,
} }
static INLINE TX_TYPE av1_get_tx_type(PLANE_TYPE plane_type, static INLINE TX_TYPE av1_get_tx_type(PLANE_TYPE plane_type,
const MACROBLOCKD *xd, int block, const MACROBLOCKD *xd, int blk_row,
TX_SIZE tx_size) { int blk_col, int block, TX_SIZE tx_size) {
const MODE_INFO *const mi = xd->mi[0]; const MODE_INFO *const mi = xd->mi[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi; const MB_MODE_INFO *const mbmi = &mi->mbmi;
(void)blk_row;
(void)blk_col;
#if CONFIG_INTRABC && (!CONFIG_EXT_TX || CONFIG_TXK_SEL) #if CONFIG_INTRABC && (!CONFIG_EXT_TX || CONFIG_TXK_SEL)
// TODO(aconverse@google.com): Handle INTRABC + EXT_TX + TXK_SEL // TODO(aconverse@google.com): Handle INTRABC + EXT_TX + TXK_SEL
if (is_intrabc_block(mbmi)) return DCT_DCT; if (is_intrabc_block(mbmi)) return DCT_DCT;
...@@ -1126,11 +1127,15 @@ static INLINE TX_TYPE av1_get_tx_type(PLANE_TYPE plane_type, ...@@ -1126,11 +1127,15 @@ static INLINE TX_TYPE av1_get_tx_type(PLANE_TYPE plane_type,
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
TX_TYPE tx_type; TX_TYPE tx_type;
if (plane_type != PLANE_TYPE_Y || xd->lossless[mbmi->segment_id] || if (xd->lossless[mbmi->segment_id] || txsize_sqr_map[tx_size] >= TX_32X32) {
txsize_sqr_map[tx_size] >= TX_32X32) {
tx_type = DCT_DCT; tx_type = DCT_DCT;
} else { } else {
tx_type = mbmi->txk_type[block]; if (plane_type == PLANE_TYPE_Y)
tx_type = mbmi->txk_type[(blk_row << 4) + blk_col];
else if (is_inter_block(mbmi))
tx_type = mbmi->txk_type[(blk_row << 5) + (blk_col << 1)];
else
tx_type = intra_mode_to_tx_type_context[mbmi->uv_mode];
} }
assert(tx_type >= DCT_DCT && tx_type < TX_TYPES); assert(tx_type >= DCT_DCT && tx_type < TX_TYPES);
return tx_type; return tx_type;
......
...@@ -2125,7 +2125,8 @@ void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block, ...@@ -2125,7 +2125,8 @@ void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd); const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const int dst_stride = pd->dst.stride; const int dst_stride = pd->dst.stride;
uint8_t *dst = uint8_t *dst =
&pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]]; &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]];
......
...@@ -610,9 +610,11 @@ static void predict_and_reconstruct_intra_block( ...@@ -610,9 +610,11 @@ static void predict_and_reconstruct_intra_block(
av1_read_coeffs_txb_facade(cm, xd, r, row, col, block_idx, plane, av1_read_coeffs_txb_facade(cm, xd, r, row, col, block_idx, plane,
pd->dqcoeff, tx_size, &max_scan_line, &eob); pd->dqcoeff, tx_size, &max_scan_line, &eob);
// tx_type will be read out in av1_read_coeffs_txb_facade // tx_type will be read out in av1_read_coeffs_txb_facade
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block_idx, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
#else // CONFIG_LV_MAP #else // CONFIG_LV_MAP
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block_idx, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
int16_t max_scan_line = 0; int16_t max_scan_line = 0;
const int eob = const int eob =
...@@ -643,7 +645,8 @@ static void predict_and_reconstruct_intra_block( ...@@ -643,7 +645,8 @@ static void predict_and_reconstruct_intra_block(
#endif // CONFIG_DPCM_INTRA #endif // CONFIG_DPCM_INTRA
} }
#else // !CONFIG_PVQ #else // !CONFIG_PVQ
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block_idx, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
av1_pvq_decode_helper2(cm, xd, mbmi, plane, row, col, tx_size, tx_type); av1_pvq_decode_helper2(cm, xd, mbmi, plane, row, col, tx_size, tx_type);
#endif // !CONFIG_PVQ #endif // !CONFIG_PVQ
} }
...@@ -693,10 +696,10 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -693,10 +696,10 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
pd->dqcoeff, tx_size, &max_scan_line, &eob); pd->dqcoeff, tx_size, &max_scan_line, &eob);
// tx_type will be read out in av1_read_coeffs_txb_facade // tx_type will be read out in av1_read_coeffs_txb_facade
const TX_TYPE tx_type = const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, block, plane_tx_size); av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, plane_tx_size);
#else // CONFIG_LV_MAP #else // CONFIG_LV_MAP
const TX_TYPE tx_type = const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, block, plane_tx_size); av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, plane_tx_size);
const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, mbmi); const SCAN_ORDER *sc = get_scan(cm, plane_tx_size, tx_type, mbmi);
int16_t max_scan_line = 0; int16_t max_scan_line = 0;
const int eob = av1_decode_block_tokens( const int eob = av1_decode_block_tokens(
...@@ -759,10 +762,12 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -759,10 +762,12 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
av1_read_coeffs_txb_facade(cm, xd, r, row, col, block_idx, plane, pd->dqcoeff, av1_read_coeffs_txb_facade(cm, xd, r, row, col, block_idx, plane, pd->dqcoeff,
tx_size, &max_scan_line, &eob); tx_size, &max_scan_line, &eob);
// tx_type will be read out in av1_read_coeffs_txb_facade // tx_type will be read out in av1_read_coeffs_txb_facade
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block_idx, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
#else // CONFIG_LV_MAP #else // CONFIG_LV_MAP
int16_t max_scan_line = 0; int16_t max_scan_line = 0;
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block_idx, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
const SCAN_ORDER *scan_order = const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi); get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int eob = const int eob =
...@@ -779,7 +784,8 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -779,7 +784,8 @@ static int reconstruct_inter_block(AV1_COMMON *cm, MACROBLOCKD *const xd,
tx_type, tx_size, dst, pd->dst.stride, tx_type, tx_size, dst, pd->dst.stride,
max_scan_line, eob); max_scan_line, eob);
#else #else
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block_idx, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, row, col, block_idx, tx_size);
eob = av1_pvq_decode_helper2(cm, xd, &xd->mi[0]->mbmi, plane, row, col, eob = av1_pvq_decode_helper2(cm, xd, &xd->mi[0]->mbmi, plane, row, col,
tx_size, tx_type); tx_size, tx_type);
#endif #endif
......
...@@ -985,7 +985,8 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -985,7 +985,8 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd,
int supertx_enabled, int supertx_enabled,
#endif #endif
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
int block, int plane, TX_SIZE tx_size, int blk_row, int blk_col, int block, int plane,
TX_SIZE tx_size,
#endif #endif
aom_reader *r) { aom_reader *r) {
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
...@@ -1004,7 +1005,8 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -1004,7 +1005,8 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd,
#else #else
// only y plane's tx_type is transmitted // only y plane's tx_type is transmitted
if (plane > 0) return; if (plane > 0) return;
TX_TYPE *tx_type = &mbmi->txk_type[block]; (void)block;
TX_TYPE *tx_type = &mbmi->txk_type[(blk_row << 4) + blk_col];
#endif #endif
if (!FIXED_TX_TYPE) { if (!FIXED_TX_TYPE) {
......
...@@ -37,7 +37,8 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -37,7 +37,8 @@ void av1_read_tx_type(const AV1_COMMON *const cm, MACROBLOCKD *xd,
int supertx_enabled, int supertx_enabled,
#endif #endif
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
int block, int plane, TX_SIZE tx_size, int blk_row, int blk_col, int block, int plane,
TX_SIZE tx_size,
#endif #endif
aom_reader *r); aom_reader *r);
......
...@@ -73,15 +73,20 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -73,15 +73,20 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
*eob = 0; *eob = 0;
if (all_zero) { if (all_zero) {
*max_scan_line = 0; *max_scan_line = 0;
#if CONFIG_TXK_SEL
if (plane == 0) mbmi->txk_type[(blk_row << 4) + blk_col] = DCT_DCT;
#endif
return 0; return 0;
} }
(void)blk_row; (void)blk_row;
(void)blk_col; (void)blk_col;
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
av1_read_tx_type(cm, xd, block, plane, get_min_tx_size(tx_size), r); av1_read_tx_type(cm, xd, blk_row, blk_col, block, plane,
get_min_tx_size(tx_size), r);
#endif #endif
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan; const int16_t *scan = scan_order->scan;
const int16_t *iscan = scan_order->iscan; const int16_t *iscan = scan_order->iscan;
......
...@@ -1563,7 +1563,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd, ...@@ -1563,7 +1563,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
const int supertx_enabled, const int supertx_enabled,
#endif #endif
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
int block, int plane, TX_SIZE tx_size, int blk_row, int blk_col, int block, int plane,
TX_SIZE tx_size,
#endif #endif
aom_writer *w) { aom_writer *w) {
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
...@@ -1583,7 +1584,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd, ...@@ -1583,7 +1584,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
// Only y plane's tx_type is transmitted // Only y plane's tx_type is transmitted
if (plane > 0) return; if (plane > 0) return;
PLANE_TYPE plane_type = get_plane_type(plane); PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
#endif #endif
if (!FIXED_TX_TYPE) { if (!FIXED_TX_TYPE) {
......
...@@ -42,7 +42,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd, ...@@ -42,7 +42,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
const int supertx_enabled, const int supertx_enabled,
#endif #endif
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
int block, int plane, TX_SIZE tx_size, int blk_row, int blk_col, int block, int plane,
TX_SIZE tx_size,
#endif #endif
aom_writer *w); aom_writer *w);
......
...@@ -5902,7 +5902,8 @@ void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -5902,7 +5902,8 @@ void av1_update_tx_type_count(const AV1_COMMON *cm, MACROBLOCKD *xd,
(void)blk_col; (void)blk_col;
// Only y plane's tx_type is updated // Only y plane's tx_type is updated
if (plane > 0) return; if (plane > 0) return;
const TX_TYPE tx_type = av1_get_tx_type(PLANE_TYPE_Y, xd, block, tx_size); TX_TYPE tx_type =
av1_get_tx_type(PLANE_TYPE_Y, xd, blk_row, blk_col, block, tx_size);
#endif #endif
#if CONFIG_EXT_TX #if CONFIG_EXT_TX
if (get_ext_tx_types(tx_size, bsize, is_inter, cm->reduced_tx_set_used) > 1 && if (get_ext_tx_types(tx_size, bsize, is_inter, cm->reduced_tx_set_used) > 1 &&
......
...@@ -125,7 +125,8 @@ static INLINE unsigned int get_token_bit_costs( ...@@ -125,7 +125,8 @@ static INLINE unsigned int get_token_bit_costs(
#if !CONFIG_LV_MAP #if !CONFIG_LV_MAP
static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
int block, TX_SIZE tx_size, int ctx) { int blk_row, int blk_col, int block,
TX_SIZE tx_size, int ctx) {
MACROBLOCKD *const xd = &mb->e_mbd; MACROBLOCKD *const xd = &mb->e_mbd;
struct macroblock_plane *const p = &mb->plane[plane]; struct macroblock_plane *const p = &mb->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
...@@ -138,7 +139,8 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, ...@@ -138,7 +139,8 @@ static int optimize_b_greedy(const AV1_COMMON *cm, MACROBLOCK *mb, int plane,
const PLANE_TYPE plane_type = pd->plane_type; const PLANE_TYPE plane_type = pd->plane_type;
const int16_t *const dequant_ptr = pd->dequant; const int16_t *const dequant_ptr = pd->dequant;
const uint8_t *const band_translate = get_band_translate(tx_size); const uint8_t *const band_translate = get_band_translate(tx_size);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *const scan_order = const SCAN_ORDER *const scan_order =
get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi); get_scan(cm, tx_size, tx_type, &xd->mi[0]->mbmi);
const int16_t *const scan = scan_order->scan; const int16_t *const scan = scan_order->scan;
...@@ -458,7 +460,8 @@ int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int blk_row, ...@@ -458,7 +460,8 @@ int av1_optimize_b(const AV1_COMMON *cm, MACROBLOCK *mb, int plane, int blk_row,
#else #else
int ctx = combine_entropy_contexts(*a, *l); int ctx = combine_entropy_contexts(*a, *l);
#endif // CONFIG_VAR_TX #endif // CONFIG_VAR_TX
return optimize_b_greedy(cm, mb, plane, block, tx_size, ctx); return optimize_b_greedy(cm, mb, plane, blk_row, blk_col, block, tx_size,
ctx);
#else // !CONFIG_LV_MAP #else // !CONFIG_LV_MAP
TXB_CTX txb_ctx; TXB_CTX txb_ctx;
get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx); get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
...@@ -508,7 +511,8 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, ...@@ -508,7 +511,8 @@ void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
#endif #endif
PLANE_TYPE plane_type = get_plane_type(plane); PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
#if CONFIG_AOM_QM || CONFIG_NEW_QUANT #if CONFIG_AOM_QM || CONFIG_NEW_QUANT
const int is_inter = is_inter_block(mbmi); const int is_inter = is_inter_block(mbmi);
...@@ -753,7 +757,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col, ...@@ -753,7 +757,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
if (x->pvq_skip[plane]) return; if (x->pvq_skip[plane]) return;
#endif #endif
const TX_TYPE tx_type = av1_get_tx_type(pd->plane_type, xd, block, tx_size); TX_TYPE tx_type =
av1_get_tx_type(pd->plane_type, xd, blk_row, blk_col, block, tx_size);
#if CONFIG_LGT #if CONFIG_LGT
PREDICTION_MODE mode = get_prediction_mode(xd->mi[0], plane, tx_size, block); PREDICTION_MODE mode = get_prediction_mode(xd->mi[0], plane, tx_size, block);
av1_inverse_transform_block(xd, dqcoeff, mode, tx_type, tx_size, dst, av1_inverse_transform_block(xd, dqcoeff, mode, tx_type, tx_size, dst,
...@@ -1345,7 +1350,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col, ...@@ -1345,7 +1350,8 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
PLANE_TYPE plane_type = get_plane_type(plane); PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
uint16_t *eob = &p->eobs[block]; uint16_t *eob = &p->eobs[block];
const int dst_stride = pd->dst.stride; const int dst_stride = pd->dst.stride;
uint8_t *dst = uint8_t *dst =
......
...@@ -78,7 +78,8 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -78,7 +78,8 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE txs_ctx = get_txsize_context(tx_size); const TX_SIZE txs_ctx = get_txsize_context(tx_size);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan; const int16_t *scan = scan_order->scan;
const int16_t *iscan = scan_order->iscan; const int16_t *iscan = scan_order->iscan;
...@@ -96,7 +97,8 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, ...@@ -96,7 +97,8 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (eob == 0) return; if (eob == 0) return;
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
av1_write_tx_type(cm, xd, block, plane, get_min_tx_size(tx_size), w); av1_write_tx_type(cm, xd, blk_row, blk_col, block, plane,
get_min_tx_size(tx_size), w);
#endif #endif
nz_map = cm->fc->nz_map[txs_ctx][plane_type]; nz_map = cm->fc->nz_map[txs_ctx][plane_type];
...@@ -292,9 +294,8 @@ int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane, ...@@ -292,9 +294,8 @@ int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
TX_SIZE txs_ctx = get_txsize_context(tx_size); TX_SIZE txs_ctx = get_txsize_context(tx_size);
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
(void)blk_row; const TX_TYPE tx_type =
(void)blk_col; av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size);
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const struct macroblock_plane *p = &x->plane[plane]; const struct macroblock_plane *p = &x->plane[plane];
const int eob = p->eobs[block]; const int eob = p->eobs[block];
...@@ -1466,9 +1467,8 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane, ...@@ -1466,9 +1467,8 @@ int av1_optimize_txb(const AV1_COMMON *cm, MACROBLOCK *x, int plane,
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE txs_ctx = get_txsize_context(tx_size); const TX_SIZE txs_ctx = get_txsize_context(tx_size);
(void)blk_row; const TX_TYPE tx_type =
(void)blk_col; av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size);
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const struct macroblock_plane *p = &x->plane[plane]; const struct macroblock_plane *p = &x->plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane]; struct macroblockd_plane *pd = &xd->plane[plane];
...@@ -1543,7 +1543,8 @@ void av1_update_txb_context_b(int plane, int block, int blk_row, int blk_col, ...@@ -1543,7 +1543,8 @@ void av1_update_txb_context_b(int plane, int block, int blk_row, int blk_col,
const uint16_t eob = p->eobs[block]; const uint16_t eob = p->eobs[block];
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
const PLANE_TYPE plane_type = pd->plane_type; const PLANE_TYPE plane_type = pd->plane_type;
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
(void)plane_bsize; (void)plane_bsize;
...@@ -1568,7 +1569,8 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row, ...@@ -1568,7 +1569,8 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block); tran_low_t *tcoeff = BLOCK_OFFSET(x->mbmi_ext->tcoeff[plane], block);
const int segment_id = mbmi->segment_id; const int segment_id = mbmi->segment_id;
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, mbmi);
const int16_t *scan = scan_order->scan; const int16_t *scan = scan_order->scan;
const int16_t *iscan = scan_order->iscan; const int16_t *iscan = scan_order->iscan;
...@@ -1876,9 +1878,9 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -1876,9 +1878,9 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_invalid_rd_stats(&best_rd_stats); av1_invalid_rd_stats(&best_rd_stats);
for (tx_type = txk_start; tx_type <= txk_end; ++tx_type) { for (tx_type = txk_start; tx_type <= txk_end; ++tx_type) {
if (plane == 0) mbmi->txk_type[block] = tx_type; if (plane == 0) mbmi->txk_type[(blk_row << 4) + blk_col] = tx_type;
const TX_TYPE ref_tx_type = TX_TYPE ref_tx_type = av1_get_tx_type(get_plane_type(plane), xd, blk_row,
av1_get_tx_type(get_plane_type(plane), xd, block, tx_size); blk_col, block, tx_size);
if (tx_type != ref_tx_type) { if (tx_type != ref_tx_type) {
// use av1_get_tx_type() to check if the tx_type is valid for the current // use av1_get_tx_type() to check if the tx_type is valid for the current
// mode if it's not, we skip it here. // mode if it's not, we skip it here.
...@@ -1908,6 +1910,7 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -1908,6 +1910,7 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size, av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size,
scan_order, a, l, use_fast_coef_costing); scan_order, a, l, use_fast_coef_costing);
int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist); int rd = RDCOST(x->rdmult, this_rd_stats.rate, this_rd_stats.dist);
if (rd < best_rd) { if (rd < best_rd) {
best_rd = rd; best_rd = rd;
best_rd_stats = this_rd_stats; best_rd_stats = this_rd_stats;
...@@ -1918,7 +1921,13 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -1918,7 +1921,13 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_merge_rd_stats(rd_stats, &best_rd_stats); av1_merge_rd_stats(rd_stats, &best_rd_stats);
if (plane == 0) mbmi->txk_type[block] = best_tx_type; // if (x->plane[plane].eobs[block] == 0)
// if (best_tx_type != DCT_DCT)
// exit(0);
if (best_eob == 0 && is_inter_block(mbmi)) best_tx_type = DCT_DCT;
if (plane == 0) mbmi->txk_type[(blk_row << 4) + blk_col] = best_tx_type;
x->plane[plane].txb_entropy_ctx[block] = best_eob; x->plane[plane].txb_entropy_ctx[block] = best_eob;
if (!is_inter_block(mbmi)) { if (!is_inter_block(mbmi)) {
......
...@@ -1745,8 +1745,8 @@ void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane, ...@@ -1745,8 +1745,8 @@ void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
#endif // !CONFIG_PVQ #endif // !CONFIG_PVQ
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
av1_inverse_transform_block(xd, dqcoeff, av1_inverse_transform_block(xd, dqcoeff,
#if CONFIG_LGT #if CONFIG_LGT
xd->mi[0]->mbmi.mode, xd->mi[0]->mbmi.mode,
...@@ -1821,8 +1821,9 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, ...@@ -1821,8 +1821,9 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
av1_block_index_to_raster_order(tx_size, block); av1_block_index_to_raster_order(tx_size, block);
const PREDICTION_MODE mode = const PREDICTION_MODE mode =
(plane == 0) ? get_y_mode(xd->mi[0], block_raster_idx) : mbmi->uv_mode; (plane == 0) ? get_y_mode(xd->mi[0], block_raster_idx) : mbmi->uv_mode;
const TX_TYPE tx_type = av1_get_tx_type( TX_TYPE tx_type =
(plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV, xd, block, tx_size); av1_get_tx_type((plane == 0) ? PLANE_TYPE_Y : PLANE_TYPE_UV, xd,
blk_row, blk_col, block, tx_size);
if (av1_use_dpcm_intra(plane, mode, tx_type, mbmi)) { if (av1_use_dpcm_intra(plane, mode, tx_type, mbmi)) {
int8_t skip; int8_t skip;
av1_encode_block_intra_dpcm(cm, x, mode, plane, block, blk_row, blk_col, av1_encode_block_intra_dpcm(cm, x, mode, plane, block, blk_row, blk_col,
...@@ -1882,7 +1883,8 @@ CALCULATE_RD : {} ...@@ -1882,7 +1883,8 @@ CALCULATE_RD : {}
} }
#if !CONFIG_PVQ #if !CONFIG_PVQ
const PLANE_TYPE plane_type = get_plane_type(plane); const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size); const TX_TYPE tx_type =
av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size);
const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi); const SCAN_ORDER *scan_order = get_scan(cm, tx_size, tx_type, mbmi);
this_rd_stats.rate = this_rd_stats.rate =
av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size, av1_cost_coeffs(cpi, x, plane, blk_row, blk_col, block, tx_size,
...@@ -2462,7 +2464,6 @@ static void choose_tx_size_type_from_rd(const AV1_COMP *const cpi, ...@@ -2462,7 +2464,6 @@ static void choose_tx_size_type_from_rd(const AV1_COMP *const cpi,
TX_TYPE best_tx_type = DCT_DCT; TX_TYPE best_tx_type = DCT_DCT;
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
TX_TYPE best_txk_type[MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; TX_TYPE best_txk_type[MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)];
const int num_blk = bsize_to_num_blk(bs);
#endif // CONFIG_TXK_SEL #endif // CONFIG_TXK_SEL
const int tx_select = cm->tx_mode == TX_MODE_SELECT; const int tx_select = cm->tx_mode == TX_MODE_SELECT;
const int is_inter = is_inter_block(mbmi); const int is_inter = is_inter_block(mbmi);
...@@ -2504,8 +2505,7 @@ static void choose_tx_size_type_from_rd(const AV1_COMP *const cpi, ...@@ -2504,8 +2505,7 @@ static void choose_tx_size_type_from_rd(const AV1_COMP *const cpi,
rect_tx_size); rect_tx_size);
if (rd < best_rd) { if (rd < best_rd) {
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
memcpy(best_txk_type, mbmi->txk_type, memcpy(best_txk_type, mbmi->txk_type, sizeof(best_txk_type[0]) * 256);
sizeof(best_txk_type[0]) * num_blk);
#endif #endif
best_tx_type = tx_type; best_tx_type = tx_type;
best_tx_size = rect_tx_size; best_tx_size = rect_tx_size;
...@@ -2611,8 +2611,7 @@ static void choose_tx_size_type_from_rd(const AV1_COMP *const cpi, ...@@ -2611,8 +2611,7 @@ static void choose_tx_size_type_from_rd(const AV1_COMP *const cpi,
last_rd = rd; last_rd = rd;
if (rd < best_rd) {