Refactor get_partition to be universal.

Change-Id: I3a2fe4073bb94c5afc24d9274e6edcdb3aed934f
This commit is contained in:
Geza Lore 2016-04-04 11:37:29 +01:00
Родитель e0dbfdeedc
Коммит f0290cd127
7 изменённых файлов: 112 добавлений и 112 удалений

Просмотреть файл

@ -353,40 +353,12 @@ typedef struct macroblockd {
static INLINE BLOCK_SIZE get_subsize(BLOCK_SIZE bsize,
PARTITION_TYPE partition) {
return subsize_lookup[partition][bsize];
if (partition == PARTITION_INVALID)
return PARTITION_INVALID;
else
return subsize_lookup[partition][bsize];
}
#if CONFIG_EXT_PARTITION_TYPES
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];
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];
MODE_INFO m_below = mi[(mi_row + bs) * mi_stride + mi_col];
if (m.mbmi.sb_type == h) {
return m_below.mbmi.sb_type == h ? PARTITION_HORZ : PARTITION_HORZ_B;
} else if (m.mbmi.sb_type == v) {
return m_right.mbmi.sb_type == v ? PARTITION_VERT : PARTITION_VERT_B;
} else if (m_below.mbmi.sb_type == h) {
return PARTITION_HORZ_A;
} else if (m_right.mbmi.sb_type == v) {
return PARTITION_VERT_A;
} else {
return PARTITION_SPLIT;
}
}
return partition;
}
#endif // CONFIG_EXT_PARTITION_TYPES
static const TX_TYPE intra_mode_to_tx_type_context[INTRA_MODES] = {
DCT_DCT, // DC
ADST_DCT, // V

Просмотреть файл

@ -355,6 +355,12 @@ void vp10_mfqe(VP10_COMMON *cm) {
const YV12_BUFFER_CONFIG *show = cm->frame_to_show;
// Last decoded frame and will store the MFQE result.
YV12_BUFFER_CONFIG *dest = &cm->post_proc_buffer;
#if CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
// TODO(any): Fix for ext parition types and 128 superblocks
assert(0);
#endif // CONFIG_EXT_PARTITION || CONFIG_EXT_PARTITION_TYPES
// Loop through each super block.
for (mi_row = 0; mi_row < cm->mi_rows; mi_row += MAX_MIB_SIZE) {
for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) {

Просмотреть файл

@ -652,6 +652,51 @@ static INLINE int txfm_partition_context(TXFM_CONTEXT *above_ctx,
}
#endif
static INLINE PARTITION_TYPE get_partition(const VP10_COMMON *const cm,
const int mi_row,
const int mi_col,
const BLOCK_SIZE bsize) {
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) {
return PARTITION_INVALID;
} else {
const int offset = mi_row * cm->mi_stride + mi_col;
MODE_INFO **mi = cm->mi_grid_visible + offset;
const MB_MODE_INFO *const mbmi = &mi[0]->mbmi;
const int bsl = b_width_log2_lookup[bsize];
const PARTITION_TYPE partition = partition_lookup[bsl][mbmi->sb_type];
#if !CONFIG_EXT_PARTITION_TYPES
return partition;
#else
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
assert(cm->mi_grid_visible[offset] == &cm->mi[offset]);
if (partition != PARTITION_NONE &&
bsize > BLOCK_8X8 &&
mi_row + hbs < cm->mi_rows &&
mi_col + hbs < cm->mi_cols) {
const BLOCK_SIZE h = get_subsize(bsize, PARTITION_HORZ_A);
const BLOCK_SIZE v = get_subsize(bsize, PARTITION_VERT_A);
const MB_MODE_INFO *const mbmi_right = &mi[hbs]->mbmi;
const MB_MODE_INFO *const mbmi_below = &mi[hbs * cm->mi_stride]->mbmi;
if (mbmi->sb_type == h) {
return mbmi_below->sb_type == h ? PARTITION_HORZ : PARTITION_HORZ_B;
} else if (mbmi->sb_type == v) {
return mbmi_right->sb_type == v ? PARTITION_VERT : PARTITION_VERT_B;
} else if (mbmi_below->sb_type == h) {
return PARTITION_HORZ_A;
} else if (mbmi_right->sb_type == v) {
return PARTITION_VERT_A;
} else {
return PARTITION_SPLIT;
}
}
return partition;
#endif // !CONFIG_EXT_PARTITION_TYPES
}
}
#ifdef __cplusplus
} // extern "C"
#endif

Просмотреть файл

@ -1292,17 +1292,15 @@ static void dec_predict_sb_complex(VP10Decoder *const pbi,
int mi_row_top, int mi_col_top,
BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
uint8_t *dst_buf[3], int dst_stride[3]) {
VP10_COMMON *const cm = &pbi->common;
const int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4;
PARTITION_TYPE partition;
BLOCK_SIZE subsize;
#if !CONFIG_EXT_PARTITION_TYPES
MB_MODE_INFO *mbmi;
#endif
int i, offset = mi_row * cm->mi_stride + mi_col;
const VP10_COMMON *const cm = &pbi->common;
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_EXT_PARTITION_TYPES
BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
const BLOCK_SIZE bsize2 = get_subsize(bsize, PARTITION_SPLIT);
#endif
int i;
const int mi_offset = mi_row * cm->mi_stride + mi_col;
uint8_t *dst_buf1[3], *dst_buf2[3], *dst_buf3[3];
DECLARE_ALIGNED(16, uint8_t,
@ -1345,16 +1343,8 @@ static void dec_predict_sb_complex(VP10Decoder *const pbi,
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
xd->mi = cm->mi_grid_visible + offset;
xd->mi[0] = cm->mi + offset;
#if CONFIG_EXT_PARTITION_TYPES
partition = get_partition(cm->mi, cm->mi_stride, cm->mi_rows, cm->mi_cols,
mi_row, mi_col, bsize);
#else
mbmi = &xd->mi[0]->mbmi;
partition = partition_lookup[bsl][mbmi->sb_type];
#endif
subsize = get_subsize(bsize, partition);
xd->mi = cm->mi_grid_visible + mi_offset;
xd->mi[0] = cm->mi + mi_offset;
for (i = 0; i < MAX_MB_PLANE; i++) {
xd->plane[i].dst.buf = dst_buf[i];

Просмотреть файл

@ -1654,13 +1654,12 @@ static void write_modes_sb(VP10_COMP *const cpi,
int mi_row, int mi_col, BLOCK_SIZE bsize) {
const VP10_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
const int bsl = b_width_log2_lookup[bsize];
const int bs = (1 << bsl) / 4;
PARTITION_TYPE partition;
BLOCK_SIZE subsize;
MODE_INFO *m = NULL;
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_SUPERTX
const int mi_offset = mi_row * cm->mi_stride + mi_col;
MB_MODE_INFO *mbmi = NULL;
const int pack_token = !supertx_enabled;
TX_SIZE supertx_size;
int plane;
@ -1669,17 +1668,10 @@ static void write_modes_sb(VP10_COMP *const cpi,
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
return;
m = cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col];
partition = partition_lookup[bsl][m->mbmi.sb_type];
#if CONFIG_EXT_PARTITION_TYPES
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);
write_partition(cm, xd, hbs, mi_row, mi_col, partition, bsize, w);
#if CONFIG_SUPERTX
xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col);
mbmi = &cm->mi_grid_visible[mi_offset]->mbmi;
xd->mi = cm->mi_grid_visible + mi_offset;
set_mi_row_col(xd, tile,
mi_row, num_8x8_blocks_high_lookup[bsize],
mi_col, num_8x8_blocks_wide_lookup[bsize],
@ -1730,59 +1722,59 @@ static void write_modes_sb(VP10_COMP *const cpi,
case PARTITION_HORZ:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
if (mi_row + bs < cm->mi_rows)
if (mi_row + hbs < cm->mi_rows)
write_modes_b_wrapper(cpi, tile, w, tok, tok_end,
supertx_enabled, mi_row + bs, mi_col);
supertx_enabled, mi_row + hbs, mi_col);
break;
case PARTITION_VERT:
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col);
if (mi_col + bs < cm->mi_cols)
if (mi_col + hbs < cm->mi_cols)
write_modes_b_wrapper(cpi, tile, w, tok, tok_end,
supertx_enabled, mi_row, mi_col + bs);
supertx_enabled, mi_row, mi_col + hbs);
break;
case PARTITION_SPLIT:
write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col, subsize);
write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col + bs, subsize);
mi_row, mi_col + hbs, subsize);
write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + bs, mi_col, subsize);
mi_row + hbs, mi_col, subsize);
write_modes_sb_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + bs, mi_col + bs, subsize);
mi_row + hbs, mi_col + hbs, subsize);
break;
#if CONFIG_EXT_PARTITION_TYPES
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, mi_col + bs);
mi_row, mi_col + hbs);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + bs, mi_col);
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 + bs, mi_col);
mi_row + hbs, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + bs, mi_col + bs);
mi_row + hbs, mi_col + hbs);
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 + bs, mi_col);
mi_row + hbs, mi_col);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row, mi_col + bs);
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 + bs);
mi_row, mi_col + hbs);
write_modes_b_wrapper(cpi, tile, w, tok, tok_end, supertx_enabled,
mi_row + bs, mi_col + bs);
mi_row + hbs, mi_col + hbs);
break;
#endif // CONFIG_EXT_PARTITION_TYPES
default:
@ -1791,15 +1783,15 @@ static void write_modes_sb(VP10_COMP *const cpi,
}
#if CONFIG_SUPERTX
if (partition != PARTITION_NONE && supertx_enabled && pack_token &&
!m->mbmi.skip) {
!mbmi->skip) {
assert(*tok < tok_end);
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const int mbmi_txb_size = txsize_to_bsize[m->mbmi.tx_size];
const int mbmi_txb_size = txsize_to_bsize[mbmi->tx_size];
const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi_txb_size];
const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi_txb_size];
int row, col;
TX_SIZE tx = plane ? get_uv_tx_size(&m->mbmi, &xd->plane[plane])
: m->mbmi.tx_size;
TX_SIZE tx = plane ? get_uv_tx_size(mbmi, &xd->plane[plane])
: mbmi->tx_size;
BLOCK_SIZE txb_size = txsize_to_bsize[tx];
int bw = num_4x4_blocks_wide_lookup[txb_size];

