Commit ac6093d1 authored by Scott LaVarnway's avatar Scott LaVarnway

New mode_info_context storage -- undo revert

mode_info_context was stored as a grid of MODE_INFO structs.
The grid now constists of pointers to MODE_INFO structs.  The
MODE_INFO structs are now stored as a stream (decoder only),
eliminating unnecessary copies and is a little more cache
friendly.

Change-Id: I031d376284c6eb98a38ad5595b797f048a6cfc0d
parent 0607abc3
......@@ -31,22 +31,6 @@ void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi) {
vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO));
}
void vp9_update_mode_info_in_image(VP9_COMMON *cm, MODE_INFO *mi) {
int i, j;
// For each in image mode_info element set the in image flag to 1
for (i = 0; i < cm->mi_rows; i++) {
MODE_INFO *ptr = mi;
for (j = 0; j < cm->mi_cols; j++) {
ptr->mbmi.in_image = 1;
ptr++; // Next element in the row
}
// Step over border element at start of next row
mi += cm->mode_info_stride;
}
}
void vp9_free_frame_buffers(VP9_COMMON *cm) {
int i;
......@@ -59,6 +43,8 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) {
vpx_free(cm->prev_mip);
vpx_free(cm->above_seg_context);
vpx_free(cm->last_frame_seg_map);
vpx_free(cm->mi_grid_base);
vpx_free(cm->prev_mi_grid_base);
vpx_free(cm->above_context[0]);
for (i = 0; i < MAX_MB_PLANE; i++)
......@@ -67,6 +53,8 @@ void vp9_free_frame_buffers(VP9_COMMON *cm) {
cm->prev_mip = NULL;
cm->above_seg_context = NULL;
cm->last_frame_seg_map = NULL;
cm->mi_grid_base = NULL;
cm->prev_mi_grid_base = NULL;
}
static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) {
......@@ -82,15 +70,18 @@ static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) {
static void setup_mi(VP9_COMMON *cm) {
cm->mi = cm->mip + cm->mode_info_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1;
vpx_memset(cm->mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_in_image(cm, cm->mi);
vpx_memset(cm->mi_grid_base, 0,
cm->mode_info_stride * (cm->mi_rows + 1) *
sizeof(*cm->mi_grid_base));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_border(cm, cm->prev_mip);
vp9_update_mode_info_in_image(cm, cm->prev_mi);
}
int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
......@@ -139,6 +130,14 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
if (!cm->prev_mip)
goto fail;
cm->mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->mi_grid_base));
if (!cm->mi_grid_base)
goto fail;
cm->prev_mi_grid_base = vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base));
if (!cm->prev_mi_grid_base)
goto fail;
setup_mi(cm);
// FIXME(jkoleszar): allocate subsampled arrays for U/V once subsampling
......
......@@ -17,7 +17,6 @@
void vp9_initialize_common();
void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi);
void vp9_update_mode_info_in_image(VP9_COMMON *cm, MODE_INFO *mi);
void vp9_create_common(VP9_COMMON *cm);
void vp9_remove_common(VP9_COMMON *cm);
......
......@@ -147,10 +147,6 @@ typedef struct {
// Flags used for prediction status of various bit-stream signals
unsigned char seg_id_predicted;
// Indicates if the block is part of the image (1) vs border (0)
// This can be useful in determining whether it provides a valid predictor
unsigned char in_image;
INTERPOLATIONFILTERTYPE interp_filter;
BLOCK_SIZE sb_type;
......@@ -206,10 +202,16 @@ typedef struct macroblockd {
struct scale_factors scale_factor[2];
MODE_INFO *prev_mode_info_context;
MODE_INFO *mode_info_context;
MODE_INFO *last_mi;
MODE_INFO *this_mi;
int mode_info_stride;
MODE_INFO *mic_stream_ptr;
// A NULL indicates that the 8x8 is not part of the image
MODE_INFO **mi_8x8;
MODE_INFO **prev_mi_8x8;
int up_available;
int left_available;
int right_available;
......@@ -319,7 +321,7 @@ extern const TX_TYPE mode2txfm_map[MB_MODE_COUNT];
static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
const MACROBLOCKD *xd, int ib) {
const MODE_INFO *const mi = xd->mode_info_context;
const MODE_INFO *const mi = xd->this_mi;
const MB_MODE_INFO *const mbmi = &mi->mbmi;
if (plane_type != PLANE_TYPE_Y_WITH_DC ||
......@@ -334,13 +336,13 @@ static INLINE TX_TYPE get_tx_type_4x4(PLANE_TYPE plane_type,
static INLINE TX_TYPE get_tx_type_8x8(PLANE_TYPE plane_type,
const MACROBLOCKD *xd) {
return plane_type == PLANE_TYPE_Y_WITH_DC ?
mode2txfm_map[xd->mode_info_context->mbmi.mode] : DCT_DCT;
mode2txfm_map[xd->this_mi->mbmi.mode] : DCT_DCT;
}
static INLINE TX_TYPE get_tx_type_16x16(PLANE_TYPE plane_type,
const MACROBLOCKD *xd) {
return plane_type == PLANE_TYPE_Y_WITH_DC ?
mode2txfm_map[xd->mode_info_context->mbmi.mode] : DCT_DCT;
mode2txfm_map[xd->this_mi->mbmi.mode] : DCT_DCT;
}
static void setup_block_dptrs(MACROBLOCKD *xd, int ss_x, int ss_y) {
......@@ -389,7 +391,7 @@ static INLINE void 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->mode_info_context->mbmi;
const MB_MODE_INFO* mbmi = &xd->this_mi->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.
......
......@@ -27,7 +27,7 @@ static void print_mi_data(VP9_COMMON *cm, FILE *file, char *descriptor,
int mi_row;
int mi_col;
int mi_index = 0;
MODE_INFO *mi = cm->mi;
MODE_INFO **mi_8x8 = cm->mi_grid_visible;
int rows = cm->mi_rows;
int cols = cm->mi_cols;
char prefix = descriptor[0];
......@@ -38,7 +38,8 @@ static void print_mi_data(VP9_COMMON *cm, FILE *file, char *descriptor,
fprintf(file, "%c ", prefix);
for (mi_col = 0; mi_col < cols; mi_col++) {
fprintf(file, "%2d ",
*((int*) ((char *) (&mi[mi_index].mbmi) + member_offset)));
*((int*) ((char *) (&mi_8x8[mi_index]->mbmi) +
member_offset)));
mi_index++;
}
fprintf(file, "\n");
......@@ -51,7 +52,7 @@ void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, char *file) {
int mi_col;
int mi_index = 0;
FILE *mvs = fopen(file, "a");
MODE_INFO *mi = cm->mi;
MODE_INFO **mi_8x8 = cm->mi_grid_visible;
int rows = cm->mi_rows;
int cols = cm->mi_cols;
......@@ -66,8 +67,8 @@ void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, 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[mi_index].mbmi.mv[0].as_mv.row,
mi[mi_index].mbmi.mv[0].as_mv.col);
fprintf(mvs, "%4d:%4d ", mi_8x8[mi_index]->mbmi.mv[0].as_mv.row,
mi_8x8[mi_index]->mbmi.mv[0].as_mv.col);
mi_index++;
}
fprintf(mvs, "\n");
......
......@@ -510,10 +510,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm) {
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_in_image(cm, cm->mi);
vp9_update_mode_info_border(cm, cm->prev_mip);
vp9_update_mode_info_in_image(cm, cm->prev_mi);
vp9_zero(cm->ref_frame_sign_bias);
......
......@@ -43,12 +43,12 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int mi_col) {
int_mv dst_list[MAX_MV_REF_CANDIDATES];
int_mv mv_list[MAX_MV_REF_CANDIDATES];
MODE_INFO *const mi = xd->mode_info_context;
MODE_INFO *const mi = xd->this_mi;
assert(ref_idx == 0 || ref_idx == 1);
assert(MAX_MV_REF_CANDIDATES == 2); // makes code here slightly easier
vp9_find_mv_refs_idx(cm, xd, mi, xd->prev_mode_info_context,
vp9_find_mv_refs_idx(cm, xd, mi, xd->last_mi,
mi->mbmi.ref_frame[ref_idx],
mv_list, block_idx, mi_row, mi_col);
......
......@@ -43,41 +43,50 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm,
int block_idx, int ref_idx,
int mi_row, int mi_col);
static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) {
static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb,
const MODE_INFO *left_mb, int b) {
// FIXME(rbultje, jingning): temporary hack because jenkins doesn't
// understand this condition. This will go away soon.
const MODE_INFO *mi = cur_mb;
if (b == 0 || b == 2) {
/* On L edge, get from MB to left of us */
--cur_mb;
mi = left_mb;
if (!mi)
return DC_PRED;
if (is_inter_block(&cur_mb->mbmi)) {
if (mi->mbmi.ref_frame[0] != INTRA_FRAME) {
return DC_PRED;
} else if (cur_mb->mbmi.sb_type < BLOCK_8X8) {
return (cur_mb->bmi + 1 + b)->as_mode;
} else if (mi->mbmi.sb_type < BLOCK_8X8) {
return ((mi->bmi + 1 + b)->as_mode);
} else {
return cur_mb->mbmi.mode;
return mi->mbmi.mode;
}
}
assert(b == 1 || b == 3);
return (cur_mb->bmi + b - 1)->as_mode;
return (mi->bmi + b - 1)->as_mode;
}
static MB_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb,
int b, int mi_stride) {
const MODE_INFO *above_mb, int b) {
const MODE_INFO *mi = cur_mb;
if (!(b >> 1)) {
/* On top edge, get from MB above us */
cur_mb -= mi_stride;
mi = above_mb;
if (!mi)
return DC_PRED;
if (is_inter_block(&cur_mb->mbmi)) {
if (mi->mbmi.ref_frame[0] != INTRA_FRAME) {
return DC_PRED;
} else if (cur_mb->mbmi.sb_type < BLOCK_8X8) {
return (cur_mb->bmi + 2 + b)->as_mode;
} else if (mi->mbmi.sb_type < BLOCK_8X8) {
return ((mi->bmi + 2 + b)->as_mode);
} else {
return cur_mb->mbmi.mode;
return mi->mbmi.mode;
}
}
return (cur_mb->bmi + b - 2)->as_mode;
return (mi->bmi + b - 2)->as_mode;
}
#endif // VP9_COMMON_VP9_FINDNEARMV_H_
This diff is collapsed.
/*
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
*
......@@ -203,8 +204,8 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
const MV *const mv_ref = &mv_ref_search[i];
if (is_inside(cm, mi_col, mi_row, mv_ref)) {
const int check_sub_blocks = block_idx >= 0;
const MODE_INFO *const candidate_mi = &mi[mv_ref->col + mv_ref->row
* xd->mode_info_stride];
const MODE_INFO *const candidate_mi = xd->mi_8x8[mv_ref->col + mv_ref->row
* xd->mode_info_stride];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
// Keep counts for entropy encoding.
context_counter += mode_2_counter[candidate->mode];
......@@ -230,8 +231,9 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
for (; i < MVREF_NEIGHBOURS; ++i) {
const MV *const mv_ref = &mv_ref_search[i];
if (is_inside(cm, mi_col, mi_row, mv_ref)) {
const MB_MODE_INFO *const candidate = &mi[mv_ref->col + mv_ref->row
* xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const candidate = &xd->mi_8x8[mv_ref->col +
mv_ref->row
* xd->mode_info_stride]->mbmi;
if (candidate->ref_frame[0] == ref_frame) {
ADD_MV_REF_LIST(candidate->mv[0]);
......@@ -259,8 +261,9 @@ void vp9_find_mv_refs_idx(const VP9_COMMON *cm, const MACROBLOCKD *xd,
for (i = 0; i < MVREF_NEIGHBOURS; ++i) {
const MV *mv_ref = &mv_ref_search[i];
if (is_inside(cm, mi_col, mi_row, mv_ref)) {
const MB_MODE_INFO *const candidate = &mi[mv_ref->col + mv_ref->row
* xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const candidate = &xd->mi_8x8[mv_ref->col +
mv_ref->row
* xd->mode_info_stride]->mbmi;
// If the candidate is INTRA we don't want to consider its mv.
if (is_inter_block(candidate))
......
......@@ -164,6 +164,10 @@ typedef struct VP9Common {
MODE_INFO *prev_mip; /* MODE_INFO array 'mip' from last decoded frame */
MODE_INFO *prev_mi; /* 'mi' from last frame (points into prev_mip) */
MODE_INFO **mi_grid_base;
MODE_INFO **mi_grid_visible;
MODE_INFO **prev_mi_grid_base;
MODE_INFO **prev_mi_grid_visible;
// Persistent mb segment id map used in prediction.
unsigned char *last_frame_seg_map;
......
This diff is collapsed.
......@@ -19,12 +19,12 @@ int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const MODE_INFO * const above_mi = xd->mi_8x8[-xd->mode_info_stride];
const MODE_INFO * const left_mi = xd->mi_8x8[-1];
const int above_sip = above_mi ? above_mi->mbmi.seg_id_predicted : 0;
const int left_sip = left_mi ? left_mi->mbmi.seg_id_predicted : 0;
return above_mbmi->seg_id_predicted +
(xd->left_available ? left_mbmi->seg_id_predicted : 0);
return above_sip + (xd->left_available ? left_sip : 0);
}
static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg,
......@@ -32,16 +32,15 @@ static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg,
return seg->pred_probs[vp9_get_pred_context_seg_id(xd)];
}
void vp9_set_pred_flag_seg_id(VP9_COMMON *cm, BLOCK_SIZE bsize,
int mi_row, int mi_col, uint8_t pred_flag);
void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag);
static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const MODE_INFO * const above_mi = xd->mi_8x8[-xd->mode_info_stride];
const MODE_INFO * const left_mi = xd->mi_8x8[-1];
const int above_skip_coeff = above_mi ? above_mi->mbmi.skip_coeff : 0;
const int left_skip_coeff = left_mi ? left_mi->mbmi.skip_coeff : 0;
return above_mbmi->skip_coeff +
(xd->left_available ? left_mbmi->skip_coeff : 0);
return above_skip_coeff + (xd->left_available ? left_skip_coeff : 0);
}
static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
......@@ -50,11 +49,11 @@ static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
}
static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) {
return xd->mode_info_context->mbmi.skip_coeff;
return xd->this_mi->mbmi.skip_coeff;
}
void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE bsize,
int mi_row, int mi_col, uint8_t pred_flag);
void vp9_set_pred_flag_mbskip(MACROBLOCKD *xd, BLOCK_SIZE bsize,
uint8_t pred_flag);
unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd);
......@@ -114,8 +113,9 @@ static const vp9_prob *get_tx_probs(BLOCK_SIZE bsize, uint8_t context,
}
static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd,
const struct tx_probs *tx_probs) {
const BLOCK_SIZE bsize = xd->mode_info_context->mbmi.sb_type;
const struct tx_probs *tx_probs,
const MODE_INFO *m) {
const BLOCK_SIZE bsize = m->mbmi.sb_type;
const int context = vp9_get_pred_context_tx_size(xd);
return get_tx_probs(bsize, context, tx_probs);
}
......
......@@ -24,11 +24,13 @@
void vp9_setup_interp_filters(MACROBLOCKD *xd,
INTERPOLATIONFILTERTYPE mcomp_filter_type,
VP9_COMMON *cm) {
if (xd->mode_info_context) {
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
if (xd->mi_8x8 && xd->this_mi) {
MB_MODE_INFO * mbmi = &xd->this_mi->mbmi;
set_scale_factors(xd, mbmi->ref_frame[0] - 1, mbmi->ref_frame[1] - 1,
cm->active_ref_scale);
} else {
set_scale_factors(xd, -1, -1, cm->active_ref_scale);
}
switch (mcomp_filter_type) {
......@@ -128,7 +130,7 @@ static void build_inter_predictors(int plane, int block, BLOCK_SIZE bsize,
const int bh = plane_block_height(bsize, pd);
const int x = 4 * (block & ((1 << bwl) - 1));
const int y = 4 * (block >> bwl);
const MODE_INFO *const mi = xd->mode_info_context;
const MODE_INFO *mi = xd->this_mi;
const int use_second_ref = mi->mbmi.ref_frame[1] > 0;
int ref;
......@@ -193,7 +195,7 @@ static INLINE void foreach_predicted_block_in_plane(
// size of the predictor to use.
int pred_w, pred_h;
if (xd->mode_info_context->mbmi.sb_type < BLOCK_8X8) {
if (xd->this_mi->mbmi.sb_type < BLOCK_8X8) {
assert(bsize == BLOCK_8X8);
pred_w = 0;
pred_h = 0;
......
......@@ -95,7 +95,7 @@ static int read_intra_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r) {
MACROBLOCKD *const xd = &pbi->mb;
struct segmentation *const seg = &pbi->common.seg;
const BLOCK_SIZE bsize = xd->mode_info_context->mbmi.sb_type;
const BLOCK_SIZE bsize = xd->this_mi->mbmi.sb_type;
int segment_id;
if (!seg->enabled)
......@@ -114,7 +114,7 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
struct segmentation *const seg = &cm->seg;
const BLOCK_SIZE bsize = xd->mode_info_context->mbmi.sb_type;
const BLOCK_SIZE bsize = xd->this_mi->mbmi.sb_type;
int pred_segment_id, segment_id;
if (!seg->enabled)
......@@ -128,7 +128,7 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
if (seg->temporal_update) {
const vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
const int pred_flag = vp9_read(r, pred_prob);
vp9_set_pred_flag_seg_id(cm, bsize, mi_row, mi_col, pred_flag);
vp9_set_pred_flag_seg_id(xd, pred_flag);
segment_id = pred_flag ? pred_segment_id
: read_segment_id(r, seg);
} else {
......@@ -156,7 +156,8 @@ static void read_intra_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &m->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type;
const int mis = cm->mode_info_stride;
const MODE_INFO *above_mi = xd->mi_8x8[-cm->mode_info_stride];
const MODE_INFO *left_mi = xd->mi_8x8[-1];
mbmi->segment_id = read_intra_segment_id(pbi, mi_row, mi_col, r);
mbmi->skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
......@@ -165,9 +166,9 @@ static void read_intra_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
mbmi->ref_frame[1] = NONE;
if (bsize >= BLOCK_8X8) {
const MB_PREDICTION_MODE A = above_block_mode(m, 0, mis);
const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, 0);
const MB_PREDICTION_MODE L = xd->left_available ?
left_block_mode(m, 0) : DC_PRED;
left_block_mode(m, left_mi, 0) : DC_PRED;
mbmi->mode = read_intra_mode(r, vp9_kf_y_mode_prob[A][L]);
} else {
// Only 4x4, 4x8, 8x4 blocks
......@@ -178,9 +179,9 @@ static void read_intra_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) {
const int ib = idy * 2 + idx;
const MB_PREDICTION_MODE A = above_block_mode(m, ib, mis);
const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, ib);
const MB_PREDICTION_MODE L = (xd->left_available || idx) ?
left_block_mode(m, ib) : DC_PRED;
left_block_mode(m, left_mi, ib) : DC_PRED;
const MB_PREDICTION_MODE b_mode = read_intra_mode(r,
vp9_kf_y_mode_prob[A][L]);
m->bmi[ib].as_mode = b_mode;
......@@ -453,8 +454,8 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
ref0 = mbmi->ref_frame[0];
is_compound = has_second_ref(mbmi);
vp9_find_mv_refs(cm, xd, mi, xd->prev_mode_info_context,
ref0, mbmi->ref_mvs[ref0], mi_row, mi_col);
vp9_find_mv_refs(cm, xd, mi, xd->last_mi, ref0, mbmi->ref_mvs[ref0],
mi_row, mi_col);
inter_mode_ctx = mbmi->mode_context[ref0];
......@@ -474,7 +475,7 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
if (is_compound) {
const MV_REFERENCE_FRAME ref1 = mbmi->ref_frame[1];
vp9_find_mv_refs(cm, xd, mi, xd->prev_mode_info_context,
vp9_find_mv_refs(cm, xd, mi, xd->last_mi,
ref1, mbmi->ref_mvs[ref1], mi_row, mi_col);
if (bsize < BLOCK_8X8 || mbmi->mode != ZEROMV) {
......@@ -669,20 +670,21 @@ void vp9_prepare_read_mode_info(VP9D_COMP* pbi, vp9_reader *r) {
void vp9_read_mode_info(VP9D_COMP* pbi, int mi_row, int mi_col, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MODE_INFO *mi = xd->mode_info_context;
MODE_INFO *mi = xd->this_mi;
const BLOCK_SIZE bsize = mi->mbmi.sb_type;
const int bw = 1 << mi_width_log2(bsize);
const int bh = 1 << mi_height_log2(bsize);
const int y_mis = MIN(bh, cm->mi_rows - mi_row);
const int x_mis = MIN(bw, cm->mi_cols - mi_col);
int x, y;
int x, y, z;
if (cm->frame_type == KEY_FRAME || cm->intra_only)
read_intra_frame_mode_info(pbi, mi, mi_row, mi_col, r);
else
read_inter_frame_mode_info(pbi, mi, mi_row, mi_col, r);
for (y = 0; y < y_mis; y++)
for (x = !y; x < x_mis; x++)
mi[y * cm->mode_info_stride + x] = *mi;
for (y = 0, z = 0; y < y_mis; y++, z += cm->mode_info_stride)
for (x = !y; x < x_mis; x++) {
xd->mi_8x8[z + x] = mi;
}
}
......@@ -80,6 +80,7 @@ static void read_tx_probs(struct tx_probs *tx_probs, vp9_reader *r) {
static void setup_plane_dequants(VP9_COMMON *cm, MACROBLOCKD *xd, int q_index) {
int i;
xd->plane[0].dequant = cm->y_dequant[q_index];
for (i = 1; i < MAX_MB_PLANE; i++)
xd->plane[i].dequant = cm->uv_dequant[q_index];
}
......@@ -124,7 +125,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, void *arg) {
MACROBLOCKD* const xd = arg;
struct macroblockd_plane *const pd = &xd->plane[plane];
MODE_INFO *const mi = xd->mode_info_context;
MODE_INFO *const mi = xd->this_mi;
const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
block);
uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block,
......@@ -148,7 +149,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE bsize, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi;
if (mbmi->skip_coeff) {
reset_skip_context(xd, bsize);
......@@ -171,12 +172,20 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int offset = mi_row * cm->mode_info_stride + mi_col;
xd->mode_info_context = cm->mi + offset;
xd->mode_info_context->mbmi.sb_type = bsize;
xd->mode_info_stride = cm->mode_info_stride;
xd->mi_8x8 = cm->mi_grid_visible + offset;
xd->prev_mi_8x8 = cm->prev_mi_grid_visible + offset;
// we are using the mode info context stream here
xd->this_mi =
xd->mi_8x8[0] = xd->mic_stream_ptr;
xd->this_mi->mbmi.sb_type = bsize;
xd->mic_stream_ptr++;
// Special case: if prev_mi is NULL, the previous mode info context
// cannot be used.
xd->prev_mode_info_context = cm->prev_mi ? cm->prev_mi + offset : NULL;
xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL;
set_skip_context(cm, xd, mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
......@@ -191,7 +200,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize,
static void set_ref(VP9D_COMP *pbi, int i, int mi_row, int mi_col) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
MB_MODE_INFO *const mbmi = &xd->this_mi->mbmi;
const int ref = mbmi->ref_frame[i] - LAST_FRAME;
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]];
const struct scale_factors *sf = &cm->active_ref_scale[ref];
......@@ -222,7 +231,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
bsize = BLOCK_8X8;
// Has to be called after set_offsets
mbmi = &xd->mode_info_context->mbmi;
mbmi = &xd->this_mi->mbmi;
if (!is_inter_block(mbmi)) {
// Intra reconstruction
......@@ -246,7 +255,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
assert(mbmi->sb_type == bsize);
if (eobtotal == 0)
// skip loopfilter
vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, 1);
vp9_set_pred_flag_mbskip(xd, bsize, 1);
else if (eobtotal > 0)
foreach_transformed_block(xd, bsize, decode_block, xd);
}
......@@ -960,6 +969,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
setup_plane_dequants(cm, &pbi->mb, cm->base_qindex);
xd->mi_8x8 = cm->mi_grid_visible;
xd->mic_stream_ptr = cm->mi;
xd->mode_info_stride = cm->mode_info_stride;
cm->fc = cm->frame_contexts[cm->frame_context_idx];
vp9_zero(cm->counts);
......
......@@ -94,7 +94,7 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) {
FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
const int ref = is_inter_block(&xd->mode_info_context->mbmi);
const int ref = is_inter_block(&xd->this_mi->mbmi);
int band, c = 0;
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size][type][ref];
......@@ -224,7 +224,7 @@ static void decode_block(int plane, int block, BLOCK_SIZE plane_bsize,
MACROBLOCKD *xd = &arg->pbi->mb;
struct segmentation *seg = &arg->pbi->common.seg;
struct macroblockd_plane* pd = &xd->plane[plane];
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int segment_id = xd->this_mi->mbmi.segment_id;
const int seg_eob = get_tx_eob(seg, segment_id, tx_size);
int aoff, loff, eob;
......
......@@ -386,12 +386,17 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
if (cm->show_frame) {
// current mip will be the prev_mip for the next frame
MODE_INFO *temp = cm->prev_mip;
MODE_INFO **temp2 = cm->prev_mi_grid_base;
cm->prev_mip = cm->mip;
cm->mip = temp;
cm->prev_mi_grid_base = cm->mi_grid_base;
cm->mi_grid_base = temp2;
// update the upper left visible macroblock ptrs
cm->mi = cm->mip + cm->mode_info_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1;
cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1;
cm->current_video_frame++;
}
......
......@@ -198,10 +198,11 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi,
(unsigned int *)cpi->y_mode_count[j]);
}
static void write_selected_tx_size(const VP9_COMP *cpi, TX_SIZE tx_size,
BLOCK_SIZE bsize, vp9_writer *w) {
static void write_selected_tx_size(const VP9_COMP *cpi, MODE_INFO *m,
TX_SIZE tx_size, BLOCK_SIZE bsize,
vp9_writer *w) {
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const vp9_prob *tx_probs = get_tx_probs2(xd, &cpi->common.fc.tx_probs);
const vp9_prob *tx_probs = get_tx_probs2(xd, &cpi->common.fc.tx_probs, m);
vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
if (bsize >= BLOCK_16X16 && tx_size != TX_4X4) {
vp9_write(w, tx_size != TX_8X8, tx_probs[1]);
......@@ -359,7 +360,7 @@ static void encode_ref_frame(VP9_COMP *cpi, vp9_writer *bc) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mi = &xd->mode_info_context->mbmi;
MB_MODE_INFO *mi = &xd->this_mi->mbmi;
const int segment_id = mi->segment_id;
int seg_ref_active = vp9_segfeature_active(&cm->seg, segment_id,
SEG_LVL_REF_FRAME);
......@@ -437,7 +438,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
!(rf != INTRA_FRAME &&
(skip_coeff || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) {
write_selected_tx_size(cpi, mi->tx_size, bsize, bc);
write_selected_tx_size(cpi, m, mi->tx_size, bsize, bc);
}