Added support for extended partitions with copy_mode

Change-Id: I815374bd89e3faf2bac1b4155dbbe7366f0a1d29
This commit is contained in:
Peter de Rivaz 2015-06-23 12:00:05 +01:00 committed by Debargha Mukherjee
parent ffcd76e328
commit 269f6e2cb1
10 changed files with 222 additions and 25 deletions

View File

@ -657,7 +657,11 @@ static int check_inside(const TileInfo *const tile, int mi_row, int mi_col) {
mi_row < tile->mi_row_end && mi_col < tile->mi_col_end;
}
static int is_right_available(BLOCK_SIZE bsize, int mi_row, int mi_col) {
static int is_right_available(BLOCK_SIZE bsize,
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
int mi_row, int mi_col) {
int depth, max_depth = 4 - MIN(b_width_log2_lookup[bsize],
b_height_log2_lookup[bsize]);
int block[4] = {0};
@ -679,8 +683,15 @@ static int is_right_available(BLOCK_SIZE bsize, int mi_row, int mi_col) {
if (block[max_depth] > 0)
return 0;
} else {
#if CONFIG_EXT_PARTITION
if (block[max_depth] == 0)
return 1;
if (block[max_depth] == 2)
return partition != PARTITION_VERT_A;
#else
if (block[max_depth] == 0 || block[max_depth] == 2)
return 1;
#endif
else if (block[max_depth] == 3)
return 0;
}
@ -708,7 +719,11 @@ static int is_second_rec(int mi_row, int mi_col, BLOCK_SIZE bsize) {
int vp9_construct_ref_inter_list(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
BLOCK_SIZE bsize, int mi_row, int mi_col,
BLOCK_SIZE bsize,
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
int mi_row, int mi_col,
MB_MODE_INFO *ref_list[18]) {
int bw = 4 << b_width_log2_lookup[bsize];
int bh = 4 << b_height_log2_lookup[bsize];
@ -771,7 +786,11 @@ int vp9_construct_ref_inter_list(VP9_COMMON *cm, MACROBLOCKD *xd,
row_offset = row_offset_cand[i];
col_offset = col_offset_cand[i];
if ((col_offset < (bw / 8) ||
(col_offset == (bw / 8) && is_right_available(bsize, mi_row, mi_col)))
(col_offset == (bw / 8) && is_right_available(bsize,
#if CONFIG_EXT_PARTITION
partition,
#endif
mi_row, mi_col)))
&& check_inside(tile, mi_row + row_offset, mi_col + col_offset)) {
mi_offset = row_offset * cm->mi_stride + col_offset;
ref_mbmi = &xd->mi[mi_offset].src_mi->mbmi;

View File

@ -385,7 +385,11 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_COPY_MODE
int vp9_construct_ref_inter_list(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
BLOCK_SIZE bsize, int mi_row, int mi_col,
BLOCK_SIZE bsize,
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
int mi_row, int mi_col,
MB_MODE_INFO *ref_list[18]);
#endif // CONFIG_COPY_MODE

View File

@ -1583,6 +1583,11 @@ static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
#endif
int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize) {
@ -1597,10 +1602,22 @@ static void decode_block(VP9_COMMON *const cm, MACROBLOCKD *const xd,
} else {
mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
}
vp9_read_mode_info(cm, xd, tile, supertx_enabled, mi_row, mi_col, r);
vp9_read_mode_info(cm, xd, tile, supertx_enabled,
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r);
#else
MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
vp9_read_mode_info(cm, xd, tile, mi_row, mi_col, r);
vp9_read_mode_info(cm, xd, tile,
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r);
#endif // CONFIG_SUPERTX
#if CONFIG_TX_SKIP
q_idx = vp9_get_qindex(&cm->seg, mbmi->segment_id, cm->base_qindex);
@ -1765,6 +1782,11 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, subsize);
} else {
@ -1773,6 +1795,11 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, subsize);
break;
@ -1780,12 +1807,22 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, subsize);
if (mi_row + hbs < cm->mi_rows)
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row + hbs, mi_col, r, subsize);
break;
@ -1793,12 +1830,22 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, subsize);
if (mi_col + hbs < cm->mi_cols)
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col + hbs, r, subsize);
break;
@ -1824,16 +1871,31 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, bsize2);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col + hbs, r, bsize2);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row + hbs, mi_col, r, subsize);
break;
@ -1841,16 +1903,31 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, subsize);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row + hbs, mi_col, r, bsize2);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row + hbs, mi_col + hbs, r, bsize2);
break;
@ -1858,16 +1935,31 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, bsize2);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row + hbs, mi_col, r, bsize2);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col + hbs, r, subsize);
break;
@ -1875,16 +1967,31 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r, subsize);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col + hbs, r, bsize2);
decode_block(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row + hbs, mi_col + hbs, r, bsize2);
break;

View File

@ -1289,6 +1289,11 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm,
const TileInfo *const tile,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
#endif
int mi_row, int mi_col, vp9_reader *r) {
MODE_INFO *const mi = xd->mi[0].src_mi;
@ -1308,7 +1313,11 @@ static void read_inter_frame_mode_info(VP9_COMMON *const cm,
#if CONFIG_COPY_MODE
if (mbmi->sb_type >= BLOCK_8X8)
num_candidate = vp9_construct_ref_inter_list(
cm, xd, tile, mbmi->sb_type, mi_row, mi_col, inter_ref_list);
cm, xd, tile, mbmi->sb_type,
#if CONFIG_EXT_PARTITION
partition,
#endif
mi_row, mi_col, inter_ref_list);
if (mbmi->sb_type >= BLOCK_8X8 && num_candidate > 0) {
int ctx = vp9_get_copy_mode_context(xd);
int is_copy = vp9_read(r, cm->fc.copy_noref_prob[ctx][mbmi->sb_type]);
@ -1610,6 +1619,11 @@ void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
const TileInfo *const tile,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
#endif
int mi_row, int mi_col, vp9_reader *r) {
if (frame_is_intra_only(cm))
@ -1618,6 +1632,11 @@ void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
read_inter_frame_mode_info(cm, xd, tile,
#if CONFIG_SUPERTX
supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
partition,
#endif
#endif
mi_row, mi_col, r);
}

View File

@ -23,6 +23,11 @@ void vp9_read_mode_info(VP9_COMMON *cm, MACROBLOCKD *xd,
const struct TileInfo *const tile,
#if CONFIG_SUPERTX
int supertx_enabled,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
#endif
int mi_row, int mi_col, vp9_reader *r);

View File

@ -19,12 +19,17 @@ static const BLOCK_SIZE square[] = {
};
static void alloc_mode_context(VP9_COMMON *cm, int num_4x4_blk,
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
PICK_MODE_CONTEXT *ctx) {
const int num_blk = (num_4x4_blk < 4 ? 4 : num_4x4_blk);
const int num_pix = num_blk << 4;
int i, k;
ctx->num_4x4_blk = num_blk;
#if CONFIG_EXT_PARTITION
ctx->partition = partition;
#endif
CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
for (i = 0; i < MAX_MB_PLANE; ++i) {
@ -79,6 +84,32 @@ static void free_mode_context(PICK_MODE_CONTEXT *ctx) {
static void alloc_tree_contexts(VP9_COMMON *cm, PC_TREE *tree,
int num_4x4_blk) {
#if CONFIG_EXT_PARTITION
alloc_mode_context(cm, num_4x4_blk, PARTITION_NONE, &tree->none);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ, &tree->horizontal[0]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->vertical[0]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->horizontal[1]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->vertical[1]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_A,
&tree->horizontala[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_A,
&tree->horizontala[1]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ_A,
&tree->horizontala[2]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ_B,
&tree->horizontalb[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_B,
&tree->horizontalb[1]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_B,
&tree->horizontalb[2]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_A, &tree->verticala[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_A, &tree->verticala[1]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT_A, &tree->verticala[2]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT_B, &tree->verticalb[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_B, &tree->verticalb[1]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_B, &tree->verticalb[2]);
#else
alloc_mode_context(cm, num_4x4_blk, &tree->none);
alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontal[0]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->vertical[0]);
@ -87,20 +118,6 @@ static void alloc_tree_contexts(VP9_COMMON *cm, PC_TREE *tree,
* Figure out a better way to do this. */
alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontal[1]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->vertical[1]);
#if CONFIG_EXT_PARTITION
alloc_mode_context(cm, num_4x4_blk/4, &tree->horizontala[0]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->horizontala[1]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontala[2]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontalb[0]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->horizontalb[1]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->horizontalb[2]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->verticala[0]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->verticala[1]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->verticala[2]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->verticalb[0]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->verticalb[1]);
alloc_mode_context(cm, num_4x4_blk/4, &tree->verticalb[2]);
#endif
}
@ -147,9 +164,13 @@ void vp9_setup_pc_tree(VP9_COMMON *cm, VP9_COMP *cpi) {
// 4x4 blocks smaller than 8x8 but in the same 8x8 block share the same
// context so we only need to allocate 1 for each 8x8 block.
#if CONFIG_EXT_PARTITION
for (i = 0; i < leaf_nodes; ++i)
alloc_mode_context(cm, 1, PARTITION_NONE, &cpi->leaf_tree[i]);
#else
for (i = 0; i < leaf_nodes; ++i)
alloc_mode_context(cm, 1, &cpi->leaf_tree[i]);
#endif
// Sets up all the leaf nodes in the tree.
for (pc_tree_index = 0; pc_tree_index < leaf_nodes; ++pc_tree_index) {
PC_TREE *const tree = &cpi->pc_tree[pc_tree_index];

View File

@ -69,6 +69,9 @@ typedef struct {
// search loop
MV pred_mv[MAX_REF_FRAMES];
INTERP_FILTER pred_interp_filter;
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition;
#endif
} PICK_MODE_CONTEXT;
typedef struct PC_TREE {

View File

@ -1483,6 +1483,11 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile,
vp9_rd_pick_inter_mode_sb(cpi, x, tile, mi_row, mi_col, rd_cost,
#if CONFIG_SUPERTX
totalrate_nocoef,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
ctx->partition,
#endif
#endif
bsize, ctx, best_rd);
}

View File

@ -5991,6 +5991,11 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
RD_COST *rd_cost,
#if CONFIG_SUPERTX
int *returnrate_nocoef,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
#endif
BLOCK_SIZE bsize,
PICK_MODE_CONTEXT *ctx,
@ -6098,8 +6103,11 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
&comp_mode_p);
#if CONFIG_COPY_MODE
inter_ref_count =
vp9_construct_ref_inter_list(cm, xd, tile, bsize, mi_row, mi_col,
inter_ref_list);
vp9_construct_ref_inter_list(cm, xd, tile, bsize,
#if CONFIG_EXT_PARTITION
partition,
#endif
mi_row, mi_col, inter_ref_list);
mbmi->inter_ref_count = inter_ref_count;
#endif // CONFIG_COPY_MODE

View File

@ -39,6 +39,12 @@ void vp9_rd_pick_inter_mode_sb(struct VP9_COMP *cpi, struct macroblock *x,
#if CONFIG_SUPERTX
int *returnrate_nocoef,
#endif
#if CONFIG_COPY_MODE
#if CONFIG_EXT_PARTITION
PARTITION_TYPE partition,
#endif
#endif
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far);