summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-08-12 15:18:24 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-08-12 15:18:24 -0700
commitc66320b3e4283b72dba38333ea9861354e159758 (patch)
tree8e0289eb89ab0794f367250ae767f8eb7266c034 /vp9
parentbd1bc1d30392382d13c8238da3e2d24db7e98e71 (diff)
parent8b0e6035a219d8df8a9ea09fa9c465ab484c8b62 (diff)
downloadlibvpx-c66320b3e4283b72dba38333ea9861354e159758.tar
libvpx-c66320b3e4283b72dba38333ea9861354e159758.tar.gz
libvpx-c66320b3e4283b72dba38333ea9861354e159758.tar.bz2
libvpx-c66320b3e4283b72dba38333ea9861354e159758.zip
Merge "Entropy context related cleanups."
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_alloccommon.c7
-rw-r--r--vp9/common/vp9_entropy.h13
-rw-r--r--vp9/common/vp9_onyxc_int.h12
-rw-r--r--vp9/decoder/vp9_decodframe.c13
-rw-r--r--vp9/encoder/vp9_encodeframe.c13
-rw-r--r--vp9/encoder/vp9_tokenize.c2
6 files changed, 26 insertions, 34 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index 554a31730..a9027b7df 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -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;
diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h
index 861c0786c..1106af588 100644
--- a/vp9/common/vp9_entropy.h
+++ b/vp9/common/vp9_entropy.h
@@ -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));
}
}
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 4391a0a2c..6cb3e2c19 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -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;
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index b80ba48e3..23bcc9cb9 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -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);
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 2e855c862..0eae07d04 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -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
diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c
index d52f9b2bb..5d305175d 100644
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -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;