summaryrefslogtreecommitdiff
path: root/vp8/decoder/decodemv.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@google.com>2012-08-20 14:43:34 -0700
committerRonald S. Bultje <rbultje@google.com>2012-08-20 14:43:34 -0700
commit5d4cffb35f4bc23462eedc95a4802c65e32d7d5a (patch)
tree6fce23691dfa0c01aeb422f6c6b68c75296e91f2 /vp8/decoder/decodemv.c
parent319dd1c0f58d3db46713460ca10e920f2b18b605 (diff)
downloadlibvpx-5d4cffb35f4bc23462eedc95a4802c65e32d7d5a.tar
libvpx-5d4cffb35f4bc23462eedc95a4802c65e32d7d5a.tar.gz
libvpx-5d4cffb35f4bc23462eedc95a4802c65e32d7d5a.tar.bz2
libvpx-5d4cffb35f4bc23462eedc95a4802c65e32d7d5a.zip
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
Diffstat (limited to 'vp8/decoder/decodemv.c')
-rw-r--r--vp8/decoder/decodemv.c97
1 files changed, 74 insertions, 23 deletions
diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c
index 94826ef6c..5e0600c2d 100644
--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -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;