Commit 3dd33911 authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Debargha Mukherjee

Add a new layout for HORZ/VERT_A/B partitions

This hides behind --enable-ext_partition_types_ab. When that flag is
set, the mixed partitions change from

   +-+-+---+          +-+-+---+
   |   |   |          | | |   |
   |---+   |    to    | | |   |
   |   |   |          | | |   |
   +-+-+---+          +-+-+---+

(that's PARTITION_VERT_A; other partitions change similarly).

Since 128x32 and 32x128 block support hasn't yet been merged, this
patch also temporarily disables these partitions for 128x128 blocks.

Change-Id: Ic479c0fc129f590b8ad56d72dc98ba79ae1bd1cf
parent 6905dc79
......@@ -371,9 +371,10 @@ static int has_top_right(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if (xd->n8_w > xd->n8_h)
if (xd->is_sec_rect) has_tr = 0;
#if CONFIG_EXT_PARTITION_TYPES
// The bottom left square of a Vertical A does not have a top right as it is
// decoded before the right hand rectangle of the partition
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
// The bottom left square of a Vertical A (in the old format) does
// not have a top right as it is decoded before the right hand
// rectangle of the partition
if (xd->mi[0]->mbmi.partition == PARTITION_VERT_A)
if ((mask_row & bs) && !(mask_col & bs)) has_tr = 0;
#endif // CONFIG_EXT_PARTITION_TYPES
......
......@@ -974,8 +974,10 @@ static INLINE void update_ext_partition_context(MACROBLOCKD *xd, int mi_row,
BLOCK_SIZE bsize,
PARTITION_TYPE partition) {
if (bsize >= BLOCK_8X8) {
#if !CONFIG_EXT_PARTITION_TYPES_AB
const int hbs = mi_size_wide[bsize] / 2;
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
#endif
switch (partition) {
case PARTITION_SPLIT:
if (bsize != BLOCK_8X8) break;
......@@ -986,6 +988,30 @@ static INLINE void update_ext_partition_context(MACROBLOCKD *xd, int mi_row,
case PARTITION_VERT_4:
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
break;
#if CONFIG_EXT_PARTITION_TYPES_AB
case PARTITION_HORZ_A:
update_partition_context(xd, mi_row, mi_col,
get_subsize(bsize, PARTITION_HORZ_4), subsize);
update_partition_context(xd, mi_row + mi_size_high[bsize] / 2, mi_col,
subsize, subsize);
break;
case PARTITION_HORZ_B:
update_partition_context(xd, mi_row, mi_col, subsize, subsize);
update_partition_context(xd, mi_row + mi_size_high[bsize] / 2, mi_col,
get_subsize(bsize, PARTITION_HORZ_4), subsize);
break;
case PARTITION_VERT_A:
update_partition_context(xd, mi_row, mi_col,
get_subsize(bsize, PARTITION_VERT_4), subsize);
update_partition_context(xd, mi_row, mi_col + mi_size_wide[bsize] / 2,
subsize, subsize);
break;
case PARTITION_VERT_B:
update_partition_context(xd, mi_row, mi_col, subsize, subsize);
update_partition_context(xd, mi_row, mi_col + mi_size_wide[bsize] / 2,
get_subsize(bsize, PARTITION_VERT_4), subsize);
break;
#else
case PARTITION_HORZ_A:
update_partition_context(xd, mi_row, mi_col, bsize2, subsize);
update_partition_context(xd, mi_row + hbs, mi_col, subsize, subsize);
......@@ -1002,6 +1028,7 @@ static INLINE void update_ext_partition_context(MACROBLOCKD *xd, int mi_row,
update_partition_context(xd, mi_row, mi_col, subsize, subsize);
update_partition_context(xd, mi_row, mi_col + hbs, bsize2, subsize);
break;
#endif
default: assert(0 && "Invalid partition type");
}
}
......@@ -1228,6 +1255,16 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
const MB_MODE_INFO *const mbmi_below = &mi[bhigh / 2 * cm->mi_stride]->mbmi;
if (sswide == bwide) {
#if CONFIG_EXT_PARTITION_TYPES_AB
// Smaller height but same width. Is PARTITION_HORZ, PARTITION_HORZ_4,
// PARTITION_HORZ_A or PARTITION_HORZ_B.
if (sshigh * 2 == bhigh)
return (mbmi_below->sb_type == subsize) ? PARTITION_HORZ
: PARTITION_HORZ_B;
assert(sshigh * 4 == bhigh);
return (mbmi_below->sb_type == subsize) ? PARTITION_HORZ_4
: PARTITION_HORZ_A;
#else
// Smaller height but same width. Is PARTITION_HORZ_4, PARTITION_HORZ or
// PARTITION_HORZ_B. To distinguish the latter two, check if the lower
// half was split.
......@@ -1238,7 +1275,18 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
return PARTITION_HORZ;
else
return PARTITION_HORZ_B;
#endif
} else if (sshigh == bhigh) {
#if CONFIG_EXT_PARTITION_TYPES_AB
// Smaller width but same height. Is PARTITION_VERT, PARTITION_VERT_4,
// PARTITION_VERT_A or PARTITION_VERT_B.
if (sswide * 2 == bwide)
return (mbmi_right->sb_type == subsize) ? PARTITION_VERT
: PARTITION_VERT_B;
assert(sswide * 4 == bwide);
return (mbmi_right->sb_type == subsize) ? PARTITION_VERT_4
: PARTITION_VERT_A;
#else
// Smaller width but same height. Is PARTITION_VERT_4, PARTITION_VERT or
// PARTITION_VERT_B. To distinguish the latter two, check if the right
// half was split.
......@@ -1249,7 +1297,9 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
return PARTITION_VERT;
else
return PARTITION_VERT_B;
#endif
} else {
#if !CONFIG_EXT_PARTITION_TYPES_AB
// Smaller width and smaller height. Might be PARTITION_SPLIT or could be
// PARTITION_HORZ_A or PARTITION_VERT_A. If subsize isn't halved in both
// dimensions, we immediately know this is a split (which will recurse to
......@@ -1261,6 +1311,7 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
if (mi_size_wide[mbmi_below->sb_type] == bwide) return PARTITION_HORZ_A;
if (mi_size_high[mbmi_right->sb_type] == bhigh) return PARTITION_VERT_A;
#endif
return PARTITION_SPLIT;
}
......
......@@ -435,7 +435,7 @@ static const uint16_t *const orders[BLOCK_SIZES_ALL] = {
/* clang-format on */
#endif // CONFIG_EXT_PARTITION
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
static const uint16_t orders_verta_64x64[4] = {
0, 2, 1, 2,
};
......@@ -525,9 +525,9 @@ static const uint16_t *const orders_verta[BLOCK_SIZES] = {
static int has_top_right(const AV1_COMMON *cm, BLOCK_SIZE bsize, int mi_row,
int mi_col, int top_available, int right_available,
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
PARTITION_TYPE partition,
#endif
#endif // CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
TX_SIZE txsz, int row_off, int col_off, int ss_x) {
if (!top_available || !right_available) return 0;
......@@ -578,7 +578,7 @@ static int has_top_right(const AV1_COMMON *cm, BLOCK_SIZE bsize, int mi_row,
// General case (neither top row nor rightmost column): check if the
// top-right block is coded before the current block.
const uint16_t *const order =
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
(partition == PARTITION_VERT_A) ? orders_verta[bsize] :
#endif // CONFIG_EXT_PARTITION_TYPES
orders[bsize];
......@@ -2969,7 +2969,7 @@ static void predict_intra_block_helper(const AV1_COMMON *cm,
(MI_SIZE_LOG2 - tx_size_wide_log2[0])) <
xd->tile.mi_col_end;
const int bottom_available = (yd > 0);
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
const PARTITION_TYPE partition = xd->mi[0]->mbmi.partition;
#endif
......@@ -2980,9 +2980,9 @@ static void predict_intra_block_helper(const AV1_COMMON *cm,
const int have_top_right =
has_top_right(cm, bsize, mi_row, mi_col, have_top, right_available,
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
partition,
#endif
#endif // CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
tx_size, row_off, col_off, pd->subsampling_x);
const int have_bottom_left =
has_bottom_left(cm, bsize, mi_row, mi_col, bottom_available, have_left,
......
......@@ -1409,6 +1409,9 @@ static void dec_predict_sb_complex(AV1Decoder *const pbi, MACROBLOCKD *const xd,
}
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error HORZ/VERT_A/B partitions not yet updated in superres code
#endif
case PARTITION_HORZ_A:
dec_predict_b_extend(pbi, xd, tile, 0, mi_row, mi_col, mi_row, mi_col,
mi_row_top, mi_col_top, dst_buf, dst_stride,
......@@ -2173,6 +2176,9 @@ static void detoken_and_recon_sb(AV1Decoder *const pbi, MACROBLOCKD *const xd,
detoken_and_recon_sb(pbi, xd, mi_row + hbs, mi_col + hbs, r, subsize);
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error NC_MODE_INFO+MOTION_VAR not yet supported for new HORZ/VERT_AB partitions
#endif
case PARTITION_HORZ_A:
decode_token_and_recon_block(pbi, xd, mi_row, mi_col, r, bsize2);
decode_token_and_recon_block(pbi, xd, mi_row, mi_col + hbs, r, bsize2);
......@@ -2306,6 +2312,9 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
AV1_COMMON *const cm = &pbi->common;
const int num_8x8_wh = mi_size_wide[bsize];
const int hbs = num_8x8_wh >> 1;
#if CONFIG_EXT_PARTITION_TYPES && CONFIG_EXT_PARTITION_TYPES_AB
const int qbs = num_8x8_wh >> 2;
#endif
#if CONFIG_CB4X4
const int unify_bsize = 1;
#else
......@@ -2314,9 +2323,11 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
PARTITION_TYPE partition;
BLOCK_SIZE subsize;
#if CONFIG_EXT_PARTITION_TYPES
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
const int quarter_step = num_8x8_wh / 4;
int i;
#if !CONFIG_EXT_PARTITION_TYPES_AB
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
#endif
#endif
const int has_rows = (mi_row + hbs) < cm->mi_rows;
const int has_cols = (mi_col + hbs) < cm->mi_cols;
......@@ -2392,6 +2403,32 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
DEC_PARTITION(mi_row + hbs, mi_col + hbs, subsize);
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
case PARTITION_HORZ_A:
DEC_BLOCK(mi_row, mi_col, get_subsize(bsize, PARTITION_HORZ_4));
DEC_BLOCK(mi_row + qbs, mi_col, get_subsize(bsize, PARTITION_HORZ_4));
DEC_BLOCK(mi_row + hbs, mi_col, subsize);
break;
case PARTITION_HORZ_B:
DEC_BLOCK(mi_row, mi_col, subsize);
DEC_BLOCK(mi_row + hbs, mi_col, get_subsize(bsize, PARTITION_HORZ_4));
if (mi_row + 3 * qbs < cm->mi_rows)
DEC_BLOCK(mi_row + 3 * qbs, mi_col,
get_subsize(bsize, PARTITION_HORZ_4));
break;
case PARTITION_VERT_A:
DEC_BLOCK(mi_row, mi_col, get_subsize(bsize, PARTITION_VERT_4));
DEC_BLOCK(mi_row, mi_col + qbs, get_subsize(bsize, PARTITION_VERT_4));
DEC_BLOCK(mi_row, mi_col + hbs, subsize);
break;
case PARTITION_VERT_B:
DEC_BLOCK(mi_row, mi_col, subsize);
DEC_BLOCK(mi_row, mi_col + hbs, get_subsize(bsize, PARTITION_VERT_4));
if (mi_col + 3 * qbs < cm->mi_cols)
DEC_BLOCK(mi_row, mi_col + 3 * qbs,
get_subsize(bsize, PARTITION_VERT_4));
break;
#else
case PARTITION_HORZ_A:
DEC_BLOCK(mi_row, mi_col, bsize2);
DEC_BLOCK(mi_row, mi_col + hbs, bsize2);
......@@ -2412,6 +2449,7 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
DEC_BLOCK(mi_row, mi_col + hbs, bsize2);
DEC_BLOCK(mi_row + hbs, mi_col + hbs, bsize2);
break;
#endif
case PARTITION_HORZ_4:
for (i = 0; i < 4; ++i) {
int this_mi_row = mi_row + i * quarter_step;
......
......@@ -2781,6 +2781,9 @@ static void write_tokens_sb(AV1_COMP *cpi, const TileInfo *const tile,
subsize);
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error NC_MODE_INFO+MOTION_VAR not yet supported for new HORZ/VERT_AB partitions
#endif
case PARTITION_HORZ_A:
write_tokens_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
write_tokens_b(cpi, tile, w, tok, tok_end, mi_row, mi_col + hbs);
......@@ -2902,7 +2905,10 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
#if CONFIG_EXT_PARTITION_TYPES
const int quarter_step = mi_size_wide[bsize] / 4;
int i;
#endif
#if CONFIG_EXT_PARTITION_TYPES_AB
const int qbs = mi_size_wide[bsize] / 4;
#endif // CONFIG_EXT_PARTITION_TYPES_AB
#endif // CONFIG_EXT_PARTITION_TYPES
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_CB4X4
......@@ -2976,6 +2982,42 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
mi_row + hbs, mi_col + hbs, subsize);
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
case PARTITION_HORZ_A:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + qbs, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + hbs, mi_col);
break;
case PARTITION_HORZ_B:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + hbs, mi_col);
if (mi_row + 3 * qbs < cm->mi_rows)
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + 3 * qbs, mi_col);
break;
case PARTITION_VERT_A:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col + qbs);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col + hbs);
break;
case PARTITION_VERT_B:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col + hbs);
if (mi_col + 3 * qbs < cm->mi_cols)
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col + 3 * qbs);
break;
#else
case PARTITION_HORZ_A:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
......@@ -3008,6 +3050,7 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + hbs, mi_col + hbs);
break;
#endif
case PARTITION_HORZ_4:
for (i = 0; i < 4; ++i) {
int this_mi_row = mi_row + i * quarter_step;
......
......@@ -1010,6 +1010,9 @@ static void update_state_sb_supertx(const AV1_COMP *const cpi, ThreadData *td,
pmc = &pc_tree->split_supertx;
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error HORZ/VERT_A/B partitions not yet updated in superres code
#endif
case PARTITION_HORZ_A:
set_offsets_supertx(cpi, td, tile, mi_row, mi_col, bsize2);
update_state_supertx(cpi, td, &pc_tree->horizontala[0], mi_row, mi_col,
......@@ -1143,6 +1146,9 @@ static void update_supertx_param_sb(const AV1_COMP *const cpi, ThreadData *td,
}
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error HORZ/VERT_A/B partitions not yet updated in superres code
#endif
case PARTITION_HORZ_A:
for (i = 0; i < 3; i++)
update_supertx_param(td, &pc_tree->horizontala[i], best_tx,
......@@ -1234,6 +1240,9 @@ static void set_mode_info_sb(const AV1_COMP *const cpi, ThreadData *td,
}
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error NC_MODE_INFO+MOTION_VAR not yet supported for new HORZ/VERT_AB partitions
#endif
case PARTITION_HORZ_A:
set_mode_info_b(cpi, tile, td, mi_row, mi_col, bsize2,
&pc_tree->horizontala[0]);
......@@ -2178,6 +2187,9 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int hbs = mi_size_wide[bsize] / 2;
#if CONFIG_EXT_PARTITION_TYPES && CONFIG_EXT_PARTITION_TYPES_AB
const int qbs = mi_size_wide[bsize] / 4;
#endif
const int is_partition_root = bsize >= BLOCK_8X8;
const int ctx = is_partition_root
? partition_plane_context(xd, mi_row, mi_col,
......@@ -2190,9 +2202,11 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
const PARTITION_TYPE partition = pc_tree->partitioning;
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_EXT_PARTITION_TYPES
const BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
int quarter_step = mi_size_wide[bsize] / 4;
int i;
#if !CONFIG_EXT_PARTITION_TYPES_AB
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
#endif
#endif
#if CONFIG_CB4X4
......@@ -2359,7 +2373,53 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
subsize, pc_tree->split[3], rate);
}
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
case PARTITION_HORZ_A:
encode_b(cpi, tile, td, tp, mi_row, mi_col, dry_run,
get_subsize(bsize, PARTITION_HORZ_4), partition,
&pc_tree->horizontala[0], rate);
encode_b(cpi, tile, td, tp, mi_row + qbs, mi_col, dry_run,
get_subsize(bsize, PARTITION_HORZ_4), partition,
&pc_tree->horizontala[1], rate);
encode_b(cpi, tile, td, tp, mi_row + hbs, mi_col, dry_run, subsize,
partition, &pc_tree->horizontala[2], rate);
break;
case PARTITION_HORZ_B:
encode_b(cpi, tile, td, tp, mi_row, mi_col, dry_run, subsize, partition,
&pc_tree->horizontalb[0], rate);
encode_b(cpi, tile, td, tp, mi_row + hbs, mi_col, dry_run,
get_subsize(bsize, PARTITION_HORZ_4), partition,
&pc_tree->horizontalb[1], rate);
if (mi_row + 3 * qbs < cm->mi_rows)
encode_b(cpi, tile, td, tp, mi_row + 3 * qbs, mi_col, dry_run,
get_subsize(bsize, PARTITION_HORZ_4), partition,
&pc_tree->horizontalb[2], rate);
break;
case PARTITION_VERT_A:
encode_b(cpi, tile, td, tp, mi_row, mi_col, dry_run,
get_subsize(bsize, PARTITION_VERT_4), partition,
&pc_tree->verticala[0], rate);
encode_b(cpi, tile, td, tp, mi_row, mi_col + qbs, dry_run,
get_subsize(bsize, PARTITION_VERT_4), partition,
&pc_tree->verticala[1], rate);
encode_b(cpi, tile, td, tp, mi_row, mi_col + hbs, dry_run, subsize,
partition, &pc_tree->verticala[2], rate);
break;
case PARTITION_VERT_B:
encode_b(cpi, tile, td, tp, mi_row, mi_col, dry_run, subsize, partition,
&pc_tree->verticalb[0], rate);
encode_b(cpi, tile, td, tp, mi_row, mi_col + hbs, dry_run,
get_subsize(bsize, PARTITION_VERT_4), partition,
&pc_tree->verticalb[1], rate);
if (mi_col + 3 * qbs < cm->mi_cols)
encode_b(cpi, tile, td, tp, mi_row, mi_col + 3 * qbs, dry_run,
get_subsize(bsize, PARTITION_VERT_4), partition,
&pc_tree->verticalb[2], rate);
break;
#else
case PARTITION_HORZ_A:
encode_b(cpi, tile, td, tp, mi_row, mi_col, dry_run, bsize2, partition,
&pc_tree->horizontala[0], rate);
......@@ -2393,6 +2453,7 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
encode_b(cpi, tile, td, tp, mi_row + hbs, mi_col + hbs, dry_run, bsize2,
partition, &pc_tree->verticalb[2], rate);
break;
#endif
case PARTITION_HORZ_4:
for (i = 0; i < 4; ++i) {
int this_mi_row = mi_row + i * quarter_step;
......@@ -3282,9 +3343,10 @@ static void rd_test_partition3(
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
RD_STATS sum_rdc, this_rdc;
#if CONFIG_SUPERTX
#if CONFIG_SUPERTX || CONFIG_EXT_PARTITION_TYPES_AB
const AV1_COMMON *const cm = &cpi->common;
#endif
#if CONFIG_SUPERTX
TileInfo *const tile_info = &tile_data->tile_info;
int sum_rate_nocoef, this_rate_nocoef;
int abort_flag;
......@@ -3308,7 +3370,18 @@ static void rd_test_partition3(
RTP_STX_TRY_ARGS partition, &ctxs[0], &ctxs[1]))
return;
if (!rd_try_subblock(cpi, td, tile_data, tp, 0, 1, mi_row2, mi_col2, subsize2,
// With the new layout of mixed partitions for PARTITION_HORZ_B and
// PARTITION_VERT_B, the last subblock might start past halfway through the
// main block, so we might signal it even though the subblock lies strictly
// outside the image. In that case, we won't spend any bits coding it and the
// difference (obviously) doesn't contribute to the error.
#if CONFIG_EXT_PARTITION_TYPES_AB
const int try_block2 = mi_row2 < cm->mi_rows && mi_col2 < cm->mi_cols;
#else
const int try_block2 = 1;
#endif
if (try_block2 &&
!rd_try_subblock(cpi, td, tile_data, tp, 0, 1, mi_row2, mi_col2, subsize2,
best_rdc, &sum_rdc, &this_rdc,
RTP_STX_TRY_ARGS partition, &ctxs[1], &ctxs[2]))
return;
......@@ -3481,7 +3554,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif // CONFIG_SUPERTX
int do_rectangular_split = 1;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES && !CONFIG_EXT_PARTITION_TYPES_AB
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
#endif
......@@ -4299,9 +4372,31 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
}
#if CONFIG_EXT_PARTITION_TYPES
const int ext_partition_allowed =
do_rectangular_split && bsize > BLOCK_8X8 && partition_none_allowed;
#if CONFIG_EXT_PARTITION && CONFIG_EXT_PARTITION_TYPES_AB
// Don't allow A/B partitions on 128x128 blocks for now (support for
// 128x32 and 32x128 blocks doesn't yet exist).
const int ab_partition_allowed =
ext_partition_allowed && bsize < BLOCK_128X128;
#else
const int ab_partition_allowed = ext_partition_allowed;
#endif
// PARTITION_HORZ_A
if (partition_horz_allowed && do_rectangular_split && bsize > BLOCK_8X8 &&
partition_none_allowed) {
if (partition_horz_allowed && ab_partition_allowed) {
#if CONFIG_EXT_PARTITION_TYPES_AB
rd_test_partition3(
cpi, td, tile_data, tp, pc_tree, &best_rdc, pc_tree->horizontala,
ctx_none, mi_row, mi_col, bsize, PARTITION_HORZ_A,
#if CONFIG_SUPERTX
best_rd, &best_rate_nocoef, &x_ctx,
#endif
mi_row, mi_col, get_subsize(bsize, PARTITION_HORZ_4),
mi_row + mi_step / 2, mi_col, get_subsize(bsize, PARTITION_HORZ_4),
mi_row + mi_step, mi_col, get_subsize(bsize, PARTITION_HORZ));
#else
subsize = get_subsize(bsize, PARTITION_HORZ_A);
rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc,
pc_tree->horizontala, ctx_none, mi_row, mi_col, bsize,
......@@ -4311,11 +4406,22 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif
mi_row, mi_col, bsize2, mi_row, mi_col + mi_step, bsize2,
mi_row + mi_step, mi_col, subsize);
#endif
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
}
// PARTITION_HORZ_B
if (partition_horz_allowed && do_rectangular_split && bsize > BLOCK_8X8 &&
partition_none_allowed) {
if (partition_horz_allowed && ab_partition_allowed) {
#if CONFIG_EXT_PARTITION_TYPES_AB
rd_test_partition3(
cpi, td, tile_data, tp, pc_tree, &best_rdc, pc_tree->horizontalb,
ctx_none, mi_row, mi_col, bsize, PARTITION_HORZ_B,
#if CONFIG_SUPERTX
best_rd, &best_rate_nocoef, &x_ctx,
#endif
mi_row, mi_col, get_subsize(bsize, PARTITION_HORZ), mi_row + mi_step,
mi_col, get_subsize(bsize, PARTITION_HORZ_4), mi_row + 3 * mi_step / 2,
mi_col, get_subsize(bsize, PARTITION_HORZ_4));
#else
subsize = get_subsize(bsize, PARTITION_HORZ_B);
rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc,
pc_tree->horizontalb, ctx_none, mi_row, mi_col, bsize,
......@@ -4325,11 +4431,22 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif
mi_row, mi_col, subsize, mi_row + mi_step, mi_col,
bsize2, mi_row + mi_step, mi_col + mi_step, bsize2);
#endif
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
}
// PARTITION_VERT_A
if (partition_vert_allowed && do_rectangular_split && bsize > BLOCK_8X8 &&
partition_none_allowed) {
if (partition_vert_allowed && ab_partition_allowed) {
#if CONFIG_EXT_PARTITION_TYPES_AB
rd_test_partition3(
cpi, td, tile_data, tp, pc_tree, &best_rdc, pc_tree->verticala,
ctx_none, mi_row, mi_col, bsize, PARTITION_VERT_A,
#if CONFIG_SUPERTX
best_rd, &best_rate_nocoef, &x_ctx,
#endif
mi_row, mi_col, get_subsize(bsize, PARTITION_VERT_4), mi_row,
mi_col + mi_step / 2, get_subsize(bsize, PARTITION_VERT_4), mi_row,
mi_col + mi_step, get_subsize(bsize, PARTITION_VERT));
#else
subsize = get_subsize(bsize, PARTITION_VERT_A);
rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc,
pc_tree->verticala, ctx_none, mi_row, mi_col, bsize,
......@@ -4339,11 +4456,22 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif
mi_row, mi_col, bsize2, mi_row + mi_step, mi_col, bsize2,
mi_row, mi_col + mi_step, subsize);
#endif
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
}
// PARTITION_VERT_B
if (partition_vert_allowed && do_rectangular_split && bsize > BLOCK_8X8 &&
partition_none_allowed) {
if (partition_vert_allowed && ab_partition_allowed) {
#if CONFIG_EXT_PARTITION_TYPES_AB
rd_test_partition3(
cpi, td, tile_data, tp, pc_tree, &best_rdc, pc_tree->verticalb,
ctx_none, mi_row, mi_col, bsize, PARTITION_VERT_B,
#if CONFIG_SUPERTX
best_rd, &best_rate_nocoef, &x_ctx,
#endif
mi_row, mi_col, get_subsize(bsize, PARTITION_VERT), mi_row,
mi_col + mi_step, get_subsize(bsize, PARTITION_VERT_4), mi_row,
mi_col + 3 * mi_step / 2, get_subsize(bsize, PARTITION_VERT_4));
#else
subsize = get_subsize(bsize, PARTITION_VERT_B);
rd_test_partition3(cpi, td, tile_data, tp, pc_tree, &best_rdc,
pc_tree->verticalb, ctx_none, mi_row, mi_col, bsize,
......@@ -4353,6 +4481,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif
mi_row, mi_col, subsize, mi_row, mi_col + mi_step,
bsize2, mi_row + mi_step, mi_col + mi_step, bsize2);
#endif
restore_context(x, &x_ctx, mi_row, mi_col, bsize);
}
......@@ -6498,6 +6627,9 @@ static int check_intra_sb(const AV1_COMP *const cpi, const TileInfo *const tile,
}
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error HORZ/VERT_A/B partitions not yet updated in superres code
#endif
case PARTITION_HORZ_A:
for (i = 0; i < 3; i++) {
if (check_intra_b(&pc_tree->horizontala[i])) return 1;
......@@ -6552,6 +6684,9 @@ static int check_supertx_sb(BLOCK_SIZE bsize, TX_SIZE supertx_size,
else
return check_supertx_sb(subsize, supertx_size, pc_tree->split[0]);
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error HORZ/VERT_A/B partitions not yet updated in superres code
#endif
case PARTITION_HORZ_A:
return check_supertx_b(supertx_size, &pc_tree->horizontala[0]);
case PARTITION_HORZ_B:
......@@ -7203,6 +7338,9 @@ static void predict_sb_complex(const AV1_COMP *const cpi, ThreadData *td,
}
break;
#if CONFIG_EXT_PARTITION_TYPES
#if CONFIG_EXT_PARTITION_TYPES_AB
#error HORZ/VERT_A/B partitions not yet updated in superres code
#endif
case PARTITION_HORZ_A:
predict_b_extend(cpi, td, tile, 0, mi_row, mi_col, mi_row, mi_col,
mi_row_top, mi_col_top, dst_buf, dst_stride, top_bsize,
......
......@@ -167,6 +167,9 @@ static void count_segs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
const int bs = mi_size_wide[bsize], hbs = bs / 2;
#if CONFIG_EXT_PARTITION_TYPES
PARTITION_TYPE partition;
#if CONFIG_EXT_PARTITION_TYPES_AB
const int qbs = bs / 4;
#endif // CONFIG_EXT_PARTITION_TYPES_AB
#else
int bw, bh;
#endif // CONFIG_EXT_PARTITION_TYPES
......@@ -193,6 +196,28 @@ static void count_segs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
CSEGS(hbs, bs, 0, 0);
CSEGS(hbs, bs, 0, hbs);
break;
#if CONFIG_EXT_PARTITION_TYPES_AB
case PARTITION_HORZ_A:
CSEGS(bs, qbs, 0, 0);
CSEGS(bs, qbs, qbs, 0);
CSEGS(bs, hbs, hbs, 0);
break;
case PARTITION_HORZ_B:
CSEGS(bs, hbs, 0, 0);
CSEGS(bs, qbs, hbs, 0);
if (mi_row + 3 * qbs < cm->mi_rows) CSEGS(bs, qbs, 3 * qbs, 0);
break;
case PARTITION_VERT_A:
CSEGS(qbs, bs, 0, 0);
CSEGS(qbs, bs, 0, qbs);
CSEGS(hbs, bs, 0, hbs);
break;
case PARTITION_VERT_B:
CSEGS(hbs, bs, 0, 0);
CSEGS(qbs, bs, 0, hbs);
if (mi_col + 3 * qbs < cm->mi_cols) CSEGS(qbs, bs, 0, 3 * qbs);
break;
#else
case PARTITION_HORZ_A:
CSEGS(hbs, hbs, 0, 0);
CSEGS(hbs, hbs, 0, hbs);
......@@ -213,6 +238,7 @@ static void count_segs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
CSEGS(hbs, hbs, 0, hbs);
CSEGS(hbs, hbs, hbs, hbs);
break;
#endif
case PARTITION_SPLIT: {
const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize];
int n;
......
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