summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_encodeframe.c
diff options
context:
space:
mode:
authorJingning Han <jingning@google.com>2013-04-16 00:18:02 -0700
committerJingning Han <jingning@google.com>2013-04-16 18:41:26 -0700
commit90a91cc683a8c52443de8a6720875712978a492e (patch)
tree1fbbc6061f019d06a4de4f794c0910e3990ced49 /vp9/encoder/vp9_encodeframe.c
parent0e65e08e2739c4c7f7552d57eb0878a5a87e8b40 (diff)
downloadlibvpx-90a91cc683a8c52443de8a6720875712978a492e.tar
libvpx-90a91cc683a8c52443de8a6720875712978a492e.tar.gz
libvpx-90a91cc683a8c52443de8a6720875712978a492e.tar.bz2
libvpx-90a91cc683a8c52443de8a6720875712978a492e.zip
Recursive partition syntax coding
Enable recursive partition information coding from SB64X64 down to MB16X16. The bit-stream syntax is now supporting rectangular block sizes. It starts from SB64X64 and recursively describes the partition type of the current block. If the partition type is PARTITION_NONE, the block is coded as a single unit; if it is PARTITION_HORZ or PARTITION_VERT, the block is segmented into two independently coded rectangular units, with no further partition needed; otherwise, the block is segmented into 4 square blocks. i.e., PARTITION_SPLIT case, each can be potentially further partitioned. Forward adaptive probability modeling is used for the partition information coding, conditioned on the current block size. Change-Id: I499365fb547839d555498e3bcc0387d8a3587d87
Diffstat (limited to 'vp9/encoder/vp9_encodeframe.c')
-rw-r--r--vp9/encoder/vp9_encodeframe.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index b76baf588..1170fc114 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -857,17 +857,18 @@ static void encode_sb(VP9_COMP *cpi,
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
+ BLOCK_SIZE_TYPE bsize = BLOCK_SIZE_SB32X32;
- cpi->sb32_count[is_sb]++;
if (is_sb) {
- set_offsets(cpi, mb_row, mb_col, BLOCK_SIZE_SB32X32);
+ set_offsets(cpi, mb_row, mb_col, bsize);
update_state(cpi, &x->sb32_context[xd->sb_index],
- BLOCK_SIZE_SB32X32, output_enabled);
+ bsize, output_enabled);
encode_superblock(cpi, tp,
- output_enabled, mb_row, mb_col, BLOCK_SIZE_SB32X32);
+ output_enabled, mb_row, mb_col, bsize);
if (output_enabled) {
update_stats(cpi, mb_row, mb_col);
+ cpi->partition_count[partition_plane(bsize)][PARTITION_NONE]++;
}
if (output_enabled) {
@@ -876,6 +877,8 @@ static void encode_sb(VP9_COMP *cpi,
}
} else {
int i;
+ if (output_enabled)
+ cpi->partition_count[partition_plane(bsize)][PARTITION_SPLIT]++;
for (i = 0; i < 4; i++) {
const int x_idx = i & 1, y_idx = i >> 1;
@@ -924,20 +927,21 @@ static void encode_sb64(VP9_COMP *cpi,
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
+ BLOCK_SIZE_TYPE bsize = BLOCK_SIZE_SB64X64;
- cpi->sb64_count[is_sb[0] == 2]++;
if (is_sb[0] == 2) {
- set_offsets(cpi, mb_row, mb_col, BLOCK_SIZE_SB64X64);
- update_state(cpi, &x->sb64_context, BLOCK_SIZE_SB64X64, 1);
+ set_offsets(cpi, mb_row, mb_col, bsize);
+ update_state(cpi, &x->sb64_context, bsize, 1);
encode_superblock(cpi, tp,
- 1, mb_row, mb_col, BLOCK_SIZE_SB64X64);
+ 1, mb_row, mb_col, bsize);
update_stats(cpi, mb_row, mb_col);
(*tp)->Token = EOSB_TOKEN;
(*tp)++;
+ cpi->partition_count[partition_plane(bsize)][PARTITION_NONE]++;
} else {
int i;
-
+ cpi->partition_count[partition_plane(bsize)][PARTITION_SPLIT]++;
for (i = 0; i < 4; i++) {
const int x_idx = i & 1, y_idx = i >> 1;
@@ -1024,7 +1028,9 @@ static void encode_sb_row(VP9_COMP *cpi,
vpx_memcpy(cm->left_context + y_idx, l2, sizeof(l2));
vpx_memcpy(cm->above_context + mb_col + x_idx, a2, sizeof(a2));
- mb_rate += vp9_cost_bit(cm->prob_sb32_coded, 0);
+ // TODO(jingning): pre-calculate the overhead costs
+ mb_rate += vp9_cost_bit(cm->fc.partition_prob
+ [partition_plane(BLOCK_SIZE_SB32X32)][0], 0);
if (cpi->sf.splitmode_breakout) {
sb32_skip = splitmodes_used;
@@ -1037,7 +1043,8 @@ static void encode_sb_row(VP9_COMP *cpi,
pick_sb_modes(cpi, mb_row + y_idx, mb_col + x_idx,
tp, &sb_rate, &sb_dist, BLOCK_SIZE_SB32X32,
&x->sb32_context[xd->sb_index]);
- sb_rate += vp9_cost_bit(cm->prob_sb32_coded, 1);
+ sb_rate += vp9_cost_bit(cm->fc.partition_prob
+ [partition_plane(BLOCK_SIZE_SB32X32)][0], 1);
}
/* Decide whether to encode as a SB or 4xMBs */
@@ -1069,13 +1076,15 @@ static void encode_sb_row(VP9_COMP *cpi,
memcpy(cm->above_context + mb_col, &a, sizeof(a));
memcpy(cm->left_context, &l, sizeof(l));
- sb32_rate += vp9_cost_bit(cm->prob_sb64_coded, 0);
+ sb32_rate += vp9_cost_bit(cm->fc.partition_prob
+ [partition_plane(BLOCK_SIZE_SB64X64)][0], 0);
if (!sb64_skip && !(mb_col + 3 >= cm->mb_cols ||
mb_row + 3 >= cm->mb_rows)) {
pick_sb_modes(cpi, mb_row, mb_col, tp, &sb64_rate, &sb64_dist,
BLOCK_SIZE_SB64X64, &x->sb64_context);
- sb64_rate += vp9_cost_bit(cm->prob_sb64_coded, 1);
+ sb64_rate += vp9_cost_bit(cm->fc.partition_prob
+ [partition_plane(BLOCK_SIZE_SB64X64)][0], 1);
}
/* Decide whether to encode as a SB or 4xMBs */
@@ -1139,8 +1148,8 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
vp9_zero(cpi->mbsplit_count)
vp9_zero(cpi->common.fc.mv_ref_ct)
vp9_zero(cpi->sb_ymode_count)
- vp9_zero(cpi->sb32_count);
- vp9_zero(cpi->sb64_count);
+ vp9_zero(cpi->partition_count);
+
#if CONFIG_COMP_INTERINTRA_PRED
vp9_zero(cpi->interintra_count);
vp9_zero(cpi->interintra_select_count);