ref: 8b0e6035a219d8df8a9ea09fa9c465ab484c8b62
parent: 097046ae28c41d2c6a066d3ad864d738d9dbb794
author: Dmitry Kovalev <[email protected]>
date: Mon Aug 12 07:24:24 EDT 2013
Entropy context related cleanups. Adding set_skip_context() function used from both encoder and decoder. Change-Id: Ia22cfad3211a00a63eb294f64f857b78f4aa9b85
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -145,11 +145,8 @@
// 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;
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -156,17 +156,16 @@
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));
}
}
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -236,6 +236,18 @@
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;
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -167,7 +167,7 @@
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 @@
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 @@
// 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 @@
// 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);
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -480,17 +480,8 @@
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 @@
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
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -282,7 +282,7 @@
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;