diff --git a/vp9/common/vp9_findnearmv.c b/vp9/common/vp9_findnearmv.c index 643b229a6275daffffb2bb885e83f778a6721c4d..cea06b4bd8aed38268dbb121f93f73a353e28a9e 100644 --- a/vp9/common/vp9_findnearmv.c +++ b/vp9/common/vp9_findnearmv.c @@ -41,7 +41,8 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd, void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, int_mv *dst_nearest, int_mv *dst_near, - int block_idx, int ref_idx) { + int block_idx, int ref_idx, + int mi_row, int mi_col) { int_mv dst_list[MAX_MV_REF_CANDIDATES]; int_mv mv_list[MAX_MV_REF_CANDIDATES]; MODE_INFO *mi = xd->mode_info_context; @@ -53,7 +54,8 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, vp9_find_mv_refs_idx(cm, xd, xd->mode_info_context, xd->prev_mode_info_context, mbmi->ref_frame[ref_idx], - mv_list, cm->ref_frame_sign_bias, block_idx); + mv_list, cm->ref_frame_sign_bias, block_idx, + mi_row, mi_col); dst_list[1].as_int = 0; if (block_idx == 0) { diff --git a/vp9/common/vp9_findnearmv.h b/vp9/common/vp9_findnearmv.h index b0fa505b5da721247f56d67a1079be1f20e43582..907e580cdeb48b7e8394e32ef7a1f91eadba8f38 100644 --- a/vp9/common/vp9_findnearmv.h +++ b/vp9/common/vp9_findnearmv.h @@ -53,7 +53,8 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *pc, MACROBLOCKD *xd, int_mv *dst_nearest, int_mv *dst_near, - int block_idx, int ref_idx); + int block_idx, int ref_idx, + int mi_row, int mi_col); static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) { // FIXME(rbultje, jingning): temporary hack because jenkins doesn't diff --git a/vp9/common/vp9_mvref_common.c b/vp9/common/vp9_mvref_common.c index ae009b0ff9bcdd7f9eac46b678c6bf84bab178c2..8cf171697b0bcb773ab4ec86e8d9e275bf02208b 100644 --- a/vp9/common/vp9_mvref_common.c +++ b/vp9/common/vp9_mvref_common.c @@ -105,7 +105,7 @@ static void get_non_matching_candidates(const MODE_INFO *candidate_mi, // Performs mv sign inversion if indicated by the reference frame combination. -static void scale_mv(MACROBLOCKD *xd, MV_REFERENCE_FRAME this_ref_frame, +static void scale_mv(MV_REFERENCE_FRAME this_ref_frame, MV_REFERENCE_FRAME candidate_ref_frame, int_mv *candidate_mv, int *ref_sign_bias) { @@ -139,10 +139,10 @@ static void add_candidate_mv(int_mv *mv_list, int *mv_scores, void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, MODE_INFO *lf_here, MV_REFERENCE_FRAME ref_frame, int_mv *mv_ref_list, int *ref_sign_bias, - int block_idx) { + int block_idx, int mi_row, int mi_col) { int i; MODE_INFO *candidate_mi; - MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi; + MB_MODE_INFO *mbmi = &here->mbmi; int_mv c_refmv; int_mv c2_refmv; MV_REFERENCE_FRAME c_ref_frame; @@ -150,8 +150,7 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, int candidate_scores[MAX_MV_REF_CANDIDATES] = { 0 }; int refmv_count = 0; const int (*mv_ref_search)[2] = mv_ref_blocks[mbmi->sb_type]; - const int mi_col = get_mi_col(xd); - const int mi_row = get_mi_row(xd); + const int mi_stride = cm->mode_info_stride; int intra_count = 0; int zero_count = 0; int newmv_count = 0; @@ -176,7 +175,7 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, int b; candidate_mi = here + mv_ref_search[i][0] + - (mv_ref_search[i][1] * xd->mode_info_stride); + mi_stride * mv_ref_search[i][1]; if (block_idx >= 0) { if (mv_ref_search[i][0]) @@ -186,13 +185,12 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, } else { b = -1; } - if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, b)) { - add_candidate_mv(mv_ref_list, candidate_scores, - &refmv_count, c_refmv, 16); - } + if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, b)) + add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv, + 16); // Count number of neihgbours coded intra and zeromv - intra_count += (candidate_mi->mbmi.mode < NEARESTMV); + intra_count += is_intra_mode(candidate_mi->mbmi.mode); zero_count += (candidate_mi->mbmi.mode == ZEROMV); newmv_count += (candidate_mi->mbmi.mode >= NEWMV); } @@ -203,26 +201,25 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, (refmv_count < MAX_MV_REF_CANDIDATES); ++i) { const int mi_search_col = mi_col + mv_ref_search[i][0]; const int mi_search_row = mi_row + mv_ref_search[i][1]; - if ((mi_search_col >= cm->cur_tile_mi_col_start) && - (mi_search_col < cm->cur_tile_mi_col_end) && - (mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) { + if (mi_search_col >= cm->cur_tile_mi_col_start && + mi_search_col < cm->cur_tile_mi_col_end && + mi_search_row >= 0 && + mi_search_row < cm->mi_rows) { candidate_mi = here + mv_ref_search[i][0] + - (mv_ref_search[i][1] * xd->mode_info_stride); + mi_stride * mv_ref_search[i][1]; - if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) { - add_candidate_mv(mv_ref_list, candidate_scores, - &refmv_count, c_refmv, 16); - } + if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) + add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv, + 16); } } // Look in the last frame if it exists if (lf_here && (refmv_count < MAX_MV_REF_CANDIDATES)) { candidate_mi = lf_here; - if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) { - add_candidate_mv(mv_ref_list, candidate_scores, - &refmv_count, c_refmv, 16); - } + if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) + add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv, + 16); } // If we have not found enough candidates consider ones where the @@ -233,24 +230,25 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, (refmv_count < MAX_MV_REF_CANDIDATES); ++i) { const int mi_search_col = mi_col + mv_ref_search[i][0]; const int mi_search_row = mi_row + mv_ref_search[i][1]; - if ((mi_search_col >= cm->cur_tile_mi_col_start) && - (mi_search_col < cm->cur_tile_mi_col_end) && - (mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) { + if (mi_search_col >= cm->cur_tile_mi_col_start && + mi_search_col < cm->cur_tile_mi_col_end && + mi_search_row >= 0 && + mi_search_row < cm->mi_rows) { candidate_mi = here + mv_ref_search[i][0] + - (mv_ref_search[i][1] * xd->mode_info_stride); + mi_stride * mv_ref_search[i][1]; get_non_matching_candidates(candidate_mi, ref_frame, &c_ref_frame, &c_refmv, &c2_ref_frame, &c2_refmv); if (c_ref_frame != INTRA_FRAME) { - scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias); + scale_mv(ref_frame, c_ref_frame, &c_refmv, ref_sign_bias); add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv, 1); } if (c2_ref_frame != INTRA_FRAME) { - scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias); + scale_mv(ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias); add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c2_refmv, 1); } @@ -265,13 +263,13 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, &c2_ref_frame, &c2_refmv); if (c_ref_frame != INTRA_FRAME) { - scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias); + scale_mv(ref_frame, c_ref_frame, &c_refmv, ref_sign_bias); add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c_refmv, 1); } if (c2_ref_frame != INTRA_FRAME) { - scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias); + scale_mv(ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias); add_candidate_mv(mv_ref_list, candidate_scores, &refmv_count, c2_refmv, 1); } @@ -295,7 +293,6 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here, } // Clamp vectors - for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { + for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) clamp_mv_ref(xd, &mv_ref_list[i]); - } } diff --git a/vp9/common/vp9_mvref_common.h b/vp9/common/vp9_mvref_common.h index 7290f10abdf50fd17cfbe56415a04c4aa2102d15..c32a8bf2ca381ed17f0eb0be795400c8dcaae8f6 100644 --- a/vp9/common/vp9_mvref_common.h +++ b/vp9/common/vp9_mvref_common.h @@ -21,7 +21,8 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MV_REFERENCE_FRAME ref_frame, int_mv *mv_ref_list, int *ref_sign_bias, - int block_idx); + int block_idx, + int mi_row, int mi_col); static INLINE void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, @@ -29,9 +30,10 @@ static INLINE void vp9_find_mv_refs(VP9_COMMON *cm, MODE_INFO *lf_here, MV_REFERENCE_FRAME ref_frame, int_mv *mv_ref_list, - int *ref_sign_bias) { + int *ref_sign_bias, + int mi_row, int mi_col) { vp9_find_mv_refs_idx(cm, xd, here, lf_here, ref_frame, - mv_ref_list, ref_sign_bias, -1); + mv_ref_list, ref_sign_bias, -1, mi_row, mi_col); } #endif // VP9_COMMON_VP9_MVREF_COMMON_H_ diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index a8ba914753d61e310cdef5ba7c31d04db8d05201..72c813f62c79c014a38b6a8bdce071ea350878c2 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -278,14 +278,6 @@ static void set_mi_row_col(VP9_COMMON *cm, MACROBLOCKD *xd, xd->right_available = (mi_col + bw < cm->cur_tile_mi_col_end); } -static int get_mi_row(const MACROBLOCKD *xd) { - return ((-xd->mb_to_top_edge) >> (3 + LOG2_MI_SIZE)); -} - -static int get_mi_col(const MACROBLOCKD *xd) { - return ((-xd->mb_to_left_edge) >> (3 + LOG2_MI_SIZE)); -} - static int get_token_alloc(int mb_rows, int mb_cols) { return mb_rows * mb_cols * (48 * 16 + 4); } diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index bddaacb6e395a02e3cc1916d4aeac837a12ba1b6..4066d5a746ffb877143e196d0de0cb211b0303a0 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -439,7 +439,7 @@ static int read_is_inter_block(VP9D_COMP *pbi, int segment_id, vp9_reader *r) { } static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi, - vp9_reader *r) { + int mi_row, int mi_col, vp9_reader *r) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; nmv_context *const nmvc = &cm->fc.nmvc; @@ -459,7 +459,8 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi, ref1 = mbmi->ref_frame[1]; vp9_find_mv_refs(cm, xd, mi, xd->prev_mode_info_context, - ref0, mbmi->ref_mvs[ref0], cm->ref_frame_sign_bias); + ref0, mbmi->ref_mvs[ref0], cm->ref_frame_sign_bias, + mi_row, mi_col); inter_mode_ctx = mbmi->mb_mode_context[ref0]; @@ -482,7 +483,8 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi, if (ref1 > INTRA_FRAME) { vp9_find_mv_refs(cm, xd, mi, xd->prev_mode_info_context, - ref1, mbmi->ref_mvs[ref1], cm->ref_frame_sign_bias); + ref1, mbmi->ref_mvs[ref1], cm->ref_frame_sign_bias, + mi_row, mi_col); if (bsize < BLOCK_SIZE_SB8X8 || mbmi->mode != ZEROMV) { vp9_find_best_ref_mvs(xd, mbmi->ref_mvs[ref1], @@ -502,10 +504,13 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi, const int b_mode = read_inter_mode(cm, r, inter_mode_ctx); if (b_mode == NEARESTMV || b_mode == NEARMV) { - vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest, &nearby, j, 0); + vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest, &nearby, j, 0, + mi_row, mi_col); + if (ref1 > 0) vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest_second, - &nearby_second, j, 1); + &nearby_second, j, 1, + mi_row, mi_col); } switch (b_mode) { @@ -615,7 +620,7 @@ static void read_inter_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *mi, !mbmi->mb_skip_coeff || !inter_block, r); if (inter_block) - read_inter_block_mode_info(pbi, mi, r); + read_inter_block_mode_info(pbi, mi, mi_row, mi_col, r); else read_intra_block_mode_info(pbi, mi, r); } diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 24376712c314d43ddba009bc9b036d3016293352..1303948dd3e3e9244f2f03ea52a238845c087ae2 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -1860,12 +1860,12 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x, vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, &frame_mv[NEARESTMV][mbmi->ref_frame[0]], &frame_mv[NEARMV][mbmi->ref_frame[0]], - i, 0); + i, 0, mi_row, mi_col); if (mbmi->ref_frame[1] > 0) vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, &frame_mv[NEARESTMV][mbmi->ref_frame[1]], &frame_mv[NEARMV][mbmi->ref_frame[1]], - i, 1); + i, 1, mi_row, mi_col); // search for the best motion vector on this segment for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) { @@ -2433,7 +2433,7 @@ static void setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x, xd->prev_mode_info_context, frame_type, mbmi->ref_mvs[frame_type], - cpi->common.ref_frame_sign_bias); + cpi->common.ref_frame_sign_bias, mi_row, mi_col); // Candidate refinement carried out at encoder and decoder vp9_find_best_ref_mvs(xd,