summaryrefslogtreecommitdiff
path: root/vp9/decoder
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-04-19 14:25:32 -0700
committerDmitry Kovalev <dkovalev@google.com>2013-04-19 14:25:32 -0700
commitc09f652590fe6a18f76eeee15c8722ce236c8a0a (patch)
treeca963c3770078ef32268ecca6ae9ada0953ab20e /vp9/decoder
parentec2599cc916f53b61a668c0f2e29977c6e8af908 (diff)
downloadlibvpx-c09f652590fe6a18f76eeee15c8722ce236c8a0a.tar
libvpx-c09f652590fe6a18f76eeee15c8722ce236c8a0a.tar.gz
libvpx-c09f652590fe6a18f76eeee15c8722ce236c8a0a.tar.bz2
libvpx-c09f652590fe6a18f76eeee15c8722ce236c8a0a.zip
Removing get_segment_id function and using existing vp9_get_pred_mb_segid.
Change-Id: Iff35d4b2f8f65511f80c594958c01fb4673fa033
Diffstat (limited to 'vp9/decoder')
-rw-r--r--vp9/decoder/vp9_decodemv.c114
1 files changed, 42 insertions, 72 deletions
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 2a8521a14..d64c8e62f 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -84,8 +84,8 @@ static int read_mb_segid(vp9_reader *r, MACROBLOCKD *xd) {
static int read_mb_segid_except(vp9_reader *r,
VP9_COMMON *cm, MACROBLOCKD *xd,
int mb_row, int mb_col) {
- const int mb_index = mb_row * cm->mb_cols + mb_col;
- const int pred_seg_id = vp9_get_pred_mb_segid(cm, xd, mb_index);
+ const BLOCK_SIZE_TYPE sb_type = xd->mode_info_context->mbmi.sb_type;
+ const int pred_seg_id = vp9_get_pred_mb_segid(cm, sb_type, mb_row, mb_col);
const vp9_prob *const p = xd->mb_segment_tree_probs;
const vp9_prob prob = xd->mb_segment_mispred_tree_probs[pred_seg_id];
@@ -116,30 +116,6 @@ static void set_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi,
}
}
-static int get_segment_id(VP9_COMMON *cm, MB_MODE_INFO *mbmi,
- int mb_row, int mb_col) {
- const int mb_index = mb_row * cm->mb_cols + mb_col;
- const BLOCK_SIZE_TYPE sb_type = mbmi->sb_type;
- if (sb_type) {
- const int bw = 1 << mb_width_log2(sb_type);
- const int bh = 1 << mb_height_log2(sb_type);
- const int ymbs = MIN(cm->mb_rows - mb_row, bh);
- const int xmbs = MIN(cm->mb_cols - mb_col, bw);
- int segment_id = INT_MAX;
- int x, y;
-
- for (y = 0; y < ymbs; y++) {
- for (x = 0; x < xmbs; x++) {
- const int index = mb_index + (y * cm->mb_cols + x);
- segment_id = MIN(segment_id, cm->last_frame_seg_map[index]);
- }
- }
- return segment_id;
- } else {
- return cm->last_frame_seg_map[mb_index];
- }
-}
-
extern const int vp9_i8x8_block[4];
static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
int mb_row, int mb_col,
@@ -149,19 +125,19 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
const int mis = cm->mode_info_stride;
m->mbmi.ref_frame = INTRA_FRAME;
- // Read the Macroblock segmentation map if it is being updated explicitly
- // this frame (reset to 0 by default).
+ // Read segmentation map if it is being updated explicitly this frame
m->mbmi.segment_id = 0;
if (xd->segmentation_enabled && xd->update_mb_segmentation_map) {
m->mbmi.segment_id = read_mb_segid(r, xd);
set_segment_id(cm, &m->mbmi, mb_row, mb_col, m->mbmi.segment_id);
}
- m->mbmi.mb_skip_coeff = vp9_segfeature_active(&pbi->mb, m->mbmi.segment_id,
+ m->mbmi.mb_skip_coeff = vp9_segfeature_active(xd, m->mbmi.segment_id,
SEG_LVL_SKIP);
if (!m->mbmi.mb_skip_coeff)
m->mbmi.mb_skip_coeff = vp9_read(r, vp9_get_pred_prob(cm, xd, PRED_MBSKIP));
+ // luma mode
m->mbmi.mode = m->mbmi.sb_type ?
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]);
@@ -169,19 +145,19 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
m->mbmi.ref_frame = INTRA_FRAME;
if (m->mbmi.mode == I4X4_PRED) {
- int i = 0;
- do {
+ int i;
+ for (i = 0; i < 16; ++i) {
const B_PREDICTION_MODE a = above_block_mode(m, i, mis);
const B_PREDICTION_MODE l = xd->left_available || (i & 3) ?
left_block_mode(m, i) : B_DC_PRED;
m->bmi[i].as_mode.first = read_kf_bmode(r, cm->kf_bmode_prob[a][l]);
- } while (++i < 16);
+ }
}
if (m->mbmi.mode == I8X8_PRED) {
int i;
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 4; ++i) {
const int ib = vp9_i8x8_block[i];
const int mode8x8 = read_i8x8_mode(r, cm->fc.i8x8_mode_prob);
@@ -190,7 +166,10 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
m->bmi[ib + 4].as_mode.first = mode8x8;
m->bmi[ib + 5].as_mode.first = mode8x8;
}
- } else {
+ }
+
+ // chroma mode
+ if (m->mbmi.mode != I8X8_PRED) {
m->mbmi.uv_mode = read_uv_mode(r, cm->kf_uv_mode_prob[m->mbmi.mode]);
}
@@ -527,12 +506,10 @@ static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *r) {
for (i = 0; i < VP9_I32X32_MODES - 1; ++i)
cm->fc.sb_ymode_prob[i] = vp9_read_prob(r);
- for (j = 0; j < PARTITION_PLANES; j++) {
- if (vp9_read_bit(r)) {
+ for (j = 0; j < PARTITION_PLANES; j++)
+ if (vp9_read_bit(r))
for (i = 0; i < PARTITION_TYPES - 1; i++)
cm->fc.partition_prob[j][i] = vp9_read_prob(r);
- }
- }
read_nmvprobs(r, nmvc, xd->allow_high_precision_mv);
}
@@ -541,47 +518,40 @@ static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *r) {
// This function either reads the segment id for the current macroblock from
// the bitstream or if the value is temporally predicted asserts the predicted
// value
-static void read_mb_segment_id(VP9D_COMP *pbi,
- int mb_row, int mb_col,
- vp9_reader *r) {
+static int read_mb_segment_id(VP9D_COMP *pbi, int mb_row, int mb_col,
+ vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MODE_INFO *const mi = xd->mode_info_context;
MB_MODE_INFO *const mbmi = &mi->mbmi;
- const int mb_index = mb_row * cm->mb_cols + mb_col;
-
- if (xd->segmentation_enabled) {
- if (xd->update_mb_segmentation_map) {
- // Is temporal coding of the segment id for this mb enabled.
- if (cm->temporal_update) {
- // Get the context based probability for reading the
- // prediction status flag
- vp9_prob pred_prob = vp9_get_pred_prob(cm, xd, PRED_SEG_ID);
-
- // Read the prediction status flag
- unsigned char seg_pred_flag = vp9_read(r, pred_prob);
-
- // Store the prediction flag.
- vp9_set_pred_flag(xd, PRED_SEG_ID, seg_pred_flag);
-
- // If the value is flagged as correctly predicted
- // then use the predicted value, otherwise decode it explicitly
- mbmi->segment_id = seg_pred_flag ?
- vp9_get_pred_mb_segid(cm, xd, mb_index) :
- read_mb_segid_except(r, cm, xd, mb_row, mb_col);
- } else {
- // Normal unpredicted coding mode
- mbmi->segment_id = read_mb_segid(r, xd);
- }
- set_segment_id(cm, mbmi, mb_row, mb_col, mbmi->segment_id);
+ if (!xd->segmentation_enabled)
+ return 0; // Default for disabled segmentation
+
+ if (xd->update_mb_segmentation_map) {
+ int segment_id;
+
+ if (cm->temporal_update) {
+ // Temporal coding of the segment id for this mb is enabled.
+ // Get the context based probability for reading the
+ // prediction status flag
+ const vp9_prob pred_prob = vp9_get_pred_prob(cm, xd, PRED_SEG_ID);
+ const int pred_flag = vp9_read(r, pred_prob);
+ vp9_set_pred_flag(xd, PRED_SEG_ID, pred_flag);
+
+ // If the value is flagged as correctly predicted
+ // then use the predicted value, otherwise decode it explicitly
+ segment_id = pred_flag ? vp9_get_pred_mb_segid(cm, mbmi->sb_type,
+ mb_row, mb_col)
+ : read_mb_segid_except(r, cm, xd, mb_row, mb_col);
} else {
- mbmi->segment_id = get_segment_id(cm, mbmi, mb_row, mb_col);
+ segment_id = read_mb_segid(r, xd); // Normal unpredicted coding mode
}
+
+ set_segment_id(cm, mbmi, mb_row, mb_col, segment_id); // Side effect
+ return segment_id;
} else {
- // The encoder explicitly sets the segment_id to 0
- // when segmentation is disabled
- mbmi->segment_id = 0;
+ return vp9_get_pred_mb_segid(cm, mbmi->sb_type, mb_row, mb_col);
}
}
@@ -656,7 +626,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mb_to_right_edge = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
// Read the macroblock segment id.
- read_mb_segment_id(pbi, mb_row, mb_col, r);
+ mbmi->segment_id = read_mb_segment_id(pbi, mb_row, mb_col, r);
mbmi->mb_skip_coeff = vp9_segfeature_active(xd, mbmi->segment_id,
SEG_LVL_SKIP);