experiment with CONTEXT conversion

This commit changed the ENTROPY_CONTEXT conversion between MBs that
have different transform sizes.

In additioin, this commit also did a number of cleanup/bug fix:
1. removed duplicate function vp9_fix_contexts() and changed to use
vp8_reset_mb_token_contexts() for both encoder and decoder
2. fixed a bug in stuff_mb_16x16 where wrong context was used for
the UV.
3. changed reset all context to 0 if a MB is skipped to simplify the
logic.

Change-Id: I7bc57a5fb6dbf1f85eac1543daaeb3a61633275c
This commit is contained in:
Yaowu Xu 2012-11-28 15:15:51 -08:00
parent fbf052df42
commit ab480cede5
9 changed files with 228 additions and 140 deletions

1
configure vendored
View File

@ -249,6 +249,7 @@ EXPERIMENT_LIST="
comp_interintra_pred
tx32x32
dwt32x32hybrid
cnvcontext
"
CONFIG_LIST="
external_build

View File

@ -102,13 +102,11 @@ typedef enum
TM_PRED, /* Truemotion prediction */
I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */
B_PRED, /* block based prediction, each block has its own prediction mode */
NEARESTMV,
NEARMV,
ZEROMV,
NEWMV,
SPLITMV,
MB_MODE_COUNT
} MB_PREDICTION_MODE;

View File

@ -129,4 +129,10 @@ void vp9_coef_tree_initialize(void);
void vp9_adapt_coef_probs(struct VP9Common *);
static void vp9_reset_mb_tokens_context(MACROBLOCKD* const xd) {
/* Clear entropy contexts */
vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
}
#endif

View File

@ -14,6 +14,7 @@
#include "vp9/common/vp9_reconintra.h"
#include "vp9/common/vp9_reconintra4x4.h"
#include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_entropy.h"
#include "vp9/decoder/vp9_decodframe.h"
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/common/vp9_invtrans.h"
@ -443,12 +444,12 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
vp9_dequant_idct_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride);
}
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
}
if (!xd->mode_info_context->mbmi.mb_skip_coeff) {
vp9_decode_mb_tokens_4x4_uv(pbi, xd, bc);
}
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
vp9_build_intra_predictors_mbuv(xd);
pbi->idct_add_uv_block(xd->qcoeff + 16 * 16,
xd->block[16].dequant,

View File

@ -15,7 +15,6 @@
#include "vpx_mem/vpx_mem.h"
#include "vpx_ports/mem.h"
#include "vp9/decoder/vp9_detokenize.h"
#include "vp9/common/vp9_seg_common.h"
#define EOB_CONTEXT_NODE 0
@ -59,22 +58,6 @@ static const unsigned char cat6_prob[15] = {
254, 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0
};
void vp9_reset_mb_tokens_context(MACROBLOCKD* const xd) {
/* Clear entropy contexts */
if ((xd->mode_info_context->mbmi.mode != B_PRED &&
xd->mode_info_context->mbmi.mode != I8X8_PRED &&
xd->mode_info_context->mbmi.mode != SPLITMV)
|| xd->mode_info_context->mbmi.txfm_size == TX_16X16) {
vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES));
} else {
vpx_memset(xd->above_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1);
vpx_memset(xd->left_context, 0, sizeof(ENTROPY_CONTEXT_PLANES) - 1);
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
}
}
DECLARE_ALIGNED(16, extern const unsigned char, vp9_norm[256]);
static int get_signed(BOOL_DECODER *br, int value_to_sign) {
@ -321,15 +304,23 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
unsigned short* const eobs = xd->eobs;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
int c, i, eobtotal = 0, seg_eob;
// Luma block
eobs[0] = c = decode_coefs(pbi, xd, bc, A, L, PLANE_TYPE_Y_WITH_DC,
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
ENTROPY_CONTEXT left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
#else
ENTROPY_CONTEXT above_ec = A[0];
ENTROPY_CONTEXT left_ec = L[0];
#endif
eobs[0] = c = decode_coefs(pbi, xd, bc, &above_ec, &left_ec,
PLANE_TYPE_Y_WITH_DC,
get_tx_type(xd, &xd->block[0]),
get_eob(xd, segment_id, 256),
xd->qcoeff, vp9_default_zig_zag1d_16x16,
TX_16X16, vp9_coef_bands_16x16);
A[1] = A[2] = A[3] = A[0];
L[1] = L[2] = L[3] = L[0];
A[1] = A[2] = A[3] = A[0] = above_ec;
L[1] = L[2] = L[3] = L[0] = left_ec;
eobtotal += c;
// 8x8 chroma blocks
@ -337,13 +328,21 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
for (i = 16; i < 24; i += 4) {
ENTROPY_CONTEXT* const a = A + vp9_block2above_8x8[i];
ENTROPY_CONTEXT* const l = L + vp9_block2left_8x8[i];
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, PLANE_TYPE_UV,
#if CONFIG_CNVCONTEXT
above_ec = (a[0] + a[1]) != 0;
left_ec = (l[0] + l[1]) != 0;
#else
above_ec = a[0];
left_ec = l[0];
#endif
eobs[i] = c = decode_coefs(pbi, xd, bc,
&above_ec, &left_ec,
PLANE_TYPE_UV,
DCT_DCT, seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8);
a[1] = a[0];
l[1] = l[0];
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
eobtotal += c;
}
A[8] = 0;
@ -374,8 +373,8 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
eobtotal += c - 4;
type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
eobs[24] = 0;
type = PLANE_TYPE_Y_WITH_DC;
}
@ -385,15 +384,21 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
for (i = 0; i < 16; i += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[i];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[i];
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, type,
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
eobs[i] = c = decode_coefs(pbi, xd, bc, &above_ec, &left_ec, type,
type == PLANE_TYPE_Y_WITH_DC ?
get_tx_type(xd, xd->block + i) : DCT_DCT,
seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8);
a[1] = a[0];
l[1] = l[0];
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
eobtotal += c;
}
@ -415,13 +420,21 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
for (i = 16; i < 24; i += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[i];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[i];
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, PLANE_TYPE_UV,
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
eobs[i] = c = decode_coefs(pbi, xd, bc,
&above_ec, &left_ec,
PLANE_TYPE_UV,
DCT_DCT, seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8);
a[1] = a[0];
l[1] = l[0];
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
eobtotal += c;
}
}
@ -517,8 +530,8 @@ static int vp9_decode_mb_tokens_4x4(VP9D_COMP* const dx,
DCT_DCT, vp9_default_zig_zag1d) - 16;
type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
xd->eobs[24] = 0;
type = PLANE_TYPE_Y_WITH_DC;
}

View File

@ -16,6 +16,7 @@
#include "vp9/common/vp9_common.h"
#include "vp9/encoder/vp9_onyx_int.h"
#include "vp9/common/vp9_extend.h"
#include "vp9/common/vp9_entropy.h"
#include "vp9/common/vp9_entropymode.h"
#include "vp9/common/vp9_quant_common.h"
#include "vp9/encoder/vp9_segmentation.h"
@ -2287,7 +2288,7 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
mbmi->mb_skip_coeff = 1;
if (output_enabled)
cpi->skip_true_count[mb_skip_context]++;
vp9_fix_contexts(xd);
vp9_reset_mb_tokens_context(xd);
} else {
vp9_stuff_mb(cpi, xd, t, !output_enabled);
mbmi->mb_skip_coeff = 0;
@ -2525,7 +2526,7 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x,
if (cpi->common.mb_no_coeff_skip) {
// TODO(rbultje) this should be done per-sb instead of per-mb?
cpi->skip_true_count[mb_skip_context]++;
vp9_fix_contexts(xd);
vp9_reset_mb_tokens_context(xd);
} else {
vp9_stuff_mb(cpi, xd, t, 0);
// TODO(rbultje) this should be done per-sb instead of per-mb?

View File

@ -727,14 +727,21 @@ void vp9_optimize_mby_8x8(MACROBLOCK *x) {
tl = (ENTROPY_CONTEXT *)&t_left;
type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
for (b = 0; b < 16; b += 4) {
optimize_b(x, b, type,
ta + vp9_block2above_8x8[b], tl + vp9_block2left_8x8[b],
TX_8X8);
ta[vp9_block2above_8x8[b] + 1] = ta[vp9_block2above_8x8[b]];
tl[vp9_block2left_8x8[b] + 1] = tl[vp9_block2left_8x8[b]];
ENTROPY_CONTEXT *const a = ta + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = tl + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
optimize_b(x, b, type, &above_ec, &left_ec, TX_8X8);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
// 8x8 always have 2nd roder haar block
// 8x8 always have 2nd order block
if (has_2nd_order) {
check_reset_8x8_2nd_coeffs(&x->e_mbd,
ta + vp9_block2above_8x8[24],
@ -744,25 +751,23 @@ void vp9_optimize_mby_8x8(MACROBLOCK *x) {
void vp9_optimize_mbuv_8x8(MACROBLOCK *x) {
int b;
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta;
ENTROPY_CONTEXT *tl;
ENTROPY_CONTEXT *const ta = (ENTROPY_CONTEXT *)x->e_mbd.above_context;
ENTROPY_CONTEXT *const tl = (ENTROPY_CONTEXT *)x->e_mbd.left_context;
if (!x->e_mbd.above_context || !x->e_mbd.left_context)
if (!ta || !tl)
return;
vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
for (b = 16; b < 24; b += 4) {
optimize_b(x, b, PLANE_TYPE_UV,
ta + vp9_block2above_8x8[b], tl + vp9_block2left_8x8[b],
TX_8X8);
ta[vp9_block2above_8x8[b] + 1] = ta[vp9_block2above_8x8[b]];
tl[vp9_block2left_8x8[b] + 1] = tl[vp9_block2left_8x8[b]];
ENTROPY_CONTEXT *const a = ta + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = tl + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
optimize_b(x, b, PLANE_TYPE_UV, &above_ec, &left_ec, TX_8X8);
}
}
@ -772,18 +777,21 @@ static void optimize_mb_8x8(MACROBLOCK *x) {
}
void vp9_optimize_mby_16x16(MACROBLOCK *x) {
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta, *tl;
ENTROPY_CONTEXT_PLANES *const t_above = x->e_mbd.above_context;
ENTROPY_CONTEXT_PLANES *const t_left = x->e_mbd.left_context;
ENTROPY_CONTEXT ta, tl;
if (!x->e_mbd.above_context || !x->e_mbd.left_context)
if (!t_above || !t_left)
return;
vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES));
vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES));
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
optimize_b(x, 0, PLANE_TYPE_Y_WITH_DC, ta, tl, TX_16X16);
#if CONFIG_CNVCONTEXT
ta = (t_above->y1[0] + t_above->y1[1] + t_above->y1[2] + t_above->y1[3]) != 0;
tl = (t_left->y1[0] + t_left->y1[1] + t_left->y1[2] + t_left->y1[3]) != 0;
#else
ta = t_above->y1[0];
tl = t_left->y1[0];
#endif
optimize_b(x, 0, PLANE_TYPE_Y_WITH_DC, &ta, &tl, TX_16X16);
}
static void optimize_mb_16x16(MACROBLOCK *x) {

View File

@ -423,7 +423,7 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
if (!cpi->common.mb_no_coeff_skip) {
vp9_stuff_mb(cpi, xd, t, dry_run);
} else {
vp9_fix_contexts(xd);
vp9_reset_mb_tokens_context(xd);
}
if (dry_run)
*t = t_backup;
@ -434,45 +434,60 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
cpi->skip_false_count[mb_skip_context] += skip_inc;
if (has_2nd_order) {
if (tx_size == TX_8X8) {
tokenize_b(cpi, xd, xd->block + 24, t, PLANE_TYPE_Y2,
A + vp9_block2above_8x8[24], L + vp9_block2left_8x8[24],
TX_8X8, dry_run);
} else {
tokenize_b(cpi, xd, xd->block + 24, t, PLANE_TYPE_Y2,
A + vp9_block2above[24], L + vp9_block2left[24],
TX_4X4, dry_run);
}
tokenize_b(cpi, xd, xd->block + 24, t, PLANE_TYPE_Y2,
A + vp9_block2above_8x8[24], L + vp9_block2left_8x8[24],
tx_size, dry_run);
plane_type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
plane_type = PLANE_TYPE_Y_WITH_DC;
}
if (tx_size == TX_16X16) {
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
ENTROPY_CONTEXT left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
#else
ENTROPY_CONTEXT above_ec = A[0];
ENTROPY_CONTEXT left_ec = L[0];
#endif
tokenize_b(cpi, xd, xd->block, t, PLANE_TYPE_Y_WITH_DC,
A, L, TX_16X16, dry_run);
A[1] = A[2] = A[3] = A[0];
L[1] = L[2] = L[3] = L[0];
&above_ec, &left_ec, TX_16X16, dry_run);
A[1] = A[2] = A[3] = A[0] = above_ec;
L[1] = L[2] = L[3] = L[0] = left_ec;
for (b = 16; b < 24; b += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
above_ec = (a[0] + a[1]) != 0;
left_ec = (l[0] + l[1]) != 0;
#else
above_ec = a[0];
left_ec = l[0];
#endif
tokenize_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b],
TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
A[8] = 0;
L[8] = 0;
} else if (tx_size == TX_8X8) {
for (b = 0; b < 16; b += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
tokenize_b(cpi, xd, xd->block + b, t, plane_type,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b],
TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
if (xd->mode_info_context->mbmi.mode == I8X8_PRED ||
xd->mode_info_context->mbmi.mode == SPLITMV) {
@ -483,11 +498,19 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
}
} else {
for (b = 16; b < 24; b += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
tokenize_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b],
TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
}
} else {
@ -794,66 +817,97 @@ static void stuff_mb_8x8(VP9_COMP *cpi, MACROBLOCKD *xd,
TX_8X8, dry_run);
plane_type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
#if CONFIG_CNVCONTEXT
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
#endif
plane_type = PLANE_TYPE_Y_WITH_DC;
}
for (b = 0; b < 16; b += 4) {
stuff_b(cpi, xd, xd->block + b, t, plane_type, A + vp9_block2above_8x8[b],
L + vp9_block2left_8x8[b], TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
stuff_b(cpi, xd, xd->block + b, t, plane_type,
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
for (b = 16; b < 24; b += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
stuff_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b],
TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
}
static void stuff_mb_16x16(VP9_COMP *cpi, MACROBLOCKD *xd,
TOKENEXTRA **t, int dry_run) {
ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)xd->left_context;
ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
int b;
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (A[0] + A[1] + A[2] + A[3]) != 0;
ENTROPY_CONTEXT left_ec = (L[0] + L[1] + L[2] + L[3]) != 0;
#else
ENTROPY_CONTEXT above_ec = A[0];
ENTROPY_CONTEXT left_ec = L[0];
#endif
stuff_b(cpi, xd, xd->block, t, PLANE_TYPE_Y_WITH_DC,
&above_ec, &left_ec, TX_16X16, dry_run);
A[1] = A[2] = A[3] = A[0] = above_ec;
L[1] = L[2] = L[3] = L[0] = left_ec;
stuff_b(cpi, xd, xd->block, t, PLANE_TYPE_Y_WITH_DC, A, L, TX_16X16, dry_run);
A[1] = A[2] = A[3] = A[0];
L[1] = L[2] = L[3] = L[0];
for (b = 16; b < 24; b += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
above_ec = (a[0] + a[1]) != 0;
left_ec = (l[0] + l[1]) != 0;
#else
above_ec = a[0];
left_ec = l[0];
#endif
stuff_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp9_block2above_8x8[b],
L + vp9_block2above_8x8[b], TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
vpx_memset(&A[8], 0, sizeof(A[8]));
vpx_memset(&L[8], 0, sizeof(L[8]));
A[8] = 0;
L[8] = 0;
}
static void stuff_mb_4x4(VP9_COMP *cpi, MACROBLOCKD *xd,
TOKENEXTRA **t, int dry_run) {
ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)xd->left_context;
ENTROPY_CONTEXT *const A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
int b;
PLANE_TYPE plane_type;
int has_2nd_order = (xd->mode_info_context->mbmi.mode != B_PRED &&
xd->mode_info_context->mbmi.mode != I8X8_PRED &&
xd->mode_info_context->mbmi.mode != SPLITMV);
if (has_2nd_order && get_tx_type(xd, &xd->block[0]) != DCT_DCT)
has_2nd_order = 0;
int has_2nd_order = get_2nd_order_usage(xd);
if (has_2nd_order) {
stuff_b(cpi, xd, xd->block + 24, t, PLANE_TYPE_Y2, A + vp9_block2above[24],
L + vp9_block2left[24], TX_4X4, dry_run);
plane_type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
plane_type = PLANE_TYPE_Y_WITH_DC;
}
@ -880,22 +934,30 @@ static void stuff_mb_8x8_4x4uv(VP9_COMP *cpi, MACROBLOCKD *xd,
TX_8X8, dry_run);
plane_type = PLANE_TYPE_Y_NO_DC;
} else {
xd->above_context->y2 = 0;
xd->left_context->y2 = 0;
plane_type = PLANE_TYPE_Y_WITH_DC;
}
for (b = 0; b < 16; b += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[b];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[b];
#if CONFIG_CNVCONTEXT
ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
ENTROPY_CONTEXT left_ec = (l[0] + l[1]) != 0;
#else
ENTROPY_CONTEXT above_ec = a[0];
ENTROPY_CONTEXT left_ec = l[0];
#endif
stuff_b(cpi, xd, xd->block + b, t, plane_type,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b],
TX_8X8, dry_run);
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]];
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
&above_ec, &left_ec, TX_8X8, dry_run);
a[1] = a[0] = above_ec;
l[1] = l[0] = left_ec;
}
for (b = 16; b < 24; b++)
stuff_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV, A + vp9_block2above[b],
L + vp9_block2left[b], TX_4X4, dry_run);
xd->above_context->y2 = 1;
xd->left_context->y2 = 1;
}
void vp9_stuff_mb(VP9_COMP *cpi, MACROBLOCKD *xd, TOKENEXTRA **t, int dry_run) {

View File

@ -56,11 +56,9 @@ extern void vp9_stuff_sb(struct VP9_COMP *cpi, MACROBLOCKD *xd,
TOKENEXTRA **t, int dry_run);
#endif
extern void vp9_fix_contexts(MACROBLOCKD *xd);
#if CONFIG_SUPERBLOCKS && CONFIG_TX32X32
extern void vp9_fix_contexts_sb(MACROBLOCKD *xd);
#endif
#ifdef ENTROPY_STATS
void init_context_counters();
void print_context_counters();