Allow frame level tx_mode switch Check the encoding statistics. If all the coding blocks use the max transform size, skip transform size coding in the frame header. Change-Id: I31cb16314e87f945d7e95a34a90a5536b3ed82d5
diff --git a/av1/encoder/block.h b/av1/encoder/block.h index 310325e..0f9ef46 100644 --- a/av1/encoder/block.h +++ b/av1/encoder/block.h
@@ -98,6 +98,10 @@ int *m_search_count_ptr; int *ex_search_count_ptr; +#if CONFIG_VAR_TX + unsigned int txb_split_count; +#endif + // These are set to their default values at the beginning, and then adjusted // further in the encoding process. BLOCK_SIZE min_partition_size;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 7d5db71..6518a52 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -4720,6 +4720,7 @@ cm->use_prev_frame_mvs ? cm->prev_mip + cm->mi_stride + 1 : NULL; #if CONFIG_VAR_TX + x->txb_split_count = 0; #if CONFIG_REF_MV av1_zero(x->blk_skip_drl); #endif @@ -4853,7 +4854,10 @@ } } -#if !CONFIG_VAR_TX +#if CONFIG_VAR_TX + if (cm->tx_mode == TX_MODE_SELECT && cpi->td.mb.txb_split_count == 0) + cm->tx_mode = ALLOW_32X32; +#else if (cm->tx_mode == TX_MODE_SELECT) { int count4x4 = 0; int count8x8_lp = 0, count8x8_8x8p = 0; @@ -4956,8 +4960,9 @@ } #if CONFIG_VAR_TX -static void update_txfm_count(MACROBLOCKD *xd, FRAME_COUNTS *counts, - TX_SIZE tx_size, int blk_row, int blk_col) { +static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd, + FRAME_COUNTS *counts, TX_SIZE tx_size, + int blk_row, int blk_col) { MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int tx_row = blk_row >> 1; const int tx_col = blk_col >> 1; @@ -4982,6 +4987,7 @@ int bh = num_4x4_blocks_high_lookup[bsize]; int i; ++counts->txfm_partition[ctx][1]; + ++x->txb_split_count; if (tx_size == TX_8X8) { mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4; @@ -4994,16 +5000,16 @@ for (i = 0; i < 4; ++i) { int offsetr = (i >> 1) * bh / 2; int offsetc = (i & 0x01) * bh / 2; - update_txfm_count(xd, counts, tx_size - 1, blk_row + offsetr, + update_txfm_count(x, xd, counts, tx_size - 1, blk_row + offsetr, blk_col + offsetc); } } } -static void tx_partition_count_update(const AV1_COMMON *const cm, - MACROBLOCKD *xd, BLOCK_SIZE plane_bsize, - int mi_row, int mi_col, - FRAME_COUNTS *td_counts) { +static void tx_partition_count_update(const AV1_COMMON *const cm, MACROBLOCK *x, + BLOCK_SIZE plane_bsize, int mi_row, + int mi_col, FRAME_COUNTS *td_counts) { + MACROBLOCKD *xd = &x->e_mbd; const int mi_width = num_4x4_blocks_wide_lookup[plane_bsize]; const int mi_height = num_4x4_blocks_high_lookup[plane_bsize]; TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize]; @@ -5017,7 +5023,7 @@ for (idy = 0; idy < mi_height; idy += bh) for (idx = 0; idx < mi_width; idx += bh) - update_txfm_count(xd, td_counts, max_tx_size, idy, idx); + update_txfm_count(x, xd, td_counts, max_tx_size, idy, idx); } static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row, @@ -5259,10 +5265,12 @@ } if (!is_rect_tx_allowed(xd, mbmi) || !is_rect_tx(mbmi->tx_size)) { #endif // CONFIG_EXT_TX && CONFIG_RECT_TX - if (is_inter) - tx_partition_count_update(cm, xd, bsize, mi_row, mi_col, td->counts); - else + if (is_inter) { + tx_partition_count_update(cm, x, bsize, mi_row, mi_col, td->counts); + } else { ++td->counts->tx_size[tx_size_cat][tx_size_ctx][coded_tx_size]; + if (mbmi->tx_size != max_txsize_lookup[bsize]) ++x->txb_split_count; + } #if CONFIG_EXT_TX && CONFIG_RECT_TX } #endif @@ -5292,7 +5300,12 @@ for (i = 0; i < mi_width; i++) if (mi_col + i < cm->mi_cols && mi_row + j < cm->mi_rows) mi_8x8[mis * j + i]->mbmi.tx_size = tx_size; + +#if CONFIG_VAR_TX + if (mbmi->tx_size != max_txsize_lookup[bsize]) ++x->txb_split_count; +#endif } + ++td->counts->tx_size_totals[txsize_sqr_map[mbmi->tx_size]]; ++td->counts ->tx_size_totals[txsize_sqr_map[get_uv_tx_size(mbmi, &xd->plane[1])]];