Commit 5d4cffb3 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Superblock coding.

This commit adds a pick_sb_mode() function which selects the best 32x32
superblock coding mode. Then it selects the best per-MB modes, compares
the two and encodes that in the bitstream.

The bitstream coding is rather simplistic right now. At the SB level,
we code a bit to indicate whether this block uses SB-coding (32x32
prediction) or MB-coding (anything else), and then we follow with the
actual modes. This could and should be modified in the future, but is
omitted from this commit because it will likely involve reorganizing
much more code rather than just adding SB coding, so it's better to let
that be judged on its own merits.

Gains on derf: about even, YT/HD: +0.75%, STD/HD: +1.5%.

Change-Id: Iae313a7cbd8f75b3c66d04a68b991cb096eaaba6
parent 319dd1c0
......@@ -148,6 +148,7 @@ typedef enum {
#define VP8_YMODES (B_PRED + 1)
#define VP8_UV_MODES (TM_PRED + 1)
#define VP8_I8X8_MODES (TM_PRED + 1)
#define VP8_I32X32_MODES (TM_PRED + 1)
#define VP8_MVREFS (1 + SPLITMV - NEARESTMV)
......@@ -293,6 +294,11 @@ typedef struct {
INTERPOLATIONFILTERTYPE interp_filter;
#endif
#if CONFIG_SUPERBLOCKS
// FIXME need a SB array of 4 MB_MODE_INFOs that
// only needs one encoded_as_sb.
unsigned char encoded_as_sb;
#endif
} MB_MODE_INFO;
typedef struct {
......
......@@ -227,6 +227,14 @@ const vp8_tree_index vp8_mv_ref_tree[8] = {
-NEWMV, -SPLITMV
};
#if CONFIG_SUPERBLOCKS
const vp8_tree_index vp8_sb_mv_ref_tree[6] = {
-ZEROMV, 2,
-NEARESTMV, 4,
-NEARMV, -NEWMV
};
#endif
const vp8_tree_index vp8_sub_mv_ref_tree[6] = {
-LEFT4X4, 2,
-ABOVE4X4, 4,
......@@ -236,12 +244,18 @@ const vp8_tree_index vp8_sub_mv_ref_tree[6] = {
struct vp8_token_struct vp8_bmode_encodings [VP8_BINTRAMODES];
struct vp8_token_struct vp8_ymode_encodings [VP8_YMODES];
#if CONFIG_SUPERBLOCKS
struct vp8_token_struct vp8_sb_kf_ymode_encodings [VP8_I32X32_MODES];
#endif
struct vp8_token_struct vp8_kf_ymode_encodings [VP8_YMODES];
struct vp8_token_struct vp8_uv_mode_encodings [VP8_UV_MODES];
struct vp8_token_struct vp8_i8x8_mode_encodings [VP8_UV_MODES];
struct vp8_token_struct vp8_i8x8_mode_encodings [VP8_I8X8_MODES];
struct vp8_token_struct vp8_mbsplit_encodings [VP8_NUMMBSPLITS];
struct vp8_token_struct vp8_mv_ref_encoding_array [VP8_MVREFS];
#if CONFIG_SUPERBLOCKS
struct vp8_token_struct vp8_sb_mv_ref_encoding_array [VP8_MVREFS];
#endif
struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
......@@ -253,11 +267,18 @@ void vp8_init_mbmode_probs(VP8_COMMON *x) {
vp8_ymode_tree, x->fc.ymode_prob, bct, y_mode_cts, 256, 1);
{
int i;
for (i = 0; i < 8; i++)
for (i = 0; i < 8; i++) {
vp8_tree_probs_from_distribution(
VP8_YMODES, vp8_kf_ymode_encodings, vp8_kf_ymode_tree,
x->kf_ymode_prob[i], bct, kf_y_mode_cts[i],
256, 1);
#if CONFIG_SUPERBLOCKS
vp8_tree_probs_from_distribution(
VP8_I32X32_MODES, vp8_sb_kf_ymode_encodings, vp8_sb_ymode_tree,
x->sb_kf_ymode_prob[i], bct, kf_y_mode_cts[i],
256, 1);
#endif
}
}
{
int i;
......@@ -360,6 +381,9 @@ void vp8_entropy_mode_init() {
vp8_tokens_from_tree(vp8_bmode_encodings, vp8_bmode_tree);
vp8_tokens_from_tree(vp8_ymode_encodings, vp8_ymode_tree);
vp8_tokens_from_tree(vp8_kf_ymode_encodings, vp8_kf_ymode_tree);
#if CONFIG_SUPERBLOCKS
vp8_tokens_from_tree(vp8_sb_kf_ymode_encodings, vp8_sb_ymode_tree);
#endif
vp8_tokens_from_tree(vp8_uv_mode_encodings, vp8_uv_mode_tree);
vp8_tokens_from_tree(vp8_i8x8_mode_encodings, vp8_i8x8_mode_tree);
vp8_tokens_from_tree(vp8_mbsplit_encodings, vp8_mbsplit_tree);
......@@ -370,6 +394,10 @@ void vp8_entropy_mode_init() {
vp8_tokens_from_tree_offset(vp8_mv_ref_encoding_array,
vp8_mv_ref_tree, NEARESTMV);
#if CONFIG_SUPERBLOCKS
vp8_tokens_from_tree_offset(vp8_sb_mv_ref_encoding_array,
vp8_sb_mv_ref_tree, NEARESTMV);
#endif
vp8_tokens_from_tree_offset(vp8_sub_mv_ref_encoding_array,
vp8_sub_mv_ref_tree, LEFT4X4);
}
......
......@@ -40,21 +40,25 @@ extern const vp8_tree_index vp8_bmode_tree[];
extern const vp8_tree_index vp8_ymode_tree[];
extern const vp8_tree_index vp8_kf_ymode_tree[];
extern const vp8_tree_index vp8_uv_mode_tree[];
#define vp8_sb_ymode_tree vp8_uv_mode_tree
extern const vp8_tree_index vp8_i8x8_mode_tree[];
extern const vp8_tree_index vp8_mbsplit_tree[];
extern const vp8_tree_index vp8_mv_ref_tree[];
extern const vp8_tree_index vp8_sb_mv_ref_tree[];
extern const vp8_tree_index vp8_sub_mv_ref_tree[];
extern struct vp8_token_struct vp8_bmode_encodings [VP8_BINTRAMODES];
extern struct vp8_token_struct vp8_ymode_encodings [VP8_YMODES];
extern struct vp8_token_struct vp8_sb_kf_ymode_encodings [VP8_I32X32_MODES];
extern struct vp8_token_struct vp8_kf_ymode_encodings [VP8_YMODES];
extern struct vp8_token_struct vp8_i8x8_mode_encodings [VP8_UV_MODES];
extern struct vp8_token_struct vp8_i8x8_mode_encodings [VP8_I8X8_MODES];
extern struct vp8_token_struct vp8_uv_mode_encodings [VP8_UV_MODES];
extern struct vp8_token_struct vp8_mbsplit_encodings [VP8_NUMMBSPLITS];
/* Inter mode values do not start at zero */
extern struct vp8_token_struct vp8_mv_ref_encoding_array [VP8_MVREFS];
extern struct vp8_token_struct vp8_sb_mv_ref_encoding_array [VP8_MVREFS];
extern struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
void vp8_entropy_mode_init(void);
......
......@@ -47,6 +47,12 @@ void vp8_machine_specific_config(VP8_COMMON *ctx) {
rtcd->recon.recon4 = vp8_recon4b_c;
rtcd->recon.recon_mb = vp8_recon_mb_c;
rtcd->recon.recon_mby = vp8_recon_mby_c;
#if CONFIG_SUPERBLOCKS
rtcd->recon.build_intra_predictors_sby_s =
vp8_build_intra_predictors_sby_s;
rtcd->recon.build_intra_predictors_sbuv_s =
vp8_build_intra_predictors_sbuv_s;
#endif
rtcd->recon.build_intra_predictors_mby =
vp8_build_intra_predictors_mby;
#if CONFIG_COMP_INTRA_PRED
......
......@@ -325,7 +325,13 @@ void vp8_loop_filter_frame
lfi.lim = lfi_n->lim[filter_level];
lfi.hev_thr = lfi_n->hev_thr[hev_index];
if (mb_col > 0)
if (mb_col > 0
#if CONFIG_SUPERBLOCKS
&& !((mb_col & 1) && mode_info_context->mbmi.encoded_as_sb &&
mode_info_context[0].mbmi.mb_skip_coeff &&
mode_info_context[-1].mbmi.mb_skip_coeff)
#endif
)
vp8_loop_filter_mbv_c
(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
......@@ -344,7 +350,13 @@ void vp8_loop_filter_frame
}
/* don't apply across umv border */
if (mb_row > 0)
if (mb_row > 0
#if CONFIG_SUPERBLOCKS
&& !((mb_row & 1) && mode_info_context->mbmi.encoded_as_sb &&
mode_info_context[0].mbmi.mb_skip_coeff &&
mode_info_context[-cm->mode_info_stride].mbmi.mb_skip_coeff)
#endif
)
vp8_loop_filter_mbh_c
(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi);
......@@ -362,7 +374,13 @@ void vp8_loop_filter_frame
}
} else {
// FIXME: Not 8x8 aware
if (mb_col > 0)
if (mb_col > 0
#if CONFIG_SUPERBLOCKS
&& !((mb_col & 1) && mode_info_context->mbmi.encoded_as_sb &&
mode_info_context[0].mbmi.mb_skip_coeff &&
mode_info_context[-1].mbmi.mb_skip_coeff)
#endif
)
LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v)
(y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
......@@ -371,7 +389,13 @@ void vp8_loop_filter_frame
(y_ptr, post->y_stride, lfi_n->blim[filter_level]);
/* don't apply across umv border */
if (mb_row > 0)
if (mb_row > 0
#if CONFIG_SUPERBLOCKS
&& !((mb_row & 1) && mode_info_context->mbmi.encoded_as_sb &&
mode_info_context[0].mbmi.mb_skip_coeff &&
mode_info_context[-cm->mode_info_stride].mbmi.mb_skip_coeff)
#endif
)
LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h)
(y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
......
......@@ -226,12 +226,15 @@ typedef struct VP8Common {
/* Y,U,V,Y2 */
ENTROPY_CONTEXT_PLANES *above_context; /* row of context for each plane */
ENTROPY_CONTEXT_PLANES left_context; /* (up to) 4 contexts "" */
ENTROPY_CONTEXT_PLANES left_context[2]; /* (up to) 4 contexts "" */
/* keyframe block modes are predicted by their above, left neighbors */
vp8_prob kf_bmode_prob [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES - 1];
vp8_prob kf_ymode_prob[8][VP8_YMODES - 1]; /* keyframe "" */
#if CONFIG_SUPERBLOCKS
vp8_prob sb_kf_ymode_prob[8][VP8_I32X32_MODES - 1];
#endif
int kf_ymode_probs_index;
int kf_ymode_probs_update;
vp8_prob kf_uv_mode_prob[VP8_YMODES] [VP8_UV_MODES - 1];
......@@ -239,6 +242,9 @@ typedef struct VP8Common {
vp8_prob prob_intra_coded;
vp8_prob prob_last_coded;
vp8_prob prob_gf_coded;
#if CONFIG_SUPERBLOCKS
vp8_prob sb_coded;
#endif
// Context probabilities when using predictive coding of segment id
vp8_prob segment_pred_probs[PREDICTION_PROBS];
......
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
......@@ -224,10 +225,24 @@ void set_pred_flag(MACROBLOCKD *const xd,
switch (pred_id) {
case PRED_SEG_ID:
xd->mode_info_context->mbmi.seg_id_predicted = pred_flag;
#if CONFIG_SUPERBLOCKS
if (xd->mode_info_context->mbmi.encoded_as_sb) {
xd->mode_info_context[1].mbmi.seg_id_predicted = pred_flag;
xd->mode_info_context[xd->mode_info_stride].mbmi.seg_id_predicted = pred_flag;
xd->mode_info_context[xd->mode_info_stride+1].mbmi.seg_id_predicted = pred_flag;
}
#endif
break;
case PRED_REF:
xd->mode_info_context->mbmi.ref_predicted = pred_flag;
#if CONFIG_SUPERBLOCKS
if (xd->mode_info_context->mbmi.encoded_as_sb) {
xd->mode_info_context[1].mbmi.ref_predicted = pred_flag;
xd->mode_info_context[xd->mode_info_stride].mbmi.ref_predicted = pred_flag;
xd->mode_info_context[xd->mode_info_stride+1].mbmi.ref_predicted = pred_flag;
}
#endif
break;
case PRED_MBSKIP:
......
......@@ -124,6 +124,52 @@ void vp8_recon2b_c
}
}
#if CONFIG_SUPERBLOCKS
void vp8_recon_mby_s_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *xd, uint8_t *dst) {
int x, y;
BLOCKD *b = &xd->block[0];
int stride = b->dst_stride;
short *diff = b->diff;
for (y = 0; y < 16; y++) {
for (x = 0; x < 16; x++) {
int a = dst[x] + diff[x];
if (a < 0)
a = 0;
else if (a > 255)
a = 255;
dst[x] = a;
}
dst += stride;
diff += 16;
}
}
void vp8_recon_mbuv_s_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *xd, uint8_t *udst, uint8_t *vdst) {
int x, y, i;
uint8_t *dst = udst;
for (i = 0; i < 2; i++, dst = vdst) {
BLOCKD *b = &xd->block[16 + 4 * i];
int stride = b->dst_stride;
short *diff = b->diff;
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
int a = dst[x] + diff[x];
if (a < 0)
a = 0;
else if (a > 255)
a = 255;
dst[x] = a;
}
dst += stride;
diff += 8;
}
}
}
#endif
void vp8_recon_mby_c(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *xd) {
#if ARCH_ARM
BLOCKD *b = &xd->block[0];
......
......@@ -100,6 +100,11 @@ extern prototype_recon_macroblock(vp8_recon_recon_mb);
#endif
extern prototype_recon_macroblock(vp8_recon_recon_mby);
#ifndef vp8_recon_build_intra_predictors_sby_s
#define vp8_recon_build_intra_predictors_sby_s vp8_build_intra_predictors_sby_s
#endif
extern prototype_build_intra_predictors(vp8_recon_build_intra_predictors_sby_s);
#ifndef vp8_recon_build_intra_predictors_mby
#define vp8_recon_build_intra_predictors_mby vp8_build_intra_predictors_mby
#endif
......@@ -126,6 +131,11 @@ extern prototype_build_intra_predictors\
extern prototype_build_intra_predictors\
(vp8_recon_build_intra_predictors_mby_s);
#ifndef vp8_recon_build_intra_predictors_sbuv_s
#define vp8_recon_build_intra_predictors_sbuv_s vp8_build_intra_predictors_sbuv_s
#endif
extern prototype_build_intra_predictors(vp8_recon_build_intra_predictors_sbuv_s);
#ifndef vp8_recon_build_intra_predictors_mbuv
#define vp8_recon_build_intra_predictors_mbuv vp8_build_intra_predictors_mbuv
#endif
......@@ -214,10 +224,16 @@ typedef struct vp8_recon_rtcd_vtable {
vp8_recon_fn_t recon4;
vp8_recon_mb_fn_t recon_mb;
vp8_recon_mb_fn_t recon_mby;
#if CONFIG_SUPERBLOCKS
vp8_build_intra_pred_fn_t build_intra_predictors_sby_s;
#endif
vp8_build_intra_pred_fn_t build_intra_predictors_mby_s;
vp8_build_intra_pred_fn_t build_intra_predictors_mby;
#if CONFIG_COMP_INTRA_PRED
vp8_build_intra_pred_fn_t build_comp_intra_predictors_mby;
#endif
#if CONFIG_SUPERBLOCKS
vp8_build_intra_pred_fn_t build_intra_predictors_sbuv_s;
#endif
vp8_build_intra_pred_fn_t build_intra_predictors_mbuv_s;
vp8_build_intra_pred_fn_t build_intra_predictors_mbuv;
......
......@@ -759,6 +759,56 @@ void vp8_build_1st_inter16x16_predictors_mb(MACROBLOCKD *xd,
vp8_build_1st_inter16x16_predictors_mbuv(xd, dst_u, dst_v, dst_uvstride);
}
#if CONFIG_SUPERBLOCKS
void vp8_build_inter32x32_predictors_sb(MACROBLOCKD *x,
unsigned char *dst_y,
unsigned char *dst_u,
unsigned char *dst_v,
int dst_ystride,
int dst_uvstride) {
uint8_t *y1 = x->pre.y_buffer, *u1 = x->pre.u_buffer, *v1 = x->pre.v_buffer;
uint8_t *y2 = x->second_pre.y_buffer, *u2 = x->second_pre.u_buffer,
*v2 = x->second_pre.v_buffer;
int n;
for (n = 0; n < 4; n++)
{
const int x_idx = n & 1, y_idx = n >> 1;
x->pre.y_buffer = y1 + y_idx * 16 * x->pre.y_stride + x_idx * 16;
x->pre.u_buffer = u1 + y_idx * 8 * x->pre.uv_stride + x_idx * 8;
x->pre.v_buffer = v1 + y_idx * 8 * x->pre.uv_stride + x_idx * 8;
vp8_build_1st_inter16x16_predictors_mb(x,
dst_y + y_idx * 16 * dst_ystride + x_idx * 16,
dst_u + y_idx * 8 * dst_uvstride + x_idx * 8,
dst_v + y_idx * 8 * dst_uvstride + x_idx * 8,
dst_ystride, dst_uvstride);
if (x->mode_info_context->mbmi.second_ref_frame) {
x->second_pre.y_buffer = y2 + y_idx * 16 * x->pre.y_stride + x_idx * 16;
x->second_pre.u_buffer = u2 + y_idx * 8 * x->pre.uv_stride + x_idx * 8;
x->second_pre.v_buffer = v2 + y_idx * 8 * x->pre.uv_stride + x_idx * 8;
vp8_build_2nd_inter16x16_predictors_mb(x,
dst_y + y_idx * 16 * dst_ystride + x_idx * 16,
dst_u + y_idx * 8 * dst_uvstride + x_idx * 8,
dst_v + y_idx * 8 * dst_uvstride + x_idx * 8,
dst_ystride, dst_uvstride);
}
}
x->pre.y_buffer = y1;
x->pre.u_buffer = u1;
x->pre.v_buffer = v1;
if (x->mode_info_context->mbmi.second_ref_frame) {
x->second_pre.y_buffer = y2;
x->second_pre.u_buffer = u2;
x->second_pre.v_buffer = v2;
}
}
#endif
/*
* The following functions should be called after an initial
* call to vp8_build_inter16x16_predictors_mb() or _mby()/_mbuv().
......
This diff is collapsed.
......@@ -29,34 +29,31 @@ int dec_mvcount = 0;
#endif
static int vp8_read_bmode(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_bmode_tree, p);
return i;
return vp8_treed_read(bc, vp8_bmode_tree, p);
}
static int vp8_read_ymode(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_ymode_tree, p);
return vp8_treed_read(bc, vp8_ymode_tree, p);
}
return i;
#if CONFIG_SUPERBLOCKS
static int vp8_sb_kfread_ymode(vp8_reader *bc, const vp8_prob *p) {
return vp8_treed_read(bc, vp8_uv_mode_tree, p);
}
#endif
static int vp8_kfread_ymode(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_kf_ymode_tree, p);
return i;
return vp8_treed_read(bc, vp8_kf_ymode_tree, p);
}
static int vp8_read_i8x8_mode(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_i8x8_mode_tree, p);
return i;
static int vp8_read_i8x8_mode(vp8_reader *bc, const vp8_prob *p) {
return vp8_treed_read(bc, vp8_i8x8_mode_tree, p);
}
static int vp8_read_uv_mode(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_uv_mode_tree, p);
return i;
return vp8_treed_read(bc, vp8_uv_mode_tree, p);
}
// This function reads the current macro block's segnent id from the bitstream
......@@ -112,8 +109,14 @@ static void vp8_kfread_modes(VP8D_COMP *pbi,
m->mbmi.mb_skip_coeff = 0;
}
#if CONFIG_SUPERBLOCKS
if (m->mbmi.encoded_as_sb) {
y_mode = (MB_PREDICTION_MODE) vp8_sb_kfread_ymode(bc,
pbi->common.sb_kf_ymode_prob[pbi->common.kf_ymode_probs_index]);
} else
#endif
y_mode = (MB_PREDICTION_MODE) vp8_kfread_ymode(bc,
pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]);
pbi->common.kf_ymode_prob[pbi->common.kf_ymode_probs_index]);
#if CONFIG_COMP_INTRA_PRED
m->mbmi.second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1);
#endif
......@@ -398,16 +401,18 @@ static MV_REFERENCE_FRAME read_ref_frame(VP8D_COMP *pbi,
return (MV_REFERENCE_FRAME)ref_frame;
}
static MB_PREDICTION_MODE read_mv_ref(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_mv_ref_tree, p);
#if CONFIG_SUPERBLOCKS
static MB_PREDICTION_MODE read_sb_mv_ref(vp8_reader *bc, const vp8_prob *p) {
return (MB_PREDICTION_MODE) vp8_treed_read(bc, vp8_sb_mv_ref_tree, p);
}
#endif
return (MB_PREDICTION_MODE)i;
static MB_PREDICTION_MODE read_mv_ref(vp8_reader *bc, const vp8_prob *p) {
return (MB_PREDICTION_MODE) vp8_treed_read(bc, vp8_mv_ref_tree, p);
}
static B_PREDICTION_MODE sub_mv_ref(vp8_reader *bc, const vp8_prob *p) {
const int i = vp8_treed_read(bc, vp8_sub_mv_ref_tree, p);
return (B_PREDICTION_MODE)i;
return (B_PREDICTION_MODE) vp8_treed_read(bc, vp8_sub_mv_ref_tree, p);
}
#ifdef VPX_MODE_COUNT
......@@ -537,15 +542,36 @@ static void read_mb_segment_id(VP8D_COMP *pbi,
// Else .... decode it explicitly
else {
vp8_read_mb_segid(bc, mbmi, xd);
cm->last_frame_seg_map[index] = mbmi->segment_id;
}
}
// Normal unpredicted coding mode
else {
vp8_read_mb_segid(bc, mbmi, xd);
}
#if CONFIG_SUPERBLOCKS
if (mbmi->encoded_as_sb) {
cm->last_frame_seg_map[index] =
cm->last_frame_seg_map[index + 1] =
cm->last_frame_seg_map[index + cm->mb_cols] =
cm->last_frame_seg_map[index + cm->mb_cols + 1] = mbmi->segment_id;
} else
#endif
{
cm->last_frame_seg_map[index] = mbmi->segment_id;
}
} else {
#if CONFIG_SUPERBLOCKS
if (mbmi->encoded_as_sb) {
mbmi->segment_id =
cm->last_frame_seg_map[index] &&
cm->last_frame_seg_map[index + 1] &&
cm->last_frame_seg_map[index + cm->mb_cols] &&
cm->last_frame_seg_map[index + cm->mb_cols + 1];
} else
#endif
{
mbmi->segment_id = cm->last_frame_seg_map[index];
}
}
} else {
// The encoder explicitly sets the segment_id to 0
......@@ -667,6 +693,11 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->mode =
get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE);
} else {
#if CONFIG_SUPERBLOCKS
if (mbmi->encoded_as_sb) {
mbmi->mode = read_sb_mv_ref(bc, mv_ref_p);
} else
#endif
mbmi->mode = read_mv_ref(bc, mv_ref_p);
vp8_accum_mv_refs(&pbi->common, mbmi->mode, rct);
......@@ -963,6 +994,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->mode = (MB_PREDICTION_MODE)
get_segdata(xd, mbmi->segment_id, SEG_LVL_MODE);
else {
// FIXME write using SB mode tree
mbmi->mode = (MB_PREDICTION_MODE)
vp8_read_ymode(bc, pbi->common.fc.ymode_prob);
pbi->common.fc.ymode_counts[mbmi->mode]++;
......@@ -1045,6 +1077,9 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
int mb_row = (sb_row << 1);
for (sb_col = 0; sb_col < sb_cols; sb_col++) {
#if CONFIG_SUPERBLOCKS
mi->mbmi.encoded_as_sb = vp8_read(&pbi->bc, cm->sb_coded);
#endif
for (i = 0; i < 4; i++) {
int dy = row_delta[i];
......@@ -1059,6 +1094,10 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
prev_mi += offset_extended;
continue;
}
#if CONFIG_SUPERBLOCKS
if (i)
mi->mbmi.encoded_as_sb = 0;
#endif
// Make sure the MacroBlockD mode info pointer is set correctly
xd->mode_info_context = mi;
......@@ -1074,6 +1113,18 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) {
read_mb_modes_mv(pbi, mi, &mi->mbmi, prev_mi, mb_row,
mb_col);
#if CONFIG_SUPERBLOCKS
if (mi->mbmi.encoded_as_sb) {
assert(!i);
mb_col += 2;
mi[1] = mi[cm->mode_info_stride] =
mi[cm->mode_info_stride + 1] = mi[0];
mi += 2;
prev_mi += 2;
break;
}
#endif
/* next macroblock */
mb_row += dy;
mb_col += dx;
......
This diff is collapsed.
......@@ -127,6 +127,19 @@ void vp8_dequant_dc_idct_add_y_block_8x8_c
}
#if CONFIG_SUPERBLOCKS
void vp8_dequant_dc_idct_add_y_block_8x8_inplace_c
(short *q, short *dq,
unsigned char *dst, int stride, char *eobs, short *dc, MACROBLOCKD *xd) {
vp8_dequant_dc_idct_add_8x8_c(q, dq, dst, dst, stride, stride, dc[0]);
vp8_dequant_dc_idct_add_8x8_c(&q[64], dq, dst + 8, dst + 8, stride, stride, dc[1]);
vp8_dequant_dc_idct_add_8x8_c(&q[128], dq, dst + 8 * stride, dst + 8 * stride, stride, stride, dc[4]);
vp8_dequant_dc_idct_add_8x8_c(&q[192], dq, dst + 8 * stride + 8, dst + 8 * stride + 8, stride, stride, dc[8]);
}
#endif
void vp8_dequant_idct_add_y_block_8x8_c
(short *q, short *dq, unsigned char *pre,
unsigned char *dst, int stride, char *eobs, MACROBLOCKD *xd) {
......@@ -153,6 +166,18 @@ void vp8_dequant_idct_add_uv_block_8x8_c
vp8_dequant_idct_add_8x8_c(q, dq, pre, dstv, 8, stride);
}
#if CONFIG_SUPERBLOCKS
void vp8_dequant_idct_add_uv_block_8x8_inplace_c
(short *q, short *dq,
unsigned char *dstu, unsigned char *dstv, int stride, char *eobs, MACROBLOCKD *xd) {
vp8_dequant_idct_add_8x8_c(q, dq, dstu, dstu, stride, stride);
q += 64;
vp8_dequant_idct_add_8x8_c(q, dq, dstv, dstv, stride, stride);
}
#endif
#if CONFIG_LOSSLESS
void vp8_dequant_dc_idct_add_y_block_lossless_c
(short *q, short *dq, unsigned char *pre,
......
......@@ -149,7 +149,7 @@ VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf) {
pbi->decoded_key_frame = 0;
pbi->interleaved_decoding = CONFIG_NEWBESTREFMV;
pbi->interleaved_decoding = CONFIG_NEWBESTREFMV || CONFIG_SUPERBLOCKS;
return (VP8D_PTR) pbi;
}
......
......@@ -288,6 +288,12 @@ static void kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p) {
vp8_write_token(bc, vp8_kf_ymode_tree, p, vp8_kf_ymode_encodings + m);
}
#if CONFIG_SUPERBLOCKS
static void sb_kfwrite_ymode(vp8_writer *bc, int m, const vp8_prob *p) {
vp8_write_token(bc, vp8_uv_mode_tree, p, vp8_sb_kf_ymode_encodings + m);
}
#endif
static void write_i8x8_mode(vp8_writer *bc, int m, const vp8_prob *p) {
vp8_write_token(bc, vp8_i8x8_mode_tree, p, vp8_i8x8_mode_encodings + m);
}
......@@ -533,6 +539,16 @@ static void write_mv_ref
vp8_mv_ref_encoding_array - NEARESTMV + m);
}
#if CONFIG_SUPERBLOCKS
static void write_sb_mv_ref(vp8_writer *w, MB_PREDICTION_MODE m, const vp8_prob *p) {
#if CONFIG_DEBUG
assert(NEARESTMV <= m && m < SPLITMV);
#endif
vp8_write_token(w, vp8_sb_mv_ref_tree, p,
vp8_sb_mv_ref_encoding_array - NEARESTMV + m);
}
#endif
static void write_sub_mv_ref
(
vp8_writer *w, B_PREDICTION_MODE m, const vp8_prob *p
......@@ -810,6 +826,9 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
// Process the 4 MBs in the order:
// top-left, top-right, bottom-left, bottom-right
#if CONFIG_SUPERBLOCKS
vp8_write(w, m->mbmi.encoded_as_sb, pc->sb_coded);
#endif
for (i = 0; i < 4; i++) {
MB_MODE_INFO *mi;
MV_REFERENCE_FRAME rf;
......@@ -872,7 +891,15 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
if (pc->mb_no_coeff_skip &&
(!segfeature_active(xd, segment_id, SEG_LVL_EOB) ||
(get_segdata(xd, segment_id, SEG_LVL_EOB) != 0))) {
vp8_encode_bool(w, mi->mb_skip_coeff,
int skip_coeff = mi->mb_skip_coeff;
#if CONFIG_SUPERBLOCKS
if (mi->encoded_as_sb) {
skip_coeff &= m[1].mbmi.mb_skip_coeff;
skip_coeff &= m[mis].mbmi.mb_skip_coeff;
skip_coeff &= m[mis + 1].mbmi.mb_skip_coeff;
}
#endif
vp8_encode_bool(w, skip_coeff,
get_pred_prob(pc, xd, PRED_MBSKIP));
}
......@@ -884,6 +911,8 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
active_section = 6;
#endif
// TODO(rbultje) write using SB tree structure
if (!segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
write_ymode(w, mode, pc->fc.ymode_prob);
}
......@@ -949,7 +978,14 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
// Is the segment coding of mode enabled
if (!segfeature_active(xd, segment_id, SEG_LVL_MODE)) {
write_mv_ref(w, mode, mv_ref_p);
#if CONFIG_SUPERBLOCKS
if (mi->encoded_as_sb) {
write_sb_mv_ref(w, mode, mv_ref_p);
} else
#endif
{
write_mv_ref(w, mode, mv_ref_p);
}
vp8_accum_mv_refs(&cpi->common, mode, ct);
}
......@@ -1085,6 +1121,17 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) {
}
}
#if CONFIG_SUPERBLOCK