Allow extended partition support to encode
Change-Id: I75246e2ee35a1b7c1ad46669c464e582e3a9961c
This commit is contained in:
committed by
Debargha Mukherjee
parent
e0617385d6
commit
3bf31c4c98
@@ -405,6 +405,37 @@ static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize,
|
||||
return subsize_lookup[partition][bsize];
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
static INLINE PARTITION_TYPE get_partition(const MODE_INFO *const mi,
|
||||
int mi_stride, int mi_rows,
|
||||
int mi_cols, int mi_row,
|
||||
int mi_col, BLOCK_SIZE bsize) {
|
||||
const int bsl = b_width_log2_lookup[bsize];
|
||||
const int bs = (1 << bsl) / 4;
|
||||
MODE_INFO *m = mi[mi_row * mi_stride + mi_col].src_mi;
|
||||
PARTITION_TYPE partition = partition_lookup[bsl][m->mbmi.sb_type];
|
||||
if (partition != PARTITION_NONE && bsize > BLOCK_8X8 &&
|
||||
mi_row + bs < mi_rows && mi_col + bs < mi_cols) {
|
||||
BLOCK_SIZE h = get_subsize(bsize, PARTITION_HORZ_A);
|
||||
BLOCK_SIZE v = get_subsize(bsize, PARTITION_VERT_A);
|
||||
MODE_INFO *m_right = mi[mi_row * mi_stride + mi_col + bs].src_mi;
|
||||
MODE_INFO *m_below = mi[(mi_row + bs) * mi_stride + mi_col].src_mi;
|
||||
if (m->mbmi.sb_type == h) {
|
||||
return m_below->mbmi.sb_type == h ? PARTITION_HORZ : PARTITION_HORZ_B;
|
||||
} else if (m_below->mbmi.sb_type == h) {
|
||||
return m->mbmi.sb_type == h ? PARTITION_HORZ : PARTITION_HORZ_A;
|
||||
} else if (m->mbmi.sb_type == v) {
|
||||
return m_right->mbmi.sb_type == v ? PARTITION_VERT : PARTITION_VERT_B;
|
||||
} else if (m_right->mbmi.sb_type == v) {
|
||||
return m->mbmi.sb_type == v ? PARTITION_VERT : PARTITION_VERT_A;
|
||||
} else {
|
||||
return PARTITION_SPLIT;
|
||||
}
|
||||
}
|
||||
return partition;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES];
|
||||
|
||||
#if CONFIG_SUPERTX
|
||||
|
||||
@@ -64,10 +64,10 @@ typedef enum PARTITION_TYPE {
|
||||
PARTITION_HORZ,
|
||||
PARTITION_VERT,
|
||||
PARTITION_SPLIT,
|
||||
PARTITION_HORZ_A, // HORZ split and the left partition is recursively split
|
||||
PARTITION_HORZ_B, // HORZ split and the right partition is recursively split
|
||||
PARTITION_VERT_A, // VERT split and the top partition is recursively split
|
||||
PARTITION_VERT_B, // VERT split and the bottom partition is recursively split
|
||||
PARTITION_HORZ_A, // HORZ split and the left partition is split again
|
||||
PARTITION_HORZ_B, // HORZ split and the right partition is split again
|
||||
PARTITION_VERT_A, // VERT split and the top partition is split again
|
||||
PARTITION_VERT_B, // VERT split and the bottom partition is split again
|
||||
EXT_PARTITION_TYPES,
|
||||
PARTITION_TYPES = PARTITION_SPLIT + 1,
|
||||
PARTITION_INVALID = EXT_PARTITION_TYPES
|
||||
|
||||
@@ -1870,8 +1870,12 @@ void vp9_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer,
|
||||
struct macroblockd_plane planes[MAX_MB_PLANE],
|
||||
int start, int stop, int y_only) {
|
||||
const int num_planes = y_only ? 1 : MAX_MB_PLANE;
|
||||
#if CONFIG_EXT_PARTITION
|
||||
const int use_420 = 0;
|
||||
#else
|
||||
const int use_420 = y_only || (planes[1].subsampling_y == 1 &&
|
||||
planes[1].subsampling_x == 1);
|
||||
#endif
|
||||
LOOP_FILTER_MASK lfm;
|
||||
int mi_row, mi_col;
|
||||
|
||||
|
||||
@@ -612,7 +612,7 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert("Invalid block index.");
|
||||
assert(0 && "Invalid block index.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -372,6 +372,47 @@ static INLINE void update_partition_context(MACROBLOCKD *xd,
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
static INLINE void update_ext_partition_context(MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col,
|
||||
BLOCK_SIZE subsize,
|
||||
BLOCK_SIZE bsize,
|
||||
PARTITION_TYPE partition) {
|
||||
if (bsize >= BLOCK_8X8) {
|
||||
const int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4;
|
||||
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
|
||||
switch (partition) {
|
||||
case PARTITION_SPLIT:
|
||||
if (bsize != BLOCK_8X8)
|
||||
break;
|
||||
case PARTITION_NONE:
|
||||
case PARTITION_HORZ:
|
||||
case PARTITION_VERT:
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case PARTITION_HORZ_B:
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, subsize);
|
||||
update_partition_context(xd, mi_row + hbs, mi_col, bsize2, subsize);
|
||||
break;
|
||||
case PARTITION_VERT_A:
|
||||
update_partition_context(xd, mi_row, mi_col, bsize2, subsize);
|
||||
update_partition_context(xd, mi_row, mi_col + hbs, 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 + hbs, bsize2, subsize);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Invalid partition type");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static INLINE int partition_plane_context(const MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col,
|
||||
BLOCK_SIZE bsize) {
|
||||
|
||||
@@ -1491,24 +1491,24 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
|
||||
break;
|
||||
#if CONFIG_EXT_PARTITION
|
||||
case PARTITION_HORZ_A:
|
||||
decode_partition(cm, xd, tile, mi_row, mi_col, r, bsize2);
|
||||
decode_partition(cm, xd, tile, mi_row, mi_col + hbs, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row, mi_col, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row, mi_col + hbs, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row + hbs, mi_col, r, subsize);
|
||||
break;
|
||||
case PARTITION_HORZ_B:
|
||||
decode_block(cm, xd, tile, mi_row, mi_col, r, subsize);
|
||||
decode_partition(cm, xd, tile, mi_row + hbs, mi_col, r, bsize2);
|
||||
decode_partition(cm, xd, tile, mi_row + hbs, mi_col + hbs, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row + hbs, mi_col, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row + hbs, mi_col + hbs, r, bsize2);
|
||||
break;
|
||||
case PARTITION_VERT_A:
|
||||
decode_partition(cm, xd, tile, mi_row, mi_col, r, bsize2);
|
||||
decode_partition(cm, xd, tile, mi_row + hbs, mi_col, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row, mi_col, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row + hbs, mi_col, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row, mi_col + hbs, r, subsize);
|
||||
break;
|
||||
case PARTITION_VERT_B:
|
||||
decode_block(cm, xd, tile, mi_row, mi_col, r, subsize);
|
||||
decode_partition(cm, xd, tile, mi_row, mi_col + hbs, r, bsize2);
|
||||
decode_partition(cm, xd, tile, mi_row + hbs, mi_col + hbs, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row, mi_col + hbs, r, bsize2);
|
||||
decode_block(cm, xd, tile, mi_row + hbs, mi_col + hbs, r, bsize2);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -1566,16 +1566,20 @@ static void decode_partition(VP9_COMMON *const cm, MACROBLOCKD *const xd,
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
case PARTITION_HORZ_B:
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, subsize);
|
||||
update_partition_context(xd, mi_row + hbs, mi_col, bsize2, subsize);
|
||||
break;
|
||||
case PARTITION_VERT_A:
|
||||
update_partition_context(xd, mi_row, mi_col, bsize2, subsize);
|
||||
update_partition_context(xd, mi_row, mi_col + hbs, 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 + hbs, bsize2, subsize);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Invalid partition type");
|
||||
|
||||
@@ -1178,8 +1178,11 @@ static void write_modes_sb(VP9_COMP *cpi,
|
||||
return;
|
||||
|
||||
m = cm->mi[mi_row * cm->mi_stride + mi_col].src_mi;
|
||||
|
||||
partition = partition_lookup[bsl][m->mbmi.sb_type];
|
||||
#if CONFIG_EXT_PARTITION
|
||||
partition = get_partition(cm->mi, cm->mi_stride, cm->mi_rows, cm->mi_cols,
|
||||
mi_row, mi_col, bsize);
|
||||
#endif
|
||||
write_partition(cm, xd, bs, mi_row, mi_col, partition, bsize, w);
|
||||
subsize = get_subsize(bsize, partition);
|
||||
#if CONFIG_SUPERTX
|
||||
@@ -1270,6 +1273,28 @@ static void write_modes_sb(VP9_COMP *cpi,
|
||||
#endif
|
||||
mi_row + bs, mi_col + bs, subsize);
|
||||
break;
|
||||
#if CONFIG_EXT_PARTITION
|
||||
case PARTITION_HORZ_A:
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col + bs);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row + bs, mi_col);
|
||||
break;
|
||||
case PARTITION_HORZ_B:
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row + bs, mi_col);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row + bs, mi_col + bs);
|
||||
break;
|
||||
case PARTITION_VERT_A:
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row + bs, mi_col);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col + bs);
|
||||
break;
|
||||
case PARTITION_VERT_B:
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row, mi_col + bs);
|
||||
write_modes_b(cpi, tile, w, tok, tok_end, mi_row + bs, mi_col + bs);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@@ -1282,9 +1307,13 @@ static void write_modes_sb(VP9_COMP *cpi,
|
||||
#endif
|
||||
|
||||
// update partition context
|
||||
#if CONFIG_EXT_PARTITION
|
||||
update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition);
|
||||
#else
|
||||
if (bsize >= BLOCK_8X8 &&
|
||||
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void write_modes(VP9_COMP *cpi,
|
||||
|
||||
@@ -87,9 +87,33 @@ 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
|
||||
}
|
||||
|
||||
static void free_tree_contexts(PC_TREE *tree) {
|
||||
#if CONFIG_EXT_PARTITION
|
||||
int i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
free_mode_context(&tree->horizontala[i]);
|
||||
free_mode_context(&tree->horizontalb[i]);
|
||||
free_mode_context(&tree->verticala[i]);
|
||||
free_mode_context(&tree->verticalb[i]);
|
||||
}
|
||||
#endif
|
||||
free_mode_context(&tree->none);
|
||||
free_mode_context(&tree->horizontal[0]);
|
||||
free_mode_context(&tree->horizontal[1]);
|
||||
|
||||
@@ -74,6 +74,12 @@ typedef struct PC_TREE {
|
||||
PICK_MODE_CONTEXT none;
|
||||
PICK_MODE_CONTEXT horizontal[2];
|
||||
PICK_MODE_CONTEXT vertical[2];
|
||||
#if CONFIG_EXT_PARTITION
|
||||
PICK_MODE_CONTEXT horizontala[3];
|
||||
PICK_MODE_CONTEXT horizontalb[3];
|
||||
PICK_MODE_CONTEXT verticala[3];
|
||||
PICK_MODE_CONTEXT verticalb[3];
|
||||
#endif
|
||||
union {
|
||||
struct PC_TREE *split[4];
|
||||
PICK_MODE_CONTEXT *leaf_split[4];
|
||||
|
||||
@@ -1639,6 +1639,9 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
int ctx;
|
||||
PARTITION_TYPE partition;
|
||||
BLOCK_SIZE subsize = bsize;
|
||||
#if CONFIG_EXT_PARTITION
|
||||
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
|
||||
#endif
|
||||
|
||||
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
|
||||
return;
|
||||
@@ -1652,6 +1655,10 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
}
|
||||
|
||||
partition = partition_lookup[bsl][subsize];
|
||||
#if CONFIG_EXT_PARTITION
|
||||
if (bsize > BLOCK_8X8)
|
||||
partition = pc_tree->partitioning;
|
||||
#endif
|
||||
if (output_enabled && bsize != BLOCK_4X4)
|
||||
cm->counts.partition[ctx][partition]++;
|
||||
|
||||
@@ -1721,8 +1728,13 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
(*tp)->token = EOSB_TOKEN;
|
||||
(*tp)++;
|
||||
}
|
||||
#if CONFIG_EXT_PARTITION
|
||||
update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize,
|
||||
partition);
|
||||
#else
|
||||
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
if (output_enabled) {
|
||||
@@ -1769,13 +1781,51 @@ static void encode_sb(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
subsize, pc_tree->split[3]);
|
||||
}
|
||||
break;
|
||||
#if CONFIG_EXT_PARTITION
|
||||
case PARTITION_HORZ_A:
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, bsize2,
|
||||
&pc_tree->horizontala[0]);
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, bsize2,
|
||||
&pc_tree->horizontala[1]);
|
||||
encode_b(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, subsize,
|
||||
&pc_tree->horizontala[2]);
|
||||
break;
|
||||
case PARTITION_HORZ_B:
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize,
|
||||
&pc_tree->horizontalb[0]);
|
||||
encode_b(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, bsize2,
|
||||
&pc_tree->horizontalb[1]);
|
||||
encode_b(cpi, tile, tp, mi_row + hbs, mi_col + hbs, output_enabled,
|
||||
bsize2, &pc_tree->horizontalb[2]);
|
||||
break;
|
||||
case PARTITION_VERT_A:
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, bsize2,
|
||||
&pc_tree->verticala[0]);
|
||||
encode_b(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, bsize2,
|
||||
&pc_tree->verticala[1]);
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, subsize,
|
||||
&pc_tree->verticala[2]);
|
||||
|
||||
break;
|
||||
case PARTITION_VERT_B:
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize,
|
||||
&pc_tree->verticalb[0]);
|
||||
encode_b(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, bsize2,
|
||||
&pc_tree->verticalb[1]);
|
||||
encode_b(cpi, tile, tp, mi_row + hbs, mi_col + hbs, output_enabled,
|
||||
bsize2, &pc_tree->verticalb[2]);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
assert("Invalid partition type.");
|
||||
assert(0 && "Invalid partition type.");
|
||||
break;
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition);
|
||||
#else
|
||||
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check to see if the given partition size is allowed for a specified number
|
||||
@@ -2094,12 +2144,15 @@ static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
subsize, pc_tree->split[3]);
|
||||
break;
|
||||
default:
|
||||
assert("Invalid partition type.");
|
||||
assert(0 && "Invalid partition type.");
|
||||
break;
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition);
|
||||
#else
|
||||
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void rd_use_partition(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
@@ -2797,6 +2850,76 @@ static INLINE int get_motion_inconsistency(MOTION_DIRECTION this_mv,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
static void rd_test_partition3(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
TOKENEXTRA **tp, PC_TREE *pc_tree,
|
||||
RD_COST *best_rdc, PICK_MODE_CONTEXT ctxs[3],
|
||||
PICK_MODE_CONTEXT *ctx,
|
||||
int mi_row, int mi_col, BLOCK_SIZE bsize,
|
||||
PARTITION_TYPE partition,
|
||||
int mi_row0, int mi_col0, BLOCK_SIZE subsize0,
|
||||
int mi_row1, int mi_col1, BLOCK_SIZE subsize1,
|
||||
int mi_row2, int mi_col2, BLOCK_SIZE subsize2) {
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
RD_COST this_rdc, sum_rdc;
|
||||
|
||||
if (cpi->sf.adaptive_motion_search)
|
||||
load_pred_mv(x, ctx);
|
||||
rd_pick_sb_modes(cpi, tile, mi_row0, mi_col0, &sum_rdc, subsize0, &ctxs[0],
|
||||
best_rdc->rdcost);
|
||||
|
||||
if (sum_rdc.rdcost < best_rdc->rdcost) {
|
||||
PICK_MODE_CONTEXT *ctx = &ctxs[0];
|
||||
update_state(cpi, ctx, mi_row0, mi_col0, subsize0, 0);
|
||||
encode_superblock(cpi, tp, 0, mi_row0, mi_col0, subsize0, ctx);
|
||||
|
||||
if (cpi->sf.adaptive_motion_search)
|
||||
load_pred_mv(x, ctx);
|
||||
rd_pick_sb_modes(cpi, tile, mi_row1, mi_col1, &this_rdc, subsize1, &ctxs[1],
|
||||
best_rdc->rdcost - sum_rdc.rdcost);
|
||||
|
||||
if (this_rdc.rate == INT_MAX) {
|
||||
sum_rdc.rdcost = INT64_MAX;
|
||||
} else {
|
||||
sum_rdc.rate += this_rdc.rate;
|
||||
sum_rdc.dist += this_rdc.dist;
|
||||
sum_rdc.rdcost += this_rdc.rdcost;
|
||||
}
|
||||
|
||||
if (sum_rdc.rdcost < best_rdc->rdcost) {
|
||||
PICK_MODE_CONTEXT *ctx = &ctxs[1];
|
||||
update_state(cpi, ctx, mi_row1, mi_col1, subsize1, 0);
|
||||
encode_superblock(cpi, tp, 0, mi_row1, mi_col1, subsize1, ctx);
|
||||
|
||||
if (cpi->sf.adaptive_motion_search)
|
||||
load_pred_mv(x, ctx);
|
||||
rd_pick_sb_modes(cpi, tile, mi_row2, mi_col2, &this_rdc, subsize2,
|
||||
&ctxs[2], best_rdc->rdcost - sum_rdc.rdcost);
|
||||
|
||||
if (this_rdc.rate == INT_MAX) {
|
||||
sum_rdc.rdcost = INT64_MAX;
|
||||
} else {
|
||||
sum_rdc.rate += this_rdc.rate;
|
||||
sum_rdc.dist += this_rdc.dist;
|
||||
sum_rdc.rdcost += this_rdc.rdcost;
|
||||
}
|
||||
|
||||
if (sum_rdc.rdcost < best_rdc->rdcost) {
|
||||
int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
|
||||
sum_rdc.rate += cpi->partition_cost[pl][partition];
|
||||
sum_rdc.rdcost = RDCOST(x->rdmult, x->rddiv, sum_rdc.rate,
|
||||
sum_rdc.dist);
|
||||
if (sum_rdc.rdcost < best_rdc->rdcost) {
|
||||
*best_rdc = sum_rdc;
|
||||
pc_tree->partitioning = partition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO(jingning,jimbankoski,rbultje): properly skip partition types that are
|
||||
// unlikely to be selected depending on previous rate-distortion optimization
|
||||
// results, for encoding speed-up.
|
||||
@@ -2827,6 +2950,9 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
#endif
|
||||
int do_split = bsize >= BLOCK_8X8;
|
||||
int do_rect = 1;
|
||||
#if CONFIG_EXT_PARTITION
|
||||
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
|
||||
#endif
|
||||
|
||||
// Override skipping rectangular partition operations for edge blocks
|
||||
const int force_horz_split = (mi_row + mi_step >= cm->mi_rows);
|
||||
@@ -3610,6 +3736,57 @@ static void rd_pick_partition(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
// PARTITION_HORZ_A
|
||||
if (partition_horz_allowed && do_rect && bsize > BLOCK_8X8 &&
|
||||
partition_none_allowed) {
|
||||
subsize = get_subsize(bsize, PARTITION_HORZ_A);
|
||||
rd_test_partition3(cpi, tile, tp, pc_tree, &best_rdc,
|
||||
pc_tree->horizontala,
|
||||
ctx, mi_row, mi_col, bsize, PARTITION_HORZ_A,
|
||||
mi_row, mi_col, bsize2,
|
||||
mi_row, mi_col + mi_step, bsize2,
|
||||
mi_row + mi_step, mi_col, subsize);
|
||||
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
|
||||
}
|
||||
// PARTITION_HORZ_B
|
||||
if (partition_horz_allowed && do_rect && bsize > BLOCK_8X8 &&
|
||||
partition_none_allowed) {
|
||||
subsize = get_subsize(bsize, PARTITION_HORZ_B);
|
||||
rd_test_partition3(cpi, tile, tp, pc_tree, &best_rdc,
|
||||
pc_tree->horizontalb,
|
||||
ctx, mi_row, mi_col, bsize, PARTITION_HORZ_B,
|
||||
mi_row, mi_col, subsize,
|
||||
mi_row + mi_step, mi_col, bsize2,
|
||||
mi_row + mi_step, mi_col + mi_step, bsize2);
|
||||
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
|
||||
}
|
||||
// PARTITION_VERT_A
|
||||
if (partition_vert_allowed && do_rect && bsize > BLOCK_8X8 &&
|
||||
partition_none_allowed) {
|
||||
subsize = get_subsize(bsize, PARTITION_VERT_A);
|
||||
rd_test_partition3(cpi, tile, tp, pc_tree, &best_rdc,
|
||||
pc_tree->verticala,
|
||||
ctx, mi_row, mi_col, bsize, PARTITION_VERT_A,
|
||||
mi_row, mi_col, bsize2,
|
||||
mi_row + mi_step, mi_col, bsize2,
|
||||
mi_row, mi_col + mi_step, subsize);
|
||||
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
|
||||
}
|
||||
// PARTITION_VERT_B
|
||||
if (partition_vert_allowed && do_rect && bsize > BLOCK_8X8 &&
|
||||
partition_none_allowed) {
|
||||
subsize = get_subsize(bsize, PARTITION_VERT_B);
|
||||
rd_test_partition3(cpi, tile, tp, pc_tree, &best_rdc,
|
||||
pc_tree->verticalb,
|
||||
ctx, mi_row, mi_col, bsize, PARTITION_VERT_B,
|
||||
mi_row, mi_col, subsize,
|
||||
mi_row, mi_col + mi_step, bsize2,
|
||||
mi_row + mi_step, mi_col + mi_step, bsize2);
|
||||
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO(jbb): This code added so that we avoid static analysis
|
||||
// warning related to the fact that best_rd isn't used after this
|
||||
// point. This code should be refactored so that the duplicate
|
||||
@@ -4237,7 +4414,7 @@ static void nonrd_select_partition(VP9_COMP *cpi,
|
||||
nonrd_increment_rate_distortion(rd_cost, &this_rdc);
|
||||
break;
|
||||
default:
|
||||
assert("Invalid partition type.");
|
||||
assert(0 && "Invalid partition type.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4321,7 +4498,7 @@ static void nonrd_use_partition(VP9_COMP *cpi,
|
||||
nonrd_increment_rate_distortion(rd_cost, &this_rdc);
|
||||
break;
|
||||
default:
|
||||
assert("Invalid partition type.");
|
||||
assert(0 && "Invalid partition type.");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5742,9 +5919,13 @@ static void predict_sb_complex(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
if (bsize < top_bsize)
|
||||
update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition);
|
||||
#else
|
||||
if (bsize < top_bsize && (partition != PARTITION_SPLIT || bsize == BLOCK_8X8))
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_VP9_HIGHBITDEPTH
|
||||
@@ -5958,9 +6139,13 @@ static void predict_sb_complex_highbd(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
if (bsize < top_bsize)
|
||||
update_ext_partition_context(xd, mi_row, mi_col, subsize, bsize, partition);
|
||||
#else
|
||||
if (bsize < top_bsize && (partition != PARTITION_SPLIT || bsize == BLOCK_8X8))
|
||||
update_partition_context(xd, mi_row, mi_col, subsize, bsize);
|
||||
#endif
|
||||
}
|
||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||
|
||||
|
||||
@@ -321,9 +321,17 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) {
|
||||
fill_token_costs_pxd(x->token_costs_pxd, cm->fc.coef_probs_pxd);
|
||||
#endif // CONFIG_TX_SKIP
|
||||
|
||||
#if CONFIG_EXT_PARTITION
|
||||
vp9_cost_tokens(cpi->partition_cost[0], get_partition_probs(cm, 0),
|
||||
vp9_partition_tree);
|
||||
for (i = 1; i < PARTITION_CONTEXTS; ++i)
|
||||
vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(cm, i),
|
||||
vp9_ext_partition_tree);
|
||||
#else
|
||||
for (i = 0; i < PARTITION_CONTEXTS; ++i)
|
||||
vp9_cost_tokens(cpi->partition_cost[i], get_partition_probs(cm, i),
|
||||
vp9_partition_tree);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!cpi->sf.use_nonrd_pick_mode || (cm->current_video_frame & 0x07) == 1 ||
|
||||
|
||||
Reference in New Issue
Block a user