From: Scott LaVarnway Date: Tue, 21 Apr 2015 12:36:58 +0000 (-0700) Subject: Revert "Remove mi_grid_* structures." X-Git-Tag: v1.5.0~749 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b17f7f4eb86107ac9ed9e31a2a8bba238a1247a;p=libvpx Revert "Remove mi_grid_* structures." (see I3a05cf1610679fed26e0b2eadd315a9ae91afdd6) For the test clip used, the decoder performance improved by ~2%. This is also an intermediate step towards adding back the mode_info streams. Change-Id: Idddc4a3f46e4180fbebddc156c4bbf177d5c2e0d --- diff --git a/vp9/common/vp9_blockd.c b/vp9/common/vp9_blockd.c index 3cd9f44e9..05329e5e1 100644 --- a/vp9/common/vp9_blockd.c +++ b/vp9/common/vp9_blockd.c @@ -40,7 +40,7 @@ void vp9_foreach_transformed_block_in_plane( const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, foreach_transformed_block_visitor visit, void *arg) { const struct macroblockd_plane *const pd = &xd->plane[plane]; - const MB_MODE_INFO* mbmi = &xd->mi[0].src_mi->mbmi; + const MB_MODE_INFO* mbmi = &xd->mi[0]->mbmi; // block and transform sizes, in number of 4x4 blocks log 2 ("*_b") // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8 // transform size varies per plane, look it up in a common way. diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index 124057634..018a9c2b9 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -130,7 +130,6 @@ typedef struct { } MB_MODE_INFO; typedef struct MODE_INFO { - struct MODE_INFO *src_mi; MB_MODE_INFO mbmi; b_mode_info bmi[4]; } MODE_INFO; @@ -191,7 +190,7 @@ typedef struct macroblockd { int mi_stride; - MODE_INFO *mi; + MODE_INFO **mi; MODE_INFO *left_mi; MODE_INFO *above_mi; MB_MODE_INFO *left_mbmi; @@ -245,7 +244,7 @@ extern const TX_TYPE intra_mode_to_tx_type_lookup[INTRA_MODES]; static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, const MACROBLOCKD *xd) { - const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(mbmi)) return DCT_DCT; @@ -255,7 +254,7 @@ static INLINE TX_TYPE get_tx_type(PLANE_TYPE plane_type, static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type, const MACROBLOCKD *xd, int ib) { - const MODE_INFO *const mi = xd->mi[0].src_mi; + const MODE_INFO *const mi = xd->mi[0]; if (plane_type != PLANE_TYPE_Y || xd->lossless || is_inter_block(&mi->mbmi)) return DCT_DCT; diff --git a/vp9/common/vp9_debugmodes.c b/vp9/common/vp9_debugmodes.c index e96bc4f2b..03fded01c 100644 --- a/vp9/common/vp9_debugmodes.c +++ b/vp9/common/vp9_debugmodes.c @@ -35,7 +35,7 @@ static void print_mi_data(VP9_COMMON *cm, FILE *file, const char *descriptor, fprintf(file, "%c ", prefix); for (mi_col = 0; mi_col < cols; mi_col++) { fprintf(file, "%2d ", - *((int*) ((char *) (&mi->src_mi->mbmi) + + *((int*) ((char *) (&mi->mbmi) + member_offset))); mi++; } @@ -64,7 +64,7 @@ void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, const char *file) { for (mi_row = 0; mi_row < rows; mi_row++) { fprintf(mvs, "S "); for (mi_col = 0; mi_col < cols; mi_col++) { - fprintf(mvs, "%2d ", mi->src_mi->mbmi.skip); + fprintf(mvs, "%2d ", mi->mbmi.skip); mi++; } fprintf(mvs, "\n"); @@ -78,8 +78,8 @@ void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, const char *file) { for (mi_row = 0; mi_row < rows; mi_row++) { fprintf(mvs, "V "); for (mi_col = 0; mi_col < cols; mi_col++) { - fprintf(mvs, "%4d:%4d ", mi->src_mi->mbmi.mv[0].as_mv.row, - mi->src_mi->mbmi.mv[0].as_mv.col); + fprintf(mvs, "%4d:%4d ", mi->mbmi.mv[0].as_mv.row, + mi->mbmi.mv[0].as_mv.col); mi++; } fprintf(mvs, "\n"); diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index eee096f17..3e8f77420 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -216,7 +216,7 @@ static INLINE int get_entropy_context(TX_SIZE tx_size, const ENTROPY_CONTEXT *a, static INLINE const scan_order *get_scan(const MACROBLOCKD *xd, TX_SIZE tx_size, PLANE_TYPE type, int block_idx) { - const MODE_INFO *const mi = xd->mi[0].src_mi; + const MODE_INFO *const mi = xd->mi[0]; if (is_inter_block(&mi->mbmi) || type != PLANE_TYPE_Y || xd->lossless) { return &vp9_default_scan_orders[tx_size]; diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c index e464d453d..a226ff1d3 100644 --- a/vp9/common/vp9_loopfilter.c +++ b/vp9/common/vp9_loopfilter.c @@ -826,12 +826,12 @@ static void build_y_mask(const loop_filter_info_n *const lfi_n, // by mi_row, mi_col. // TODO(JBB): This function only works for yv12. void vp9_setup_mask(VP9_COMMON *const cm, const int mi_row, const int mi_col, - MODE_INFO *mi, const int mode_info_stride, + MODE_INFO **mi, const int mode_info_stride, LOOP_FILTER_MASK *lfm) { int idx_32, idx_16, idx_8; const loop_filter_info_n *const lfi_n = &cm->lf_info; - MODE_INFO *mip = mi; - MODE_INFO *mip2 = mi; + MODE_INFO **mip = mi; + MODE_INFO **mip2 = mi; // These are offsets to the next mi in the 64x64 block. It is what gets // added to the mi ptr as we go through each loop. It helps us to avoid @@ -859,28 +859,28 @@ void vp9_setup_mask(VP9_COMMON *const cm, const int mi_row, const int mi_col, cm->mi_cols - mi_col : MI_BLOCK_SIZE); vp9_zero(*lfm); - assert(mip != NULL); + assert(mip[0] != NULL); // TODO(jimbankoski): Try moving most of the following code into decode // loop and storing lfm in the mbmi structure so that we don't have to go // through the recursive loop structure multiple times. - switch (mip->mbmi.sb_type) { + switch (mip[0]->mbmi.sb_type) { case BLOCK_64X64: - build_masks(lfi_n, mip , 0, 0, lfm); + build_masks(lfi_n, mip[0] , 0, 0, lfm); break; case BLOCK_64X32: - build_masks(lfi_n, mip, 0, 0, lfm); + build_masks(lfi_n, mip[0], 0, 0, lfm); mip2 = mip + mode_info_stride * 4; if (4 >= max_rows) break; - build_masks(lfi_n, mip2, 32, 8, lfm); + build_masks(lfi_n, mip2[0], 32, 8, lfm); break; case BLOCK_32X64: - build_masks(lfi_n, mip, 0, 0, lfm); + build_masks(lfi_n, mip[0], 0, 0, lfm); mip2 = mip + 4; if (4 >= max_cols) break; - build_masks(lfi_n, mip2, 4, 2, lfm); + build_masks(lfi_n, mip2[0], 4, 2, lfm); break; default: for (idx_32 = 0; idx_32 < 4; mip += offset_32[idx_32], ++idx_32) { @@ -890,23 +890,23 @@ void vp9_setup_mask(VP9_COMMON *const cm, const int mi_row, const int mi_col, const int mi_32_row_offset = ((idx_32 >> 1) << 2); if (mi_32_col_offset >= max_cols || mi_32_row_offset >= max_rows) continue; - switch (mip->mbmi.sb_type) { + switch (mip[0]->mbmi.sb_type) { case BLOCK_32X32: - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); break; case BLOCK_32X16: - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); if (mi_32_row_offset + 2 >= max_rows) continue; mip2 = mip + mode_info_stride * 2; - build_masks(lfi_n, mip2, shift_y + 16, shift_uv + 4, lfm); + build_masks(lfi_n, mip2[0], shift_y + 16, shift_uv + 4, lfm); break; case BLOCK_16X32: - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); if (mi_32_col_offset + 2 >= max_cols) continue; mip2 = mip + 2; - build_masks(lfi_n, mip2, shift_y + 2, shift_uv + 1, lfm); + build_masks(lfi_n, mip2[0], shift_y + 2, shift_uv + 1, lfm); break; default: for (idx_16 = 0; idx_16 < 4; mip += offset_16[idx_16], ++idx_16) { @@ -920,29 +920,29 @@ void vp9_setup_mask(VP9_COMMON *const cm, const int mi_row, const int mi_col, if (mi_16_col_offset >= max_cols || mi_16_row_offset >= max_rows) continue; - switch (mip->mbmi.sb_type) { + switch (mip[0]->mbmi.sb_type) { case BLOCK_16X16: - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); break; case BLOCK_16X8: - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); if (mi_16_row_offset + 1 >= max_rows) continue; mip2 = mip + mode_info_stride; - build_y_mask(lfi_n, mip2, shift_y+8, lfm); + build_y_mask(lfi_n, mip2[0], shift_y+8, lfm); break; case BLOCK_8X16: - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); if (mi_16_col_offset +1 >= max_cols) continue; mip2 = mip + 1; - build_y_mask(lfi_n, mip2, shift_y+1, lfm); + build_y_mask(lfi_n, mip2[0], shift_y+1, lfm); break; default: { const int shift_y = shift_32_y[idx_32] + shift_16_y[idx_16] + shift_8_y[0]; - build_masks(lfi_n, mip, shift_y, shift_uv, lfm); + build_masks(lfi_n, mip[0], shift_y, shift_uv, lfm); mip += offset[0]; for (idx_8 = 1; idx_8 < 4; mip += offset[idx_8], ++idx_8) { const int shift_y = shift_32_y[idx_32] + @@ -956,7 +956,7 @@ void vp9_setup_mask(VP9_COMMON *const cm, const int mi_row, const int mi_col, if (mi_8_col_offset >= max_cols || mi_8_row_offset >= max_rows) continue; - build_y_mask(lfi_n, mip, shift_y, lfm); + build_y_mask(lfi_n, mip[0], shift_y, lfm); } break; } @@ -1151,7 +1151,7 @@ static void highbd_filter_selectively_vert(uint16_t *s, int pitch, void vp9_filter_block_plane_non420(VP9_COMMON *cm, struct macroblockd_plane *plane, - MODE_INFO *mi_8x8, + MODE_INFO **mi_8x8, int mi_row, int mi_col) { const int ss_x = plane->subsampling_x; const int ss_y = plane->subsampling_y; @@ -1175,7 +1175,7 @@ void vp9_filter_block_plane_non420(VP9_COMMON *cm, // Determine the vertical edges that need filtering for (c = 0; c < MI_BLOCK_SIZE && mi_col + c < cm->mi_cols; c += col_step) { - const MODE_INFO *mi = mi_8x8[c].src_mi; + const MODE_INFO *mi = mi_8x8[c]; const BLOCK_SIZE sb_type = mi[0].mbmi.sb_type; const int skip_this = mi[0].mbmi.skip && is_inter_block(&mi[0].mbmi); // left edge of current unit is block/partition edge -> no skip @@ -1545,7 +1545,7 @@ void vp9_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer, path = LF_PATH_SLOW; for (mi_row = start; mi_row < stop; mi_row += MI_BLOCK_SIZE) { - MODE_INFO *mi = cm->mi + mi_row * cm->mi_stride; + MODE_INFO **mi = cm->mi_grid_visible + mi_row * cm->mi_stride; for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE) { int plane; diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h index ab3b179e9..f7cbde678 100644 --- a/vp9/common/vp9_loopfilter.h +++ b/vp9/common/vp9_loopfilter.h @@ -95,7 +95,7 @@ struct VP9LfSyncData; // by mi_row, mi_col. void vp9_setup_mask(struct VP9Common *const cm, const int mi_row, const int mi_col, - MODE_INFO *mi_8x8, const int mode_info_stride, + MODE_INFO **mi_8x8, const int mode_info_stride, LOOP_FILTER_MASK *lfm); void vp9_filter_block_plane_ss00(struct VP9Common *const cm, @@ -110,7 +110,7 @@ void vp9_filter_block_plane_ss11(struct VP9Common *const cm, void vp9_filter_block_plane_non420(struct VP9Common *cm, struct macroblockd_plane *plane, - MODE_INFO *mi_8x8, + MODE_INFO **mi_8x8, int mi_row, int mi_col); void vp9_loop_filter_init(struct VP9Common *cm); diff --git a/vp9/common/vp9_mvref_common.c b/vp9/common/vp9_mvref_common.c index 52a731329..436be6cab 100644 --- a/vp9/common/vp9_mvref_common.c +++ b/vp9/common/vp9_mvref_common.c @@ -37,7 +37,7 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, const POSITION *const mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row * - xd->mi_stride].src_mi; + xd->mi_stride]; const MB_MODE_INFO *const candidate = &candidate_mi->mbmi; // Keep counts for entropy encoding. context_counter += mode_2_counter[candidate->mode]; @@ -59,7 +59,7 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, const POSITION *const mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row * - xd->mi_stride].src_mi->mbmi; + xd->mi_stride]->mbmi; different_ref_found = 1; if (candidate->ref_frame[0] == ref_frame) @@ -101,7 +101,7 @@ static void find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd, const POSITION *mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row - * xd->mi_stride].src_mi->mbmi; + * xd->mi_stride]->mbmi; // If the candidate is INTRA we don't want to consider its mv. IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias, @@ -183,7 +183,7 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd, int block, int ref, int mi_row, int mi_col, int_mv *nearest_mv, int_mv *near_mv) { int_mv mv_list[MAX_MV_REF_CANDIDATES]; - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; b_mode_info *bmi = mi->bmi; int n; diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 62e4ee7a5..d7226205d 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -201,6 +201,12 @@ typedef struct VP9Common { void (*free_mi)(struct VP9Common *cm); void (*setup_mi)(struct VP9Common *cm); + // Grid of pointers to 8x8 MODE_INFO structs. Any 8x8 not in the visible + // area will be NULL. + MODE_INFO **mi_grid_base; + MODE_INFO **mi_grid_visible; + MODE_INFO **prev_mi_grid_base; + MODE_INFO **prev_mi_grid_visible; // Whether to use previous frame's motion vectors for prediction. int use_prev_frame_mvs; @@ -371,7 +377,7 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile, xd->up_available = (mi_row != 0); xd->left_available = (mi_col > tile->mi_col_start); if (xd->up_available) { - xd->above_mi = xd->mi[-xd->mi_stride].src_mi; + xd->above_mi = xd->mi[-xd->mi_stride]; xd->above_mbmi = xd->above_mi ? &xd->above_mi->mbmi : NULL; } else { xd->above_mi = NULL; @@ -379,7 +385,7 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile, } if (xd->left_available) { - xd->left_mi = xd->mi[-1].src_mi; + xd->left_mi = xd->mi[-1]; xd->left_mbmi = xd->left_mi ? &xd->left_mi->mbmi : NULL; } else { xd->left_mi = NULL; diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c index fd735f483..0aac4a9e6 100644 --- a/vp9/common/vp9_pred_common.c +++ b/vp9/common/vp9_pred_common.c @@ -344,7 +344,7 @@ int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) { // left of the entries corresponding to real blocks. // The prediction flags in these dummy entries are initialized to 0. int vp9_get_tx_size_context(const MACROBLOCKD *xd) { - const int max_tx_size = max_txsize_lookup[xd->mi[0].src_mi->mbmi.sb_type]; + const int max_tx_size = max_txsize_lookup[xd->mi[0]->mbmi.sb_type]; const MB_MODE_INFO *const above_mbmi = xd->above_mbmi; const MB_MODE_INFO *const left_mbmi = xd->left_mbmi; const int has_above = xd->up_available; diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c index c496299ce..11eaf2e2d 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -172,7 +172,7 @@ void build_inter_predictors(MACROBLOCKD *xd, int plane, int block, int x, int y, int w, int h, int mi_x, int mi_y) { struct macroblockd_plane *const pd = &xd->plane[plane]; - const MODE_INFO *mi = xd->mi[0].src_mi; + const MODE_INFO *mi = xd->mi[0]; const int is_compound = has_second_ref(&mi->mbmi); const InterpKernel *kernel = vp9_get_interp_kernel(mi->mbmi.interp_filter); int ref; @@ -246,7 +246,7 @@ static void build_inter_predictors_for_planes(MACROBLOCKD *xd, BLOCK_SIZE bsize, const int bw = 4 * num_4x4_w; const int bh = 4 * num_4x4_h; - if (xd->mi[0].src_mi->mbmi.sb_type < BLOCK_8X8) { + if (xd->mi[0]->mbmi.sb_type < BLOCK_8X8) { int i = 0, x, y; assert(bsize == BLOCK_8X8); for (y = 0; y < num_4x4_h; ++y) diff --git a/vp9/common/vp9_thread_common.c b/vp9/common/vp9_thread_common.c index 830a5177f..71bc740d4 100644 --- a/vp9/common/vp9_thread_common.c +++ b/vp9/common/vp9_thread_common.c @@ -107,7 +107,7 @@ void thread_loop_filter_rows(const YV12_BUFFER_CONFIG *const frame_buffer, for (mi_row = start; mi_row < stop; mi_row += lf_sync->num_workers * MI_BLOCK_SIZE) { - MODE_INFO *const mi = cm->mi + mi_row * cm->mi_stride; + MODE_INFO **const mi = cm->mi_grid_visible + mi_row * cm->mi_stride; for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE) { const int r = mi_row >> MI_BLOCK_SIZE_LOG2; diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 1a3b946e9..b6f51abba 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -304,7 +304,7 @@ static void predict_and_reconstruct_intra_block(int plane, int block, VP9_COMMON *const cm = args->cm; MACROBLOCKD *const xd = args->xd; struct macroblockd_plane *const pd = &xd->plane[plane]; - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block) : mi->mbmi.uv_mode; const int16_t *const dequant = (plane == 0) ? args->y_dequant @@ -367,13 +367,12 @@ static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd, const int offset = mi_row * cm->mi_stride + mi_col; int x, y; - xd->mi = cm->mi + offset; - xd->mi[0].src_mi = &xd->mi[0]; // Point to self. - xd->mi[0].mbmi.sb_type = bsize; - + xd->mi = cm->mi_grid_visible + offset; + xd->mi[0] = &cm->mi[offset]; + xd->mi[0]->mbmi.sb_type = bsize; for (y = 0; y < y_mis; ++y) for (x = !y; x < x_mis; ++x) { - xd->mi[y * cm->mi_stride + x].src_mi = &xd->mi[0]; + xd->mi[y * cm->mi_stride + x] = xd->mi[0]; } set_skip_context(xd, mi_row, mi_col); @@ -383,7 +382,7 @@ static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd, set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); - return &xd->mi[0].mbmi; + return &xd->mi[0]->mbmi; } static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd, @@ -1992,7 +1991,7 @@ void vp9_dec_build_inter_predictors_sb(VP9Decoder *const pbi, MACROBLOCKD *xd, int plane; const int mi_x = mi_col * MI_SIZE; const int mi_y = mi_row * MI_SIZE; - const MODE_INFO *mi = xd->mi[0].src_mi; + const MODE_INFO *mi = xd->mi[0]; const InterpKernel *kernel = vp9_get_interp_kernel(mi->mbmi.interp_filter); const BLOCK_SIZE sb_type = mi->mbmi.sb_type; const int is_compound = has_second_ref(&mi->mbmi); diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 072f6b7b7..6cf4f1e44 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -81,7 +81,7 @@ static TX_SIZE read_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, FRAME_COUNTS *counts, int allow_select, vp9_reader *r) { TX_MODE tx_mode = cm->tx_mode; - BLOCK_SIZE bsize = xd->mi[0].src_mi->mbmi.sb_type; + BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8) return read_selected_tx_size(cm, xd, counts, max_tx_size, r); @@ -145,7 +145,7 @@ static int read_intra_segment_id(VP9_COMMON *const cm, BLOCK_SIZE bsize, static int read_inter_segment_id(VP9_COMMON *const cm, MACROBLOCKD *const xd, int mi_row, int mi_col, vp9_reader *r) { struct segmentation *const seg = &cm->seg; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const BLOCK_SIZE bsize = mbmi->sb_type; int predicted_segment_id, segment_id; @@ -191,10 +191,10 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm, MACROBLOCKD *const xd, FRAME_COUNTS *counts, int mi_row, int mi_col, vp9_reader *r) { - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; - const MODE_INFO *above_mi = xd->mi[-cm->mi_stride].src_mi; - const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1].src_mi : NULL; + const MODE_INFO *above_mi = xd->mi[-cm->mi_stride]; + const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; const BLOCK_SIZE bsize = mbmi->sb_type; int i; @@ -566,7 +566,7 @@ static void read_inter_frame_mode_info(VP9Decoder *const pbi, const TileInfo *const tile, int mi_row, int mi_col, vp9_reader *r) { VP9_COMMON *const cm = &pbi->common; - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; int inter_block; @@ -588,7 +588,7 @@ void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd, const TileInfo *const tile, int mi_row, int mi_col, vp9_reader *r) { VP9_COMMON *const cm = &pbi->common; - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type]; const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type]; const int x_mis = MIN(bw, cm->mi_cols - mi_col); @@ -605,10 +605,10 @@ void vp9_read_mode_info(VP9Decoder *const pbi, MACROBLOCKD *xd, MV_REF *const frame_mv = frame_mvs + h * cm->mi_cols; for (w = 0; w < x_mis; ++w) { MV_REF *const mv = frame_mv + w; - mv->ref_frame[0] = mi->src_mi->mbmi.ref_frame[0]; - mv->ref_frame[1] = mi->src_mi->mbmi.ref_frame[1]; - mv->mv[0].as_int = mi->src_mi->mbmi.mv[0].as_int; - mv->mv[1].as_int = mi->src_mi->mbmi.mv[1].as_int; + mv->ref_frame[0] = mi->mbmi.ref_frame[0]; + mv->ref_frame[1] = mi->mbmi.ref_frame[1]; + mv->mv[0].as_int = mi->mbmi.mv[0].as_int; + mv->mv[1].as_int = mi->mbmi.mv[1].as_int; } } } diff --git a/vp9/decoder/vp9_decoder.c b/vp9/decoder/vp9_decoder.c index 54802226b..54921dc50 100644 --- a/vp9/decoder/vp9_decoder.c +++ b/vp9/decoder/vp9_decoder.c @@ -49,6 +49,9 @@ static void initialize_dec(void) { static void vp9_dec_setup_mi(VP9_COMMON *cm) { cm->mi = cm->mip + cm->mi_stride + 1; vpx_memset(cm->mip, 0, cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip)); + cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; + vpx_memset(cm->mi_grid_base, 0, + cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base)); } static int vp9_dec_alloc_mi(VP9_COMMON *cm, int mi_size) { @@ -56,12 +59,17 @@ static int vp9_dec_alloc_mi(VP9_COMMON *cm, int mi_size) { if (!cm->mip) return 1; cm->mi_alloc_size = mi_size; + cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*)); + if (!cm->mi_grid_base) + return 1; return 0; } static void vp9_dec_free_mi(VP9_COMMON *cm) { vpx_free(cm->mip); cm->mip = NULL; + vpx_free(cm->mi_grid_base); + cm->mi_grid_base = NULL; } VP9Decoder *vp9_decoder_create(BufferPool *const pool) { diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c index fd4087583..f0bb2ce9a 100644 --- a/vp9/decoder/vp9_detokenize.c +++ b/vp9/decoder/vp9_detokenize.c @@ -52,7 +52,7 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd, vp9_reader *r) { const int max_eob = 16 << (tx_size << 1); const FRAME_CONTEXT *const fc = cm->fc; - const int ref = is_inter_block(&xd->mi[0].src_mi->mbmi); + const int ref = is_inter_block(&xd->mi[0]->mbmi); int band, c = 0; const vp9_prob (*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = fc->coef_probs[tx_size][type][ref]; diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index d67d1f4ea..2594ac24d 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -78,8 +78,8 @@ static void prob_diff_update(const vp9_tree_index *tree, static void write_selected_tx_size(const VP9_COMMON *cm, const MACROBLOCKD *xd, vp9_writer *w) { - TX_SIZE tx_size = xd->mi[0].src_mi->mbmi.tx_size; - BLOCK_SIZE bsize = xd->mi[0].src_mi->mbmi.sb_type; + TX_SIZE tx_size = xd->mi[0]->mbmi.tx_size; + BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; const vp9_prob *const tx_probs = get_tx_probs2(max_tx_size, xd, &cm->fc->tx_probs); @@ -201,7 +201,7 @@ static void write_segment_id(vp9_writer *w, const struct segmentation *seg, // This function encodes the reference frame static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd, vp9_writer *w) { - const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const int is_compound = has_second_ref(mbmi); const int segment_id = mbmi->segment_id; @@ -338,9 +338,9 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi, } static void write_mb_modes_kf(const VP9_COMMON *cm, const MACROBLOCKD *xd, - MODE_INFO *mi_8x8, vp9_writer *w) { + MODE_INFO **mi_8x8, vp9_writer *w) { const struct segmentation *const seg = &cm->seg; - const MODE_INFO *const mi = mi_8x8; + const MODE_INFO *const mi = mi_8x8[0]; const MODE_INFO *const above_mi = xd->above_mi; const MODE_INFO *const left_mi = xd->left_mi; const MB_MODE_INFO *const mbmi = &mi->mbmi; @@ -381,8 +381,8 @@ static void write_modes_b(VP9_COMP *cpi, const TileInfo *const tile, MACROBLOCKD *const xd = &cpi->td.mb.e_mbd; MODE_INFO *m; - xd->mi = cm->mi + (mi_row * cm->mi_stride + mi_col); - m = xd->mi; + xd->mi = cm->mi_grid_visible + (mi_row * cm->mi_stride + mi_col); + m = xd->mi[0]; set_mi_row_col(xd, tile, mi_row, num_8x8_blocks_high_lookup[m->mbmi.sb_type], @@ -436,7 +436,7 @@ static void write_modes_sb(VP9_COMP *cpi, if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - m = cm->mi[mi_row * cm->mi_stride + mi_col].src_mi; + m = cm->mi_grid_visible[mi_row * cm->mi_stride + mi_col]; partition = partition_lookup[bsl][m->mbmi.sb_type]; write_partition(cm, xd, bs, mi_row, mi_col, partition, bsize, w); diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c index cf67e115e..6ac205a4f 100644 --- a/vp9/encoder/vp9_denoiser.c +++ b/vp9/encoder/vp9_denoiser.c @@ -203,7 +203,7 @@ static VP9_DENOISER_DECISION perform_motion_compensation(VP9_DENOISER *denoiser, int sse_diff = ctx->zeromv_sse - ctx->newmv_sse; MV_REFERENCE_FRAME frame; MACROBLOCKD *filter_mbd = &mb->e_mbd; - MB_MODE_INFO *mbmi = &filter_mbd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &filter_mbd->mi[0]->mbmi; MB_MODE_INFO saved_mbmi; int i, j; struct buf_2d saved_dst[MAX_MB_PLANE]; diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index d4281751b..08cb5d384 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -172,8 +172,8 @@ static INLINE void set_mode_info_offsets(VP9_COMMON *const cm, int mi_row, int mi_col) { const int idx_str = xd->mi_stride * mi_row + mi_col; - xd->mi = cm->mi + idx_str; - xd->mi[0].src_mi = &xd->mi[0]; + xd->mi = cm->mi_grid_visible + idx_str; + xd->mi[0] = cm->mi + idx_str; } static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, @@ -190,7 +190,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, set_mode_info_offsets(cm, xd, mi_row, mi_col); - mbmi = &xd->mi[0].src_mi->mbmi; + mbmi = &xd->mi[0]->mbmi; // Set up destination pointers. vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); @@ -239,7 +239,7 @@ static void duplicate_mode_info_in_sb(VP9_COMMON *cm, MACROBLOCKD *xd, for (j = 0; j < block_height; ++j) for (i = 0; i < block_width; ++i) { if (mi_row + j < cm->mi_rows && mi_col + i < cm->mi_cols) - xd->mi[j * xd->mi_stride + i].src_mi = &xd->mi[0]; + xd->mi[j * xd->mi_stride + i] = xd->mi[0]; } } @@ -249,7 +249,7 @@ static void set_block_size(VP9_COMP * const cpi, BLOCK_SIZE bsize) { if (cpi->common.mi_cols > mi_col && cpi->common.mi_rows > mi_row) { set_mode_info_offsets(&cpi->common, xd, mi_row, mi_col); - xd->mi[0].src_mi->mbmi.sb_type = bsize; + xd->mi[0]->mbmi.sb_type = bsize; } } @@ -691,7 +691,7 @@ static int choose_partitioning(VP9_COMP *cpi, sp = x->plane[0].src.stride; if (!is_key_frame) { - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; unsigned int uv_sad; const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, LAST_FRAME); @@ -955,8 +955,8 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, struct macroblock_plane *const p = x->plane; struct macroblockd_plane *const pd = xd->plane; MODE_INFO *mi = &ctx->mic; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; - MODE_INFO *mi_addr = &xd->mi[0]; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; + MODE_INFO *mi_addr = xd->mi[0]; const struct segmentation *const seg = &cm->seg; const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type]; const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type]; @@ -974,7 +974,6 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, assert(mi->mbmi.sb_type == bsize); *mi_addr = *mi; - mi_addr->src_mi = mi_addr; // If segmentation in use if (seg->enabled) { @@ -988,7 +987,7 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, // Else for cyclic refresh mode update the segment map, set the segment id // and then update the quantizer. if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { - vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0].src_mi->mbmi, mi_row, + vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, mi_row, mi_col, bsize, ctx->rate, ctx->dist, x->skip); } @@ -1015,7 +1014,7 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, for (x_idx = 0; x_idx < mi_width; x_idx++) if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { - xd->mi[x_idx + y * mis].src_mi = mi_addr; + xd->mi[x_idx + y * mis] = mi_addr; } if (cpi->oxcf.aq_mode) @@ -1088,10 +1087,10 @@ static void update_state(VP9_COMP *cpi, ThreadData *td, MV_REF *const frame_mv = frame_mvs + h * cm->mi_cols; for (w = 0; w < x_mis; ++w) { MV_REF *const mv = frame_mv + w; - mv->ref_frame[0] = mi->src_mi->mbmi.ref_frame[0]; - mv->ref_frame[1] = mi->src_mi->mbmi.ref_frame[1]; - mv->mv[0].as_int = mi->src_mi->mbmi.mv[0].as_int; - mv->mv[1].as_int = mi->src_mi->mbmi.mv[1].as_int; + mv->ref_frame[0] = mi->mbmi.ref_frame[0]; + mv->ref_frame[1] = mi->mbmi.ref_frame[1]; + mv->mv[0].as_int = mi->mbmi.mv[0].as_int; + mv->mv[1].as_int = mi->mbmi.mv[1].as_int; } } } @@ -1114,13 +1113,13 @@ void vp9_setup_src_planes(MACROBLOCK *x, const YV12_BUFFER_CONFIG *src, static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode, RD_COST *rd_cost, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; INTERP_FILTER filter_ref; if (xd->up_available) - filter_ref = xd->mi[-xd->mi_stride].src_mi->mbmi.interp_filter; + filter_ref = xd->mi[-xd->mi_stride]->mbmi.interp_filter; else if (xd->left_available) - filter_ref = xd->mi[-1].src_mi->mbmi.interp_filter; + filter_ref = xd->mi[-1]->mbmi.interp_filter; else filter_ref = EIGHTTAP; @@ -1135,7 +1134,7 @@ static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode, mbmi->mv[0].as_int = 0; mbmi->interp_filter = filter_ref; - xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = 0; + xd->mi[0]->bmi[0].as_mv[0].as_int = 0; x->skip = 1; vp9_rd_cost_init(rd_cost); @@ -1174,7 +1173,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, x->use_lp32x32fdct = 1; set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize); - mbmi = &xd->mi[0].src_mi->mbmi; + mbmi = &xd->mi[0]->mbmi; mbmi->sb_type = bsize; for (i = 0; i < MAX_MB_PLANE; ++i) { @@ -1274,7 +1273,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi, static void update_stats(VP9_COMMON *cm, ThreadData *td) { const MACROBLOCK *x = &td->mb; const MACROBLOCKD *const xd = &x->e_mbd; - const MODE_INFO *const mi = xd->mi[0].src_mi; + const MODE_INFO *const mi = xd->mi[0]; const MB_MODE_INFO *const mbmi = &mi->mbmi; const BLOCK_SIZE bsize = mbmi->sb_type; @@ -1504,15 +1503,15 @@ static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, static void set_partial_b64x64_partition(MODE_INFO *mi, int mis, int bh_in, int bw_in, int row8x8_remaining, int col8x8_remaining, - BLOCK_SIZE bsize, MODE_INFO *mi_8x8) { + BLOCK_SIZE bsize, MODE_INFO **mi_8x8) { int bh = bh_in; int r, c; for (r = 0; r < MI_BLOCK_SIZE; r += bh) { int bw = bw_in; for (c = 0; c < MI_BLOCK_SIZE; c += bw) { const int index = r * mis + c; - mi_8x8[index].src_mi = mi + index; - mi_8x8[index].src_mi->mbmi.sb_type = find_partition_size(bsize, + mi_8x8[index] = mi + index; + mi_8x8[index]->mbmi.sb_type = find_partition_size(bsize, row8x8_remaining - r, col8x8_remaining - c, &bh, &bw); } } @@ -1524,7 +1523,7 @@ static void set_partial_b64x64_partition(MODE_INFO *mi, int mis, // may not be allowed in which case this code attempts to choose the largest // allowable partition. static void set_fixed_partitioning(VP9_COMP *cpi, const TileInfo *const tile, - MODE_INFO *mi_8x8, int mi_row, int mi_col, + MODE_INFO **mi_8x8, int mi_row, int mi_col, BLOCK_SIZE bsize) { VP9_COMMON *const cm = &cpi->common; const int mis = cm->mi_stride; @@ -1543,8 +1542,8 @@ static void set_fixed_partitioning(VP9_COMP *cpi, const TileInfo *const tile, for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { int index = block_row * mis + block_col; - mi_8x8[index].src_mi = mi_upper_left + index; - mi_8x8[index].src_mi->mbmi.sb_type = bsize; + mi_8x8[index] = mi_upper_left + index; + mi_8x8[index]->mbmi.sb_type = bsize; } } } else { @@ -1571,7 +1570,7 @@ const struct { static void set_source_var_based_partition(VP9_COMP *cpi, const TileInfo *const tile, MACROBLOCK *const x, - MODE_INFO *mi_8x8, + MODE_INFO **mi_8x8, int mi_row, int mi_col) { VP9_COMMON *const cm = &cpi->common; const int mis = cm->mi_stride; @@ -1608,8 +1607,8 @@ static void set_source_var_based_partition(VP9_COMP *cpi, d16[j] = cpi->source_diff_var + offset + boffset; index = b_mi_row * mis + b_mi_col; - mi_8x8[index].src_mi = mi_upper_left + index; - mi_8x8[index].src_mi->mbmi.sb_type = BLOCK_16X16; + mi_8x8[index] = mi_upper_left + index; + mi_8x8[index]->mbmi.sb_type = BLOCK_16X16; // TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition // size to further improve quality. @@ -1630,8 +1629,8 @@ static void set_source_var_based_partition(VP9_COMP *cpi, d32[i].var = d32[i].sse - (((int64_t)d32[i].sum * d32[i].sum) >> 10); index = coord_lookup[i*4].row * mis + coord_lookup[i*4].col; - mi_8x8[index].src_mi = mi_upper_left + index; - mi_8x8[index].src_mi->mbmi.sb_type = BLOCK_32X32; + mi_8x8[index] = mi_upper_left + index; + mi_8x8[index]->mbmi.sb_type = BLOCK_32X32; } } @@ -1642,8 +1641,8 @@ static void set_source_var_based_partition(VP9_COMP *cpi, // Use 64x64 partition if (is_larger_better) { - mi_8x8[0].src_mi = mi_upper_left; - mi_8x8[0].src_mi->mbmi.sb_type = BLOCK_64X64; + mi_8x8[0] = mi_upper_left; + mi_8x8[0]->mbmi.sb_type = BLOCK_64X64; } } } else { // partial in-image SB64 @@ -1660,16 +1659,15 @@ static void update_state_rt(VP9_COMP *cpi, ThreadData *td, VP9_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; - MODE_INFO *const mi = xd->mi[0].src_mi; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MODE_INFO *const mi = xd->mi[0]; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const struct segmentation *const seg = &cm->seg; const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type]; const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type]; const int x_mis = MIN(bw, cm->mi_cols - mi_col); const int y_mis = MIN(bh, cm->mi_rows - mi_row); - xd->mi[0] = ctx->mic; - xd->mi[0].src_mi = &xd->mi[0]; + *(xd->mi[0]) = ctx->mic; if (seg->enabled && cpi->oxcf.aq_mode) { // For in frame complexity AQ or variance AQ, copy segment_id from @@ -1709,10 +1707,10 @@ static void update_state_rt(VP9_COMP *cpi, ThreadData *td, MV_REF *const frame_mv = frame_mvs + h * cm->mi_cols; for (w = 0; w < x_mis; ++w) { MV_REF *const mv = frame_mv + w; - mv->ref_frame[0] = mi->src_mi->mbmi.ref_frame[0]; - mv->ref_frame[1] = mi->src_mi->mbmi.ref_frame[1]; - mv->mv[0].as_int = mi->src_mi->mbmi.mv[0].as_int; - mv->mv[1].as_int = mi->src_mi->mbmi.mv[1].as_int; + mv->ref_frame[0] = mi->mbmi.ref_frame[0]; + mv->ref_frame[1] = mi->mbmi.ref_frame[1]; + mv->mv[0].as_int = mi->mbmi.mv[0].as_int; + mv->mv[1].as_int = mi->mbmi.mv[1].as_int; } } } @@ -1764,9 +1762,9 @@ static void encode_sb_rt(VP9_COMP *cpi, ThreadData *td, if (bsize >= BLOCK_8X8) { const int idx_str = xd->mi_stride * mi_row + mi_col; - MODE_INFO *mi_8x8 = cm->mi[idx_str].src_mi; + MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str; ctx = partition_plane_context(xd, mi_row, mi_col, bsize); - subsize = mi_8x8[0].src_mi->mbmi.sb_type; + subsize = mi_8x8[0]->mbmi.sb_type; } else { ctx = 0; subsize = BLOCK_4X4; @@ -1820,7 +1818,7 @@ static void encode_sb_rt(VP9_COMP *cpi, ThreadData *td, static void rd_use_partition(VP9_COMP *cpi, ThreadData *td, TileDataEnc *tile_data, - MODE_INFO *mi_8x8, TOKENEXTRA **tp, + MODE_INFO **mi_8x8, TOKENEXTRA **tp, int mi_row, int mi_col, BLOCK_SIZE bsize, int *rate, int64_t *dist, @@ -1841,7 +1839,7 @@ static void rd_use_partition(VP9_COMP *cpi, RD_COST last_part_rdc, none_rdc, chosen_rdc; BLOCK_SIZE sub_subsize = BLOCK_4X4; int splits_below = 0; - BLOCK_SIZE bs_type = mi_8x8[0].src_mi->mbmi.sb_type; + BLOCK_SIZE bs_type = mi_8x8[0]->mbmi.sb_type; int do_partition_search = 1; PICK_MODE_CONTEXT *ctx = &pc_tree->none; @@ -1875,7 +1873,7 @@ static void rd_use_partition(VP9_COMP *cpi, splits_below = 1; for (i = 0; i < 4; i++) { int jj = i >> 1, ii = i & 0x01; - MODE_INFO *this_mi = mi_8x8[jj * bss * mis + ii * bss].src_mi; + MODE_INFO *this_mi = mi_8x8[jj * bss * mis + ii * bss]; if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) { splits_below = 0; } @@ -1900,7 +1898,7 @@ static void rd_use_partition(VP9_COMP *cpi, } restore_context(x, mi_row, mi_col, a, l, sa, sl, bsize); - mi_8x8[0].src_mi->mbmi.sb_type = bs_type; + mi_8x8[0]->mbmi.sb_type = bs_type; pc_tree->partitioning = partition; } } @@ -2058,7 +2056,7 @@ static void rd_use_partition(VP9_COMP *cpi, // If last_part is better set the partitioning to that. if (last_part_rdc.rdcost < chosen_rdc.rdcost) { - mi_8x8[0].src_mi->mbmi.sb_type = bsize; + mi_8x8[0]->mbmi.sb_type = bsize; if (bsize >= BLOCK_8X8) pc_tree->partitioning = partition; chosen_rdc = last_part_rdc; @@ -2110,7 +2108,7 @@ static const BLOCK_SIZE max_partition_size[BLOCK_SIZES] = { // // The min and max are assumed to have been initialized prior to calling this // function so repeat calls can accumulate a min and max of more than one sb64. -static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO *mi_8x8, +static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO **mi_8x8, BLOCK_SIZE *min_block_size, BLOCK_SIZE *max_block_size, int bs_hist[BLOCK_SIZES]) { @@ -2122,7 +2120,7 @@ static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO *mi_8x8, // Check the sb_type for each block that belongs to this region. for (i = 0; i < sb_height_in_blocks; ++i) { for (j = 0; j < sb_width_in_blocks; ++j) { - MODE_INFO *mi = mi_8x8[index+j].src_mi; + MODE_INFO *mi = mi_8x8[index+j]; BLOCK_SIZE sb_type = mi ? mi->mbmi.sb_type : 0; bs_hist[sb_type]++; *min_block_size = MIN(*min_block_size, sb_type); @@ -2149,9 +2147,9 @@ static void rd_auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, BLOCK_SIZE *min_block_size, BLOCK_SIZE *max_block_size) { VP9_COMMON *const cm = &cpi->common; - MODE_INFO *mi = xd->mi[0].src_mi; - const int left_in_image = xd->left_available && mi[-1].src_mi; - const int above_in_image = xd->up_available && mi[-xd->mi_stride].src_mi; + MODE_INFO **mi = xd->mi; + const int left_in_image = xd->left_available && mi[-1]; + const int above_in_image = xd->up_available && mi[-xd->mi_stride]; const int row8x8_remaining = tile->mi_row_end - mi_row; const int col8x8_remaining = tile->mi_col_end - mi_col; int bh, bw; @@ -2170,20 +2168,19 @@ static void rd_auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, // passed in values for min and max as a starting point. // Find the min and max partition used in previous frame at this location if (cm->frame_type != KEY_FRAME) { - MODE_INFO *prev_mi = - cm->prev_mip + cm->mi_stride + 1 + mi_row * xd->mi_stride + mi_col; - + MODE_INFO **prev_mi = + &cm->prev_mi_grid_visible[mi_row * xd->mi_stride + mi_col]; get_sb_partition_size_range(xd, prev_mi, &min_size, &max_size, bs_hist); } // Find the min and max partition sizes used in the left SB64 if (left_in_image) { - MODE_INFO *left_sb64_mi = mi[-MI_BLOCK_SIZE].src_mi; + MODE_INFO **left_sb64_mi = &mi[-MI_BLOCK_SIZE]; get_sb_partition_size_range(xd, left_sb64_mi, &min_size, &max_size, bs_hist); } // Find the min and max partition sizes used in the above SB64. if (above_in_image) { - MODE_INFO *above_sb64_mi = mi[-xd->mi_stride * MI_BLOCK_SIZE].src_mi; + MODE_INFO **above_sb64_mi = &mi[-xd->mi_stride * MI_BLOCK_SIZE]; get_sb_partition_size_range(xd, above_sb64_mi, &min_size, &max_size, bs_hist); } @@ -2245,10 +2242,9 @@ static void auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, BLOCK_SIZE *min_block_size, BLOCK_SIZE *max_block_size) { VP9_COMMON *const cm = &cpi->common; - MODE_INFO *mi_8x8 = xd->mi; - const int left_in_image = xd->left_available && mi_8x8[-1].src_mi; - const int above_in_image = xd->up_available && - mi_8x8[-xd->mi_stride].src_mi; + MODE_INFO **mi_8x8 = xd->mi; + const int left_in_image = xd->left_available && mi_8x8[-1]; + const int above_in_image = xd->up_available && mi_8x8[-xd->mi_stride]; int row8x8_remaining = tile->mi_row_end - mi_row; int col8x8_remaining = tile->mi_col_end - mi_col; int bh, bw; @@ -2261,15 +2257,15 @@ static void auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, if (search_range_ctrl && (left_in_image || above_in_image || cm->frame_type != KEY_FRAME)) { int block; - MODE_INFO *mi; + MODE_INFO **mi; BLOCK_SIZE sb_type; // Find the min and max partition sizes used in the left SB64. if (left_in_image) { MODE_INFO *cur_mi; - mi = mi_8x8[-1].src_mi; + mi = &mi_8x8[-1]; for (block = 0; block < MI_BLOCK_SIZE; ++block) { - cur_mi = mi[block * xd->mi_stride].src_mi; + cur_mi = mi[block * xd->mi_stride]; sb_type = cur_mi ? cur_mi->mbmi.sb_type : 0; min_size = MIN(min_size, sb_type); max_size = MAX(max_size, sb_type); @@ -2277,9 +2273,9 @@ static void auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, } // Find the min and max partition sizes used in the above SB64. if (above_in_image) { - mi = mi_8x8[-xd->mi_stride * MI_BLOCK_SIZE].src_mi; + mi = &mi_8x8[-xd->mi_stride * MI_BLOCK_SIZE]; for (block = 0; block < MI_BLOCK_SIZE; ++block) { - sb_type = mi[block].src_mi ? mi[block].src_mi->mbmi.sb_type : 0; + sb_type = mi[block] ? mi[block]->mbmi.sb_type : 0; min_size = MIN(min_size, sb_type); max_size = MAX(max_size, sb_type); } @@ -2310,9 +2306,7 @@ static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *mi; const int idx_str = cm->mi_stride * mi_row + mi_col; - MODE_INFO *prev_mi = (cm->prev_mip + cm->mi_stride + 1 + idx_str)->src_mi; - - + MODE_INFO **prev_mi = &cm->prev_mi_grid_visible[idx_str]; BLOCK_SIZE bs, min_size, max_size; min_size = BLOCK_64X64; @@ -2321,7 +2315,7 @@ static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, if (prev_mi) { for (idy = 0; idy < mi_height; ++idy) { for (idx = 0; idx < mi_width; ++idx) { - mi = prev_mi[idy * cm->mi_stride + idx].src_mi; + mi = prev_mi[idy * cm->mi_stride + idx]; bs = mi ? mi->mbmi.sb_type : bsize; min_size = MIN(min_size, bs); max_size = MAX(max_size, bs); @@ -2331,7 +2325,7 @@ static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, if (xd->left_available) { for (idy = 0; idy < mi_height; ++idy) { - mi = xd->mi[idy * cm->mi_stride - 1].src_mi; + mi = xd->mi[idy * cm->mi_stride - 1]; bs = mi ? mi->mbmi.sb_type : bsize; min_size = MIN(min_size, bs); max_size = MAX(max_size, bs); @@ -2340,7 +2334,7 @@ static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, if (xd->up_available) { for (idx = 0; idx < mi_width; ++idx) { - mi = xd->mi[idx - cm->mi_stride].src_mi; + mi = xd->mi[idx - cm->mi_stride]; bs = mi ? mi->mbmi.sb_type : bsize; min_size = MIN(min_size, bs); max_size = MAX(max_size, bs); @@ -2850,7 +2844,7 @@ static void encode_rd_sb_row(VP9_COMP *cpi, int seg_skip = 0; const int idx_str = cm->mi_stride * mi_row + mi_col; - MODE_INFO *mi = cm->mi + idx_str; + MODE_INFO **mi = cm->mi_grid_visible + idx_str; if (sf->adaptive_pred_interp_filter) { for (i = 0; i < 64; ++i) @@ -2942,12 +2936,12 @@ static int check_dual_ref_flags(VP9_COMP *cpi) { static void reset_skip_tx_size(VP9_COMMON *cm, TX_SIZE max_tx_size) { int mi_row, mi_col; const int mis = cm->mi_stride; - MODE_INFO *mi_ptr = cm->mi; + MODE_INFO **mi_ptr = cm->mi_grid_visible; for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row, mi_ptr += mis) { for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) { - if (mi_ptr[mi_col].src_mi->mbmi.tx_size > max_tx_size) - mi_ptr[mi_col].src_mi->mbmi.tx_size = max_tx_size; + if (mi_ptr[mi_col]->mbmi.tx_size > max_tx_size) + mi_ptr[mi_col]->mbmi.tx_size = max_tx_size; } } } @@ -2997,7 +2991,7 @@ static void nonrd_pick_sb_modes(VP9_COMP *cpi, MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi; set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize); - mbmi = &xd->mi[0].src_mi->mbmi; + mbmi = &xd->mi[0]->mbmi; mbmi->sb_type = bsize; if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) @@ -3041,27 +3035,27 @@ static void fill_mode_info_sb(VP9_COMMON *cm, MACROBLOCK *x, switch (partition) { case PARTITION_NONE: set_mode_info_offsets(cm, xd, mi_row, mi_col); - *(xd->mi[0].src_mi) = pc_tree->none.mic; + *(xd->mi[0]) = pc_tree->none.mic; duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); break; case PARTITION_VERT: set_mode_info_offsets(cm, xd, mi_row, mi_col); - *(xd->mi[0].src_mi) = pc_tree->vertical[0].mic; + *(xd->mi[0]) = pc_tree->vertical[0].mic; duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, subsize); if (mi_col + hbs < cm->mi_cols) { set_mode_info_offsets(cm, xd, mi_row, mi_col + hbs); - *(xd->mi[0].src_mi) = pc_tree->vertical[1].mic; + *(xd->mi[0]) = pc_tree->vertical[1].mic; duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col + hbs, subsize); } break; case PARTITION_HORZ: set_mode_info_offsets(cm, xd, mi_row, mi_col); - *(xd->mi[0].src_mi) = pc_tree->horizontal[0].mic; + *(xd->mi[0]) = pc_tree->horizontal[0].mic; duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, subsize); if (mi_row + hbs < cm->mi_rows) { set_mode_info_offsets(cm, xd, mi_row + hbs, mi_col); - *(xd->mi[0].src_mi) = pc_tree->horizontal[1].mic; + *(xd->mi[0]) = pc_tree->horizontal[1].mic; duplicate_mode_info_in_sb(cm, xd, mi_row + hbs, mi_col, subsize); } break; @@ -3161,7 +3155,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td, if (partition_none_allowed) { nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &this_rdc, bsize, ctx); - ctx->mic.mbmi = xd->mi[0].src_mi->mbmi; + ctx->mic.mbmi = xd->mi[0]->mbmi; ctx->skip_txfm[0] = x->skip_txfm[0]; ctx->skip = x->skip; @@ -3243,7 +3237,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td, nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize, &pc_tree->horizontal[0]); - pc_tree->horizontal[0].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; pc_tree->horizontal[0].skip = x->skip; @@ -3254,7 +3248,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td, &this_rdc, subsize, &pc_tree->horizontal[1]); - pc_tree->horizontal[1].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; pc_tree->horizontal[1].skip = x->skip; @@ -3286,7 +3280,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td, pc_tree->vertical[0].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, &sum_rdc, subsize, &pc_tree->vertical[0]); - pc_tree->vertical[0].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; pc_tree->vertical[0].skip = x->skip; @@ -3296,7 +3290,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td, nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + ms, &this_rdc, subsize, &pc_tree->vertical[1]); - pc_tree->vertical[1].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; pc_tree->vertical[1].skip = x->skip; @@ -3348,7 +3342,7 @@ static void nonrd_pick_partition(VP9_COMP *cpi, ThreadData *td, static void nonrd_select_partition(VP9_COMP *cpi, ThreadData *td, TileDataEnc *tile_data, - MODE_INFO *mi, + MODE_INFO **mi, TOKENEXTRA **tp, int mi_row, int mi_col, BLOCK_SIZE bsize, int output_enabled, @@ -3367,7 +3361,7 @@ static void nonrd_select_partition(VP9_COMP *cpi, if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - subsize = (bsize >= BLOCK_8X8) ? mi[0].src_mi->mbmi.sb_type : BLOCK_4X4; + subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4; partition = partition_lookup[bsl][subsize]; if (bsize == BLOCK_32X32 && partition != PARTITION_NONE && @@ -3387,7 +3381,7 @@ static void nonrd_select_partition(VP9_COMP *cpi, pc_tree->none.pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, rd_cost, subsize, &pc_tree->none); - pc_tree->none.mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->none.mic.mbmi = xd->mi[0]->mbmi; pc_tree->none.skip_txfm[0] = x->skip_txfm[0]; pc_tree->none.skip = x->skip; break; @@ -3395,14 +3389,14 @@ static void nonrd_select_partition(VP9_COMP *cpi, pc_tree->vertical[0].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, rd_cost, subsize, &pc_tree->vertical[0]); - pc_tree->vertical[0].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; pc_tree->vertical[0].skip = x->skip; if (mi_col + hbs < cm->mi_cols) { pc_tree->vertical[1].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + hbs, &this_rdc, subsize, &pc_tree->vertical[1]); - pc_tree->vertical[1].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; pc_tree->vertical[1].skip = x->skip; if (this_rdc.rate != INT_MAX && this_rdc.dist != INT64_MAX && @@ -3416,14 +3410,14 @@ static void nonrd_select_partition(VP9_COMP *cpi, pc_tree->horizontal[0].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, rd_cost, subsize, &pc_tree->horizontal[0]); - pc_tree->horizontal[0].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; pc_tree->horizontal[0].skip = x->skip; if (mi_row + hbs < cm->mi_rows) { pc_tree->horizontal[1].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row + hbs, mi_col, &this_rdc, subsize, &pc_tree->horizontal[1]); - pc_tree->horizontal[1].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; pc_tree->horizontal[1].skip = x->skip; if (this_rdc.rate != INT_MAX && this_rdc.dist != INT64_MAX && @@ -3477,7 +3471,7 @@ static void nonrd_select_partition(VP9_COMP *cpi, static void nonrd_use_partition(VP9_COMP *cpi, ThreadData *td, TileDataEnc *tile_data, - MODE_INFO *mi, + MODE_INFO **mi, TOKENEXTRA **tp, int mi_row, int mi_col, BLOCK_SIZE bsize, int output_enabled, @@ -3494,7 +3488,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - subsize = (bsize >= BLOCK_8X8) ? mi[0].src_mi->mbmi.sb_type : BLOCK_4X4; + subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4; partition = partition_lookup[bsl][subsize]; if (output_enabled && bsize != BLOCK_4X4) { @@ -3507,7 +3501,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, pc_tree->none.pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost, subsize, &pc_tree->none); - pc_tree->none.mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->none.mic.mbmi = xd->mi[0]->mbmi; pc_tree->none.skip_txfm[0] = x->skip_txfm[0]; pc_tree->none.skip = x->skip; encode_b_rt(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, @@ -3517,7 +3511,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, pc_tree->vertical[0].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost, subsize, &pc_tree->vertical[0]); - pc_tree->vertical[0].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; pc_tree->vertical[0].skip = x->skip; encode_b_rt(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, @@ -3526,7 +3520,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, pc_tree->vertical[1].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col + hbs, dummy_cost, subsize, &pc_tree->vertical[1]); - pc_tree->vertical[1].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; pc_tree->vertical[1].skip = x->skip; encode_b_rt(cpi, td, tile_info, tp, mi_row, mi_col + hbs, @@ -3537,7 +3531,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, pc_tree->horizontal[0].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row, mi_col, dummy_cost, subsize, &pc_tree->horizontal[0]); - pc_tree->horizontal[0].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; pc_tree->horizontal[0].skip = x->skip; encode_b_rt(cpi, td, tile_info, tp, mi_row, mi_col, output_enabled, @@ -3547,7 +3541,7 @@ static void nonrd_use_partition(VP9_COMP *cpi, pc_tree->horizontal[1].pred_pixel_ready = 1; nonrd_pick_sb_modes(cpi, tile_data, x, mi_row + hbs, mi_col, dummy_cost, subsize, &pc_tree->horizontal[1]); - pc_tree->horizontal[1].mic.mbmi = xd->mi[0].src_mi->mbmi; + pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; pc_tree->horizontal[1].skip = x->skip; encode_b_rt(cpi, td, tile_info, tp, mi_row + hbs, mi_col, @@ -3607,7 +3601,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, const struct segmentation *const seg = &cm->seg; RD_COST dummy_rdc; const int idx_str = cm->mi_stride * mi_row + mi_col; - MODE_INFO *mi = cm->mi + idx_str; + MODE_INFO **mi = cm->mi_grid_visible + idx_str; PARTITION_SEARCH_TYPE partition_search_type = sf->partition_search_type; BLOCK_SIZE bsize = BLOCK_64X64; int seg_skip = 0; @@ -3653,7 +3647,7 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, case REFERENCE_PARTITION: set_offsets(cpi, tile_info, x, mi_row, mi_col, BLOCK_64X64); if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled && - xd->mi[0].src_mi->mbmi.segment_id) { + xd->mi[0]->mbmi.segment_id) { x->max_partition_size = BLOCK_64X64; x->min_partition_size = BLOCK_8X8; nonrd_pick_partition(cpi, td, tile_data, tp, mi_row, mi_col, @@ -3898,8 +3892,8 @@ static void encode_frame_internal(VP9_COMP *cpi) { MACROBLOCKD *const xd = &x->e_mbd; RD_COUNTS *const rdc = &cpi->td.rd_counts; - xd->mi = cm->mi; - xd->mi[0].src_mi = &xd->mi[0]; + xd->mi = cm->mi_grid_visible; + xd->mi[0] = cm->mi; vp9_zero(*td->counts); vp9_zero(rdc->coef_counts); @@ -4176,8 +4170,8 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, VP9_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; - MODE_INFO *mi_8x8 = xd->mi; - MODE_INFO *mi = mi_8x8; + MODE_INFO **mi_8x8 = xd->mi; + MODE_INFO *mi = mi_8x8[0]; MB_MODE_INFO *mbmi = &mi->mbmi; const int seg_skip = vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP); @@ -4251,7 +4245,7 @@ static void encode_superblock(VP9_COMP *cpi, ThreadData *td, for (y = 0; y < mi_height; y++) for (x = 0; x < mi_width; x++) if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) - mi_8x8[mis * y + x].src_mi->mbmi.tx_size = tx_size; + mi_8x8[mis * y + x]->mbmi.tx_size = tx_size; } ++td->counts->tx.tx_totals[mbmi->tx_size]; ++td->counts->tx.tx_totals[get_uv_tx_size(mbmi, &xd->plane[1])]; diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 65e299793..e6afd4722 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -128,7 +128,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, MACROBLOCKD *const xd = &mb->e_mbd; struct macroblock_plane *const p = &mb->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; - const int ref = is_inter_block(&xd->mi[0].src_mi->mbmi); + const int ref = is_inter_block(&xd->mi[0]->mbmi); vp9_token_state tokens[1025][2]; unsigned best_index[1025][2]; uint8_t token_cache[1024]; @@ -773,7 +773,7 @@ void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) { void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct encode_b_args arg = {x, &ctx, &mbmi->skip}; int plane; @@ -803,7 +803,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, struct encode_b_args* const args = arg; MACROBLOCK *const x = args->x; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct macroblock_plane *const p = &x->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane]; tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block); @@ -895,7 +895,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, case TX_4X4: tx_type = get_tx_type_4x4(pd->plane_type, xd, block); scan_order = &vp9_scan_orders[TX_4X4][tx_type]; - mode = plane == 0 ? get_y_mode(xd->mi[0].src_mi, block) : mbmi->uv_mode; + mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode; vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode, x->skip_encode ? src : dst, x->skip_encode ? src_stride : dst_stride, @@ -998,7 +998,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, case TX_4X4: tx_type = get_tx_type_4x4(pd->plane_type, xd, block); scan_order = &vp9_scan_orders[TX_4X4][tx_type]; - mode = plane == 0 ? get_y_mode(xd->mi[0].src_mi, block) : mbmi->uv_mode; + mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode; vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode, x->skip_encode ? src : dst, x->skip_encode ? src_stride : dst_stride, @@ -1037,7 +1037,7 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { const MACROBLOCKD *const xd = &x->e_mbd; - struct encode_b_args arg = {x, NULL, &xd->mi[0].src_mi->mbmi.skip}; + struct encode_b_args arg = {x, NULL, &xd->mi[0]->mbmi.skip}; vp9_foreach_transformed_block_in_plane(xd, bsize, plane, vp9_encode_block_intra, &arg); diff --git a/vp9/encoder/vp9_encodemv.c b/vp9/encoder/vp9_encodemv.c index f2c4efc13..af73fcbdc 100644 --- a/vp9/encoder/vp9_encodemv.c +++ b/vp9/encoder/vp9_encodemv.c @@ -243,7 +243,7 @@ static void inc_mvs(const MB_MODE_INFO *mbmi, const int_mv mvs[2], void vp9_update_mv_count(ThreadData *td) { const MACROBLOCKD *xd = &td->mb.e_mbd; - const MODE_INFO *mi = xd->mi[0].src_mi; + const MODE_INFO *mi = xd->mi[0]; const MB_MODE_INFO *const mbmi = &mi->mbmi; if (mbmi->sb_type < BLOCK_8X8) { diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index c6bc6aaf0..0fecd79a3 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -258,6 +258,12 @@ static void vp9_enc_setup_mi(VP9_COMMON *cm) { // Clear left border column for (i = 1; i < cm->mi_rows + 1; ++i) vpx_memset(&cm->prev_mip[i * cm->mi_stride], 0, sizeof(*cm->prev_mip)); + + cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; + cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1; + + vpx_memset(cm->mi_grid_base, 0, + cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mi_grid_base)); } static int vp9_enc_alloc_mi(VP9_COMMON *cm, int mi_size) { @@ -268,6 +274,14 @@ static int vp9_enc_alloc_mi(VP9_COMMON *cm, int mi_size) { if (!cm->prev_mip) return 1; cm->mi_alloc_size = mi_size; + + cm->mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*)); + if (!cm->mi_grid_base) + return 1; + cm->prev_mi_grid_base = (MODE_INFO **)vpx_calloc(mi_size, sizeof(MODE_INFO*)); + if (!cm->prev_mi_grid_base) + return 1; + return 0; } @@ -276,10 +290,15 @@ static void vp9_enc_free_mi(VP9_COMMON *cm) { cm->mip = NULL; vpx_free(cm->prev_mip); cm->prev_mip = NULL; + vpx_free(cm->mi_grid_base); + cm->mi_grid_base = NULL; + vpx_free(cm->prev_mi_grid_base); + cm->prev_mi_grid_base = NULL; } static void vp9_swap_mi_and_prev_mi(VP9_COMMON *cm) { // Current mip will be the prev_mip for the next frame. + MODE_INFO **temp_base = cm->prev_mi_grid_base; MODE_INFO *temp = cm->prev_mip; cm->prev_mip = cm->mip; cm->mip = temp; @@ -287,6 +306,11 @@ static void vp9_swap_mi_and_prev_mi(VP9_COMMON *cm) { // Update the upper left visible macroblock ptrs. cm->mi = cm->mip + cm->mi_stride + 1; cm->prev_mi = cm->prev_mip + cm->mi_stride + 1; + + cm->prev_mi_grid_base = cm->mi_grid_base; + cm->mi_grid_base = temp_base; + cm->mi_grid_visible = cm->mi_grid_base + cm->mi_stride + 1; + cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mi_stride + 1; } void vp9_initialize_enc(void) { @@ -567,15 +591,15 @@ static void configure_static_seg_features(VP9_COMP *cpi) { static void update_reference_segmentation_map(VP9_COMP *cpi) { VP9_COMMON *const cm = &cpi->common; - MODE_INFO *mi_8x8_ptr = cm->mi; + MODE_INFO **mi_8x8_ptr = cm->mi_grid_visible; uint8_t *cache_ptr = cm->last_frame_seg_map; int row, col; for (row = 0; row < cm->mi_rows; row++) { - MODE_INFO *mi_8x8 = mi_8x8_ptr; + MODE_INFO **mi_8x8 = mi_8x8_ptr; uint8_t *cache = cache_ptr; for (col = 0; col < cm->mi_cols; col++, mi_8x8++, cache++) - cache[0] = mi_8x8[0].src_mi->mbmi.segment_id; + cache[0] = mi_8x8[0]->mbmi.segment_id; mi_8x8_ptr += cm->mi_stride; cache_ptr += cm->mi_cols; } diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index bf9e50047..249c047ba 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -358,7 +358,7 @@ static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x, MV tmp_mv = {0, 0}; MV ref_mv_full = {ref_mv->row >> 3, ref_mv->col >> 3}; int num00, tmp_err, n; - const BLOCK_SIZE bsize = xd->mi[0].src_mi->mbmi.sb_type; + const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize]; const int new_mv_mode_penalty = NEW_MV_MODE_PENALTY; @@ -567,8 +567,8 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { vp9_setup_pre_planes(xd, 0, first_ref_buf, 0, 0, NULL); } - xd->mi = cm->mi; - xd->mi[0].src_mi = &xd->mi[0]; + xd->mi = cm->mi_grid_visible; + xd->mi[0] = cm->mi; vp9_frame_init_quantizer(cpi); @@ -621,8 +621,8 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset; xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset; xd->left_available = (mb_col != 0); - xd->mi[0].src_mi->mbmi.sb_type = bsize; - xd->mi[0].src_mi->mbmi.ref_frame[0] = INTRA_FRAME; + xd->mi[0]->mbmi.sb_type = bsize; + xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME; set_mi_row_col(xd, &tile, mb_row << 1, num_8x8_blocks_high_lookup[bsize], mb_col << 1, num_8x8_blocks_wide_lookup[bsize], @@ -630,8 +630,8 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { // Do intra 16x16 prediction. x->skip_encode = 0; - xd->mi[0].src_mi->mbmi.mode = DC_PRED; - xd->mi[0].src_mi->mbmi.tx_size = use_dc_pred ? + xd->mi[0]->mbmi.mode = DC_PRED; + xd->mi[0]->mbmi.tx_size = use_dc_pred ? (bsize >= BLOCK_16X16 ? TX_16X16 : TX_8X8) : TX_4X4; vp9_encode_intra_block_plane(x, bsize, 0); this_error = vp9_get_mb_ss(x->plane[0].src_diff); @@ -843,11 +843,11 @@ void vp9_first_pass(VP9_COMP *cpi, const struct lookahead_entry *source) { mv.row *= 8; mv.col *= 8; this_error = motion_error; - xd->mi[0].src_mi->mbmi.mode = NEWMV; - xd->mi[0].src_mi->mbmi.mv[0].as_mv = mv; - xd->mi[0].src_mi->mbmi.tx_size = TX_4X4; - xd->mi[0].src_mi->mbmi.ref_frame[0] = LAST_FRAME; - xd->mi[0].src_mi->mbmi.ref_frame[1] = NONE; + xd->mi[0]->mbmi.mode = NEWMV; + xd->mi[0]->mbmi.mv[0].as_mv = mv; + xd->mi[0]->mbmi.tx_size = TX_4X4; + xd->mi[0]->mbmi.ref_frame[0] = LAST_FRAME; + xd->mi[0]->mbmi.ref_frame[1] = NONE; vp9_build_inter_predictors_sby(xd, mb_row << 1, mb_col << 1, bsize); vp9_encode_sby_pass1(x, bsize); sum_mvr += mv.row; diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index b3a8df924..031f77f6d 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -63,8 +63,8 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, &distortion, &sse, NULL, 0, 0); } - xd->mi[0].src_mi->mbmi.mode = NEWMV; - xd->mi[0].src_mi->mbmi.mv[0].as_mv = *dst_mv; + xd->mi[0]->mbmi.mode = NEWMV; + xd->mi[0]->mbmi.mv[0].as_mv = *dst_mv; vp9_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_16X16); @@ -141,7 +141,7 @@ static int find_best_16x16_intra(VP9_COMP *cpi, PREDICTION_MODE *pbest_mode) { for (mode = DC_PRED; mode <= TM_PRED; mode++) { unsigned int err; - xd->mi[0].src_mi->mbmi.mode = mode; + xd->mi[0]->mbmi.mode = mode; vp9_predict_intra_block(xd, 0, 2, TX_16X16, mode, x->plane[0].src.buf, x->plane[0].src.stride, xd->plane[0].dst.buf, xd->plane[0].dst.stride, @@ -247,7 +247,7 @@ static void update_mbgraph_frame_stats(VP9_COMP *cpi, xd->plane[0].dst.stride = buf->y_stride; xd->plane[0].pre[0].stride = buf->y_stride; xd->plane[1].dst.stride = buf->uv_stride; - xd->mi[0].src_mi = &mi_local; + xd->mi[0] = &mi_local; mi_local.mbmi.sb_type = BLOCK_16X16; mi_local.mbmi.ref_frame[0] = LAST_FRAME; mi_local.mbmi.ref_frame[1] = NONE; diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 1f5f08a5e..ec089f17a 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -1802,7 +1802,7 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x, const int src_stride = x->plane[0].src.stride; const int ref_stride = xd->plane[0].pre[0].stride; uint8_t const *ref_buf, *src_buf; - MV *tmp_mv = &xd->mi[0].src_mi->mbmi.mv[0].as_mv; + MV *tmp_mv = &xd->mi[0]->mbmi.mv[0].as_mv; unsigned int best_sad, tmp_sad, this_sad[4]; MV this_mv; const int norm_factor = 3 + (bw >> 5); diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 416f6797b..5a16d9fc5 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -60,7 +60,7 @@ static int mv_refs_rt(const VP9_COMMON *cm, const MACROBLOCKD *xd, const POSITION *const mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { const MODE_INFO *const candidate_mi = xd->mi[mv_ref->col + mv_ref->row * - xd->mi_stride].src_mi; + xd->mi_stride]; const MB_MODE_INFO *const candidate = &candidate_mi->mbmi; // Keep counts for entropy encoding. context_counter += mode_2_counter[candidate->mode]; @@ -81,7 +81,7 @@ static int mv_refs_rt(const VP9_COMMON *cm, const MACROBLOCKD *xd, const POSITION *const mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row * - xd->mi_stride].src_mi->mbmi; + xd->mi_stride]->mbmi; different_ref_found = 1; if (candidate->ref_frame[0] == ref_frame) @@ -97,7 +97,7 @@ static int mv_refs_rt(const VP9_COMMON *cm, const MACROBLOCKD *xd, const POSITION *mv_ref = &mv_ref_search[i]; if (is_inside(tile, mi_col, mi_row, cm->mi_rows, mv_ref)) { const MB_MODE_INFO *const candidate = &xd->mi[mv_ref->col + mv_ref->row - * xd->mi_stride].src_mi->mbmi; + * xd->mi_stride]->mbmi; // If the candidate is INTRA we don't want to consider its mv. IF_DIFF_REF_FRAME_ADD_MV(candidate, ref_frame, ref_sign_bias, @@ -122,7 +122,7 @@ static int combined_motion_search(VP9_COMP *cpi, MACROBLOCK *x, int_mv *tmp_mv, int *rate_mv, int64_t best_rd_sofar) { MACROBLOCKD *xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}}; const int step_param = cpi->sf.mv.fullpel_search_step_param; const int sadpb = x->sadperbit16; @@ -296,7 +296,7 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize, if (cpi->sf.partition_search_type == VAR_BASED_PARTITION) { if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && - cyclic_refresh_segment_id_boosted(xd->mi[0].src_mi->mbmi.segment_id)) + cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id)) tx_size = TX_8X8; else if (tx_size > TX_16X16) tx_size = TX_16X16; @@ -307,7 +307,7 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize, } assert(tx_size >= TX_8X8); - xd->mi[0].src_mi->mbmi.tx_size = tx_size; + xd->mi[0]->mbmi.tx_size = tx_size; // Evaluate if the partition block is a skippable block in Y plane. { @@ -376,7 +376,7 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize, for (i = 1; i <= 2; i++) { struct macroblock_plane *const p = &x->plane[i]; struct macroblockd_plane *const pd = &xd->plane[i]; - const TX_SIZE uv_tx_size = get_uv_tx_size(&xd->mi[0].src_mi->mbmi, pd); + const TX_SIZE uv_tx_size = get_uv_tx_size(&xd->mi[0]->mbmi, pd); const BLOCK_SIZE unit_size = txsize_to_bsize[uv_tx_size]; const BLOCK_SIZE uv_bsize = get_plane_block_size(bsize, pd); const int uv_bw = b_width_log2_lookup[uv_bsize]; @@ -472,21 +472,21 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, if (cpi->common.tx_mode == TX_MODE_SELECT) { if (sse > (var << 2)) - xd->mi[0].src_mi->mbmi.tx_size = + xd->mi[0]->mbmi.tx_size = MIN(max_txsize_lookup[bsize], tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); else - xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; + xd->mi[0]->mbmi.tx_size = TX_8X8; if (cpi->sf.partition_search_type == VAR_BASED_PARTITION) { if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && - cyclic_refresh_segment_id_boosted(xd->mi[0].src_mi->mbmi.segment_id)) - xd->mi[0].src_mi->mbmi.tx_size = TX_8X8; - else if (xd->mi[0].src_mi->mbmi.tx_size > TX_16X16) - xd->mi[0].src_mi->mbmi.tx_size = TX_16X16; + cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id)) + xd->mi[0]->mbmi.tx_size = TX_8X8; + else if (xd->mi[0]->mbmi.tx_size > TX_16X16) + xd->mi[0]->mbmi.tx_size = TX_16X16; } } else { - xd->mi[0].src_mi->mbmi.tx_size = + xd->mi[0]->mbmi.tx_size = MIN(max_txsize_lookup[bsize], tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); } @@ -494,7 +494,7 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, // Evaluate if the partition block is a skippable block in Y plane. { const BLOCK_SIZE unit_size = - txsize_to_bsize[xd->mi[0].src_mi->mbmi.tx_size]; + txsize_to_bsize[xd->mi[0]->mbmi.tx_size]; const unsigned int num_blk_log2 = (b_width_log2_lookup[bsize] - b_width_log2_lookup[unit_size]) + (b_height_log2_lookup[bsize] - b_height_log2_lookup[unit_size]); @@ -776,7 +776,7 @@ static void encode_breakout_test(VP9_COMP *cpi, MACROBLOCK *x, struct buf_2d yv12_mb[][MAX_MB_PLANE], int *rate, int64_t *dist) { MACROBLOCKD *xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const BLOCK_SIZE uv_size = get_plane_block_size(bsize, &xd->plane[1]); unsigned int var = var_y, sse = sse_y; @@ -935,17 +935,17 @@ static const PREDICTION_MODE intra_mode_list[] = { void vp9_pick_intra_mode(VP9_COMP *cpi, MACROBLOCK *x, RD_COST *rd_cost, BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; RD_COST this_rdc, best_rdc; PREDICTION_MODE this_mode; struct estimate_block_intra_args args = { cpi, x, DC_PRED, 0, 0 }; const TX_SIZE intra_tx_size = MIN(max_txsize_lookup[bsize], tx_mode_to_biggest_tx_size[cpi->common.tx_mode]); - MODE_INFO *const mic = xd->mi[0].src_mi; + MODE_INFO *const mic = xd->mi[0]; int *bmode_costs; - const MODE_INFO *above_mi = xd->mi[-xd->mi_stride].src_mi; - const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1].src_mi : NULL; + const MODE_INFO *above_mi = xd->mi[-xd->mi_stride]; + const MODE_INFO *left_mi = xd->left_available ? xd->mi[-1] : NULL; const PREDICTION_MODE A = vp9_above_block_mode(mic, above_mi, 0); const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0); bmode_costs = cpi->y_mode_costs[A][L]; @@ -1027,7 +1027,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, VP9_COMMON *const cm = &cpi->common; TileInfo *const tile_info = &tile_data->tile_info; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; struct macroblockd_plane *const pd = &xd->plane[0]; PREDICTION_MODE best_mode = ZEROMV; MV_REFERENCE_FRAME ref_frame, best_ref_frame = LAST_FRAME; @@ -1105,9 +1105,9 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, x->skip = 0; if (xd->up_available) - filter_ref = xd->mi[-xd->mi_stride].src_mi->mbmi.interp_filter; + filter_ref = xd->mi[-xd->mi_stride]->mbmi.interp_filter; else if (xd->left_available) - filter_ref = xd->mi[-1].src_mi->mbmi.interp_filter; + filter_ref = xd->mi[-1]->mbmi.interp_filter; else filter_ref = cm->interp_filter; @@ -1145,11 +1145,11 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, sf, sf); if (cm->use_prev_frame_mvs) - vp9_find_mv_refs(cm, xd, tile_info, xd->mi[0].src_mi, ref_frame, + vp9_find_mv_refs(cm, xd, tile_info, xd->mi[0], ref_frame, candidates, mi_row, mi_col, NULL, NULL); else const_motion[ref_frame] = mv_refs_rt(cm, xd, tile_info, - xd->mi[0].src_mi, + xd->mi[0], ref_frame, candidates, mi_row, mi_col); @@ -1337,7 +1337,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, // For large partition blocks, extra testing is done. if (bsize > BLOCK_32X32 && - !cyclic_refresh_segment_id_boosted(xd->mi[0].src_mi->mbmi.segment_id) && + !cyclic_refresh_segment_id_boosted(xd->mi[0]->mbmi.segment_id) && cm->base_qindex) { model_rd_for_sb_y_large(cpi, bsize, x, xd, &this_rdc.rate, &this_rdc.dist, &var_y, &sse_y, mi_row, mi_col, @@ -1450,7 +1450,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, mbmi->tx_size = best_tx_size; mbmi->ref_frame[0] = best_ref_frame; mbmi->mv[0].as_int = frame_mv[best_mode][best_ref_frame].as_int; - xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int; + xd->mi[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int; x->skip_txfm[0] = best_mode_skip_txfm; // Perform intra prediction search, if the best SAD is above a certain @@ -1580,7 +1580,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, TileInfo *const tile_info = &tile_data->tile_info; SPEED_FEATURES *const sf = &cpi->sf; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const struct segmentation *const seg = &cm->seg; MV_REFERENCE_FRAME ref_frame, second_ref_frame = NONE; MV_REFERENCE_FRAME best_ref_frame = NONE; @@ -1609,7 +1609,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, &cm->frame_refs[ref_frame - 1].sf; vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf); - vp9_find_mv_refs(cm, xd, tile_info, xd->mi[0].src_mi, ref_frame, + vp9_find_mv_refs(cm, xd, tile_info, xd->mi[0], ref_frame, candidates, mi_row, mi_col, NULL, NULL); vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, candidates, @@ -1688,7 +1688,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) { int b_rate = 0; - xd->mi[0].bmi[i].as_mv[0].as_int = b_mv[this_mode].as_int; + xd->mi[0]->bmi[i].as_mv[0].as_int = b_mv[this_mode].as_int; if (this_mode == NEWMV) { const int step_param = cpi->sf.mv.fullpel_search_step_param; @@ -1705,8 +1705,8 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, mvp_full.row = b_mv[NEARESTMV].as_mv.row >> 3; mvp_full.col = b_mv[NEARESTMV].as_mv.col >> 3; } else { - mvp_full.row = xd->mi[0].bmi[0].as_mv[0].as_mv.row >> 3; - mvp_full.col = xd->mi[0].bmi[0].as_mv[0].as_mv.col >> 3; + mvp_full.row = xd->mi[0]->bmi[0].as_mv[0].as_mv.row >> 3; + mvp_full.col = xd->mi[0]->bmi[0].as_mv[0].as_mv.col >> 3; } vp9_set_mv_search_range(x, &mbmi->ref_mvs[0]->as_mv); @@ -1748,7 +1748,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, &dummy_dist, &x->pred_sse[ref_frame], NULL, 0, 0); - xd->mi[0].bmi[i].as_mv[0].as_mv = tmp_mv; + xd->mi[0]->bmi[i].as_mv[0].as_mv = tmp_mv; } else { b_rate += cpi->inter_mode_cost[mbmi->mode_context[ref_frame]] [INTER_OFFSET(this_mode)]; @@ -1758,7 +1758,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { vp9_highbd_build_inter_predictor(pd->pre[0].buf, pd->pre[0].stride, pd->dst.buf, pd->dst.stride, - &xd->mi[0].bmi[i].as_mv[0].as_mv, + &xd->mi[0]->bmi[i].as_mv[0].as_mv, &xd->block_refs[0]->sf, 4 * num_4x4_blocks_wide, 4 * num_4x4_blocks_high, 0, @@ -1770,7 +1770,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, #endif vp9_build_inter_predictor(pd->pre[0].buf, pd->pre[0].stride, pd->dst.buf, pd->dst.stride, - &xd->mi[0].bmi[i].as_mv[0].as_mv, + &xd->mi[0]->bmi[i].as_mv[0].as_mv, &xd->block_refs[0]->sf, 4 * num_4x4_blocks_wide, 4 * num_4x4_blocks_high, 0, @@ -1792,7 +1792,7 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, if (this_rdc.rdcost < b_best_rd) { b_best_rd = this_rdc.rdcost; bsi[ref_frame][i].as_mode = this_mode; - bsi[ref_frame][i].as_mv[0].as_mv = xd->mi[0].bmi[i].as_mv[0].as_mv; + bsi[ref_frame][i].as_mv[0].as_mv = xd->mi[0]->bmi[i].as_mv[0].as_mv; } } // mode search @@ -1802,11 +1802,11 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, pd->dst = orig_dst; this_rd += b_best_rd; - xd->mi[0].bmi[i] = bsi[ref_frame][i]; + xd->mi[0]->bmi[i] = bsi[ref_frame][i]; if (num_4x4_blocks_wide > 1) - xd->mi[0].bmi[i + 1] = xd->mi[0].bmi[i]; + xd->mi[0]->bmi[i + 1] = xd->mi[0]->bmi[i]; if (num_4x4_blocks_high > 1) - xd->mi[0].bmi[i + 2] = xd->mi[0].bmi[i]; + xd->mi[0]->bmi[i + 2] = xd->mi[0]->bmi[i]; } } // loop through sub8x8 blocks @@ -1821,15 +1821,15 @@ void vp9_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x, for (idy = 0; idy < 2; idy += num_4x4_blocks_high) { for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) { const int block = idy * 2 + idx; - xd->mi[0].bmi[block] = bsi[best_ref_frame][block]; + xd->mi[0]->bmi[block] = bsi[best_ref_frame][block]; if (num_4x4_blocks_wide > 1) - xd->mi[0].bmi[block + 1] = bsi[best_ref_frame][block]; + xd->mi[0]->bmi[block + 1] = bsi[best_ref_frame][block]; if (num_4x4_blocks_high > 1) - xd->mi[0].bmi[block + 2] = bsi[best_ref_frame][block]; + xd->mi[0]->bmi[block + 2] = bsi[best_ref_frame][block]; } } - mbmi->mode = xd->mi[0].bmi[3].as_mode; - ctx->mic = *(xd->mi[0].src_mi); + mbmi->mode = xd->mi[0]->bmi[3].as_mode; + ctx->mic = *(xd->mi[0]); ctx->skip_txfm[0] = 0; ctx->skip = 0; // Dummy assignment for speed -5. No effect in speed -6. diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c index 29b54b07c..9c08c5c62 100644 --- a/vp9/encoder/vp9_quantize.c +++ b/vp9/encoder/vp9_quantize.c @@ -646,7 +646,7 @@ void vp9_init_plane_quantizers(VP9_COMP *cpi, MACROBLOCK *x) { const VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; QUANTS *const quants = &cpi->quants; - const int segment_id = xd->mi[0].src_mi->mbmi.segment_id; + const int segment_id = xd->mi[0]->mbmi.segment_id; const int qindex = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex); const int rdmult = vp9_compute_rd_mult(cpi, qindex + cm->y_dc_delta_q); int i; diff --git a/vp9/encoder/vp9_rd.c b/vp9/encoder/vp9_rd.c index bbf70ead5..a2a4808da 100644 --- a/vp9/encoder/vp9_rd.c +++ b/vp9/encoder/vp9_rd.c @@ -450,7 +450,7 @@ void vp9_mv_pred(VP9_COMP *cpi, MACROBLOCK *x, uint8_t *ref_y_buffer, int ref_y_stride, int ref_frame, BLOCK_SIZE block_size) { MACROBLOCKD *xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; int i; int zero_seen = 0; int best_index = 0; @@ -550,7 +550,7 @@ YV12_BUFFER_CONFIG *vp9_get_scaled_ref_frame(const VP9_COMP *cpi, } int vp9_get_switchable_rate(const VP9_COMP *cpi, const MACROBLOCKD *const xd) { - const MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const int ctx = vp9_get_pred_context_switchable_interp(xd); return SWITCHABLE_INTERP_RATE_FACTOR * cpi->switchable_interp_costs[ctx][mbmi->interp_filter]; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 166535b8b..56ecd4e0c 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -164,7 +164,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize, int i; int64_t rate_sum = 0; int64_t dist_sum = 0; - const int ref = xd->mi[0].src_mi->mbmi.ref_frame[0]; + const int ref = xd->mi[0]->mbmi.ref_frame[0]; unsigned int sse; unsigned int var = 0; unsigned int sum_sse = 0; @@ -347,7 +347,7 @@ static int cost_coeffs(MACROBLOCK *x, const int16_t *scan, const int16_t *nb, int use_fast_coef_costing) { MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const struct macroblock_plane *p = &x->plane[plane]; const struct macroblockd_plane *pd = &xd->plane[plane]; const PLANE_TYPE type = pd->plane_type; @@ -452,7 +452,7 @@ static void dist_block(int plane, int block, TX_SIZE tx_size, #endif // CONFIG_VP9_HIGHBITDEPTH args->sse = this_sse >> shift; - if (x->skip_encode && !is_inter_block(&xd->mi[0].src_mi->mbmi)) { + if (x->skip_encode && !is_inter_block(&xd->mi[0]->mbmi)) { // TODO(jingning): tune the model to better capture the distortion. int64_t p = (pd->dequant[1] * pd->dequant[1] * (1 << ss_txfrm_size)) >> (shift + 2); @@ -482,7 +482,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize, struct rdcost_block_args *args = arg; MACROBLOCK *const x = args->x; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; int64_t rd1, rd2, rd; if (args->skip) @@ -588,7 +588,7 @@ static void txfm_rd_in_plane(MACROBLOCK *x, args.use_fast_coef_costing = use_fast_coef_casting; if (plane == 0) - xd->mi[0].src_mi->mbmi.tx_size = tx_size; + xd->mi[0]->mbmi.tx_size = tx_size; vp9_get_entropy_contexts(bsize, tx_size, pd, args.t_above, args.t_left); @@ -618,7 +618,7 @@ static void choose_largest_tx_size(VP9_COMP *cpi, MACROBLOCK *x, VP9_COMMON *const cm = &cpi->common; const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; mbmi->tx_size = MIN(max_tx_size, largest_tx_size); @@ -638,7 +638,7 @@ static void choose_tx_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x, const TX_SIZE max_tx_size = max_txsize_lookup[bs]; VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; vp9_prob skip_prob = vp9_get_skip_prob(cm, xd); int r[TX_SIZES][2], s[TX_SIZES]; int64_t d[TX_SIZES], sse[TX_SIZES]; @@ -725,7 +725,7 @@ static void super_block_yrd(VP9_COMP *cpi, MACROBLOCK *x, int *rate, int64_t sse; int64_t *ret_sse = psse ? psse : &sse; - assert(bs == xd->mi[0].src_mi->mbmi.sb_type); + assert(bs == xd->mi[0]->mbmi.sb_type); if (cpi->sf.tx_size_search_method == USE_LARGESTALL || xd->lossless) { vpx_memset(txfm_cache, 0, TX_MODES * sizeof(int64_t)); @@ -792,7 +792,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, vpx_memcpy(ta, a, sizeof(ta)); vpx_memcpy(tl, l, sizeof(tl)); - xd->mi[0].src_mi->mbmi.tx_size = TX_4X4; + xd->mi[0]->mbmi.tx_size = TX_4X4; #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { @@ -824,7 +824,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, block, p->src_diff); tran_low_t *const coeff = BLOCK_OFFSET(x->plane[0].coeff, block); - xd->mi[0].src_mi->bmi[block].as_mode = mode; + xd->mi[0]->bmi[block].as_mode = mode; vp9_predict_intra_block(xd, block, 1, TX_4X4, mode, x->skip_encode ? src : dst, @@ -924,7 +924,7 @@ static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib, int16_t *const src_diff = vp9_raster_block_offset_int16(BLOCK_8X8, block, p->src_diff); tran_low_t *const coeff = BLOCK_OFFSET(x->plane[0].coeff, block); - xd->mi[0].src_mi->bmi[block].as_mode = mode; + xd->mi[0]->bmi[block].as_mode = mode; vp9_predict_intra_block(xd, block, 1, TX_4X4, mode, x->skip_encode ? src : dst, @@ -997,10 +997,10 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP *cpi, MACROBLOCK *mb, int64_t best_rd) { int i, j; const MACROBLOCKD *const xd = &mb->e_mbd; - MODE_INFO *const mic = xd->mi[0].src_mi; + MODE_INFO *const mic = xd->mi[0]; const MODE_INFO *above_mi = xd->above_mi; const MODE_INFO *left_mi = xd->left_mi; - const BLOCK_SIZE bsize = xd->mi[0].src_mi->mbmi.sb_type; + const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize]; const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize]; int idx, idy; @@ -1068,7 +1068,7 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x, PREDICTION_MODE mode; PREDICTION_MODE mode_selected = DC_PRED; MACROBLOCKD *const xd = &x->e_mbd; - MODE_INFO *const mic = xd->mi[0].src_mi; + MODE_INFO *const mic = xd->mi[0]; int this_rate, this_rate_tokenonly, s; int64_t this_distortion, this_rd; TX_SIZE best_tx = TX_4X4; @@ -1143,7 +1143,7 @@ static int super_block_uvrd(const VP9_COMP *cpi, MACROBLOCK *x, int64_t *sse, BLOCK_SIZE bsize, int64_t ref_best_rd) { MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const TX_SIZE uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]); int plane; int pnrate = 0, pnskip = 1; @@ -1206,7 +1206,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x, if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode))) continue; - xd->mi[0].src_mi->mbmi.uv_mode = mode; + xd->mi[0]->mbmi.uv_mode = mode; if (!super_block_uvrd(cpi, x, &this_rate_tokenonly, &this_distortion, &s, &this_sse, bsize, best_rd)) @@ -1227,7 +1227,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x, } } - xd->mi[0].src_mi->mbmi.uv_mode = mode_selected; + xd->mi[0]->mbmi.uv_mode = mode_selected; return best_rd; } @@ -1238,7 +1238,7 @@ static int64_t rd_sbuv_dcpred(const VP9_COMP *cpi, MACROBLOCK *x, const VP9_COMMON *cm = &cpi->common; int64_t unused; - x->e_mbd.mi[0].src_mi->mbmi.uv_mode = DC_PRED; + x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED; vpx_memset(x->skip_txfm, 0, sizeof(x->skip_txfm)); super_block_uvrd(cpi, x, rate_tokenonly, distortion, skippable, &unused, bsize, INT64_MAX); @@ -1264,7 +1264,7 @@ static void choose_intra_uv_mode(VP9_COMP *cpi, MACROBLOCK *const x, rate_uv, rate_uv_tokenonly, dist_uv, skip_uv, bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, max_tx_size); } - *mode_uv = x->e_mbd.mi[0].src_mi->mbmi.uv_mode; + *mode_uv = x->e_mbd.mi[0]->mbmi.uv_mode; } static int cost_mv_ref(const VP9_COMP *cpi, PREDICTION_MODE mode, @@ -1279,7 +1279,7 @@ static int set_and_cost_bmi_mvs(VP9_COMP *cpi, MACROBLOCKD *xd, int i, int_mv seg_mvs[MAX_REF_FRAMES], int_mv *best_ref_mv[2], const int *mvjcost, int *mvcost[2]) { - MODE_INFO *const mic = xd->mi[0].src_mi; + MODE_INFO *const mic = xd->mi[0]; const MB_MODE_INFO *const mbmi = &mic->mbmi; int thismvcost = 0; int idx, idy; @@ -1341,7 +1341,7 @@ static int64_t encode_inter_mb_segment(VP9_COMP *cpi, MACROBLOCKD *xd = &x->e_mbd; struct macroblockd_plane *const pd = &xd->plane[0]; struct macroblock_plane *const p = &x->plane[0]; - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; const BLOCK_SIZE plane_bsize = get_plane_block_size(mi->mbmi.sb_type, pd); const int width = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; const int height = 4 * num_4x4_blocks_high_lookup[plane_bsize]; @@ -1482,7 +1482,7 @@ static INLINE int mv_check_bounds(const MACROBLOCK *x, const MV *mv) { } static INLINE void mi_buf_shift(MACROBLOCK *x, int i) { - MB_MODE_INFO *const mbmi = &x->e_mbd.mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &x->e_mbd.mi[0]->mbmi; struct macroblock_plane *const p = &x->plane[0]; struct macroblockd_plane *const pd = &x->e_mbd.plane[0]; @@ -1498,7 +1498,7 @@ static INLINE void mi_buf_shift(MACROBLOCK *x, int i) { static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src, struct buf_2d orig_pre[2]) { - MB_MODE_INFO *mbmi = &x->e_mbd.mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &x->e_mbd.mi[0]->mbmi; x->plane[0].src = orig_src; x->e_mbd.plane[0].pre[0] = orig_pre[0]; if (has_second_ref(mbmi)) @@ -1556,7 +1556,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x, const int pw = 4 * num_4x4_blocks_wide_lookup[bsize]; const int ph = 4 * num_4x4_blocks_high_lookup[bsize]; MACROBLOCKD *xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int refs[2] = {mbmi->ref_frame[0], mbmi->ref_frame[1] < 0 ? 0 : mbmi->ref_frame[1]}; int_mv ref_mv[2]; @@ -1745,7 +1745,7 @@ static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x, int i; BEST_SEG_INFO *bsi = bsi_buf + filter_idx; MACROBLOCKD *xd = &x->e_mbd; - MODE_INFO *mi = xd->mi[0].src_mi; + MODE_INFO *mi = xd->mi[0]; MB_MODE_INFO *mbmi = &mi->mbmi; int mode_idx; int k, br = 0, idx, idy; @@ -2186,7 +2186,7 @@ static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, ctx->skip = x->skip; ctx->skippable = skippable; ctx->best_mode_index = mode_index; - ctx->mic = *xd->mi[0].src_mi; + ctx->mic = *xd->mi[0]; ctx->single_pred_diff = (int)comp_pred_diff[SINGLE_REFERENCE]; ctx->comp_pred_diff = (int)comp_pred_diff[COMPOUND_REFERENCE]; ctx->hybrid_pred_diff = (int)comp_pred_diff[REFERENCE_MODE_SELECT]; @@ -2207,7 +2207,7 @@ static void setup_buffer_inter(VP9_COMP *cpi, MACROBLOCK *x, const VP9_COMMON *cm = &cpi->common; const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame); MACROBLOCKD *const xd = &x->e_mbd; - MODE_INFO *const mi = xd->mi[0].src_mi; + MODE_INFO *const mi = xd->mi[0]; int_mv *const candidates = mi->mbmi.ref_mvs[ref_frame]; const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf; @@ -2240,7 +2240,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, int_mv *tmp_mv, int *rate_mv) { MACROBLOCKD *xd = &x->e_mbd; const VP9_COMMON *cm = &cpi->common; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}}; int bestsme = INT_MAX; int step_param; @@ -2412,7 +2412,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, int64_t filter_cache[]) { VP9_COMMON *cm = &cpi->common; MACROBLOCKD *xd = &x->e_mbd; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; const int is_comp_pred = has_second_ref(mbmi); const int this_mode = mbmi->mode; int_mv *frame_mv = mode_mv[this_mode]; @@ -2457,9 +2457,9 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, if (pred_filter_search) { INTERP_FILTER af = SWITCHABLE, lf = SWITCHABLE; if (xd->up_available) - af = xd->mi[-xd->mi_stride].src_mi->mbmi.interp_filter; + af = xd->mi[-xd->mi_stride]->mbmi.interp_filter; if (xd->left_available) - lf = xd->mi[-1].src_mi->mbmi.interp_filter; + lf = xd->mi[-1]->mbmi.interp_filter; if ((this_mode != NEWMV) || (af == lf)) best_filter = af; @@ -2504,7 +2504,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, return INT64_MAX; frame_mv[refs[0]].as_int = - xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = tmp_mv.as_int; + xd->mi[0]->bmi[0].as_mv[0].as_int = tmp_mv.as_int; single_newmv[refs[0]].as_int = tmp_mv.as_int; // Estimate the rate implications of a new mv but discount this @@ -2782,8 +2782,8 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, TX_SIZE max_uv_tx_size; x->skip_encode = 0; ctx->skip = 0; - xd->mi[0].src_mi->mbmi.ref_frame[0] = INTRA_FRAME; - xd->mi[0].src_mi->mbmi.ref_frame[1] = NONE; + xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME; + xd->mi[0]->mbmi.ref_frame[1] = NONE; if (bsize >= BLOCK_8X8) { if (rd_pick_intra_sby_mode(cpi, x, &rate_y, &rate_y_tokenonly, @@ -2800,7 +2800,7 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, return; } } - max_uv_tx_size = get_uv_tx_size_impl(xd->mi[0].src_mi->mbmi.tx_size, bsize, + max_uv_tx_size = get_uv_tx_size_impl(xd->mi[0]->mbmi.tx_size, bsize, pd[1].subsampling_x, pd[1].subsampling_y); rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv, &rate_uv_tokenonly, @@ -2826,7 +2826,7 @@ void vp9_rd_pick_intra_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, } } - ctx->mic = *xd->mi[0].src_mi; + ctx->mic = *xd->mi[0]; rd_cost->rdcost = RDCOST(x->rdmult, x->rddiv, rd_cost->rate, rd_cost->dist); } @@ -2901,7 +2901,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, RD_OPT *const rd_opt = &cpi->rd; SPEED_FEATURES *const sf = &cpi->sf; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const struct segmentation *const seg = &cm->seg; PREDICTION_MODE this_mode; MV_REFERENCE_FRAME ref_frame, second_ref_frame; @@ -3150,10 +3150,10 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, ref_mv.as_int = INVALID_MV; if ((mi_row - 1) >= tile_info->mi_row_start) { - ref_mv = xd->mi[-xd->mi_stride].src_mi->mbmi.mv[0]; - rf = xd->mi[-xd->mi_stride].src_mi->mbmi.ref_frame[0]; + ref_mv = xd->mi[-xd->mi_stride]->mbmi.mv[0]; + rf = xd->mi[-xd->mi_stride]->mbmi.ref_frame[0]; for (i = 0; i < mi_width; ++i) { - ref_mbmi = &xd->mi[-xd->mi_stride + i].src_mi->mbmi; + ref_mbmi = &xd->mi[-xd->mi_stride + i]->mbmi; const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) && (ref_frame == ref_mbmi->ref_frame[0]); skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]); @@ -3162,11 +3162,11 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, if ((mi_col - 1) >= tile_info->mi_col_start) { if (ref_mv.as_int == INVALID_MV) - ref_mv = xd->mi[-1].src_mi->mbmi.mv[0]; + ref_mv = xd->mi[-1]->mbmi.mv[0]; if (rf == NONE) - rf = xd->mi[-1].src_mi->mbmi.ref_frame[0]; + rf = xd->mi[-1]->mbmi.ref_frame[0]; for (i = 0; i < mi_height; ++i) { - ref_mbmi = &xd->mi[i * xd->mi_stride - 1].src_mi->mbmi; + ref_mbmi = &xd->mi[i * xd->mi_stride - 1]->mbmi; const_motion &= (ref_mv.as_int == ref_mbmi->mv[0].as_int) && (ref_frame == ref_mbmi->ref_frame[0]); skip_ref_frame &= (rf == ref_mbmi->ref_frame[0]); @@ -3580,7 +3580,7 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, if (!x->skip && !x->select_tx_size) { int has_high_freq_coeff = 0; int plane; - int max_plane = is_inter_block(&xd->mi[0].src_mi->mbmi) + int max_plane = is_inter_block(&xd->mi[0]->mbmi) ? MAX_MB_PLANE : 1; for (plane = 0; plane < max_plane; ++plane) { x->plane[plane].eobs = ctx->eobs_pbuf[plane][1]; @@ -3610,7 +3610,7 @@ void vp9_rd_pick_inter_mode_sb_seg_skip(VP9_COMP *cpi, int64_t best_rd_so_far) { VP9_COMMON *const cm = &cpi->common; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; unsigned char segment_id = mbmi->segment_id; const int comp_pred = 0; int i; @@ -3716,7 +3716,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, RD_OPT *const rd_opt = &cpi->rd; SPEED_FEATURES *const sf = &cpi->sf; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const struct segmentation *const seg = &cm->seg; MV_REFERENCE_FRAME ref_frame, second_ref_frame; unsigned char segment_id = mbmi->segment_id; @@ -4007,7 +4007,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, tmp_best_skippable = skippable; tmp_best_mbmode = *mbmi; for (i = 0; i < 4; i++) { - tmp_best_bmodes[i] = xd->mi[0].src_mi->bmi[i]; + tmp_best_bmodes[i] = xd->mi[0]->bmi[i]; x->zcoeff_blk[TX_4X4][i] = !x->plane[0].eobs[i]; } pred_exists = 1; @@ -4051,7 +4051,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, skippable = tmp_best_skippable; *mbmi = tmp_best_mbmode; for (i = 0; i < 4; i++) - xd->mi[0].src_mi->bmi[i] = tmp_best_bmodes[i]; + xd->mi[0]->bmi[i] = tmp_best_bmodes[i]; } rate2 += rate; @@ -4160,7 +4160,7 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, sizeof(uint8_t) * ctx->num_4x4_blk); for (i = 0; i < 4; i++) - best_bmodes[i] = xd->mi[0].src_mi->bmi[i]; + best_bmodes[i] = xd->mi[0]->bmi[i]; // TODO(debargha): enhance this test with a better distortion prediction // based on qp, activity mask and history @@ -4278,14 +4278,14 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, x->skip |= best_skip2; if (!is_inter_block(&best_mbmode)) { for (i = 0; i < 4; i++) - xd->mi[0].src_mi->bmi[i].as_mode = best_bmodes[i].as_mode; + xd->mi[0]->bmi[i].as_mode = best_bmodes[i].as_mode; } else { for (i = 0; i < 4; ++i) - vpx_memcpy(&xd->mi[0].src_mi->bmi[i], &best_bmodes[i], + vpx_memcpy(&xd->mi[0]->bmi[i], &best_bmodes[i], sizeof(b_mode_info)); - mbmi->mv[0].as_int = xd->mi[0].src_mi->bmi[3].as_mv[0].as_int; - mbmi->mv[1].as_int = xd->mi[0].src_mi->bmi[3].as_mv[1].as_int; + mbmi->mv[0].as_int = xd->mi[0]->bmi[3].as_mv[0].as_int; + mbmi->mv[1].as_int = xd->mi[0]->bmi[3].as_mv[1].as_int; } for (i = 0; i < REFERENCE_MODES; ++i) { diff --git a/vp9/encoder/vp9_segmentation.c b/vp9/encoder/vp9_segmentation.c index c9874f7c6..f66de5174 100644 --- a/vp9/encoder/vp9_segmentation.c +++ b/vp9/encoder/vp9_segmentation.c @@ -107,7 +107,7 @@ static int cost_segmap(int *segcounts, vp9_prob *probs) { } static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, - const TileInfo *tile, MODE_INFO *mi, + const TileInfo *tile, MODE_INFO **mi, int *no_pred_segcounts, int (*temporal_predictor_count)[2], int *t_unpred_seg_counts, @@ -118,7 +118,7 @@ static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, return; xd->mi = mi; - segment_id = xd->mi[0].src_mi->mbmi.segment_id; + segment_id = xd->mi[0]->mbmi.segment_id; set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols); @@ -127,7 +127,7 @@ static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, // Temporal prediction not allowed on key frames if (cm->frame_type != KEY_FRAME) { - const BLOCK_SIZE bsize = xd->mi[0].src_mi->mbmi.sb_type; + const BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; // Test to see if the segment id matches the predicted value. const int pred_segment_id = vp9_get_segment_id(cm, cm->last_frame_seg_map, bsize, mi_row, mi_col); @@ -136,7 +136,7 @@ static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, // Store the prediction status for this mb and update counts // as appropriate - xd->mi[0].src_mi->mbmi.seg_id_predicted = pred_flag; + xd->mi[0]->mbmi.seg_id_predicted = pred_flag; temporal_predictor_count[pred_context][pred_flag]++; // Update the "unpredicted" segment count @@ -146,7 +146,7 @@ static void count_segs(const VP9_COMMON *cm, MACROBLOCKD *xd, } static void count_segs_sb(const VP9_COMMON *cm, MACROBLOCKD *xd, - const TileInfo *tile, MODE_INFO *mi, + const TileInfo *tile, MODE_INFO **mi, int *no_pred_segcounts, int (*temporal_predictor_count)[2], int *t_unpred_seg_counts, @@ -159,8 +159,8 @@ static void count_segs_sb(const VP9_COMMON *cm, MACROBLOCKD *xd, if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return; - bw = num_8x8_blocks_wide_lookup[mi[0].src_mi->mbmi.sb_type]; - bh = num_8x8_blocks_high_lookup[mi[0].src_mi->mbmi.sb_type]; + bw = num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type]; + bh = num_8x8_blocks_high_lookup[mi[0]->mbmi.sb_type]; if (bw == bs && bh == bs) { count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count, @@ -220,13 +220,13 @@ void vp9_choose_segmap_coding_method(VP9_COMMON *cm, MACROBLOCKD *xd) { // predicts this one for (tile_col = 0; tile_col < 1 << cm->log2_tile_cols; tile_col++) { TileInfo tile; - MODE_INFO *mi_ptr; + MODE_INFO **mi_ptr; vp9_tile_init(&tile, cm, 0, tile_col); - mi_ptr = cm->mi + tile.mi_col_start; + mi_ptr = cm->mi_grid_visible + tile.mi_col_start; for (mi_row = 0; mi_row < cm->mi_rows; mi_row += 8, mi_ptr += 8 * cm->mi_stride) { - MODE_INFO *mi = mi_ptr; + MODE_INFO **mi = mi_ptr; for (mi_col = tile.mi_col_start; mi_col < tile.mi_col_end; mi_col += 8, mi += 8) count_segs_sb(cm, xd, &tile, mi, no_pred_segcounts, diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index 424cc0843..e62e4abe8 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -44,7 +44,7 @@ static void temporal_filter_predictors_mb_c(MACROBLOCKD *xd, const int which_mv = 0; const MV mv = { mv_row, mv_col }; const InterpKernel *const kernel = - vp9_get_interp_kernel(xd->mi[0].src_mi->mbmi.interp_filter); + vp9_get_interp_kernel(xd->mi[0]->mbmi.interp_filter); enum mv_precision mv_precision_uv; int uv_stride; @@ -225,7 +225,7 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, MV best_ref_mv1 = {0, 0}; MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */ - MV *ref_mv = &x->e_mbd.mi[0].src_mi->bmi[0].as_mv[0].as_mv; + MV *ref_mv = &x->e_mbd.mi[0]->bmi[0].as_mv[0].as_mv; // Save input state struct buf_2d src = x->plane[0].src; @@ -343,8 +343,8 @@ static void temporal_filter_iterate_c(VP9_COMP *cpi, if (frames[frame] == NULL) continue; - mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.row = 0; - mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.col = 0; + mbd->mi[0]->bmi[0].as_mv[0].as_mv.row = 0; + mbd->mi[0]->bmi[0].as_mv[0].as_mv.col = 0; if (frame == alt_ref_index) { filter_weight = 2; @@ -370,8 +370,8 @@ static void temporal_filter_iterate_c(VP9_COMP *cpi, frames[frame]->v_buffer + mb_uv_offset, frames[frame]->y_stride, mb_uv_width, mb_uv_height, - mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.row, - mbd->mi[0].src_mi->bmi[0].as_mv[0].as_mv.col, + mbd->mi[0]->bmi[0].as_mv[0].as_mv.row, + mbd->mi[0]->bmi[0].as_mv[0].as_mv.col, predictor, scale, mb_col * 16, mb_row * 16); @@ -722,8 +722,8 @@ void vp9_temporal_filter(VP9_COMP *cpi, int distance) { } } cm->mi = cm->mip + cm->mi_stride + 1; - xd->mi = cm->mi; - xd->mi[0].src_mi = &xd->mi[0]; + xd->mi = cm->mi_grid_visible; + xd->mi[0] = cm->mi; } else { // ARF is produced at the native frame size and resized when coded. #if CONFIG_VP9_HIGHBITDEPTH diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 9d2595b13..862be4d38 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -497,7 +497,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize, uint8_t token_cache[32 * 32]; struct macroblock_plane *p = &x->plane[plane]; struct macroblockd_plane *pd = &xd->plane[plane]; - MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; int pt; /* near block/prev token context index */ int c; TOKENEXTRA *t = *tp; /* store tokens starting here */ @@ -612,7 +612,7 @@ void vp9_tokenize_sb(VP9_COMP *cpi, ThreadData *td, TOKENEXTRA **t, VP9_COMMON *const cm = &cpi->common; MACROBLOCK *const x = &td->mb; MACROBLOCKD *const xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; + MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const int ctx = vp9_get_skip_context(xd); const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP);