Commit ab480ced authored by Yaowu Xu's avatar Yaowu Xu
Browse files

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
parent fbf052df
...@@ -249,6 +249,7 @@ EXPERIMENT_LIST=" ...@@ -249,6 +249,7 @@ EXPERIMENT_LIST="
comp_interintra_pred comp_interintra_pred
tx32x32 tx32x32
dwt32x32hybrid dwt32x32hybrid
cnvcontext
" "
CONFIG_LIST=" CONFIG_LIST="
external_build external_build
......
...@@ -102,13 +102,11 @@ typedef enum ...@@ -102,13 +102,11 @@ typedef enum
TM_PRED, /* Truemotion prediction */ TM_PRED, /* Truemotion prediction */
I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */ I8X8_PRED, /* 8x8 based prediction, each 8x8 has its own prediction mode */
B_PRED, /* block based prediction, each block has its own prediction mode */ B_PRED, /* block based prediction, each block has its own prediction mode */
NEARESTMV, NEARESTMV,
NEARMV, NEARMV,
ZEROMV, ZEROMV,
NEWMV, NEWMV,
SPLITMV, SPLITMV,
MB_MODE_COUNT MB_MODE_COUNT
} MB_PREDICTION_MODE; } MB_PREDICTION_MODE;
......
...@@ -129,4 +129,10 @@ void vp9_coef_tree_initialize(void); ...@@ -129,4 +129,10 @@ void vp9_coef_tree_initialize(void);
void vp9_adapt_coef_probs(struct VP9Common *); 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 #endif
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "vp9/common/vp9_reconintra.h" #include "vp9/common/vp9_reconintra.h"
#include "vp9/common/vp9_reconintra4x4.h" #include "vp9/common/vp9_reconintra4x4.h"
#include "vp9/common/vp9_reconinter.h" #include "vp9/common/vp9_reconinter.h"
#include "vp9/common/vp9_entropy.h"
#include "vp9/decoder/vp9_decodframe.h" #include "vp9/decoder/vp9_decodframe.h"
#include "vp9/decoder/vp9_detokenize.h" #include "vp9/decoder/vp9_detokenize.h"
#include "vp9/common/vp9_invtrans.h" #include "vp9/common/vp9_invtrans.h"
...@@ -443,12 +444,12 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd, ...@@ -443,12 +444,12 @@ static void decode_4x4(VP9D_COMP *pbi, MACROBLOCKD *xd,
vp9_dequant_idct_add(b->qcoeff, b->dequant, b->predictor, vp9_dequant_idct_add(b->qcoeff, b->dequant, b->predictor,
*(b->base_dst) + b->dst, 16, b->dst_stride); *(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) { if (!xd->mode_info_context->mbmi.mb_skip_coeff) {
vp9_decode_mb_tokens_4x4_uv(pbi, xd, bc); 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); vp9_build_intra_predictors_mbuv(xd);
pbi->idct_add_uv_block(xd->qcoeff + 16 * 16, pbi->idct_add_uv_block(xd->qcoeff + 16 * 16,
xd->block[16].dequant, xd->block[16].dequant,
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
#include "vp9/decoder/vp9_detokenize.h" #include "vp9/decoder/vp9_detokenize.h"
#include "vp9/common/vp9_seg_common.h" #include "vp9/common/vp9_seg_common.h"
#define EOB_CONTEXT_NODE 0 #define EOB_CONTEXT_NODE 0
...@@ -59,22 +58,6 @@ static const unsigned char cat6_prob[15] = { ...@@ -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 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]); DECLARE_ALIGNED(16, extern const unsigned char, vp9_norm[256]);
static int get_signed(BOOL_DECODER *br, int value_to_sign) { 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, ...@@ -321,15 +304,23 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
unsigned short* const eobs = xd->eobs; unsigned short* const eobs = xd->eobs;
const int segment_id = xd->mode_info_context->mbmi.segment_id; const int segment_id = xd->mode_info_context->mbmi.segment_id;
int c, i, eobtotal = 0, seg_eob; int c, i, eobtotal = 0, seg_eob;
// Luma block // 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_tx_type(xd, &xd->block[0]),
get_eob(xd, segment_id, 256), get_eob(xd, segment_id, 256),
xd->qcoeff, vp9_default_zig_zag1d_16x16, xd->qcoeff, vp9_default_zig_zag1d_16x16,
TX_16X16, vp9_coef_bands_16x16); TX_16X16, vp9_coef_bands_16x16);
A[1] = A[2] = A[3] = A[0]; A[1] = A[2] = A[3] = A[0] = above_ec;
L[1] = L[2] = L[3] = L[0]; L[1] = L[2] = L[3] = L[0] = left_ec;
eobtotal += c; eobtotal += c;
// 8x8 chroma blocks // 8x8 chroma blocks
...@@ -337,13 +328,21 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi, ...@@ -337,13 +328,21 @@ static int vp9_decode_mb_tokens_16x16(VP9D_COMP* const pbi,
for (i = 16; i < 24; i += 4) { for (i = 16; i < 24; i += 4) {
ENTROPY_CONTEXT* const a = A + vp9_block2above_8x8[i]; ENTROPY_CONTEXT* const a = A + vp9_block2above_8x8[i];
ENTROPY_CONTEXT* const l = L + vp9_block2left_8x8[i]; ENTROPY_CONTEXT* const l = L + vp9_block2left_8x8[i];
#if CONFIG_CNVCONTEXT
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, PLANE_TYPE_UV, 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, DCT_DCT, seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8, vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8); TX_8X8, vp9_coef_bands_8x8);
a[1] = a[0]; a[1] = a[0] = above_ec;
l[1] = l[0]; l[1] = l[0] = left_ec;
eobtotal += c; eobtotal += c;
} }
A[8] = 0; A[8] = 0;
...@@ -374,8 +373,8 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi, ...@@ -374,8 +373,8 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
eobtotal += c - 4; eobtotal += c - 4;
type = PLANE_TYPE_Y_NO_DC; type = PLANE_TYPE_Y_NO_DC;
} else { } else {
xd->above_context->y2 = 1; xd->above_context->y2 = 0;
xd->left_context->y2 = 1; xd->left_context->y2 = 0;
eobs[24] = 0; eobs[24] = 0;
type = PLANE_TYPE_Y_WITH_DC; type = PLANE_TYPE_Y_WITH_DC;
} }
...@@ -385,15 +384,21 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi, ...@@ -385,15 +384,21 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
for (i = 0; i < 16; i += 4) { for (i = 0; i < 16; i += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[i]; ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[i];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[i]; ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[i];
#if CONFIG_CNVCONTEXT
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, type, 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 ? type == PLANE_TYPE_Y_WITH_DC ?
get_tx_type(xd, xd->block + i) : DCT_DCT, get_tx_type(xd, xd->block + i) : DCT_DCT,
seg_eob, xd->block[i].qcoeff, seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8, vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8); TX_8X8, vp9_coef_bands_8x8);
a[1] = a[0]; a[1] = a[0] = above_ec;
l[1] = l[0]; l[1] = l[0] = left_ec;
eobtotal += c; eobtotal += c;
} }
...@@ -415,13 +420,21 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi, ...@@ -415,13 +420,21 @@ static int vp9_decode_mb_tokens_8x8(VP9D_COMP* const pbi,
for (i = 16; i < 24; i += 4) { for (i = 16; i < 24; i += 4) {
ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[i]; ENTROPY_CONTEXT *const a = A + vp9_block2above_8x8[i];
ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[i]; ENTROPY_CONTEXT *const l = L + vp9_block2left_8x8[i];
#if CONFIG_CNVCONTEXT
eobs[i] = c = decode_coefs(pbi, xd, bc, a, l, PLANE_TYPE_UV, 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, DCT_DCT, seg_eob, xd->block[i].qcoeff,
vp9_default_zig_zag1d_8x8, vp9_default_zig_zag1d_8x8,
TX_8X8, vp9_coef_bands_8x8); TX_8X8, vp9_coef_bands_8x8);
a[1] = a[0]; a[1] = a[0] = above_ec;
l[1] = l[0]; l[1] = l[0] = left_ec;
eobtotal += c; eobtotal += c;
} }
} }
...@@ -517,8 +530,8 @@ static int vp9_decode_mb_tokens_4x4(VP9D_COMP* const dx, ...@@ -517,8 +530,8 @@ static int vp9_decode_mb_tokens_4x4(VP9D_COMP* const dx,
DCT_DCT, vp9_default_zig_zag1d) - 16; DCT_DCT, vp9_default_zig_zag1d) - 16;
type = PLANE_TYPE_Y_NO_DC; type = PLANE_TYPE_Y_NO_DC;
} else { } else {
xd->above_context->y2 = 1; xd->above_context->y2 = 0;
xd->left_context->y2 = 1; xd->left_context->y2 = 0;
xd->eobs[24] = 0; xd->eobs[24] = 0;
type = PLANE_TYPE_Y_WITH_DC; type = PLANE_TYPE_Y_WITH_DC;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "vp9/common/vp9_common.h" #include "vp9/common/vp9_common.h"
#include "vp9/encoder/vp9_onyx_int.h" #include "vp9/encoder/vp9_onyx_int.h"
#include "vp9/common/vp9_extend.h" #include "vp9/common/vp9_extend.h"
#include "vp9/common/vp9_entropy.h"
#include "vp9/common/vp9_entropymode.h" #include "vp9/common/vp9_entropymode.h"
#include "vp9/common/vp9_quant_common.h" #include "vp9/common/vp9_quant_common.h"
#include "vp9/encoder/vp9_segmentation.h" #include "vp9/encoder/vp9_segmentation.h"
...@@ -2287,7 +2288,7 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -2287,7 +2288,7 @@ static void encode_macroblock(VP9_COMP *cpi, MACROBLOCK *x,
mbmi->mb_skip_coeff = 1; mbmi->mb_skip_coeff = 1;
if (output_enabled) if (output_enabled)
cpi->skip_true_count[mb_skip_context]++; cpi->skip_true_count[mb_skip_context]++;
vp9_fix_contexts(xd); vp9_reset_mb_tokens_context(xd);
} else { } else {
vp9_stuff_mb(cpi, xd, t, !output_enabled); vp9_stuff_mb(cpi, xd, t, !output_enabled);
mbmi->mb_skip_coeff = 0; mbmi->mb_skip_coeff = 0;
...@@ -2525,7 +2526,7 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -2525,7 +2526,7 @@ static void encode_superblock(VP9_COMP *cpi, MACROBLOCK *x,
if (cpi->common.mb_no_coeff_skip) { if (cpi->common.mb_no_coeff_skip) {
// TODO(rbultje) this should be done per-sb instead of per-mb? // TODO(rbultje) this should be done per-sb instead of per-mb?
cpi->skip_true_count[mb_skip_context]++; cpi->skip_true_count[mb_skip_context]++;
vp9_fix_contexts(xd); vp9_reset_mb_tokens_context(xd);
} else { } else {
vp9_stuff_mb(cpi, xd, t, 0); vp9_stuff_mb(cpi, xd, t, 0);
// TODO(rbultje) this should be done per-sb instead of per-mb? // TODO(rbultje) this should be done per-sb instead of per-mb?
......
...@@ -727,14 +727,21 @@ void vp9_optimize_mby_8x8(MACROBLOCK *x) { ...@@ -727,14 +727,21 @@ void vp9_optimize_mby_8x8(MACROBLOCK *x) {
tl = (ENTROPY_CONTEXT *)&t_left; tl = (ENTROPY_CONTEXT *)&t_left;
type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC; type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC;
for (b = 0; b < 16; b += 4) { for (b = 0; b < 16; b += 4) {
optimize_b(x, b, type, ENTROPY_CONTEXT *const a = ta + vp9_block2above_8x8[b];
ta + vp9_block2above_8x8[b], tl + vp9_block2left_8x8[b], ENTROPY_CONTEXT *const l = tl + vp9_block2left_8x8[b];
TX_8X8); #if CONFIG_CNVCONTEXT
ta[vp9_block2above_8x8[b] + 1] = ta[vp9_block2above_8x8[b]]; ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
tl[vp9_block2left_8x8[b] + 1] = tl[vp9_block2left_8x8[b]]; 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) { if (has_2nd_order) {
check_reset_8x8_2nd_coeffs(&x->e_mbd, check_reset_8x8_2nd_coeffs(&x->e_mbd,
ta + vp9_block2above_8x8[24], ta + vp9_block2above_8x8[24],
...@@ -744,25 +751,23 @@ void vp9_optimize_mby_8x8(MACROBLOCK *x) { ...@@ -744,25 +751,23 @@ void vp9_optimize_mby_8x8(MACROBLOCK *x) {
void vp9_optimize_mbuv_8x8(MACROBLOCK *x) { void vp9_optimize_mbuv_8x8(MACROBLOCK *x) {
int b; int b;
ENTROPY_CONTEXT_PLANES t_above, t_left; ENTROPY_CONTEXT *const ta = (ENTROPY_CONTEXT *)x->e_mbd.above_context;
ENTROPY_CONTEXT *ta; ENTROPY_CONTEXT *const tl = (ENTROPY_CONTEXT *)x->e_mbd.left_context;
ENTROPY_CONTEXT *tl;
if (!x->e_mbd.above_context || !x->e_mbd.left_context) if (!ta || !tl)
return; 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) { for (b = 16; b < 24; b += 4) {
optimize_b(x, b, PLANE_TYPE_UV, ENTROPY_CONTEXT *const a = ta + vp9_block2above_8x8[b];
ta + vp9_block2above_8x8[b], tl + vp9_block2left_8x8[b], ENTROPY_CONTEXT *const l = tl + vp9_block2left_8x8[b];
TX_8X8); #if CONFIG_CNVCONTEXT
ta[vp9_block2above_8x8[b] + 1] = ta[vp9_block2above_8x8[b]]; ENTROPY_CONTEXT above_ec = (a[0] + a[1]) != 0;
tl[vp9_block2left_8x8[b] + 1] = tl[vp9_block2left_8x8[b]]; 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) { ...@@ -772,18 +777,21 @@ static void optimize_mb_8x8(MACROBLOCK *x) {
} }
void vp9_optimize_mby_16x16(MACROBLOCK *x) { void vp9_optimize_mby_16x16(MACROBLOCK *x) {
ENTROPY_CONTEXT_PLANES t_above, t_left; ENTROPY_CONTEXT_PLANES *const t_above = x->e_mbd.above_context;
ENTROPY_CONTEXT *ta, *tl; 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; return;
vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); #if CONFIG_CNVCONTEXT
vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); 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;
ta = (ENTROPY_CONTEXT *)&t_above; #else
tl = (ENTROPY_CONTEXT *)&t_left; ta = t_above->y1[0];
optimize_b(x, 0, PLANE_TYPE_Y_WITH_DC, ta, tl, TX_16X16); 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) { static void optimize_mb_16x16(MACROBLOCK *x) {
......
...@@ -423,7 +423,7 @@ void vp9_tokenize_mb(VP9_COMP *cpi, ...@@ -423,7 +423,7 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
if (!cpi->common.mb_no_coeff_skip) { if (!cpi->common.mb_no_coeff_skip) {
vp9_stuff_mb(cpi, xd, t, dry_run); vp9_stuff_mb(cpi, xd, t, dry_run);
} else { } else {
vp9_fix_contexts(xd); vp9_reset_mb_tokens_context(xd);
} }
if (dry_run) if (dry_run)
*t = t_backup; *t = t_backup;
...@@ -434,45 +434,60 @@ void vp9_tokenize_mb(VP9_COMP *cpi, ...@@ -434,45 +434,60 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
cpi->skip_false_count[mb_skip_context] += skip_inc; cpi->skip_false_count[mb_skip_context] += skip_inc;
if (has_2nd_order) { if (has_2nd_order) {
if (tx_size == TX_8X8) { tokenize_b(cpi, xd, xd->block + 24, t, PLANE_TYPE_Y2,
tokenize_b(cpi, xd, xd->block + 24, t, PLANE_TYPE_Y2, A + vp9_block2above_8x8[24], L + vp9_block2left_8x8[24],
A + vp9_block2above_8x8[24], L + vp9_block2left_8x8[24], tx_size, dry_run);
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);
}
plane_type = PLANE_TYPE_Y_NO_DC; plane_type = PLANE_TYPE_Y_NO_DC;
} else { } else {
xd->above_context->y2 = 1; xd->above_context->y2 = 0;
xd->left_context->y2 = 1; xd->left_context->y2 = 0;
plane_type = PLANE_TYPE_Y_WITH_DC; plane_type = PLANE_TYPE_Y_WITH_DC;
} }
if (tx_size == TX_16X16) { 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, tokenize_b(cpi, xd, xd->block, t, PLANE_TYPE_Y_WITH_DC,
A, L, TX_16X16, dry_run); &above_ec, &left_ec, TX_16X16, dry_run);
A[1] = A[2] = A[3] = A[0]; A[1] = A[2] = A[3] = A[0] = above_ec;
L[1] = L[2] = L[3] = L[0]; L[1] = L[2] = L[3] = L[0] = left_ec;
for (b = 16; b < 24; b += 4) { 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, tokenize_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b], &above_ec, &left_ec, TX_8X8, dry_run);
TX_8X8, dry_run); a[1] = a[0] = above_ec;
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]]; l[1] = l[0] = left_ec;
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
} }
A[8] = 0; A[8] = 0;
L[8] = 0; L[8] = 0;
} else if (tx_size == TX_8X8) { } else if (tx_size == TX_8X8) {
for (b = 0; b < 16; b += 4) { 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, tokenize_b(cpi, xd, xd->block + b, t, plane_type,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b], &above_ec, &left_ec, TX_8X8, dry_run);
TX_8X8, dry_run); a[1] = a[0] = above_ec;
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]]; l[1] = l[0] = left_ec;
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
} }
if (xd->mode_info_context->mbmi.mode == I8X8_PRED || if (xd->mode_info_context->mbmi.mode == I8X8_PRED ||
xd->mode_info_context->mbmi.mode == SPLITMV) { xd->mode_info_context->mbmi.mode == SPLITMV) {
...@@ -483,11 +498,19 @@ void vp9_tokenize_mb(VP9_COMP *cpi, ...@@ -483,11 +498,19 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
} }
} else { } else {
for (b = 16; b < 24; b += 4) { 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, tokenize_b(cpi, xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp9_block2above_8x8[b], L + vp9_block2left_8x8[b], &above_ec, &left_ec, TX_8X8, dry_run);
TX_8X8, dry_run); a[1] = a[0] = above_ec;
A[vp9_block2above_8x8[b] + 1] = A[vp9_block2above_8x8[b]]; l[1] = l[0] = left_ec;
L[vp9_block2left_8x8[b] + 1] = L[vp9_block2left_8x8[b]];
} }
} }
} else { } else {
...@@ -794,66 +817,97 @@ static void stuff_mb_8x8(VP9_COMP *cpi, MACROBLOCKD *xd, ...@@ -794,66 +817,97 @@ static void stuff_mb_8x8(VP9_COMP *cpi, MACROBLOCKD *xd,