const int idx_map = mb_row * cm->mb_cols + mb_col;
const struct segmentation *const seg = &cm->seg;
- set_skip_context(xd, cm->above_context, cm->left_context, mi_row, mi_col);
+ set_skip_context(xd, cpi->above_context, cpi->left_context, mi_row, mi_col);
// Activity map pointer
x->mb_activity_ptr = &cpi->mb_activity_map[idx_map];
ENTROPY_CONTEXT l[16 * MAX_MB_PLANE],
PARTITION_CONTEXT sa[8], PARTITION_CONTEXT sl[8],
BLOCK_SIZE bsize) {
- VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
int p;
int mi_height = num_8x8_blocks_high_lookup[bsize];
for (p = 0; p < MAX_MB_PLANE; p++) {
vpx_memcpy(
- cm->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x),
+ cpi->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x),
a + num_4x4_blocks_wide * p,
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >>
xd->plane[p].subsampling_x);
vpx_memcpy(
- cm->left_context[p]
+ cpi->left_context[p]
+ ((mi_row & MI_MASK) * 2 >> xd->plane[p].subsampling_y),
l + num_4x4_blocks_high * p,
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
ENTROPY_CONTEXT l[16 * MAX_MB_PLANE],
PARTITION_CONTEXT sa[8], PARTITION_CONTEXT sl[8],
BLOCK_SIZE bsize) {
- const VP9_COMMON *const cm = &cpi->common;
const MACROBLOCK *const x = &cpi->mb;
const MACROBLOCKD *const xd = &x->e_mbd;
int p;
for (p = 0; p < MAX_MB_PLANE; ++p) {
vpx_memcpy(
a + num_4x4_blocks_wide * p,
- cm->above_context[p] + (mi_col * 2 >> xd->plane[p].subsampling_x),
+ cpi->above_context[p] + (mi_col * 2 >> xd->plane[p].subsampling_x),
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_wide) >>
xd->plane[p].subsampling_x);
vpx_memcpy(
l + num_4x4_blocks_high * p,
- cm->left_context[p]
+ cpi->left_context[p]
+ ((mi_row & MI_MASK) * 2 >> xd->plane[p].subsampling_y),
(sizeof(ENTROPY_CONTEXT) * num_4x4_blocks_high) >>
xd->plane[p].subsampling_y);
int mi_col;
// Initialize the left context for the new SB row
- vpx_memset(&cm->left_context, 0, sizeof(cm->left_context));
+ vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context));
vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context));
// Code each SB in the row
// Note: this memset assumes above_context[0], [1] and [2]
// are allocated as part of the same buffer.
- vpx_memset(cm->above_context[0], 0,
- sizeof(ENTROPY_CONTEXT) * 2 * MAX_MB_PLANE * aligned_mi_cols);
+ vpx_memset(cpi->above_context[0], 0,
+ sizeof(*cpi->above_context[0]) *
+ 2 * aligned_mi_cols * MAX_MB_PLANE);
vpx_memset(cpi->above_seg_context, 0,
sizeof(*cpi->above_seg_context) * aligned_mi_cols);
}
vpx_free(cpi->mb_norm_activity_map);
cpi->mb_norm_activity_map = 0;
+ vpx_free(cpi->above_context[0]);
+ cpi->above_context[0] = NULL;
+
vpx_free(cpi->above_seg_context);
cpi->above_seg_context = NULL;
}
vpx_calloc(sizeof(unsigned int),
cm->mb_rows * cm->mb_cols));
+ // 2 contexts per 'mi unit', so that we have one context per 4x4 txfm
+ // block where mi unit size is 8x8.
+ vpx_free(cpi->above_context[0]);
+ CHECK_MEM_ERROR(cm, cpi->above_context[0],
+ vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) *
+ MAX_MB_PLANE,
+ sizeof(*cpi->above_context[0])));
+
vpx_free(cpi->above_seg_context);
CHECK_MEM_ERROR(cm, cpi->above_seg_context,
vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols),
vp9_init_dsmotion_compensation(&cpi->mb, y_stride);
}
}
+
+ {
+ int i;
+ for (i = 1; i < MAX_MB_PLANE; ++i) {
+ cpi->above_context[i] = cpi->above_context[0] +
+ i * sizeof(*cpi->above_context[0]) * 2 *
+ mi_cols_aligned_to_sb(cm->mi_cols);
+ }
+ }
}