From 863138a2ad8cb47da20e268f80195dde99a4f225 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Tue, 16 Jul 2013 10:44:48 -0700 Subject: [PATCH] Rewriting vp9_set_pred_flag_{seg_id, mbskip}. Making implementation of vp9_set_pred_flag_{seg_id, mbskip} consistent with vp9_get_segment_id without using confusing sub(a, b) macro. Passing mi_row and mi_col to functions explicitly instead of replying on mb_to_right_edge and mb_to_bottom_edge. Change-Id: I54c1087dd2ba9036f8ba7eb165b073e807d00435 --- vp9/common/vp9_pred_common.c | 49 +++++++++++++++------------------- vp9/common/vp9_pred_common.h | 8 +++--- vp9/decoder/vp9_decodemv.c | 2 +- vp9/decoder/vp9_decodframe.c | 3 ++- vp9/encoder/vp9_encodeframe.c | 2 +- vp9/encoder/vp9_segmentation.c | 2 +- 6 files changed, 31 insertions(+), 35 deletions(-) diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c index 19ac492a1..5c8e34630 100644 --- a/vp9/common/vp9_pred_common.c +++ b/vp9/common/vp9_pred_common.c @@ -16,21 +16,6 @@ #include "vp9/common/vp9_seg_common.h" #include "vp9/common/vp9_treecoder.h" -void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, - unsigned char pred_flag) { - const int mis = xd->mode_info_stride; - const int bh = 1 << mi_height_log2(bsize); - const int bw = 1 << mi_width_log2(bsize); -#define sub(a, b) (b) < 0 ? (a) + (b) : (a) - const int x_mis = sub(bw, xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)); - const int y_mis = sub(bh, xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)); -#undef sub - int x, y; - - for (y = 0; y < y_mis; y++) - for (x = 0; x < x_mis; x++) - xd->mode_info_context[y * mis + x].mbmi.seg_id_predicted = pred_flag; -} // Returns a context number for the given MB prediction signal unsigned char vp9_get_pred_context_switchable_interp(const VP9_COMMON *cm, const MACROBLOCKD *xd) { @@ -423,22 +408,32 @@ unsigned char vp9_get_pred_context_tx_size(const VP9_COMMON *cm, return above_context + left_context > max_tx_size; } -// This function sets the status of the given prediction signal. -// I.e. is the predicted value for the given signal correct. -void vp9_set_pred_flag_mbskip(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, - unsigned char pred_flag) { - const int mis = xd->mode_info_stride; +void vp9_set_pred_flag_seg_id(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize, + int mi_row, int mi_col, uint8_t pred_flag) { + MODE_INFO *mi = &cm->mi[mi_row * cm->mode_info_stride + mi_col]; + const int bw = 1 << mi_width_log2(bsize); const int bh = 1 << mi_height_log2(bsize); + const int xmis = MIN(cm->mi_cols - mi_col, bw); + const int ymis = MIN(cm->mi_rows - mi_row, bh); + int x, y; + + for (y = 0; y < ymis; y++) + for (x = 0; x < xmis; x++) + mi[y * cm->mode_info_stride + x].mbmi.seg_id_predicted = pred_flag; +} + +void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize, + int mi_row, int mi_col, uint8_t pred_flag) { + MODE_INFO *mi = &cm->mi[mi_row * cm->mode_info_stride + mi_col]; const int bw = 1 << mi_width_log2(bsize); -#define sub(a, b) (b) < 0 ? (a) + (b) : (a) - const int x_mis = sub(bw, xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)); - const int y_mis = sub(bh, xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)); -#undef sub + const int bh = 1 << mi_height_log2(bsize); + const int xmis = MIN(cm->mi_cols - mi_col, bw); + const int ymis = MIN(cm->mi_rows - mi_row, bh); int x, y; - for (y = 0; y < y_mis; y++) - for (x = 0; x < x_mis; x++) - xd->mode_info_context[y * mis + x].mbmi.mb_skip_coeff = pred_flag; + for (y = 0; y < ymis; y++) + for (x = 0; x < xmis; x++) + mi[y * cm->mode_info_stride + x].mbmi.mb_skip_coeff = pred_flag; } int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids, diff --git a/vp9/common/vp9_pred_common.h b/vp9/common/vp9_pred_common.h index 305e57cba..7fc9a1c4b 100644 --- a/vp9/common/vp9_pred_common.h +++ b/vp9/common/vp9_pred_common.h @@ -31,8 +31,8 @@ static INLINE vp9_prob vp9_get_pred_prob_seg_id(const MACROBLOCKD *xd) { return xd->seg.pred_probs[vp9_get_pred_context_seg_id(xd)]; } -void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, - unsigned char pred_flag); +void vp9_set_pred_flag_seg_id(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize, + int mi_row, int mi_col, uint8_t pred_flag); static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) { const MODE_INFO *const mi = xd->mode_info_context; @@ -52,8 +52,8 @@ static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) { return xd->mode_info_context->mbmi.mb_skip_coeff; } -void vp9_set_pred_flag_mbskip(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, - unsigned char pred_flag); +void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize, + int mi_row, int mi_col, uint8_t pred_flag); unsigned char vp9_get_pred_context_switchable_interp(const VP9_COMMON *cm, const MACROBLOCKD *xd); diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 6b07d5ce2..1387a890c 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -140,7 +140,7 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col, if (seg->temporal_update) { const vp9_prob pred_prob = vp9_get_pred_prob_seg_id(xd); const int pred_flag = vp9_read(r, pred_prob); - vp9_set_pred_flag_seg_id(xd, bsize, pred_flag); + vp9_set_pred_flag_seg_id(cm, bsize, mi_row, mi_col, pred_flag); segment_id = pred_flag ? pred_segment_id : read_segment_id(r, seg); } else { diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index e771ed43f..9d79f03ff 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -262,7 +262,8 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col, } else { assert(mbmi->sb_type == bsize); if (eobtotal == 0) - vp9_set_pred_flag_mbskip(xd, bsize, 1); // skip loopfilter + // skip loopfilter + vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, 1); else if (eobtotal > 0) foreach_transformed_block(xd, bsize, decode_block, xd); } diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 8ac46c023..3c56f8a80 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -2380,7 +2380,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, // copy skip flag on all mb_mode_info contexts in this SB // if this was a skip at this txfm size - vp9_set_pred_flag_mbskip(xd, bsize, mi->mbmi.mb_skip_coeff); + vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, mi->mbmi.mb_skip_coeff); if (output_enabled) { if (cm->txfm_mode == TX_MODE_SELECT && diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c index f3b2ea8e5..cd7eb17b2 100644 --- a/vp9/encoder/vp9_segmentation.c +++ b/vp9/encoder/vp9_segmentation.c @@ -145,7 +145,7 @@ static void count_segs(VP9_COMP *cpi, MODE_INFO *mi, // Store the prediction status for this mb and update counts // as appropriate - vp9_set_pred_flag_seg_id(xd, bsize, pred_flag); + vp9_set_pred_flag_seg_id(cm, bsize, mi_row, mi_col, pred_flag); temporal_predictor_count[pred_context][pred_flag]++; if (!pred_flag) -- 2.40.0