Commit d3a6443d authored by Jingning Han's avatar Jingning Han

Rework sub8x8 chroma reference check to support non-420 format

Make is_chroma_reference() account for all the YUV420, 444, and
422 formats.

Change-Id: Ia87e51894493dcea86843194a34e5de05799248a
parent 5106e283
...@@ -165,7 +165,9 @@ void av1_foreach_transformed_block(const MACROBLOCKD *const xd, ...@@ -165,7 +165,9 @@ void av1_foreach_transformed_block(const MACROBLOCKD *const xd,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y))
continue; continue;
#else #else
(void)mi_row; (void)mi_row;
......
...@@ -722,11 +722,19 @@ static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row, ...@@ -722,11 +722,19 @@ static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row,
} }
#if CONFIG_CB4X4 #if CONFIG_CB4X4
static INLINE int is_chroma_reference(const int mi_row, const int mi_col) { static INLINE int is_chroma_reference(const int mi_row, const int mi_col,
const BLOCK_SIZE bsize,
const int subsampling_x,
const int subsampling_y) {
#if CONFIG_CHROMA_2X2 #if CONFIG_CHROMA_2X2
return 1; return 1;
#endif #endif
return !((mi_row & 0x01) || (mi_col & 0x01)); int ref_pos = !(((mi_row & 0x01) && subsampling_y) ||
((mi_col & 0x01) && subsampling_x));
if (bsize >= BLOCK_8X8) ref_pos = 1;
return ref_pos;
} }
#endif #endif
......
...@@ -1198,7 +1198,8 @@ static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize, ...@@ -1198,7 +1198,8 @@ static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize,
const int bh = pd->height; const int bh = pd->height;
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize, pd->subsampling_x,
pd->subsampling_y))
continue; continue;
#endif #endif
......
...@@ -2182,7 +2182,14 @@ static void predict_square_intra_block(const MACROBLOCKD *xd, int wpx, int hpx, ...@@ -2182,7 +2182,14 @@ static void predict_square_intra_block(const MACROBLOCKD *xd, int wpx, int hpx,
#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 #if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
// force 4x4 chroma component block size. // force 4x4 chroma component block size.
if (plane && bsize < BLOCK_8X8) bsize = BLOCK_8X8; if (plane && bsize < BLOCK_8X8) {
if (pd->subsampling_x == 1 && pd->subsampling_y == 1)
bsize = BLOCK_8X8;
else if (pd->subsampling_x == 1)
bsize = BLOCK_8X4;
else if (pd->subsampling_y == 1)
bsize = BLOCK_4X8;
}
#endif #endif
const int have_right = const int have_right =
......
...@@ -1684,7 +1684,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, ...@@ -1684,7 +1684,8 @@ 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_wide = max_block_wide(xd, plane_bsize, plane);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize, pd->subsampling_x,
pd->subsampling_y))
continue; continue;
#endif #endif
...@@ -1779,7 +1780,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi, ...@@ -1779,7 +1780,8 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
int row, col; int row, col;
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize, pd->subsampling_x,
pd->subsampling_y))
continue; continue;
#endif #endif
......
...@@ -968,7 +968,8 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm, ...@@ -968,7 +968,8 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
#endif #endif
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col)) if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y))
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode); mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#else #else
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode); mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
...@@ -1299,7 +1300,8 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row, ...@@ -1299,7 +1300,8 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row,
#endif #endif
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col)) if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y))
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode); mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
#else #else
mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode); mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode);
......
...@@ -1692,7 +1692,8 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi, ...@@ -1692,7 +1692,8 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
} }
} }
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col)) if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y))
write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w); write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
#else // !CONFIG_CB4X4 #else // !CONFIG_CB4X4
write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w); write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mode, w);
...@@ -2042,7 +2043,8 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd, ...@@ -2042,7 +2043,8 @@ static void write_mb_modes_kf(AV1_COMMON *cm, const MACROBLOCKD *xd,
} }
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize >= BLOCK_8X8 || is_chroma_reference(mi_row, mi_col)) if (is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y))
write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w); write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
#else // !CONFIG_CB4X4 #else // !CONFIG_CB4X4
write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w); write_intra_uv_mode(ec_ctx, mbmi->uv_mode, mbmi->mode, w);
...@@ -2322,8 +2324,9 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile, ...@@ -2322,8 +2324,9 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (mbmi->sb_type < BLOCK_8X8 && plane && if (!is_chroma_reference(mi_row, mi_col, mbmi->sb_type,
!is_chroma_reference(mi_row, mi_col)) { xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y)) {
(*tok)++; (*tok)++;
continue; continue;
} }
......
...@@ -1882,7 +1882,8 @@ static void rd_pick_sb_modes(const AV1_COMP *const cpi, TileDataEnc *tile_data, ...@@ -1882,7 +1882,8 @@ static void rd_pick_sb_modes(const AV1_COMP *const cpi, TileDataEnc *tile_data,
#if CONFIG_CB4X4 #if CONFIG_CB4X4
x->skip_chroma_rd = x->skip_chroma_rd =
(bsize < BLOCK_8X8) && !is_chroma_reference(mi_row, mi_col); !is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y);
#endif #endif
#if CONFIG_AOM_HIGHBITDEPTH #if CONFIG_AOM_HIGHBITDEPTH
...@@ -5550,10 +5551,10 @@ void av1_encode_frame(AV1_COMP *cpi) { ...@@ -5550,10 +5551,10 @@ void av1_encode_frame(AV1_COMP *cpi) {
} }
} }
static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi, static void sum_intra_stats(FRAME_COUNTS *counts, MACROBLOCKD *xd,
const MODE_INFO *above_mi, const MODE_INFO *left_mi, const MODE_INFO *mi, const MODE_INFO *above_mi,
const int intraonly, const int mi_row, const MODE_INFO *left_mi, const int intraonly,
const int mi_col) { const int mi_row, const int mi_col) {
const PREDICTION_MODE y_mode = mi->mbmi.mode; const PREDICTION_MODE y_mode = mi->mbmi.mode;
const PREDICTION_MODE uv_mode = mi->mbmi.uv_mode; const PREDICTION_MODE uv_mode = mi->mbmi.uv_mode;
const BLOCK_SIZE bsize = mi->mbmi.sb_type; const BLOCK_SIZE bsize = mi->mbmi.sb_type;
...@@ -5586,10 +5587,13 @@ static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi, ...@@ -5586,10 +5587,13 @@ static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi,
} }
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && !is_chroma_reference(mi_row, mi_col)) return; if (!is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y))
return;
#else #else
(void)mi_row; (void)mi_row;
(void)mi_col; (void)mi_col;
(void)xd;
#endif #endif
++counts->uv_mode[y_mode][uv_mode]; ++counts->uv_mode[y_mode][uv_mode];
} }
...@@ -5755,7 +5759,7 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td, ...@@ -5755,7 +5759,7 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
av1_encode_intra_block_plane((AV1_COMMON *)cm, x, block_size, plane, 1, av1_encode_intra_block_plane((AV1_COMMON *)cm, x, block_size, plane, 1,
mi_row, mi_col); mi_row, mi_col);
if (!dry_run) if (!dry_run)
sum_intra_stats(td->counts, mi, xd->above_mi, xd->left_mi, sum_intra_stats(td->counts, xd, mi, xd->above_mi, xd->left_mi,
frame_is_intra_only(cm), mi_row, mi_col); frame_is_intra_only(cm), mi_row, mi_col);
// TODO(huisu): move this into sum_intra_stats(). // TODO(huisu): move this into sum_intra_stats().
......
...@@ -943,7 +943,9 @@ void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize, ...@@ -943,7 +943,9 @@ void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2 #if CONFIG_CB4X4 && !CONFIG_CHROMA_2X2
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y))
continue; continue;
if (plane) bsize = AOMMAX(bsize, BLOCK_8X8); if (plane) bsize = AOMMAX(bsize, BLOCK_8X8);
#else #else
...@@ -1121,7 +1123,9 @@ void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x, ...@@ -1121,7 +1123,9 @@ void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x,
}; };
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y))
return; return;
#else #else
(void)mi_row; (void)mi_row;
......
...@@ -711,7 +711,9 @@ void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t, ...@@ -711,7 +711,9 @@ void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) { if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y)) {
#if !CONFIG_PVQ #if !CONFIG_PVQ
if (!dry_run) { if (!dry_run) {
(*t)->token = EOSB_TOKEN; (*t)->token = EOSB_TOKEN;
...@@ -781,7 +783,9 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t, ...@@ -781,7 +783,9 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
td->counts->skip[ctx][0] += skip_inc; td->counts->skip[ctx][0] += skip_inc;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) { if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y)) {
#if !CONFIG_PVQ #if !CONFIG_PVQ
(*t)->token = EOSB_TOKEN; (*t)->token = EOSB_TOKEN;
(*t)++; (*t)++;
...@@ -806,7 +810,9 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t, ...@@ -806,7 +810,9 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
int plane; int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y))
continue; continue;
#else #else
(void)mi_row; (void)mi_row;
...@@ -819,7 +825,9 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t, ...@@ -819,7 +825,9 @@ void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
int plane; int plane;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) { for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
#if CONFIG_CB4X4 #if CONFIG_CB4X4
if (bsize < BLOCK_8X8 && plane && !is_chroma_reference(mi_row, mi_col)) if (!is_chroma_reference(mi_row, mi_col, bsize,
xd->plane[plane].subsampling_x,
xd->plane[plane].subsampling_y))
continue; continue;
#else #else
(void)mi_row; (void)mi_row;
......
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