#if CONFIG_HYBRIDTRANSFORM
void static count_tokens_adaptive_scan(const MACROBLOCKD *xd, INT16 *qcoeff_ptr,
- int block, int type,
+ int block, PLANE_TYPE type,
TX_TYPE tx_type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int eob, int seg_eob,
}
#endif
-void static count_tokens(INT16 *qcoeff_ptr, int block, int type,
+void static count_tokens(INT16 *qcoeff_ptr, int block, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int eob, int seg_eob, FRAME_CONTEXT *const fc) {
int c, pt, token, band;
}
}
-void static count_tokens_8x8(INT16 *qcoeff_ptr, int block, int type,
+void static count_tokens_8x8(INT16 *qcoeff_ptr, int block, PLANE_TYPE type,
#if CONFIG_HYBRIDTRANSFORM8X8
TX_TYPE tx_type,
#endif
}
}
-void static count_tokens_16x16(INT16 *qcoeff_ptr, int block, int type,
+void static count_tokens_16x16(INT16 *qcoeff_ptr, int block, PLANE_TYPE type,
#if CONFIG_HYBRIDTRANSFORM16X16
TX_TYPE tx_type,
#endif
} while (0);
static int vp8_decode_coefs(VP8D_COMP *dx, const MACROBLOCKD *xd,
- ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int type,
+ ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
+ PLANE_TYPE type,
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
TX_TYPE tx_type,
#endif
const int *coef_bands) {
FRAME_CONTEXT *const fc = &dx->common.fc;
BOOL_DECODER *br = xd->current_bc;
- int tmp, c = (type == 0);
+ int tmp, c = (type == PLANE_TYPE_Y_NO_DC);
const vp8_prob *prob, *coef_probs;
switch (block_type) {
ENTROPY_CONTEXT* const L = (ENTROPY_CONTEXT *)xd->left_context;
char* const eobs = xd->eobs;
- int c, i, type, eobtotal = 0, seg_eob;
+ PLANE_TYPE type;
+ int c, i, eobtotal = 0, seg_eob;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB);
INT16 *qcoeff_ptr = &xd->qcoeff[0];
// Luma block
{
const int* const scan = vp8_default_zig_zag1d_16x16;
- //printf("16: %d\n", tx_type);
c = vp8_decode_coefs(pbi, xd, A, L, type,
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
tx_type,
ENTROPY_CONTEXT* const l = L + vp8_block2left_8x8[i];
const int* const scan = vp8_default_zig_zag1d_8x8;
- //printf("8: %d\n", tx_type);
c = vp8_decode_coefs(pbi, xd, a, l, type,
#if CONFIG_HYBRIDTRANSFORM8X8 || CONFIG_HYBRIDTRANSFORM || CONFIG_HYBRIDTRANSFORM16X16
tx_type,
ENTROPY_CONTEXT *const L = (ENTROPY_CONTEXT *)xd->left_context;
char *const eobs = xd->eobs;
- int c, i, type, eobtotal = 0, seg_eob;
+ PLANE_TYPE type;
+ int c, i, eobtotal = 0, seg_eob;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int seg_active = segfeature_active(xd, segment_id, SEG_LVL_EOB);
INT16 *qcoeff_ptr = &xd->qcoeff[0];
char *const eobs = xd->eobs;
const int *scan = vp8_default_zig_zag1d;
-
- int c, i, type, eobtotal = 0, seg_eob = 16;
+ PLANE_TYPE type;
+ int c, i, eobtotal = 0, seg_eob = 16;
INT16 *qcoeff_ptr = &xd->qcoeff[0];
int segment_id = xd->mode_info_context->mbmi.segment_id;
}\
}
-void optimize_b(MACROBLOCK *mb, int i, int type,
+void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
const VP8_ENCODER_RTCD *rtcd, int tx_type) {
BLOCK *b;
coeff_ptr = b->coeff;
qcoeff_ptr = d->qcoeff;
dqcoeff_ptr = d->dqcoeff;
- i0 = !type;
+ i0 = (type == PLANE_TYPE_Y_NO_DC);
eob = d->eob;
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
**************************************************************************/
#define SUM_2ND_COEFF_THRESH 65
-static void check_reset_2nd_coeffs(MACROBLOCKD *xd, int type,
+static void check_reset_2nd_coeffs(MACROBLOCKD *xd,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
int sum = 0;
int i;
bd->dqcoeff[rc] = 0;
}
bd->eob = 0;
- *a = *l = (bd->eob != !type);
+ *a = *l = (bd->eob != 0);
}
}
#define SUM_2ND_COEFF_THRESH_8X8 32
-static void check_reset_8x8_2nd_coeffs(MACROBLOCKD *xd, int type,
+static void check_reset_8x8_2nd_coeffs(MACROBLOCKD *xd,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
int sum = 0;
BLOCKD *bd = &xd->block[24];
bd->qcoeff[8] = 0;
bd->dqcoeff[8] = 0;
bd->eob = 0;
- *a = *l = (bd->eob != !type);
+ *a = *l = (bd->eob != 0);
}
}
void vp8_optimize_mby_4x4(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
int b;
- int type;
+ PLANE_TYPE type;
int has_2nd_order;
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta;
b = 24;
optimize_b(x, b, PLANE_TYPE_Y2,
ta + vp8_block2above[b], tl + vp8_block2left[b], rtcd, TX_4X4);
- check_reset_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
+ check_reset_2nd_coeffs(&x->e_mbd,
ta + vp8_block2above[b], tl + vp8_block2left[b]);
}
}
void vp8_optimize_mby_8x8(MACROBLOCK *x, const VP8_ENCODER_RTCD *rtcd) {
int b;
- int type;
+ PLANE_TYPE type;
ENTROPY_CONTEXT_PLANES t_above, t_left;
ENTROPY_CONTEXT *ta;
ENTROPY_CONTEXT *tl;
ta = (ENTROPY_CONTEXT *)&t_above;
tl = (ENTROPY_CONTEXT *)&t_left;
- type = 0;
+ type = PLANE_TYPE_Y_NO_DC;
for (b = 0; b < 16; b += 4) {
optimize_b(x, b, type,
ta + vp8_block2above[b], tl + vp8_block2left[b],
}
// 8x8 always have 2nd roder haar block
- check_reset_8x8_2nd_coeffs(&x->e_mbd, PLANE_TYPE_Y2,
+ check_reset_8x8_2nd_coeffs(&x->e_mbd,
ta + vp8_block2above_8x8[24], tl + vp8_block2left_8x8[24]);
}
vp8_optimize_mbuv_8x8(x, rtcd);
}
-void optimize_b_16x16(MACROBLOCK *mb, int i, int type,
+void optimize_b_16x16(MACROBLOCK *mb, int i, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
const VP8_ENCODER_RTCD *rtcd) {
BLOCK *b = &mb->block[i];
static void tokenize1st_order_b_16x16(MACROBLOCKD *xd,
const BLOCKD *const b,
TOKENEXTRA **tp,
- const int type,
- const FRAME_TYPE frametype,
+ PLANE_TYPE type,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
VP8_COMP *cpi,
int dry_run) {
int pt; /* near block/prev token context index */
- int c = 0; /* start at DC unless type 0 */
+ int c = (type == PLANE_TYPE_Y_NO_DC) ? 1 : 0;
const int eob = b->eob; /* one beyond last nonzero coeff */
TOKENEXTRA *t = *tp; /* store tokens starting here */
const short *qcoeff_ptr = b->qcoeff;
#if CONFIG_HYBRIDTRANSFORM16X16
TX_TYPE tx_type = get_tx_type(xd, b);
#endif
-
int seg_eob = 256;
int segment_id = xd->mode_info_context->mbmi.segment_id;
- //if (!dry_run) printf("16: %d\n", tx_type);
-
if (segfeature_active(xd, segment_id, SEG_LVL_EOB))
seg_eob = get_segdata(xd, segment_id, SEG_LVL_EOB);
#endif
t->context_tree = cpi->common.fc.coef_probs_16x16[type][band][pt];
- t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->skip_eob_node = pt == 0 && ((band > 0 && type != PLANE_TYPE_Y_NO_DC) ||
+ (band > 1 && type == PLANE_TYPE_Y_NO_DC));
if (!dry_run) {
#if CONFIG_HYBRIDTRANSFORM16X16
if (tx_type != DCT_DCT)
static void tokenize2nd_order_b_8x8(MACROBLOCKD *xd,
const BLOCKD *const b,
TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
VP8_COMP *cpi,
const int eob = b->eob; /* one beyond last nonzero coeff */
TOKENEXTRA *t = *tp; /* store tokens starting here */
const short *qcoeff_ptr = b->qcoeff;
-
int seg_eob = 4;
int segment_id = xd->mode_info_context->mbmi.segment_id;
}
t->Token = x;
- // printf("Token : %d\n", x);
- t->context_tree = cpi->common.fc.coef_probs_8x8 [type] [band] [pt];
+ t->context_tree = cpi->common.fc.coef_probs_8x8[PLANE_TYPE_Y2][band][pt];
- t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->skip_eob_node = ((pt == 0) && (band > 0));
assert(vp8_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run)
- ++cpi->coef_counts_8x8 [type] [band] [pt] [x];
+ ++cpi->coef_counts_8x8[PLANE_TYPE_Y2][band][pt][x];
pt = vp8_prev_token_class[x];
++t;
} while (c < eob && ++c < seg_eob);
*tp = t;
- pt = (c != !type); /* 0 <-> all coeff data is zero */
+ pt = (c != 0); /* 0 <-> all coeff data is zero */
*a = *l = pt;
}
token = DCT_EOB_TOKEN;
t->Token = token;
- t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
+ t->context_tree = cpi->common.fc.coef_probs[PLANE_TYPE_Y2][band][pt];
t->skip_eob_node = ((pt == 0) && (band > 0));
assert(vp8_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run)
- ++cpi->coef_counts [1] [band] [pt] [token];
+ ++cpi->coef_counts[PLANE_TYPE_Y2][band][pt][token];
pt = vp8_prev_token_class[token];
++t;
} while (c < eob && ++c < seg_eob);
static void tokenize1st_order_b_8x8(MACROBLOCKD *xd,
const BLOCKD *const b,
TOKENEXTRA **tp,
- const int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
- const FRAME_TYPE frametype,
+ PLANE_TYPE type,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
VP8_COMP *cpi,
int dry_run) {
int pt; /* near block/prev token context index */
- int c = type ? 0 : 1; /* start at DC unless type 0 */
+ int c = (type == PLANE_TYPE_Y_NO_DC) ? 1 : 0; /* start at DC unless type 0 */
TOKENEXTRA *t = *tp; /* store tokens starting here */
const short *qcoeff_ptr = b->qcoeff;
#if CONFIG_HYBRIDTRANSFORM8X8
#endif
t->context_tree = cpi->common.fc.coef_probs_8x8[type][band][pt];
- t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->skip_eob_node = pt == 0 && ((band > 0 && type != PLANE_TYPE_Y_NO_DC) ||
+ (band > 1 && type == PLANE_TYPE_Y_NO_DC));
assert(vp8_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run) {
static void tokenize1st_order_chroma_4x4(MACROBLOCKD *xd,
TOKENEXTRA **tp,
- int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
VP8_COMP *cpi,
int dry_run) {
unsigned int block;
token = DCT_EOB_TOKEN;
t->Token = token;
- t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
+ t->context_tree = cpi->common.fc.coef_probs[PLANE_TYPE_UV][band][pt];
t->skip_eob_node = ((pt == 0) && (band > 0));
assert(vp8_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run)
- ++cpi->coef_counts [2] [band] [pt] [token];
+ ++cpi->coef_counts[PLANE_TYPE_UV][band][pt][token];
pt = vp8_prev_token_class[token];
++t;
} while (c < eob && ++c < seg_eob);
#if CONFIG_HYBRIDTRANSFORM
static void tokenize1st_order_ht_4x4(MACROBLOCKD *xd,
TOKENEXTRA **tp,
- int type,
+ PLANE_TYPE type,
VP8_COMP *cpi,
int dry_run) {
unsigned int block;
const int tmp1 = vp8_block2above[block];
const int tmp2 = vp8_block2left[block];
const int16_t *qcoeff_ptr = b->qcoeff;
- int c = type ? 0 : 1;
+ int c = (type == PLANE_TYPE_Y_NO_DC) ? 1 : 0;
a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
t->Token = token;
if (tx_type != DCT_DCT)
- t->context_tree = cpi->common.fc.hybrid_coef_probs [type] [band] [pt];
+ t->context_tree = cpi->common.fc.hybrid_coef_probs[type][band][pt];
else
- t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
+ t->context_tree = cpi->common.fc.coef_probs[type][band][pt];
- t->skip_eob_node = pt == 0 &&
- ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->skip_eob_node = pt == 0 && ((band > 0 && type != PLANE_TYPE_Y_NO_DC) ||
+ (band > 1 && type == PLANE_TYPE_Y_NO_DC));
assert(vp8_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run) {
if (tx_type != DCT_DCT)
- ++cpi->hybrid_coef_counts[type] [band] [pt] [token];
+ ++cpi->hybrid_coef_counts[type][band][pt][token];
else
- ++cpi->coef_counts [type] [band] [pt] [token];
+ ++cpi->coef_counts [type][band][pt][token];
}
pt = vp8_prev_token_class[token];
++t;
*a = *l = pt;
}
- tokenize1st_order_chroma_4x4(xd, tp, PLANE_TYPE_UV, cpi, dry_run);
+ tokenize1st_order_chroma_4x4(xd, tp, cpi, dry_run);
}
#endif
static void tokenize1st_order_b_4x4(MACROBLOCKD *xd,
TOKENEXTRA **tp,
- int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
+ PLANE_TYPE type,
VP8_COMP *cpi,
int dry_run) {
unsigned int block;
for (block = 0; block < 16; block++, b++) {
const int eob = b->eob;
const int16_t *qcoeff_ptr = b->qcoeff;
- int c = type ? 0 : 1;
+ int c = (type == PLANE_TYPE_Y_NO_DC) ? 1 : 0;
a = (ENTROPY_CONTEXT *)xd->above_context + vp8_block2above[block];
l = (ENTROPY_CONTEXT *)xd->left_context + vp8_block2left[block];
token = DCT_EOB_TOKEN;
t->Token = token;
- t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
+ t->context_tree = cpi->common.fc.coef_probs[type][band][pt];
- t->skip_eob_node = pt == 0 &&
- ((band > 0 && type > 0) || (band > 1 && type == 0));
+ t->skip_eob_node = pt == 0 && ((band > 0 && type != PLANE_TYPE_Y_NO_DC) ||
+ (band > 1 && type == PLANE_TYPE_Y_NO_DC));
assert(vp8_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run)
- ++cpi->coef_counts [type] [band] [pt] [token];
+ ++cpi->coef_counts[type][band][pt][token];
pt = vp8_prev_token_class[token];
++t;
} while (c < eob && ++c < seg_eob);
*a = *l = pt;
}
- tokenize1st_order_chroma_4x4(xd, tp, PLANE_TYPE_UV, cpi, dry_run);
+ tokenize1st_order_chroma_4x4(xd, tp, cpi, dry_run);
}
int mby_is_skippable_4x4(MACROBLOCKD *xd, int has_y2_block) {
MACROBLOCKD *xd,
TOKENEXTRA **t,
int dry_run) {
- int plane_type;
+ PLANE_TYPE plane_type;
int has_y2_block;
int b;
int tx_size = xd->mode_info_context->mbmi.txfm_size;
} else
skip_inc = 0;
- has_y2_block = (xd->mode_info_context->mbmi.mode != B_PRED
+ has_y2_block = (tx_size != TX_16X16
+ && xd->mode_info_context->mbmi.mode != B_PRED
&& xd->mode_info_context->mbmi.mode != I8X8_PRED
&& xd->mode_info_context->mbmi.mode != SPLITMV);
- if (tx_size == TX_16X16) has_y2_block = 0; // Because of inter frames
switch (tx_size) {
case TX_16X16:
if (!dry_run)
cpi->skip_false_count[mb_skip_context] += skip_inc;
- plane_type = 3;
if (has_y2_block) {
if (tx_size == TX_8X8) {
ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)xd->left_context;
tokenize2nd_order_b_8x8(xd,
- xd->block + 24, t, 1, xd->frame_type,
+ xd->block + 24, t,
A + vp8_block2above_8x8[24],
L + vp8_block2left_8x8[24],
cpi, dry_run);
} else
tokenize2nd_order_b_4x4(xd, t, cpi, dry_run);
- plane_type = 0;
- }
+ plane_type = PLANE_TYPE_Y_NO_DC;
+ } else
+ plane_type = PLANE_TYPE_Y_WITH_DC;
if (tx_size == TX_16X16) {
ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)xd->left_context;
- tokenize1st_order_b_16x16(xd, xd->block, t, 3,
- xd->frame_type, A, L, cpi, dry_run);
+ tokenize1st_order_b_16x16(xd, xd->block, t, PLANE_TYPE_Y_WITH_DC,
+ A, L, cpi, dry_run);
for (b = 1; b < 16; b++) {
*(A + vp8_block2above[b]) = *(A);
*(L + vp8_block2left[b] ) = *(L);
}
for (b = 16; b < 24; b += 4) {
- tokenize1st_order_b_8x8(xd, xd->block + b, t, 2, xd->frame_type,
- A + vp8_block2above_8x8[b], L + vp8_block2left_8x8[b], cpi, dry_run);
+ tokenize1st_order_b_8x8(xd, xd->block + b, t, PLANE_TYPE_UV,
+ A + vp8_block2above_8x8[b],
+ L + vp8_block2left_8x8[b], cpi, dry_run);
*(A + vp8_block2above_8x8[b]+1) = *(A + vp8_block2above_8x8[b]);
*(L + vp8_block2left_8x8[b]+1 ) = *(L + vp8_block2left_8x8[b]);
}
else if (tx_size == TX_8X8) {
ENTROPY_CONTEXT *A = (ENTROPY_CONTEXT *)xd->above_context;
ENTROPY_CONTEXT *L = (ENTROPY_CONTEXT *)xd->left_context;
- if (xd->mode_info_context->mbmi.mode == I8X8_PRED) {
- plane_type = PLANE_TYPE_Y_WITH_DC;
- }
for (b = 0; b < 16; b += 4) {
tokenize1st_order_b_8x8(xd,
- xd->block + b,
- t, plane_type, xd->frame_type,
+ xd->block + b, t, plane_type,
A + vp8_block2above_8x8[b],
L + vp8_block2left_8x8[b],
cpi, dry_run);
*(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
}
if (xd->mode_info_context->mbmi.mode == I8X8_PRED) {
- tokenize1st_order_chroma_4x4(xd, t, PLANE_TYPE_UV, cpi, dry_run);
+ tokenize1st_order_chroma_4x4(xd, t, cpi, dry_run);
} else {
for (b = 16; b < 24; b += 4) {
- tokenize1st_order_b_8x8(xd,
- xd->block + b, t, 2, xd->frame_type,
+ tokenize1st_order_b_8x8(xd, xd->block + b, t, PLANE_TYPE_UV,
A + vp8_block2above_8x8[b],
- L + vp8_block2left_8x8[b],
- cpi, dry_run);
+ L + vp8_block2left_8x8[b], cpi, dry_run);
*(A + vp8_block2above_8x8[b] + 1) = *(A + vp8_block2above_8x8[b]);
*(L + vp8_block2left_8x8[b] + 1) = *(L + vp8_block2left_8x8[b]);
}