Commit 36fe3200 authored by Jingning Han's avatar Jingning Han

Skip non-reference position chroma uv intra mode coding

Skip coding the intra mode for chroma component for sub8x8 blocks
that are not in the reference position.

Change-Id: Ic3daab2668ab41c3b743664faf195e34124ead33
parent 9ce464c2
......@@ -910,7 +910,13 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
}
#endif
#if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col))
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#else
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#endif
#if CONFIG_EXT_INTRA
read_intra_angle_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
......@@ -1195,9 +1201,9 @@ static INLINE void read_mb_interp_filter(AV1_COMMON *const cm,
#endif // CONFIG_DUAL_FILTER
}
static void read_intra_block_mode_info(AV1_COMMON *const cm,
MACROBLOCKD *const xd, MODE_INFO *mi,
aom_reader *r) {
static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row,
const int mi_col, MACROBLOCKD *const xd,
MODE_INFO *mi, aom_reader *r) {
MB_MODE_INFO *const mbmi = &mi->mbmi;
const BLOCK_SIZE bsize = mi->mbmi.sb_type;
int i;
......@@ -1230,7 +1236,15 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm,
}
#endif
#if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col))
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#else
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
(void)mi_row;
(void)mi_col;
#endif
#if CONFIG_EXT_INTRA
read_intra_angle_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
......@@ -2105,7 +2119,7 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
mi, mi_row, mi_col, r);
#endif // CONFIG_MOTION_VAR && CONFIG_SUPERTX
else
read_intra_block_mode_info(cm, xd, mi, r);
read_intra_block_mode_info(cm, mi_row, mi_col, xd, mi, r);
read_tx_type(cm, xd, mbmi,
#if CONFIG_SUPERTX
......
......@@ -1362,6 +1362,7 @@ static void write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
}
static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
const int mi_row, const int mi_col,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif
......@@ -1421,8 +1422,6 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#endif // CONFIG_SUPERTX
#if CONFIG_DELTA_Q
if (cm->delta_q_present_flag) {
int mi_row = (-xd->mb_to_top_edge) >> (MI_SIZE_LOG2 + 3);
int mi_col = (-xd->mb_to_left_edge) >> (MI_SIZE_LOG2 + 3);
int super_block_upper_left =
((mi_row & MAX_MIB_MASK) == 0) && ((mi_col & MAX_MIB_MASK) == 0);
if ((bsize != BLOCK_64X64 || skip == 0) && super_block_upper_left) {
......@@ -1505,8 +1504,13 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mbmi->uv_mode],
ec_ctx->uv_mode_cdf[mode], INTRA_MODES);
#else
#if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col))
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
#else
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mode]);
#endif // CONFIG_CB4X4
#endif
#if CONFIG_EXT_INTRA
write_intra_angle_info(cm, xd, w);
......@@ -1766,11 +1770,13 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
}
#if CONFIG_DELTA_Q
static void write_mb_modes_kf(AV1_COMMON *cm, MACROBLOCKD *xd,
MODE_INFO **mi_8x8, aom_writer *w) {
static void write_mb_modes_kf(AV1_COMMON *cm, MACROBLOCKD *xd, const int mi_row,
const int mi_col, MODE_INFO **mi_8x8,
aom_writer *w) {
int skip;
#else
static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
const int mi_row, const int mi_col,
MODE_INFO **mi_8x8, aom_writer *w) {
#endif
const struct segmentation *const seg = &cm->seg;
......@@ -1797,8 +1803,6 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
#if CONFIG_DELTA_Q
skip = write_skip(cm, xd, mbmi->segment_id, mi, w);
if (cm->delta_q_present_flag) {
int mi_row = (-xd->mb_to_top_edge) >> 6;
int mi_col = (-xd->mb_to_left_edge) >> 6;
int super_block_upper_left = ((mi_row & 7) == 0) && ((mi_col & 7) == 0);
if ((bsize != BLOCK_64X64 || skip == 0) && super_block_upper_left) {
int reduced_delta_qindex =
......@@ -1855,8 +1859,13 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_intra_mode_ind[mbmi->uv_mode],
ec_ctx->uv_mode_cdf[mbmi->mode], INTRA_MODES);
#else
#if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col))
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
#else
write_intra_mode(w, mbmi->uv_mode, cm->fc->uv_mode_prob[mbmi->mode]);
#endif // CONFIG_CB4X4
#endif
#if CONFIG_EXT_INTRA
write_intra_angle_info(cm, xd, w);
......@@ -1972,7 +1981,7 @@ static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile,
#endif
if (frame_is_intra_only(cm)) {
write_mb_modes_kf(cm, xd, xd->mi, w);
write_mb_modes_kf(cm, xd, mi_row, mi_col, xd->mi, w);
} else {
#if CONFIG_VAR_TX
xd->above_txfm_context = cm->above_txfm_context + mi_col;
......@@ -2009,7 +2018,7 @@ static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile,
m->mbmi.ref_frame[0], m->mbmi.ref_frame[1]);
}
#endif // 0
pack_inter_mode_mvs(cpi, m,
pack_inter_mode_mvs(cpi, m, mi_row, mi_col,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
......
......@@ -5406,7 +5406,8 @@ void av1_encode_frame(AV1_COMP *cpi) {
static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi,
const MODE_INFO *above_mi, const MODE_INFO *left_mi,
const int intraonly) {
const int intraonly, const int mi_row,
const int mi_col) {
const PREDICTION_MODE y_mode = mi->mbmi.mode;
const PREDICTION_MODE uv_mode = mi->mbmi.uv_mode;
const BLOCK_SIZE bsize = mi->mbmi.sb_type;
......@@ -5438,6 +5439,12 @@ static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi,
}
}
#if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && !is_chroma_reference(mi_row, mi_col)) return;
#else
(void)mi_row;
(void)mi_col;
#endif
++counts->uv_mode[y_mode][uv_mode];
}
......@@ -5603,7 +5610,7 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
mi_row, mi_col);
if (!dry_run)
sum_intra_stats(td->counts, mi, xd->above_mi, xd->left_mi,
frame_is_intra_only(cm));
frame_is_intra_only(cm), mi_row, mi_col);
// TODO(huisu): move this into sum_intra_stats().
if (!dry_run && (bsize >= BLOCK_8X8 || unify_bsize)) {
......
......@@ -10091,8 +10091,15 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
}
#endif // CONFIG_FILTER_INTRA
#if CONFIG_CB4X4
rate2 = rate_y + intra_mode_cost[mbmi->mode];
if (!x->skip_chroma_rd)
rate2 += rate_uv + cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode];
#else
rate2 = rate_y + intra_mode_cost[mbmi->mode] + rate_uv +
cpi->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode];
#endif
#if CONFIG_PALETTE
if (cpi->common.allow_screen_content_tools && mbmi->mode == DC_PRED)
rate2 += av1_cost_bit(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment