xd->fullpixel_mask = 0xffffffff;
if(cm->full_pixel)
xd->fullpixel_mask = 0xfffffff8;
+
+ vp8_zero(x->coef_counts);
+}
+
+static void sum_coef_counts(MACROBLOCK *x, MACROBLOCK *x_thread)
+{
+ int i = 0;
+ do
+ {
+ int j = 0;
+ do
+ {
+ int k = 0;
+ do
+ {
+ /* at every context */
+
+ /* calc probs and branch cts for this frame only */
+ int t = 0; /* token/prob index */
+
+ do
+ {
+ x->coef_counts [i][j][k][t] +=
+ x_thread->coef_counts [i][j][k][t];
+ }
+ while (++t < ENTROPY_NODES);
+ }
+ while (++k < PREV_COEF_CONTEXTS);
+ }
+ while (++j < COEF_BANDS);
+ }
+ while (++i < BLOCK_TYPES);
}
void vp8_encode_frame(VP8_COMP *cpi)
vp8_zero(cpi->MVcount);
- vp8_zero(cpi->coef_counts);
-
vp8cx_frame_init_quantizer(cpi);
vp8_initialize_rd_consts(cpi,
for (i = 0; i < cpi->encoding_thread_count; i++)
{
totalrate += cpi->mb_row_ei[i].totalrate;
+
+ /* add up counts for each thread */
+ sum_coef_counts(x, &cpi->mb_row_ei[i].mb);
}
}
else
#endif
{
+
/* for each macroblock row in image */
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
{
sum_intra_stats(cpi, x);
- vp8_tokenize_mb(cpi, &x->e_mbd, t);
+ vp8_tokenize_mb(cpi, x, t);
if (xd->mode_info_context->mbmi.mode != B_PRED)
vp8_inverse_transform_mby(xd);
if (!x->skip)
{
- vp8_tokenize_mb(cpi, xd, t);
+ vp8_tokenize_mb(cpi, x, t);
if (xd->mode_info_context->mbmi.mode != B_PRED)
vp8_inverse_transform_mby(xd);
#ifdef ENTROPY_STATS
_int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
#endif
-void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ;
+void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t) ;
void vp8_fix_contexts(MACROBLOCKD *x);
#include "dct_value_tokens.h"
static void tokenize2nd_order_b
(
- MACROBLOCKD *x,
+ MACROBLOCK *x,
TOKENEXTRA **tp,
VP8_COMP *cpi
)
{
+ MACROBLOCKD *xd = &x->e_mbd;
int pt; /* near block/prev token context index */
int c; /* start at DC */
TOKENEXTRA *t = *tp;/* store tokens starting here */
int band, rc, v, token;
int eob;
- b = x->block + 24;
+ b = xd->block + 24;
qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)x->above_context + 8;
- l = (ENTROPY_CONTEXT *)x->left_context + 8;
- eob = x->eobs[24];
+ a = (ENTROPY_CONTEXT *)xd->above_context + 8;
+ l = (ENTROPY_CONTEXT *)xd->left_context + 8;
+ eob = xd->eobs[24];
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
if(!eob)
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
t++;
*tp = t;
*a = *l = 0;
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [0] [pt] [token];
+ ++x->coef_counts [1] [0] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c = 1;
t->skip_eob_node = ((pt == 0));
- ++cpi->coef_counts [1] [band] [pt] [token];
+ ++x->coef_counts [1] [band] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
t++;
}
static void tokenize1st_order_b
(
- MACROBLOCKD *x,
+ MACROBLOCK *x,
TOKENEXTRA **tp,
int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
VP8_COMP *cpi
)
{
+ MACROBLOCKD *xd = &x->e_mbd;
unsigned int block;
const BLOCKD *b;
int pt; /* near block/prev token context index */
int band, rc, v;
int tmp1, tmp2;
- b = x->block;
+ b = xd->block;
/* Luma */
for (block = 0; block < 16; block++, b++)
{
tmp1 = vp8_block2above[block];
tmp2 = vp8_block2left[block];
qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)x->above_context + tmp1;
- l = (ENTROPY_CONTEXT *)x->left_context + tmp2;
+ a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
+ l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
t->context_tree = cpi->common.fc.coef_probs [type] [c] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [c] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [type] [c] [pt] [DCT_EOB_TOKEN];
t++;
*tp = t;
*a = *l = 0;
t->context_tree = cpi->common.fc.coef_probs [type] [c] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [c] [pt] [token];
+ ++x->coef_counts [type] [c] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c++;
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = (pt == 0);
- ++cpi->coef_counts [type] [band] [pt] [token];
+ ++x->coef_counts [type] [band] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
t++;
}
tmp1 = vp8_block2above[block];
tmp2 = vp8_block2left[block];
qcoeff_ptr = b->qcoeff;
- a = (ENTROPY_CONTEXT *)x->above_context + tmp1;
- l = (ENTROPY_CONTEXT *)x->left_context + tmp2;
+ a = (ENTROPY_CONTEXT *)xd->above_context + tmp1;
+ l = (ENTROPY_CONTEXT *)xd->left_context + tmp2;
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [2] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [2] [0] [pt] [DCT_EOB_TOKEN];
t++;
*tp = t;
*a = *l = 0;
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [2] [0] [pt] [token];
+ ++x->coef_counts [2] [0] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c = 1;
t->skip_eob_node = (pt == 0);
- ++cpi->coef_counts [2] [band] [pt] [token];
+ ++x->coef_counts [2] [band] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
t->skip_eob_node = 0;
- ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
t++;
}
}
-void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
+void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
{
+ MACROBLOCKD *xd = &x->e_mbd;
int plane_type;
int has_y2_block;
- has_y2_block = (x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV);
+ has_y2_block = (xd->mode_info_context->mbmi.mode != B_PRED
+ && xd->mode_info_context->mbmi.mode != SPLITMV);
- x->mode_info_context->mbmi.mb_skip_coeff = mb_is_skippable(x, has_y2_block);
- if (x->mode_info_context->mbmi.mb_skip_coeff)
+ xd->mode_info_context->mbmi.mb_skip_coeff =
+ mb_is_skippable(xd, has_y2_block);
+ if (xd->mode_info_context->mbmi.mb_skip_coeff)
{
if (!cpi->common.mb_no_coeff_skip)
{
}
else
{
- vp8_fix_contexts(x);
+ vp8_fix_contexts(xd);
cpi->skip_true_count++;
}
TOKENEXTRA **tp,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
+ VP8_COMP *cpi,
+ MACROBLOCK *x
)
{
int pt; /* near block/prev token context index */
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [1] [0] [pt] [DCT_EOB_TOKEN];
++t;
*tp = t;
pt = 0;
*a = *l = pt;
-
}
static void stuff1st_order_b
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
int type,
- VP8_COMP *cpi
+ VP8_COMP *cpi,
+ MACROBLOCK *x
)
{
int pt; /* near block/prev token context index */
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
++t;
*tp = t;
pt = 0; /* 0 <-> all coeff data is zero */
*a = *l = pt;
-
}
+
static
void stuff1st_order_buv
(
TOKENEXTRA **tp,
ENTROPY_CONTEXT *a,
ENTROPY_CONTEXT *l,
- VP8_COMP *cpi
+ VP8_COMP *cpi,
+ MACROBLOCK *x
)
{
int pt; /* near block/prev token context index */
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
t->skip_eob_node = 0;
- ++cpi->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN];
+ ++x->coef_counts[2] [0] [pt] [DCT_EOB_TOKEN];
++t;
*tp = t;
pt = 0; /* 0 <-> all coeff data is zero */
*a = *l = pt;
-
}
-void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
+void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCK *x, TOKENEXTRA **t)
{
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
+ MACROBLOCKD *xd = &x->e_mbd;
+ ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)xd->above_context;
+ ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)xd->left_context;
int plane_type;
int b;
plane_type = 3;
- if((x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV))
+ if((xd->mode_info_context->mbmi.mode != B_PRED
+ && xd->mode_info_context->mbmi.mode != SPLITMV))
{
stuff2nd_order_b(t,
- A + vp8_block2above[24], L + vp8_block2left[24], cpi);
+ A + vp8_block2above[24], L + vp8_block2left[24], cpi, x);
plane_type = 0;
}
for (b = 0; b < 16; b++)
stuff1st_order_b(t,
A + vp8_block2above[b],
- L + vp8_block2left[b], plane_type, cpi);
+ L + vp8_block2left[b], plane_type, cpi, x);
for (b = 16; b < 24; b++)
stuff1st_order_buv(t,
A + vp8_block2above[b],
- L + vp8_block2left[b], cpi);
+ L + vp8_block2left[b], cpi, x);
}
void vp8_fix_contexts(MACROBLOCKD *x)