Просмотреть файл

@ -2572,12 +2572,11 @@ static void rd_use_partition(VP10_COMP *cpi,
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int mis = cm->mi_stride;
const int bsl = b_width_log2_lookup[bsize];
const int mi_step = num_4x4_blocks_wide_lookup[bsize] / 2;
const int bss = (1 << bsl) / 4;
const int bs = num_8x8_blocks_wide_lookup[bsize];
const int hbs = bs / 2;
int i, pl;
PARTITION_TYPE partition = PARTITION_NONE;
BLOCK_SIZE subsize;
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
RD_SEARCH_MACROBLOCK_CONTEXT x_ctx;
RD_COST last_part_rdc, none_rdc, chosen_rdc;
BLOCK_SIZE sub_subsize = BLOCK_4X4;
@ -2605,9 +2604,6 @@ static void rd_use_partition(VP10_COMP *cpi,
vp10_rd_cost_reset(&none_rdc);
vp10_rd_cost_reset(&chosen_rdc);
partition = partition_lookup[bsl][bs_type];
subsize = get_subsize(bsize, partition);
pc_tree->partitioning = partition;
#if CONFIG_VAR_TX
@ -2632,7 +2628,7 @@ static void rd_use_partition(VP10_COMP *cpi,
splits_below = 1;
for (i = 0; i < 4; i++) {
int jj = i >> 1, ii = i & 0x01;
MODE_INFO *this_mi = mi_8x8[jj * bss * mis + ii * bss];
MODE_INFO *this_mi = mi_8x8[jj * hbs * mis + ii * hbs];
if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) {
splits_below = 0;
}
@ -2642,8 +2638,8 @@ static void rd_use_partition(VP10_COMP *cpi,
// If partition is not none try none unless each of the 4 splits are split
// even further..
if (partition != PARTITION_NONE && !splits_below &&
mi_row + (mi_step >> 1) < cm->mi_rows &&
mi_col + (mi_step >> 1) < cm->mi_cols) {
mi_row + hbs < cm->mi_rows &&
mi_col + hbs < cm->mi_cols) {
pc_tree->partitioning = PARTITION_NONE;
rd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &none_rdc,
#if CONFIG_SUPERTX
@ -2694,7 +2690,7 @@ static void rd_use_partition(VP10_COMP *cpi,
subsize, &pc_tree->horizontal[0],
INT64_MAX);
if (last_part_rdc.rate != INT_MAX &&
bsize >= BLOCK_8X8 && mi_row + (mi_step >> 1) < cm->mi_rows) {
bsize >= BLOCK_8X8 && mi_row + hbs < cm->mi_rows) {
RD_COST tmp_rdc;
#if CONFIG_SUPERTX
int rt_nocoef = 0;
@ -2704,7 +2700,7 @@ static void rd_use_partition(VP10_COMP *cpi,
update_state(cpi, td, ctx, mi_row, mi_col, subsize, 0);
encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx);
rd_pick_sb_modes(cpi, tile_data, x,
mi_row + (mi_step >> 1), mi_col, &tmp_rdc,
mi_row + hbs, mi_col, &tmp_rdc,
#if CONFIG_SUPERTX
&rt_nocoef,
#endif
@ -2737,7 +2733,7 @@ static void rd_use_partition(VP10_COMP *cpi,
#endif
subsize, &pc_tree->vertical[0], INT64_MAX);
if (last_part_rdc.rate != INT_MAX &&
bsize >= BLOCK_8X8 && mi_col + (mi_step >> 1) < cm->mi_cols) {
bsize >= BLOCK_8X8 && mi_col + hbs < cm->mi_cols) {
RD_COST tmp_rdc;
#if CONFIG_SUPERTX
int rt_nocoef = 0;
@ -2747,7 +2743,7 @@ static void rd_use_partition(VP10_COMP *cpi,
update_state(cpi, td, ctx, mi_row, mi_col, subsize, 0);
encode_superblock(cpi, td, tp, 0, mi_row, mi_col, subsize, ctx);
rd_pick_sb_modes(cpi, tile_data, x,
mi_row, mi_col + (mi_step >> 1), &tmp_rdc,
mi_row, mi_col + hbs, &tmp_rdc,
#if CONFIG_SUPERTX
&rt_nocoef,
#endif
@ -2790,8 +2786,8 @@ static void rd_use_partition(VP10_COMP *cpi,
last_part_rate_nocoef = 0;
#endif
for (i = 0; i < 4; i++) {
int x_idx = (i & 1) * (mi_step >> 1);
int y_idx = (i >> 1) * (mi_step >> 1);
int x_idx = (i & 1) * hbs;
int y_idx = (i >> 1) * hbs;
int jj = i >> 1, ii = i & 0x01;
RD_COST tmp_rdc;
#if CONFIG_SUPERTX
@ -2802,7 +2798,7 @@ static void rd_use_partition(VP10_COMP *cpi,
vp10_rd_cost_init(&tmp_rdc);
rd_use_partition(cpi, td, tile_data,
mi_8x8 + jj * bss * mis + ii * bss, tp,
mi_8x8 + jj * hbs * mis + ii * hbs, tp,
mi_row + y_idx, mi_col + x_idx, subsize,
&tmp_rdc.rate, &tmp_rdc.dist,
#if CONFIG_SUPERTX
@ -2842,10 +2838,10 @@ static void rd_use_partition(VP10_COMP *cpi,
&& cpi->sf.adjust_partitioning_from_last_frame
&& cpi->sf.partition_search_type == SEARCH_PARTITION
&& partition != PARTITION_SPLIT && bsize > BLOCK_8X8
&& (mi_row + mi_step < cm->mi_rows ||
mi_row + (mi_step >> 1) == cm->mi_rows)
&& (mi_col + mi_step < cm->mi_cols ||
mi_col + (mi_step >> 1) == cm->mi_cols)) {
&& (mi_row + bs < cm->mi_rows ||
mi_row + hbs == cm->mi_rows)
&& (mi_col + bs < cm->mi_cols ||
mi_col + hbs == cm->mi_cols)) {
BLOCK_SIZE split_subsize = get_subsize(bsize, PARTITION_SPLIT);
chosen_rdc.rate = 0;
chosen_rdc.dist = 0;
@ -2859,8 +2855,8 @@ static void rd_use_partition(VP10_COMP *cpi,
// Split partition.
for (i = 0; i < 4; i++) {
int x_idx = (i & 1) * (mi_step >> 1);
int y_idx = (i >> 1) * (mi_step >> 1);
int x_idx = (i & 1) * hbs;
int y_idx = (i >> 1) * hbs;
RD_COST tmp_rdc;
#if CONFIG_SUPERTX
int rt_nocoef = 0;

Просмотреть файл

@ -180,8 +180,7 @@ static void count_segs_sb(const VP10_COMMON *cm, MACROBLOCKD *xd,
if (bsize == BLOCK_8X8)
partition = PARTITION_NONE;
else
partition = get_partition(cm->mi, cm->mi_stride, cm->mi_rows, cm->mi_cols,
mi_row, mi_col, bsize);
partition = get_partition(cm, mi_row, mi_col, bsize);
switch (partition) {
case PARTITION_NONE:
count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count,