Changing initialization order of mb_to_top_edge & mb_to_bottom_edge

Making consistent initialization of mb_to_{top,botton,left,right}_edge
variables after set_mb_row & set_mb_col calls. A little bit of code cleanup
additionally.

Change-Id: I245bfe32c5701e9836956dc25cf8c770d109cbc1
This commit is contained in:
Dmitry Kovalev 2013-03-21 12:51:57 -07:00
parent 8a3233b54d
commit 407940243f

View File

@ -76,12 +76,10 @@ static MB_PREDICTION_MODE read_uv_mode(vp9_reader *bc, const vp9_prob *p) {
// This function reads the current macro block's segnent id from the bitstream // This function reads the current macro block's segnent id from the bitstream
// It should only be called if a segment map update is indicated. // It should only be called if a segment map update is indicated.
static void read_mb_segid(vp9_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *xd) { static void read_mb_segid(vp9_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *xd) {
/* Is segmentation enabled */
if (xd->segmentation_enabled && xd->update_mb_segmentation_map) { if (xd->segmentation_enabled && xd->update_mb_segmentation_map) {
/* If so then read the segment id. */ const vp9_prob *const p = xd->mb_segment_tree_probs;
mi->segment_id = vp9_read(r, xd->mb_segment_tree_probs[0]) ? mi->segment_id = vp9_read(r, p[0]) ? 2 + vp9_read(r, p[2])
(unsigned char)(2 + vp9_read(r, xd->mb_segment_tree_probs[2])): : vp9_read(r, p[1]);
(unsigned char)(vp9_read(r, xd->mb_segment_tree_probs[1]));
} }
} }
@ -90,21 +88,15 @@ static void read_mb_segid(vp9_reader *r, MB_MODE_INFO *mi, MACROBLOCKD *xd) {
static void read_mb_segid_except(VP9_COMMON *cm, static void read_mb_segid_except(VP9_COMMON *cm,
vp9_reader *r, MB_MODE_INFO *mi, vp9_reader *r, MB_MODE_INFO *mi,
MACROBLOCKD *xd, int mb_row, int mb_col) { MACROBLOCKD *xd, int mb_row, int mb_col) {
int pred_seg_id = vp9_get_pred_mb_segid(cm, xd, const int mb_index = mb_row * cm->mb_cols + mb_col;
mb_row * cm->mb_cols + mb_col); const int pred_seg_id = vp9_get_pred_mb_segid(cm, xd, mb_index);
const vp9_prob *p = xd->mb_segment_tree_probs; const vp9_prob *const p = xd->mb_segment_tree_probs;
vp9_prob p1 = xd->mb_segment_mispred_tree_probs[pred_seg_id]; const vp9_prob prob = xd->mb_segment_mispred_tree_probs[pred_seg_id];
/* Is segmentation enabled */
if (xd->segmentation_enabled && xd->update_mb_segmentation_map) { if (xd->segmentation_enabled && xd->update_mb_segmentation_map) {
/* If so then read the segment id. */ mi->segment_id = vp9_read(r, prob)
if (vp9_read(r, p1)) { ? 2 + (pred_seg_id < 2 ? vp9_read(r, p[2]) : (pred_seg_id == 2))
mi->segment_id = 2 + : (pred_seg_id >= 2 ? vp9_read(r, p[1]) : (pred_seg_id == 0));
(pred_seg_id < 2 ? vp9_read(r, p[2]) : (pred_seg_id == 2));
} else {
mi->segment_id =
pred_seg_id >= 2 ? vp9_read(r, p[1]) : (pred_seg_id == 0);
}
} }
} }
@ -265,8 +257,8 @@ static int read_nmv_component_fp(vp9_reader *r,
offset += f << 1; offset += f << 1;
if (usehp) { if (usehp) {
offset += mv_class == MV_CLASS_0 ? const vp9_prob p = mv_class == MV_CLASS_0 ? mvcomp->class0_hp : mvcomp->hp;
vp9_read(r, mvcomp->class0_hp) : vp9_read(r, mvcomp->hp); offset += vp9_read(r, p);
} else { } else {
offset += 1; // If hp is not used, the default value of the hp bit is 1 offset += 1; // If hp is not used, the default value of the hp bit is 1
} }
@ -567,10 +559,10 @@ static void read_mb_segment_id(VP9D_COMP *pbi,
int mb_row, int mb_col, int mb_row, int mb_col,
BOOL_DECODER* const bc) { BOOL_DECODER* const bc) {
VP9_COMMON *const cm = &pbi->common; VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb; MACROBLOCKD *const xd = &pbi->mb;
MODE_INFO *mi = xd->mode_info_context; MODE_INFO *mi = xd->mode_info_context;
MB_MODE_INFO *mbmi = &mi->mbmi; MB_MODE_INFO *mbmi = &mi->mbmi;
int index = mb_row * pbi->common.mb_cols + mb_col; int mb_index = mb_row * pbi->common.mb_cols + mb_col;
if (xd->segmentation_enabled) { if (xd->segmentation_enabled) {
if (xd->update_mb_segmentation_map) { if (xd->update_mb_segmentation_map) {
@ -589,7 +581,7 @@ static void read_mb_segment_id(VP9D_COMP *pbi,
// If the value is flagged as correctly predicted // If the value is flagged as correctly predicted
// then use the predicted value // then use the predicted value
if (seg_pred_flag) { if (seg_pred_flag) {
mbmi->segment_id = vp9_get_pred_mb_segid(cm, xd, index); mbmi->segment_id = vp9_get_pred_mb_segid(cm, xd, mb_index);
} else { } else {
// Decode it explicitly // Decode it explicitly
read_mb_segid_except(cm, bc, mbmi, xd, mb_row, mb_col); read_mb_segid_except(cm, bc, mbmi, xd, mb_row, mb_col);
@ -607,12 +599,12 @@ static void read_mb_segment_id(VP9D_COMP *pbi,
for (y = 0; y < ymbs; y++) { for (y = 0; y < ymbs; y++) {
for (x = 0; x < xmbs; x++) { for (x = 0; x < xmbs; x++) {
cm->last_frame_seg_map[index + x + y * cm->mb_cols] = cm->last_frame_seg_map[mb_index + x + y * cm->mb_cols] =
mbmi->segment_id; mbmi->segment_id;
} }
} }
} else { } else {
cm->last_frame_seg_map[index] = mbmi->segment_id; cm->last_frame_seg_map[mb_index] = mbmi->segment_id;
} }
} else { } else {
if (mbmi->sb_type) { if (mbmi->sb_type) {
@ -625,12 +617,12 @@ static void read_mb_segment_id(VP9D_COMP *pbi,
for (y = 0; y < ymbs; y++) { for (y = 0; y < ymbs; y++) {
for (x = 0; x < xmbs; x++) { for (x = 0; x < xmbs; x++) {
segment_id = MIN(segment_id, segment_id = MIN(segment_id,
cm->last_frame_seg_map[index + x + y * cm->mb_cols]); cm->last_frame_seg_map[mb_index + x + y * cm->mb_cols]);
} }
} }
mbmi->segment_id = segment_id; mbmi->segment_id = segment_id;
} else { } else {
mbmi->segment_id = cm->last_frame_seg_map[index]; mbmi->segment_id = cm->last_frame_seg_map[mb_index];
} }
} }
} else { } else {
@ -668,7 +660,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
VP9_COMMON *const cm = &pbi->common; VP9_COMMON *const cm = &pbi->common;
nmv_context *const nmvc = &pbi->common.fc.nmvc; nmv_context *const nmvc = &pbi->common.fc.nmvc;
const int mis = pbi->common.mode_info_stride; const int mis = pbi->common.mode_info_stride;
MACROBLOCKD *const xd = &pbi->mb; MACROBLOCKD *const xd = &pbi->mb;
int_mv *const mv = &mbmi->mv[0]; int_mv *const mv = &mbmi->mv[0];
const int mb_size = 1 << mi->mbmi.sb_type; const int mb_size = 1 << mi->mbmi.sb_type;
@ -677,10 +669,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
cm->height == cm->last_height && cm->height == cm->last_height &&
!cm->error_resilient_mode; !cm->error_resilient_mode;
int mb_to_left_edge; int mb_to_left_edge, mb_to_right_edge, mb_to_top_edge, mb_to_bottom_edge;
int mb_to_right_edge;
int mb_to_top_edge = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
int mb_to_bottom_edge = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
mbmi->need_to_clamp_mvs = 0; mbmi->need_to_clamp_mvs = 0;
mbmi->need_to_clamp_secondmv = 0; mbmi->need_to_clamp_secondmv = 0;
@ -697,6 +686,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
set_mb_row(cm, xd, mb_row, mb_size); set_mb_row(cm, xd, mb_row, mb_size);
set_mb_col(cm, xd, mb_col, mb_size); set_mb_col(cm, xd, mb_col, mb_size);
mb_to_top_edge = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
mb_to_bottom_edge = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
mb_to_left_edge = xd->mb_to_left_edge - LEFT_TOP_MARGIN; mb_to_left_edge = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
mb_to_right_edge = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN; mb_to_right_edge = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
@ -898,13 +889,13 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->uv_mode = DC_PRED; mbmi->uv_mode = DC_PRED;
switch (mbmi->mode) { switch (mbmi->mode) {
case SPLITMV: { case SPLITMV: {
const int s = mbmi->partitioning = const int s = treed_read(bc, vp9_mbsplit_tree, cm->fc.mbsplit_prob);
treed_read(bc, vp9_mbsplit_tree, cm->fc.mbsplit_prob); const int num_p = vp9_mbsplit_count[s];
const int num_p = vp9_mbsplit_count [s];
int j = 0; int j = 0;
cm->fc.mbsplit_counts[s]++;
cm->fc.mbsplit_counts[s]++;
mbmi->need_to_clamp_mvs = 0; mbmi->need_to_clamp_mvs = 0;
mbmi->partitioning = s;
do { // for each subset j do { // for each subset j
int_mv leftmv, abovemv, second_leftmv, second_abovemv; int_mv leftmv, abovemv, second_leftmv, second_abovemv;
int_mv blockmv, secondmv; int_mv blockmv, secondmv;
@ -1084,9 +1075,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
if (mbmi->mode == B_PRED) { if (mbmi->mode == B_PRED) {
int j = 0; int j = 0;
do { do {
int m; int m = read_bmode(bc, pbi->common.fc.bmode_prob);
m = mi->bmi[j].as_mode.first = read_bmode(bc, mi->bmi[j].as_mode.first = m;
pbi->common.fc.bmode_prob);
#if CONFIG_NEWBINTRAMODES #if CONFIG_NEWBINTRAMODES
if (m == B_CONTEXT_PRED) m -= CONTEXT_PRED_REPLACEMENTS; if (m == B_CONTEXT_PRED) m -= CONTEXT_PRED_REPLACEMENTS;
#endif #endif