Merge "Inlining set_partition_seg_context function."

This commit is contained in:
Dmitry Kovalev 2013-10-21 14:43:37 -07:00 committed by Gerrit Code Review
commit f6d870f7ae
5 changed files with 68 additions and 88 deletions

View File

@ -206,10 +206,6 @@ typedef struct macroblockd {
int left_available; int left_available;
int right_available; int right_available;
// partition contexts
PARTITION_CONTEXT *above_seg_context;
PARTITION_CONTEXT *left_seg_context;
/* Distance of MB away from frame edges */ /* Distance of MB away from frame edges */
int mb_to_left_edge; int mb_to_left_edge;
int mb_to_right_edge; int mb_to_right_edge;
@ -232,44 +228,7 @@ typedef struct macroblockd {
int q_index; int q_index;
} MACROBLOCKD; } MACROBLOCKD;
static INLINE void update_partition_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type,
BLOCK_SIZE sb_size) {
const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2;
const int bwl = b_width_log2(sb_type);
const int bhl = b_height_log2(sb_type);
const int boffset = b_width_log2(BLOCK_64X64) - bsl;
const char pcval0 = ~(0xe << boffset);
const char pcval1 = ~(0xf << boffset);
const char pcvalue[2] = {pcval0, pcval1};
assert(MAX(bwl, bhl) <= bsl);
// update the partition context at the end notes. set partition bits
// of block sizes larger than the current one to be one, and partition
// bits of smaller block sizes to be zero.
vpx_memset(xd->above_seg_context, pcvalue[bwl == bsl], bs);
vpx_memset(xd->left_seg_context, pcvalue[bhl == bsl], bs);
}
static INLINE int partition_plane_context(MACROBLOCKD *xd, BLOCK_SIZE sb_type) {
int bsl = mi_width_log2(sb_type), bs = 1 << bsl;
int above = 0, left = 0, i;
int boffset = mi_width_log2(BLOCK_64X64) - bsl;
assert(mi_width_log2(sb_type) == mi_height_log2(sb_type));
assert(bsl >= 0);
assert(boffset >= 0);
for (i = 0; i < bs; i++)
above |= (xd->above_seg_context[i] & (1 << boffset));
for (i = 0; i < bs; i++)
left |= (xd->left_seg_context[i] & (1 << boffset));
above = (above > 0);
left = (left > 0);
return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
}
static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) { static BLOCK_SIZE get_subsize(BLOCK_SIZE bsize, PARTITION_TYPE partition) {
const BLOCK_SIZE subsize = subsize_lookup[partition][bsize]; const BLOCK_SIZE subsize = subsize_lookup[partition][bsize];

View File

@ -253,12 +253,6 @@ static INLINE void set_skip_context(VP9_COMMON *cm, MACROBLOCKD *xd,
} }
} }
static INLINE void set_partition_seg_context(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int mi_col) {
xd->above_seg_context = cm->above_seg_context + mi_col;
xd->left_seg_context = cm->left_seg_context + (mi_row & MI_MASK);
}
// return the node index in the prob tree for binary coding // return the node index in the prob tree for binary coding
static int check_bsize_coverage(int bs, int mi_rows, int mi_cols, static int check_bsize_coverage(int bs, int mi_rows, int mi_cols,
int mi_row, int mi_col) { int mi_row, int mi_col) {
@ -307,4 +301,53 @@ static INLINE int frame_is_intra_only(const VP9_COMMON *const cm) {
return cm->frame_type == KEY_FRAME || cm->intra_only; return cm->frame_type == KEY_FRAME || cm->intra_only;
} }
static INLINE void update_partition_context(VP9_COMMON *cm,
int mi_row, int mi_col,
BLOCK_SIZE sb_type,
BLOCK_SIZE sb_size) {
PARTITION_CONTEXT *above_ctx = cm->above_seg_context + mi_col;
PARTITION_CONTEXT *left_ctx = cm->left_seg_context + (mi_row & MI_MASK);
const int bsl = b_width_log2(sb_size), bs = (1 << bsl) / 2;
const int bwl = b_width_log2(sb_type);
const int bhl = b_height_log2(sb_type);
const int boffset = b_width_log2(BLOCK_64X64) - bsl;
const char pcval0 = ~(0xe << boffset);
const char pcval1 = ~(0xf << boffset);
const char pcvalue[2] = {pcval0, pcval1};
assert(MAX(bwl, bhl) <= bsl);
// update the partition context at the end notes. set partition bits
// of block sizes larger than the current one to be one, and partition
// bits of smaller block sizes to be zero.
vpx_memset(above_ctx, pcvalue[bwl == bsl], bs);
vpx_memset(left_ctx, pcvalue[bhl == bsl], bs);
}
static INLINE int partition_plane_context(const VP9_COMMON *cm,
int mi_row, int mi_col,
BLOCK_SIZE sb_type) {
const PARTITION_CONTEXT *above_ctx = cm->above_seg_context + mi_col;
const PARTITION_CONTEXT *left_ctx = cm->left_seg_context + (mi_row & MI_MASK);
int bsl = mi_width_log2(sb_type), bs = 1 << bsl;
int above = 0, left = 0, i;
int boffset = mi_width_log2(BLOCK_64X64) - bsl;
assert(mi_width_log2(sb_type) == mi_height_log2(sb_type));
assert(bsl >= 0);
assert(boffset >= 0);
for (i = 0; i < bs; i++)
above |= (above_ctx[i] & (1 << boffset));
for (i = 0; i < bs; i++)
left |= (left_ctx[i] & (1 << boffset));
above = (above > 0);
left = (left > 0);
return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
}
#endif // VP9_COMMON_VP9_ONYXC_INT_H_ #endif // VP9_COMMON_VP9_ONYXC_INT_H_

View File

@ -196,7 +196,6 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL; xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL;
set_skip_context(cm, xd, mi_row, mi_col); set_skip_context(cm, xd, mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
// Distance of Mb to the various image edges. These are specified to 8th pel // Distance of Mb to the various image edges. These are specified to 8th pel
// as they are always compared to values that are in 1/8th pel units // as they are always compared to values that are in 1/8th pel units
@ -274,7 +273,6 @@ static void decode_modes_sb(VP9D_COMP *pbi, int tile_col,
int mi_row, int mi_col, int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE bsize, int index) { vp9_reader* r, BLOCK_SIZE bsize, int index) {
VP9_COMMON *const cm = &pbi->common; VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2; const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
PARTITION_TYPE partition = PARTITION_NONE; PARTITION_TYPE partition = PARTITION_NONE;
BLOCK_SIZE subsize; BLOCK_SIZE subsize;
@ -289,8 +287,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int tile_col,
int pl; int pl;
const int idx = check_bsize_coverage(hbs, cm->mi_rows, cm->mi_cols, const int idx = check_bsize_coverage(hbs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col); mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
if (idx == 0) if (idx == 0)
partition = treed_read(r, vp9_partition_tree, partition = treed_read(r, vp9_partition_tree,
@ -335,10 +332,8 @@ static void decode_modes_sb(VP9D_COMP *pbi, int tile_col,
// update partition context // update partition context
if (bsize >= BLOCK_8X8 && if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) { (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
set_partition_seg_context(cm, xd, mi_row, mi_col); update_partition_context(cm, mi_row, mi_col, subsize, bsize);
update_partition_context(xd, subsize, bsize);
}
} }
static void setup_token_decoder(const uint8_t *data, static void setup_token_decoder(const uint8_t *data,

View File

@ -600,7 +600,6 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
int mi_row, int mi_col, BLOCK_SIZE bsize, int mi_row, int mi_col, BLOCK_SIZE bsize,
int index) { int index) {
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
const int mis = cm->mode_info_stride; const int mis = cm->mode_info_stride;
int bsl = b_width_log2(bsize); int bsl = b_width_log2(bsize);
int bs = (1 << bsl) / 4; // mode_info step for subsize int bs = (1 << bsl) / 4; // mode_info step for subsize
@ -621,8 +620,7 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
int pl; int pl;
const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols, const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col); mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
// encode the partition information // encode the partition information
if (idx == 0) if (idx == 0)
write_token(bc, vp9_partition_tree, write_token(bc, vp9_partition_tree,
@ -664,10 +662,8 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO **mi_8x8, vp9_writer *bc,
// update partition context // update partition context
if (bsize >= BLOCK_8X8 && if (bsize >= BLOCK_8X8 &&
(bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) { (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
set_partition_seg_context(cm, xd, mi_row, mi_col); update_partition_context(cm, mi_row, mi_col, subsize, bsize);
update_partition_context(xd, subsize, bsize);
}
} }
static void write_modes(VP9_COMP *cpi, vp9_writer* const bc, static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,

View File

@ -500,7 +500,6 @@ static void set_offsets(VP9_COMP *cpi, int mi_row, int mi_col,
const struct segmentation *const seg = &cm->seg; const struct segmentation *const seg = &cm->seg;
set_skip_context(cm, xd, mi_row, mi_col); set_skip_context(cm, xd, mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
// Activity map pointer // Activity map pointer
x->mb_activity_ptr = &cpi->mb_activity_map[idx_map]; x->mb_activity_ptr = &cpi->mb_activity_map[idx_map];
@ -819,8 +818,7 @@ static void encode_sb(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row, int mi_col,
c1 = BLOCK_4X4; c1 = BLOCK_4X4;
if (bsize >= BLOCK_8X8) { if (bsize >= BLOCK_8X8) {
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
c1 = *(get_sb_partitioning(x, bsize)); c1 = *(get_sb_partitioning(x, bsize));
} }
partition = partition_lookup[bsl][c1]; partition = partition_lookup[bsl][c1];
@ -862,10 +860,8 @@ static void encode_sb(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row, int mi_col,
break; break;
} }
if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) { if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
set_partition_seg_context(cm, xd, mi_row, mi_col); update_partition_context(cm, mi_row, mi_col, c1, bsize);
update_partition_context(xd, c1, bsize);
}
} }
// Check to see if the given partition size is allowed for a specified number // Check to see if the given partition size is allowed for a specified number
@ -1056,8 +1052,7 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO **mi_8x8,
pick_sb_modes(cpi, mi_row, mi_col, &none_rate, &none_dist, bsize, pick_sb_modes(cpi, mi_row, mi_col, &none_rate, &none_dist, bsize,
get_block_context(x, bsize), INT64_MAX); get_block_context(x, bsize), INT64_MAX);
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
none_rate += x->partition_cost[pl][PARTITION_NONE]; none_rate += x->partition_cost[pl][PARTITION_NONE];
restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
@ -1147,8 +1142,8 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO **mi_8x8,
default: default:
assert(0); assert(0);
} }
set_partition_seg_context(cm, xd, mi_row, mi_col);
pl = partition_plane_context(xd, bsize); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
if (last_part_rate < INT_MAX) if (last_part_rate < INT_MAX)
last_part_rate += x->partition_cost[pl][partition]; last_part_rate += x->partition_cost[pl][partition];
@ -1198,12 +1193,10 @@ static void rd_use_partition(VP9_COMP *cpi, MODE_INFO **mi_8x8,
split_rate += rt; split_rate += rt;
split_dist += dt; split_dist += dt;
set_partition_seg_context(cm, xd, mi_row + y_idx, mi_col + x_idx); pl = partition_plane_context(cm, mi_row + y_idx, mi_col + x_idx, bsize);
pl = partition_plane_context(xd, bsize);
split_rate += x->partition_cost[pl][PARTITION_NONE]; split_rate += x->partition_cost[pl][PARTITION_NONE];
} }
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
if (split_rate < INT_MAX) { if (split_rate < INT_MAX) {
split_rate += x->partition_cost[pl][PARTITION_SPLIT]; split_rate += x->partition_cost[pl][PARTITION_SPLIT];
@ -1532,8 +1525,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
get_block_context(x, bsize), best_rd); get_block_context(x, bsize), best_rd);
if (this_rate != INT_MAX) { if (this_rate != INT_MAX) {
if (bsize >= BLOCK_8X8) { if (bsize >= BLOCK_8X8) {
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
this_rate += x->partition_cost[pl][PARTITION_NONE]; this_rate += x->partition_cost[pl][PARTITION_NONE];
} }
sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist);
@ -1593,8 +1585,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
} }
} }
if (sum_rd < best_rd && i == 4) { if (sum_rd < best_rd && i == 4) {
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; sum_rate += x->partition_cost[pl][PARTITION_SPLIT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
@ -1650,8 +1641,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
} }
} }
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
sum_rate += x->partition_cost[pl][PARTITION_HORZ]; sum_rate += x->partition_cost[pl][PARTITION_HORZ];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
@ -1693,8 +1683,7 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
} }
} }
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, bsize);
pl = partition_plane_context(xd, bsize);
sum_rate += x->partition_cost[pl][PARTITION_VERT]; sum_rate += x->partition_cost[pl][PARTITION_VERT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
if (sum_rd < best_rd) { if (sum_rd < best_rd) {
@ -1726,7 +1715,6 @@ static void rd_pick_partition(VP9_COMP *cpi, TOKENEXTRA **tp, int mi_row,
static void rd_pick_reference_frame(VP9_COMP *cpi, int mi_row, int mi_col) { static void rd_pick_reference_frame(VP9_COMP *cpi, int mi_row, int mi_col) {
VP9_COMMON * const cm = &cpi->common; VP9_COMMON * const cm = &cpi->common;
MACROBLOCK * const x = &cpi->mb; MACROBLOCK * const x = &cpi->mb;
MACROBLOCKD * const xd = &x->e_mbd;
int bsl = b_width_log2(BLOCK_64X64), bs = 1 << bsl; int bsl = b_width_log2(BLOCK_64X64), bs = 1 << bsl;
int ms = bs / 2; int ms = bs / 2;
ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE];
@ -1746,8 +1734,7 @@ static void rd_pick_reference_frame(VP9_COMP *cpi, int mi_row, int mi_col) {
cpi->set_ref_frame_mask = 1; cpi->set_ref_frame_mask = 1;
pick_sb_modes(cpi, mi_row, mi_col, &r, &d, BLOCK_64X64, pick_sb_modes(cpi, mi_row, mi_col, &r, &d, BLOCK_64X64,
get_block_context(x, BLOCK_64X64), INT64_MAX); get_block_context(x, BLOCK_64X64), INT64_MAX);
set_partition_seg_context(cm, xd, mi_row, mi_col); pl = partition_plane_context(cm, mi_row, mi_col, BLOCK_64X64);
pl = partition_plane_context(xd, BLOCK_64X64);
r += x->partition_cost[pl][PARTITION_NONE]; r += x->partition_cost[pl][PARTITION_NONE];
*(get_sb_partitioning(x, BLOCK_64X64)) = BLOCK_64X64; *(get_sb_partitioning(x, BLOCK_64X64)) = BLOCK_64X64;