Commit ab00d209 authored by Scott LaVarnway's avatar Scott LaVarnway
Browse files

Improved tokenize

For a realtime HD encodings, up to 1.6% gains seen.



Change-Id: If45028e23db95124da63f9d38ffe06e05596cc6e
Showing with 93 additions and 21 deletions
...@@ -62,7 +62,7 @@ extern const unsigned char vp8_block2left[25]; ...@@ -62,7 +62,7 @@ extern const unsigned char vp8_block2left[25];
extern const unsigned char vp8_block2above[25]; extern const unsigned char vp8_block2above[25];
#define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \ #define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \
Dest = ((A)!=0) + ((B)!=0); Dest = (A)+(B);
typedef enum typedef enum
......
...@@ -116,7 +116,33 @@ static void tokenize2nd_order_b ...@@ -116,7 +116,33 @@ static void tokenize2nd_order_b
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l); VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
for (c = 0; c < b->eob; c++) if(!b->eob)
{
/* c = band for this case */
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];
t++;
*tp = t;
*a = *l = 0;
return;
}
v = qcoeff_ptr[0];
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 [1] [0] [pt];
t->skip_eob_node = 0;
++cpi->coef_counts [1] [0] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c = 1;
for (; c < b->eob; c++)
{ {
rc = vp8_default_zig_zag1d[c]; rc = vp8_default_zig_zag1d[c];
band = vp8_coef_bands[c]; band = vp8_coef_bands[c];
...@@ -128,7 +154,7 @@ static void tokenize2nd_order_b ...@@ -128,7 +154,7 @@ static void tokenize2nd_order_b
t->Token = token; t->Token = token;
t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt]; t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
t->skip_eob_node = ((pt == 0) && (band > 0)); t->skip_eob_node = ((pt == 0));
++cpi->coef_counts [1] [band] [pt] [token]; ++cpi->coef_counts [1] [band] [pt] [token];
...@@ -141,7 +167,7 @@ static void tokenize2nd_order_b ...@@ -141,7 +167,7 @@ static void tokenize2nd_order_b
t->Token = DCT_EOB_TOKEN; t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt]; t->context_tree = cpi->common.fc.coef_probs [1] [band] [pt];
t->skip_eob_node = ((pt == 0) && (band > 0)); t->skip_eob_node = 0;
++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN]; ++cpi->coef_counts [1] [band] [pt] [DCT_EOB_TOKEN];
...@@ -149,8 +175,7 @@ static void tokenize2nd_order_b ...@@ -149,8 +175,7 @@ static void tokenize2nd_order_b
} }
*tp = t; *tp = t;
pt = (c != 0); /* 0 <-> all coeff data is zero */ *a = *l = 1;
*a = *l = pt;
} }
...@@ -188,6 +213,33 @@ static void tokenize1st_order_b ...@@ -188,6 +213,33 @@ static void tokenize1st_order_b
c = type ? 0 : 1; c = type ? 0 : 1;
if(c >= b->eob)
{
/* c = band for this case */
t->Token = DCT_EOB_TOKEN;
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];
t++;
*tp = t;
*a = *l = 0;
continue;
}
v = qcoeff_ptr[c];
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 [type] [c] [pt];
t->skip_eob_node = 0;
++cpi->coef_counts [type] [c] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c++;
for (; c < b->eob; c++) for (; c < b->eob; c++)
{ {
rc = vp8_default_zig_zag1d[c]; rc = vp8_default_zig_zag1d[c];
...@@ -200,9 +252,7 @@ static void tokenize1st_order_b ...@@ -200,9 +252,7 @@ static void tokenize1st_order_b
t->Token = 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 && t->skip_eob_node = (pt == 0);
((band > 0 && type > 0) || (band > 1 && type == 0));
++cpi->coef_counts [type] [band] [pt] [token]; ++cpi->coef_counts [type] [band] [pt] [token];
pt = vp8_prev_token_class[token]; pt = vp8_prev_token_class[token];
...@@ -214,18 +264,15 @@ static void tokenize1st_order_b ...@@ -214,18 +264,15 @@ static void tokenize1st_order_b
t->Token = DCT_EOB_TOKEN; t->Token = DCT_EOB_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 && t->skip_eob_node = 0;
((band > 0 && type > 0) || (band > 1 && type == 0));
++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN]; ++cpi->coef_counts [type] [band] [pt] [DCT_EOB_TOKEN];
t++; t++;
} }
*tp = t; *tp = t;
pt = (c != !type); /* 0 <-> all coeff data is zero */ *a = *l = 1;
*a = *l = pt;
} }
/* Chroma */ /* Chroma */
for (block = 16; block < 24; block++, b++) for (block = 16; block < 24; block++, b++)
{ {
...@@ -237,7 +284,34 @@ static void tokenize1st_order_b ...@@ -237,7 +284,34 @@ static void tokenize1st_order_b
VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l); VP8_COMBINEENTROPYCONTEXTS(pt, *a, *l);
for (c = 0; c < b->eob; c++) if(!b->eob)
{
/* c = band for this case */
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];
t++;
*tp = t;
*a = *l = 0;
continue;
}
v = qcoeff_ptr[0];
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] [0] [pt];
t->skip_eob_node = 0;
++cpi->coef_counts [2] [0] [pt] [token];
pt = vp8_prev_token_class[token];
t++;
c = 1;
for (; c < b->eob; c++)
{ {
rc = vp8_default_zig_zag1d[c]; rc = vp8_default_zig_zag1d[c];
band = vp8_coef_bands[c]; band = vp8_coef_bands[c];
...@@ -249,7 +323,7 @@ static void tokenize1st_order_b ...@@ -249,7 +323,7 @@ static void tokenize1st_order_b
t->Token = token; t->Token = token;
t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt]; t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
t->skip_eob_node = ((pt == 0) && (band > 0)); t->skip_eob_node = (pt == 0);
++cpi->coef_counts [2] [band] [pt] [token]; ++cpi->coef_counts [2] [band] [pt] [token];
...@@ -262,17 +336,15 @@ static void tokenize1st_order_b ...@@ -262,17 +336,15 @@ static void tokenize1st_order_b
t->Token = DCT_EOB_TOKEN; t->Token = DCT_EOB_TOKEN;
t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt]; t->context_tree = cpi->common.fc.coef_probs [2] [band] [pt];
t->skip_eob_node = ((pt == 0) && (band > 0)); t->skip_eob_node = 0;
++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN]; ++cpi->coef_counts [2] [band] [pt] [DCT_EOB_TOKEN];
t++; t++;
} }
*tp = t; *tp = t;
pt = (c != 0); /* 0 <-> all coeff data is zero */ *a = *l = 1;
*a = *l = pt;
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment