From: Adrian Grange Date: Wed, 18 Apr 2012 16:08:55 +0000 (-0700) Subject: Added update of mode context pointers in decoder X-Git-Tag: v1.3.0~1217^2~379^2~63 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1cc406ab4a16549fc3b44c0b20f7e81dfc2b649c;p=libvpx Added update of mode context pointers in decoder With the NEWENTROPY experiment enabled encoding certain clips produced invlid bitstreams, or files that had a high degree of artefacts. This was the results of pointers in MACROBLOCKD not being setup correctly (mode_info_context and prev_mode_info_context). Change-Id: Ice13e1efa8bd122997d2f8f3f1e761c6c16e0403 --- diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c index 1c82f8ff8..1b9bd463a 100644 --- a/vp8/decoder/decodemv.c +++ b/vp8/decoder/decodemv.c @@ -109,7 +109,6 @@ static void vp8_kfread_modes(VP8D_COMP *pbi, { #if CONFIG_NEWENTROPY MACROBLOCKD *const xd = & pbi->mb; - xd->mode_info_context = m; m->mbmi.mb_skip_coeff = vp8_read(bc, get_pred_prob(cm, xd, PRED_MBSKIP)); #else m->mbmi.mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false); @@ -201,6 +200,7 @@ static void vp8_kfread_modes(VP8D_COMP *pbi, #if CONFIG_COMP_INTRA_PRED m->mbmi.second_uv_mode = (MB_PREDICTION_MODE) (DC_PRED - 1); #endif + } static int read_mvcomponent(vp8_reader *r, const MV_CONTEXT *mvc) @@ -1019,6 +1019,7 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) int i; VP8_COMMON *cm = &pbi->common; MODE_INFO *mi = cm->mi; + MACROBLOCKD *const xd = &pbi->mb; int sb_row, sb_col; int sb_rows = (cm->mb_rows + 1)>>1; int sb_cols = (cm->mb_cols + 1)>>1; @@ -1062,6 +1063,10 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi) continue; } + // Make sure the MacroBlockD mode info pointer is set correctly + xd->mode_info_context = mi; + xd->prev_mode_info_context = prev_mi; + pbi->mb.mb_to_top_edge = mb_to_top_edge = -((mb_row * 16)) << 3; mb_to_top_edge -= LEFT_TOP_MARGIN; diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index 8ad7ad2db..198e1c324 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -859,7 +859,6 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi) // Make sure the MacroBlockD mode info pointer is set correctly xd->mode_info_context = m; - xd->prev_mode_info_context = prev_m; #ifdef ENTROPY_STATS @@ -1126,6 +1125,7 @@ static void write_kfmodes(VP8_COMP *cpi) vp8_writer *const bc = & cpi->bc; VP8_COMMON *const c = & cpi->common; const int mis = c->mode_info_stride; + MACROBLOCKD *xd = &cpi->mb.e_mbd; MODE_INFO *m; int i; int row, col; @@ -1138,8 +1138,6 @@ static void write_kfmodes(VP8_COMP *cpi) int row_delta[4] = { 0, +1, 0, -1}; int col_delta[4] = {+1, -1, +1, +1}; - MACROBLOCKD *xd = &cpi->mb.e_mbd; - if (c->mb_no_coeff_skip) { // Divide by 0 check. 0 case possible with segment features @@ -1218,6 +1216,9 @@ static void write_kfmodes(VP8_COMP *cpi) continue; } + // Make sure the MacroBlockD mode info pointer is set correctly + xd->mode_info_context = m; + ym = m->mbmi.mode; segment_id = m->mbmi.segment_id; @@ -1230,49 +1231,50 @@ static void write_kfmodes(VP8_COMP *cpi) ( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) || (get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0) ) ) { - #if CONFIG_NEWENTROPY +#if CONFIG_NEWENTROPY vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, get_pred_prob(c, xd, PRED_MBSKIP)); - #else +#else vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false); - #endif +#endif } - #if CONFIG_QIMODE +#if CONFIG_QIMODE kfwrite_ymode(bc, ym, c->kf_ymode_prob[c->kf_ymode_probs_index]); - #else +#else kfwrite_ymode(bc, ym, c->kf_ymode_prob); - #endif +#endif + if (ym == B_PRED) { const int mis = c->mode_info_stride; int i = 0; - #if CONFIG_COMP_INTRA_PRED +#if CONFIG_COMP_INTRA_PRED int uses_second = m->bmi[0].as_mode.second != (B_PREDICTION_MODE) (B_DC_PRED - 1); vp8_write(bc, uses_second, 128); - #endif +#endif do { const B_PREDICTION_MODE A = above_block_mode(m, i, mis); const B_PREDICTION_MODE L = left_block_mode(m, i); const int bm = m->bmi[i].as_mode.first; - #if CONFIG_COMP_INTRA_PRED +#if CONFIG_COMP_INTRA_PRED const int bm2 = m->bmi[i].as_mode.second; - #endif +#endif - #ifdef ENTROPY_STATS +#ifdef ENTROPY_STATS ++intra_mode_stats [A] [L] [bm]; - #endif +#endif write_bmode(bc, bm, c->kf_bmode_prob [A] [L]); - #if CONFIG_COMP_INTRA_PRED +#if CONFIG_COMP_INTRA_PRED if (uses_second) { write_bmode(bc, bm2, c->kf_bmode_prob [A] [L]); } - #endif +#endif } while (++i < 16); } @@ -1293,6 +1295,7 @@ static void write_kfmodes(VP8_COMP *cpi) #else write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob); #endif + // Next MB mb_row += dy; mb_col += dx;