Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1046)

Unified Diff: source/libvpx/vp8/encoder/tokenize.c

Issue 7671004: Update libvpx snapshot to v0.9.7-p1 (Cayuga). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp8/encoder/tokenize.h ('k') | source/libvpx/vp8/encoder/variance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp8/encoder/tokenize.c
===================================================================
--- source/libvpx/vp8/encoder/tokenize.c (revision 96967)
+++ source/libvpx/vp8/encoder/tokenize.c (working copy)
@@ -21,7 +21,7 @@
compressions, then generating context.c = initial stats. */
#ifdef ENTROPY_STATS
-_int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens];
+_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_fix_contexts(MACROBLOCKD *x);
@@ -95,115 +95,192 @@
static void tokenize2nd_order_b
(
- const BLOCKD *const b,
+ MACROBLOCKD *x,
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
)
{
- int pt; /* near block/prev token context index */
- int c = 0; /* start at DC */
- const int eob = b->eob; /* one beyond last nonzero coeff */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- int x;
- const short *qcoeff_ptr = b->qcoeff;
+ int pt; /* near block/prev token context index */
+ int c; /* start at DC */
+ TOKENEXTRA *t = *tp;/* store tokens starting here */
+ const BLOCKD *b;
+ const short *qcoeff_ptr;
+ ENTROPY_CONTEXT * a;
+ ENTROPY_CONTEXT * l;
+ int band, rc, v, token;
+
+ b = x->block + 24;
+ qcoeff_ptr = b->qcoeff;
+ a = (ENTROPY_CONTEXT *)x->above_context + 8;
+ l = (ENTROPY_CONTEXT *)x->left_context + 8;
+
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- do
+ for (c = 0; c < b->eob; c++)
{
- const int band = vp8_coef_bands[c];
+ rc = vp8_default_zig_zag1d[c];
+ band = vp8_coef_bands[c];
+ v = qcoeff_ptr[rc];
- if (c < eob)
- {
- int rc = vp8_default_zig_zag1d[c];
- const int v = qcoeff_ptr[rc];
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ token = vp8_dct_value_tokens_ptr[v].Token;
- assert(-DCT_MAX_VALUE <= v && v < (DCT_MAX_VALUE));
+ t->Token = token;
+ t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
- t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- x = vp8_dct_value_tokens_ptr[v].Token;
- }
- else
- x = DCT_EOB_TOKEN;
+ t->skip_eob_node = ((pt == 0) && (band > 0));
- t->Token = x;
- t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
+ ++cpi->coef_counts [1] [band] [pt] [token];
- t->skip_eob_node = pt == 0 && ((band > 0 && type > 0) || (band > 1 && type == 0));
+ pt = vp8_prev_token_class[token];
+ t++;
+ }
+ if (c < 16)
+ {
+ band = vp8_coef_bands[c];
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
- ++cpi->coef_counts [type] [band] [pt] [x];
+ t->skip_eob_node = ((pt == 0) && (band > 0));
+
+ ++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
+
+ t++;
}
- while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < 16);
*tp = t;
- pt = (c != !type); /* 0 <-> all coeff data is zero */
+ pt = (c != 0); /* 0 <-> all coeff data is zero */
*a = *l = pt;
}
static void tokenize1st_order_b
(
- const BLOCKD *const b,
+ MACROBLOCKD *x,
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,
+ int type, /* which plane: 0=Y no DC, 1=Y2, 2=UV, 3=Y with DC */
VP8_COMP *cpi
)
{
- int pt; /* near block/prev token context index */
- int c = type ? 0 : 1; /* start at DC unless type 0 */
- const int eob = b->eob; /* one beyond last nonzero coeff */
- TOKENEXTRA *t = *tp; /* store tokens starting here */
- int x;
- const short *qcoeff_ptr = b->qcoeff;
- VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ unsigned int block;
+ const BLOCKD *b;
+ int pt; /* near block/prev token context index */
+ int c;
+ int token;
+ TOKENEXTRA *t = *tp;/* store tokens starting here */
+ const short *qcoeff_ptr;
+ ENTROPY_CONTEXT * a;
+ ENTROPY_CONTEXT * l;
+ int band, rc, v;
+ int tmp1, tmp2;
- do
+ b = x->block;
+ /* Luma */
+ for (block = 0; block < 16; block++, b++)
{
- const int band = vp8_coef_bands[c];
+ 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;
- x = DCT_EOB_TOKEN;
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- if (c < eob)
+ c = type ? 0 : 1;
+
+ for (; c < b->eob; c++)
{
- int rc = vp8_default_zig_zag1d[c];
- const int v = qcoeff_ptr[rc];
+ rc = vp8_default_zig_zag1d[c];
+ band = vp8_coef_bands[c];
+ v = qcoeff_ptr[rc];
- assert(-DCT_MAX_VALUE <= v && v < (DCT_MAX_VALUE));
-
t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
- x = vp8_dct_value_tokens_ptr[v].Token;
+ token = vp8_dct_value_tokens_ptr[v].Token;
+
+ t->Token = token;
+ 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));
+
+ ++cpi->coef_counts [type] [band] [pt] [token];
+
+ pt = vp8_prev_token_class[token];
+ t++;
}
+ if (c < 16)
+ {
+ band = vp8_coef_bands[c];
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [type] [band] [pt];
- t->Token = x;
- 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 > 0) || (band > 1 && type == 0));
+ ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
- ++cpi->coef_counts [type] [band] [pt] [x];
+ t++;
+ }
+ *tp = t;
+ pt = (c != !type); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
+
}
- while (pt = vp8_prev_token_class[x], ++t, c < eob && ++c < 16);
+ /* Chroma */
+ for (block = 16; block < 24; 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;
- *tp = t;
- pt = (c != !type); /* 0 <-> all coeff data is zero */
- *a = *l = pt;
+ VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
+ for (c = 0; c < b->eob; c++)
+ {
+ rc = vp8_default_zig_zag1d[c];
+ band = vp8_coef_bands[c];
+ v = qcoeff_ptr[rc];
+
+ t->Extra = vp8_dct_value_tokens_ptr[v].Extra;
+ token = vp8_dct_value_tokens_ptr[v].Token;
+
+ t->Token = token;
+ t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
+
+ t->skip_eob_node = ((pt == 0) && (band > 0));
+
+ ++cpi->coef_counts [2] [band] [pt] [token];
+
+ pt = vp8_prev_token_class[token];
+ t++;
+ }
+ if (c < 16)
+ {
+ band = vp8_coef_bands[c];
+ t->Token = DCT_EOB_TOKEN;
+ t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
+
+ t->skip_eob_node = ((pt == 0) && (band > 0));
+
+ ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
+
+ t++;
+ }
+ *tp = t;
+ pt = (c != 0); /* 0 <-> all coeff data is zero */
+ *a = *l = pt;
+ }
+
}
-static int mb_is_skippable(MACROBLOCKD *x)
+static int mb_is_skippable(MACROBLOCKD *x, int has_y2_block)
{
- int has_y2_block;
int skip = 1;
int i = 0;
- has_y2_block = (x->mode_info_context->mbmi.mode != B_PRED
- && x->mode_info_context->mbmi.mode != SPLITMV);
if (has_y2_block)
{
for (i = 0; i < 16; i++)
@@ -219,33 +296,15 @@
void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
{
- ENTROPY_CONTEXT * A = (ENTROPY_CONTEXT *)x->above_context;
- ENTROPY_CONTEXT * L = (ENTROPY_CONTEXT *)x->left_context;
int plane_type;
- int b;
+ int has_y2_block;
- TOKENEXTRA *start = *t;
- TOKENEXTRA *tp = *t;
+ has_y2_block = (x->mode_info_context->mbmi.mode != B_PRED
+ && x->mode_info_context->mbmi.mode != SPLITMV);
- x->mode_info_context->mbmi.dc_diff = 1;
-
-#if 0
-
- if (x->mbmi.force_no_skip)
- {
- x->mbmi.mb_skip_coeff = 1;
- //reset for next_mb.
- x->mbmi.force_no_skip = 0;
- }
-
-#endif
-
-#if 1
-
- x->mode_info_context->mbmi.mb_skip_coeff = mb_is_skippable(x);
+ x->mode_info_context->mbmi.mb_skip_coeff = mb_is_skippable(x, has_y2_block);
if (x->mode_info_context->mbmi.mb_skip_coeff)
{
-
cpi->skip_true_count++;
if (!cpi->common.mb_no_coeff_skip)
@@ -255,79 +314,21 @@
vp8_fix_contexts(x);
}
- if (x->mode_info_context->mbmi.mode != B_PRED && x->mode_info_context->mbmi.mode != SPLITMV)
- x->mode_info_context->mbmi.dc_diff = 0;
- else
- x->mode_info_context->mbmi.dc_diff = 1;
-
-
return;
}
cpi->skip_false_count++;
-#endif
-#if 0
- vpx_memcpy(cpi->coef_counts_backup, cpi->coef_counts, sizeof(cpi->coef_counts));
-#endif
- if (x->mode_info_context->mbmi.mode == B_PRED || x->mode_info_context->mbmi.mode == SPLITMV)
+ plane_type = 3;
+ if(has_y2_block)
{
- plane_type = 3;
- }
- else
- {
- tokenize2nd_order_b(x->block + 24, t, 1, x->frame_type,
- A + vp8_block2above[24], L + vp8_block2left[24], cpi);
+ tokenize2nd_order_b(x, t, cpi);
plane_type = 0;
}
- for (b = 0; b < 16; b++)
- tokenize1st_order_b(x->block + b, t, plane_type, x->frame_type,
- A + vp8_block2above[b],
- L + vp8_block2left[b], cpi);
+ tokenize1st_order_b(x, t, plane_type, cpi);
- for (b = 16; b < 24; b++)
- tokenize1st_order_b(x->block + b, t, 2, x->frame_type,
- A + vp8_block2above[b],
- L + vp8_block2left[b], cpi);
-
-#if 0
-
- if (cpi->common.mb_no_coeff_skip)
- {
- int skip = 1;
-
- while ((tp != *t) && skip)
- {
- skip = (skip && (tp->Token == DCT_EOB_TOKEN));
- tp ++;
- }
-
- if (skip != x->mbmi.mb_skip_coeff)
- skip += 0;
-
- x->mbmi.mb_skip_coeff = skip;
-
- if (x->mbmi.mb_skip_coeff == 1)
- {
- x->mbmi.dc_diff = 0;
- //redo the coutnts
- vpx_memcpy(cpi->coef_counts, cpi->coef_counts_backup, sizeof(cpi->coef_counts));
-
- *t = start;
- cpi->skip_true_count++;
- //skip_true_count++;
- }
- else
- {
-
- cpi->skip_false_count++;
- //skip_false_count++;
- }
- }
-
-#endif
}
@@ -349,9 +350,9 @@
fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n");
- fprintf(f, "int Contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens];\n\n");
+ fprintf(f, "int Contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];\n\n");
- fprintf(f, "const int default_contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens] = {");
+ fprintf(f, "const int default_contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {");
# define Comma( X) (X? ",":"")
@@ -384,7 +385,7 @@
fprintf(f, "%s %d", Comma(t), y);
}
- while (++t < vp8_coef_tokens);
+ while (++t < MAX_ENTROPY_TOKENS);
fprintf(f, "}");
}
@@ -413,10 +414,7 @@
static __inline void stuff2nd_order_b
(
- 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
@@ -425,9 +423,6 @@
int pt; /* near block/prev token context index */
TOKENEXTRA *t = *tp; /* store tokens starting here */
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- (void) frametype;
- (void) type;
- (void) b;
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [1] [0] [pt];
@@ -443,10 +438,7 @@
static __inline void stuff1st_order_b
(
- 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
@@ -455,9 +447,6 @@
int pt; /* near block/prev token context index */
TOKENEXTRA *t = *tp; /* store tokens starting here */
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- (void) frametype;
- (void) type;
- (void) b;
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [0] [1] [pt];
@@ -472,10 +461,7 @@
static __inline
void stuff1st_order_buv
(
- 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
@@ -484,9 +470,6 @@
int pt; /* near block/prev token context index */
TOKENEXTRA *t = *tp; /* store tokens starting here */
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
- (void) frametype;
- (void) type;
- (void) b;
t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [2] [0] [pt];
@@ -506,24 +489,17 @@
int plane_type;
int b;
- stuff2nd_order_b(x->block + 24, t, 1, x->frame_type,
+ stuff2nd_order_b(t,
A + vp8_block2above[24], L + vp8_block2left[24], cpi);
plane_type = 0;
-
- if (x->mode_info_context->mbmi.mode != B_PRED && x->mode_info_context->mbmi.mode != SPLITMV)
- x->mode_info_context->mbmi.dc_diff = 0;
- else
- x->mode_info_context->mbmi.dc_diff = 1;
-
-
for (b = 0; b < 16; b++)
- stuff1st_order_b(x->block + b, t, plane_type, x->frame_type,
+ stuff1st_order_b(t,
A + vp8_block2above[b],
L + vp8_block2left[b], cpi);
for (b = 16; b < 24; b++)
- stuff1st_order_buv(x->block + b, t, 2, x->frame_type,
+ stuff1st_order_buv(t,
A + vp8_block2above[b],
L + vp8_block2left[b], cpi);
« no previous file with comments | « source/libvpx/vp8/encoder/tokenize.h ('k') | source/libvpx/vp8/encoder/variance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698