summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-10-21 14:43:37 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-10-21 14:43:37 -0700
commitf6d870f7ae6f968bdbc342af80c8f71fa98f2ac2 (patch)
treeef2f7dc7761f7c2e2c0b173730986d5bf4f0aa0a /vp9
parent1e05c9a7e64ac29ddcd036c1f0e22c70cecb25b4 (diff)
parenta0be71c703ad17dc59c1f3d6308bb020d716c1a8 (diff)
downloadlibvpx-f6d870f7ae6f968bdbc342af80c8f71fa98f2ac2.tar
libvpx-f6d870f7ae6f968bdbc342af80c8f71fa98f2ac2.tar.gz
libvpx-f6d870f7ae6f968bdbc342af80c8f71fa98f2ac2.tar.bz2
libvpx-f6d870f7ae6f968bdbc342af80c8f71fa98f2ac2.zip
Merge "Inlining set_partition_seg_context function."
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_blockd.h41
-rw-r--r--vp9/common/vp9_onyxc_int.h55
-rw-r--r--vp9/decoder/vp9_decodframe.c11
-rw-r--r--vp9/encoder/vp9_bitstream.c10
-rw-r--r--vp9/encoder/vp9_encodeframe.c39
5 files changed, 68 insertions, 88 deletions
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index 31959c150..0dfdd8630 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -206,10 +206,6 @@ typedef struct macroblockd {
int left_available;
int right_available;
- // partition contexts
- PARTITION_CONTEXT *above_seg_context;
- PARTITION_CONTEXT *left_seg_context;
-
/* Distance of MB away from frame edges */
int mb_to_left_edge;
int mb_to_right_edge;
@@ -232,44 +228,7 @@ typedef struct macroblockd {
int q_index;
} 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) {
const BLOCK_SIZE subsize = subsize_lookup[partition][bsize];
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 5fc180bb5..bc6535d61 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -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
static int check_bsize_coverage(int bs, int mi_rows, int mi_cols,
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;
}
+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_
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index 5ac5c2be3..b79ff554d 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -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;
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
// 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,
vp9_reader* r, BLOCK_SIZE bsize, int index) {
VP9_COMMON *const cm = &pbi->common;
- MACROBLOCKD *const xd = &pbi->mb;
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
PARTITION_TYPE partition = PARTITION_NONE;
BLOCK_SIZE subsize;
@@ -289,8 +287,7 @@ static void decode_modes_sb(VP9D_COMP *pbi, int tile_col,
int pl;
const int idx = check_bsize_coverage(hbs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col);
- 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 (idx == 0)
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
if (bsize >= BLOCK_8X8 &&
- (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) {
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- update_partition_context(xd, subsize, bsize);
- }
+ (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
+ update_partition_context(cm, mi_row, mi_col, subsize, bsize);
}
static void setup_token_decoder(const uint8_t *data,
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index b2c6e0368..5d7334ae5 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -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 index) {
VP9_COMMON *const cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
const int mis = cm->mode_info_stride;
int bsl = b_width_log2(bsize);
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;
const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols,
mi_row, mi_col);
- 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);
// encode the partition information
if (idx == 0)
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
if (bsize >= BLOCK_8X8 &&
- (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT)) {
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- update_partition_context(xd, subsize, bsize);
- }
+ (bsize == BLOCK_8X8 || partition != PARTITION_SPLIT))
+ update_partition_context(cm, mi_row, mi_col, subsize, bsize);
}
static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 0515db2be..98284a690 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -500,7 +500,6 @@ static void set_offsets(VP9_COMP *cpi, int mi_row, int mi_col,
const struct segmentation *const seg = &cm->seg;
set_skip_context(cm, xd, mi_row, mi_col);
- set_partition_seg_context(cm, xd, mi_row, mi_col);
// Activity map pointer
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;
if (bsize >= BLOCK_8X8) {
- 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);
c1 = *(get_sb_partitioning(x, bsize));
}
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;
}
- if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) {
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- update_partition_context(xd, c1, bsize);
- }
+ if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8)
+ update_partition_context(cm, mi_row, mi_col, c1, bsize);
}
// 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,
get_block_context(x, bsize), INT64_MAX);
- 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);
none_rate += x->partition_cost[pl][PARTITION_NONE];
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:
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)
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_dist += dt;
- set_partition_seg_context(cm, xd, mi_row + y_idx, mi_col + x_idx);
- pl = partition_plane_context(xd, bsize);
+ pl = partition_plane_context(cm, mi_row + y_idx, mi_col + x_idx, bsize);
split_rate += x->partition_cost[pl][PARTITION_NONE];
}
- 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 (split_rate < INT_MAX) {
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);
if (this_rate != INT_MAX) {
if (bsize >= BLOCK_8X8) {
- 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);
this_rate += x->partition_cost[pl][PARTITION_NONE];
}
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) {
- 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);
sum_rate += x->partition_cost[pl][PARTITION_SPLIT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
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) {
- 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);
sum_rate += x->partition_cost[pl][PARTITION_HORZ];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
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) {
- 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);
sum_rate += x->partition_cost[pl][PARTITION_VERT];
sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
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) {
VP9_COMMON * const cm = &cpi->common;
MACROBLOCK * const x = &cpi->mb;
- MACROBLOCKD * const xd = &x->e_mbd;
int bsl = b_width_log2(BLOCK_64X64), bs = 1 << bsl;
int ms = bs / 2;
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;
pick_sb_modes(cpi, mi_row, mi_col, &r, &d, BLOCK_64X64,
get_block_context(x, BLOCK_64X64), INT64_MAX);
- set_partition_seg_context(cm, xd, mi_row, mi_col);
- pl = partition_plane_context(xd, BLOCK_64X64);
+ pl = partition_plane_context(cm, mi_row, mi_col, BLOCK_64X64);
r += x->partition_cost[pl][PARTITION_NONE];
*(get_sb_partitioning(x, BLOCK_64X64)) = BLOCK_64X64;