Commit c66320b3 authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review

Merge "Entropy context related cleanups."

parents bd1bc1d3 8b0e6035
......@@ -145,11 +145,8 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
// 2 contexts per 'mi unit', so that we have one context per 4x4 txfm
// block where mi unit size is 8x8.
# if CONFIG_ALPHA
oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * 8 * mi_cols, 1);
#else
oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * 6 * mi_cols, 1);
#endif
oci->above_context[0] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * MAX_MB_PLANE *
(2 * mi_cols), 1);
if (!oci->above_context[0])
goto fail;
......
......@@ -156,17 +156,16 @@ extern DECLARE_ALIGNED(16, int16_t,
void vp9_coef_tree_initialize(void);
void vp9_adapt_coef_probs(struct VP9Common *);
static INLINE void vp9_reset_sb_tokens_context(MACROBLOCKD* const xd,
BLOCK_SIZE_TYPE bsize) {
/* Clear entropy contexts */
static INLINE void reset_skip_context(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) {
const int bw = 1 << b_width_log2(bsize);
const int bh = 1 << b_height_log2(bsize);
int i;
for (i = 0; i < MAX_MB_PLANE; i++) {
vpx_memset(xd->plane[i].above_context, 0,
sizeof(ENTROPY_CONTEXT) * bw >> xd->plane[i].subsampling_x);
vpx_memset(xd->plane[i].left_context, 0,
sizeof(ENTROPY_CONTEXT) * bh >> xd->plane[i].subsampling_y);
struct macroblockd_plane *const pd = &xd->plane[i];
vpx_memset(pd->above_context, 0,
sizeof(ENTROPY_CONTEXT) * (bw >> pd->subsampling_x));
vpx_memset(pd->left_context, 0,
sizeof(ENTROPY_CONTEXT) * (bh >> pd->subsampling_y));
}
}
......
......@@ -236,6 +236,18 @@ static int mi_cols_aligned_to_sb(int n_mis) {
return ALIGN_POWER_OF_TWO(n_mis, LOG2_MI_BLOCK_SIZE);
}
static INLINE void set_skip_context(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int mi_col) {
const int above_idx = mi_col * 2;
const int left_idx = (mi_row * 2) & 15;
int i;
for (i = 0; i < MAX_MB_PLANE; i++) {
struct macroblockd_plane *const pd = &xd->plane[i];
pd->above_context = cm->above_context[i] + (above_idx >> pd->subsampling_x);
pd->left_context = cm->left_context[i] + (left_idx >> pd->subsampling_y);
}
}
static INLINE void set_partition_seg_context(VP9_COMMON *cm, MACROBLOCKD *xd,
int mi_row, int mi_col) {
xd->above_seg_context = cm->above_seg_context + mi_col;
......
......@@ -167,7 +167,7 @@ static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
MACROBLOCKD *const xd = &pbi->mb;
if (xd->mode_info_context->mbmi.mb_skip_coeff) {
vp9_reset_sb_tokens_context(xd, bsize);
reset_skip_context(xd, bsize);
return -1;
} else {
if (xd->seg.enabled)
......@@ -185,7 +185,6 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize,
const int bh = 1 << mi_height_log2(bsize);
const int bw = 1 << mi_width_log2(bsize);
const int mi_idx = mi_row * cm->mode_info_stride + mi_col;
int i;
xd->mode_info_context = cm->mi + mi_idx;
xd->mode_info_context->mbmi.sb_type = bsize;
......@@ -193,14 +192,8 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize,
// cannot be used.
xd->prev_mode_info_context = cm->prev_mi ? cm->prev_mi + mi_idx : NULL;
for (i = 0; i < MAX_MB_PLANE; i++) {
struct macroblockd_plane *pd = &xd->plane[i];
pd->above_context = cm->above_context[i] +
(mi_col * 2 >> pd->subsampling_x);
pd->left_context = cm->left_context[i] +
(((mi_row * 2) & 15) >> pd->subsampling_y);
}
set_skip_context(cm, xd, mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
// Distance of Mb to the various image edges. These are specified to 8th pel
......@@ -675,7 +668,7 @@ static const uint8_t *decode_tiles(VP9D_COMP *pbi, const uint8_t *data) {
// Note: this memset assumes above_context[0], [1] and [2]
// are allocated as part of the same buffer.
vpx_memset(pc->above_context[0], 0,
sizeof(ENTROPY_CONTEXT) * 2 * MAX_MB_PLANE * aligned_mi_cols);
sizeof(ENTROPY_CONTEXT) * MAX_MB_PLANE * (2 * aligned_mi_cols));
vpx_memset(pc->above_seg_context, 0,
sizeof(PARTITION_CONTEXT) * aligned_mi_cols);
......
......@@ -480,17 +480,8 @@ static void set_offsets(VP9_COMP *cpi, int mi_row, int mi_col,
const int mb_col = mi_col >> 1;
const int idx_map = mb_row * cm->mb_cols + mb_col;
const struct segmentation *const seg = &xd->seg;
int i;
// entropy context structures
for (i = 0; i < MAX_MB_PLANE; i++) {
xd->plane[i].above_context = cm->above_context[i]
+ (mi_col * 2 >> xd->plane[i].subsampling_x);
xd->plane[i].left_context = cm->left_context[i]
+ (((mi_row * 2) & 15) >> xd->plane[i].subsampling_y);
}
// partition contexts
set_skip_context(cm, xd, mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
// Activity map pointer
......@@ -2630,7 +2621,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
mbmi->mb_skip_coeff = 1;
if (output_enabled)
cm->counts.mbskip[mb_skip_context][1]++;
vp9_reset_sb_tokens_context(xd, MAX(bsize, BLOCK_8X8));
reset_skip_context(xd, MAX(bsize, BLOCK_8X8));
}
// copy skip flag on all mb_mode_info contexts in this SB
......
......@@ -282,7 +282,7 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run,
if (mbmi->mb_skip_coeff) {
if (!dry_run)
cm->counts.mbskip[mb_skip_context][1] += skip_inc;
vp9_reset_sb_tokens_context(xd, bsize);
reset_skip_context(xd, bsize);
if (dry_run)
*t = t_backup;
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment