Commit 2bf1dc2e authored by Jingning Han's avatar Jingning Han

Enable bit-stream support to SB8X8

This commit enables bit-stream writing and reading for recursive
partition down to block 8x8.

Change-Id: I163cd48d191cc94ead49cbb7fc91374f6bf204e2
parent d139655b
...@@ -511,6 +511,55 @@ static INLINE int partition_plane_context(MACROBLOCKD *xd, ...@@ -511,6 +511,55 @@ static INLINE int partition_plane_context(MACROBLOCKD *xd,
return (left * 2 + above) + (bsl - 1) * PARTITION_PLOFFSET; return (left * 2 + above) + (bsl - 1) * PARTITION_PLOFFSET;
} }
static BLOCK_SIZE_TYPE get_subsize(BLOCK_SIZE_TYPE bsize,
PARTITION_TYPE partition) {
BLOCK_SIZE_TYPE subsize;
switch (partition) {
case PARTITION_NONE:
subsize = bsize;
break;
case PARTITION_HORZ:
if (bsize == BLOCK_SIZE_SB64X64)
subsize = BLOCK_SIZE_SB64X32;
else if (bsize == BLOCK_SIZE_SB32X32)
subsize = BLOCK_SIZE_SB32X16;
#if CONFIG_SB8X8
else if (bsize == BLOCK_SIZE_MB16X16)
subsize = BLOCK_SIZE_SB16X8;
#endif
else
assert(0);
break;
case PARTITION_VERT:
if (bsize == BLOCK_SIZE_SB64X64)
subsize = BLOCK_SIZE_SB32X64;
else if (bsize == BLOCK_SIZE_SB32X32)
subsize = BLOCK_SIZE_SB16X32;
#if CONFIG_SB8X8
else if (bsize == BLOCK_SIZE_MB16X16)
subsize = BLOCK_SIZE_SB8X16;
#endif
else
assert(0);
break;
case PARTITION_SPLIT:
if (bsize == BLOCK_SIZE_SB64X64)
subsize = BLOCK_SIZE_SB32X32;
else if (bsize == BLOCK_SIZE_SB32X32)
subsize = BLOCK_SIZE_MB16X16;
#if CONFIG_SB8X8
else if (bsize == BLOCK_SIZE_MB16X16)
subsize = BLOCK_SIZE_SB8X8;
#endif
else
assert(0);
break;
default:
assert(0);
}
return subsize;
}
#define ACTIVE_HT 110 // quantization stepsize threshold #define ACTIVE_HT 110 // quantization stepsize threshold
#define ACTIVE_HT8 300 #define ACTIVE_HT8 300
......
...@@ -146,7 +146,11 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m, ...@@ -146,7 +146,11 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
m->mbmi.mb_skip_coeff = vp9_read(r, vp9_get_pred_prob(cm, xd, PRED_MBSKIP)); m->mbmi.mb_skip_coeff = vp9_read(r, vp9_get_pred_prob(cm, xd, PRED_MBSKIP));
// luma mode // luma mode
#if CONFIG_SB8X8
m->mbmi.mode = m->mbmi.sb_type > BLOCK_SIZE_SB8X8 ?
#else
m->mbmi.mode = m->mbmi.sb_type > BLOCK_SIZE_MB16X16 ? m->mbmi.mode = m->mbmi.sb_type > BLOCK_SIZE_MB16X16 ?
#endif
read_kf_sb_ymode(r, cm->sb_kf_ymode_prob[cm->kf_ymode_probs_index]): read_kf_sb_ymode(r, cm->sb_kf_ymode_prob[cm->kf_ymode_probs_index]):
read_kf_mb_ymode(r, cm->kf_ymode_prob[cm->kf_ymode_probs_index]); read_kf_mb_ymode(r, cm->kf_ymode_prob[cm->kf_ymode_probs_index]);
...@@ -154,11 +158,10 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m, ...@@ -154,11 +158,10 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
if (m->mbmi.mode == I4X4_PRED) { if (m->mbmi.mode == I4X4_PRED) {
int i; int i;
for (i = 0; i < 16; ++i) { for (i = 0; i < (16 >> (2 * CONFIG_SB8X8)); ++i) {
const B_PREDICTION_MODE a = above_block_mode(m, i, mis); const B_PREDICTION_MODE a = above_block_mode(m, i, mis);
const B_PREDICTION_MODE l = xd->left_available || (i & 3) ? const B_PREDICTION_MODE l = xd->left_available || (i & 3) ?
left_block_mode(m, i) : B_DC_PRED; left_block_mode(m, i) : B_DC_PRED;
m->bmi[i].as_mode.first = read_kf_bmode(r, cm->kf_bmode_prob[a][l]); m->bmi[i].as_mode.first = read_kf_bmode(r, cm->kf_bmode_prob[a][l]);
} }
} }
......
...@@ -576,10 +576,12 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -576,10 +576,12 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
set_refs(pbi, mi_row, mi_col); set_refs(pbi, mi_row, mi_col);
#if CONFIG_SB8X8 #if CONFIG_SB8X8
if (bsize >= BLOCK_SIZE_SB8X8) if (bsize == BLOCK_SIZE_SB8X8 &&
decode_sb(pbi, xd, mi_row, mi_col, r, bsize); (xd->mode_info_context->mbmi.mode == SPLITMV ||
xd->mode_info_context->mbmi.mode == I4X4_PRED))
decode_atom(pbi, xd, mi_row, mi_col, r, bsize);
else else
decode_atom(pbi, xd, mi_row, mi_col, r, BLOCK_SIZE_SB8X8); decode_sb(pbi, xd, mi_row, mi_col, r, bsize);
#else #else
// TODO(jingning): merge decode_sb_ and decode_mb_ // TODO(jingning): merge decode_sb_ and decode_mb_
if (bsize > BLOCK_SIZE_MB16X16) { if (bsize > BLOCK_SIZE_MB16X16) {
...@@ -616,7 +618,11 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -616,7 +618,11 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
if (mi_row >= pc->mi_rows || mi_col >= pc->mi_cols) if (mi_row >= pc->mi_rows || mi_col >= pc->mi_cols)
return; return;
#if CONFIG_SB8X8
if (bsize > BLOCK_SIZE_SB8X8) {
#else
if (bsize > BLOCK_SIZE_MB16X16) { if (bsize > BLOCK_SIZE_MB16X16) {
#endif
int pl; int pl;
// read the partition information // read the partition information
xd->left_seg_context = xd->left_seg_context =
...@@ -628,34 +634,35 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -628,34 +634,35 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
pc->fc.partition_counts[pl][partition]++; pc->fc.partition_counts[pl][partition]++;
} }
subsize = get_subsize(bsize, partition);
switch (partition) { switch (partition) {
case PARTITION_NONE: case PARTITION_NONE:
subsize = bsize;
decode_modes_b(pbi, mi_row, mi_col, r, subsize); decode_modes_b(pbi, mi_row, mi_col, r, subsize);
break; break;
case PARTITION_HORZ: case PARTITION_HORZ:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB64X32 :
BLOCK_SIZE_SB32X16;
decode_modes_b(pbi, mi_row, mi_col, r, subsize); decode_modes_b(pbi, mi_row, mi_col, r, subsize);
if ((mi_row + bs) < pc->mi_rows) if ((mi_row + bs) < pc->mi_rows)
decode_modes_b(pbi, mi_row + bs, mi_col, r, subsize); decode_modes_b(pbi, mi_row + bs, mi_col, r, subsize);
break; break;
case PARTITION_VERT: case PARTITION_VERT:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB32X64 :
BLOCK_SIZE_SB16X32;
decode_modes_b(pbi, mi_row, mi_col, r, subsize); decode_modes_b(pbi, mi_row, mi_col, r, subsize);
if ((mi_col + bs) < pc->mi_cols) if ((mi_col + bs) < pc->mi_cols)
decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize); decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize);
break; break;
case PARTITION_SPLIT: case PARTITION_SPLIT:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB32X32 :
BLOCK_SIZE_MB16X16;
for (n = 0; n < 4; n++) { for (n = 0; n < 4; n++) {
int j = n >> 1, i = n & 0x01; int j = n >> 1, i = n & 0x01;
if (subsize == BLOCK_SIZE_SB32X32) if (subsize == BLOCK_SIZE_SB32X32)
xd->sb_index = n; xd->sb_index = n;
#if CONFIG_SB8X8
else if (subsize == BLOCK_SIZE_MB16X16)
xd->mb_index = n;
else
xd->b_index = n;
#else
else else
xd->mb_index = n; xd->mb_index = n;
#endif
decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize); decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize);
} }
break; break;
...@@ -663,7 +670,11 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col, ...@@ -663,7 +670,11 @@ static void decode_modes_sb(VP9D_COMP *pbi, int mi_row, int mi_col,
assert(0); assert(0);
} }
// update partition context // update partition context
#if CONFIG_SB8X8
if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_MB16X16))
#else
if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_SB32X32)) if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_SB32X32))
#endif
return; return;
xd->left_seg_context = pc->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3); xd->left_seg_context = pc->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
......
...@@ -944,7 +944,11 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, ...@@ -944,7 +944,11 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
vp9_write(bc, skip_coeff, vp9_get_pred_prob(c, xd, PRED_MBSKIP)); vp9_write(bc, skip_coeff, vp9_get_pred_prob(c, xd, PRED_MBSKIP));
} }
#if CONFIG_SB8X8
if (m->mbmi.sb_type > BLOCK_SIZE_SB8X8)
#else
if (m->mbmi.sb_type > BLOCK_SIZE_MB16X16) if (m->mbmi.sb_type > BLOCK_SIZE_MB16X16)
#endif
sb_kfwrite_ymode(bc, ym, c->sb_kf_ymode_prob[c->kf_ymode_probs_index]); sb_kfwrite_ymode(bc, ym, c->sb_kf_ymode_prob[c->kf_ymode_probs_index]);
else else
kfwrite_ymode(bc, ym, c->kf_ymode_prob[c->kf_ymode_probs_index]); kfwrite_ymode(bc, ym, c->kf_ymode_prob[c->kf_ymode_probs_index]);
...@@ -960,7 +964,6 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, ...@@ -960,7 +964,6 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
++intra_mode_stats [A] [L] [bm]; ++intra_mode_stats [A] [L] [bm];
#endif #endif
write_kf_bmode(bc, bm, c->kf_bmode_prob[a][l]); write_kf_bmode(bc, bm, c->kf_bmode_prob[a][l]);
} while (++i < (16 >> (CONFIG_SB8X8 * 2))); } while (++i < (16 >> (CONFIG_SB8X8 * 2)));
} }
...@@ -1210,7 +1213,11 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, ...@@ -1210,7 +1213,11 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
else else
assert(0); assert(0);
#if CONFIG_SB8X8
if (bsize > BLOCK_SIZE_SB8X8) {
#else
if (bsize > BLOCK_SIZE_MB16X16) { if (bsize > BLOCK_SIZE_MB16X16) {
#endif
int pl; int pl;
xd->left_seg_context = xd->left_seg_context =
cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3); cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
...@@ -1221,34 +1228,23 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, ...@@ -1221,34 +1228,23 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
vp9_partition_encodings + partition); vp9_partition_encodings + partition);
} }
subsize = get_subsize(bsize, partition);
switch (partition) { switch (partition) {
case PARTITION_NONE: case PARTITION_NONE:
subsize = bsize;
write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col); write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col);
break; break;
case PARTITION_HORZ: case PARTITION_HORZ:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB64X32 :
BLOCK_SIZE_SB32X16;
write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col); write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col);
if ((mi_row + bh) < cm->mi_rows) if ((mi_row + bh) < cm->mi_rows)
write_modes_b(cpi, m + bh * mis, bc, tok, tok_end, mi_row + bh, mi_col); write_modes_b(cpi, m + bh * mis, bc, tok, tok_end, mi_row + bh, mi_col);
break; break;
case PARTITION_VERT: case PARTITION_VERT:
subsize = (bsize == BLOCK_SIZE_SB64X64) ? BLOCK_SIZE_SB32X64 :
BLOCK_SIZE_SB16X32;
write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col); write_modes_b(cpi, m, bc, tok, tok_end, mi_row, mi_col);
if ((mi_col + bw) < cm->mi_cols) if ((mi_col + bw) < cm->mi_cols)
write_modes_b(cpi, m + bw, bc, tok, tok_end, mi_row, mi_col + bw); write_modes_b(cpi, m + bw, bc, tok, tok_end, mi_row, mi_col + bw);
break; break;
case PARTITION_SPLIT: case PARTITION_SPLIT:
// TODO(jingning): support recursive partitioning down to 16x16 as for
// now. need to merge in 16x8, 8x16, 8x8, and smaller partitions.
if (bsize == BLOCK_SIZE_SB64X64)
subsize = BLOCK_SIZE_SB32X32;
else if (bsize == BLOCK_SIZE_SB32X32)
subsize = BLOCK_SIZE_MB16X16;
else
assert(0);
for (n = 0; n < 4; n++) { for (n = 0; n < 4; n++) {
int j = n >> 1, i = n & 0x01; int j = n >> 1, i = n & 0x01;
write_modes_sb(cpi, m + j * bs * mis + i * bs, bc, tok, tok_end, write_modes_sb(cpi, m + j * bs * mis + i * bs, bc, tok, tok_end,
...@@ -1260,7 +1256,11 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, ...@@ -1260,7 +1256,11 @@ static void write_modes_sb(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
} }
// update partition context // update partition context
#if CONFIG_SB8X8
if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_MB16X16))
#else
if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_SB32X32)) if ((partition == PARTITION_SPLIT) && (bsize > BLOCK_SIZE_SB32X32))
#endif
return; return;
xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3); xd->left_seg_context = cm->left_seg_context + ((mi_row >> CONFIG_SB8X8) & 3);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment