Commit 10bf2eeb authored by Jason Garrett-Glaser's avatar Jason Garrett-Glaser

VP8: simplify token_prob handling

~1.5% faster decode_block_coeffs

Originally committed as revision 24659 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 9c87c037
...@@ -810,13 +810,11 @@ static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], ...@@ -810,13 +810,11 @@ static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16],
uint8_t probs[8][3][NUM_DCT_TOKENS-1], uint8_t probs[8][3][NUM_DCT_TOKENS-1],
int i, int zero_nhood, int16_t qmul[2]) int i, int zero_nhood, int16_t qmul[2])
{ {
uint8_t *token_prob; uint8_t *token_prob = probs[vp8_coeff_band[i]][zero_nhood];
int nonzero = 0; int nonzero = 0;
int coeff; int coeff;
do { do {
token_prob = probs[vp8_coeff_band[i]][zero_nhood];
if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
return nonzero; return nonzero;
...@@ -824,17 +822,14 @@ skip_eob: ...@@ -824,17 +822,14 @@ skip_eob:
if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0 if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0
if (++i == 16) if (++i == 16)
return nonzero; // invalid input; blocks should end with EOB return nonzero; // invalid input; blocks should end with EOB
zero_nhood = 0;
token_prob = probs[vp8_coeff_band[i]][0]; token_prob = probs[vp8_coeff_band[i]][0];
goto skip_eob; goto skip_eob;
} }
if (!vp56_rac_get_prob_branchy(c, token_prob[2])) { // DCT_1 if (!vp56_rac_get_prob_branchy(c, token_prob[2])) { // DCT_1
coeff = 1; coeff = 1;
zero_nhood = 1; token_prob = probs[vp8_coeff_band[i+1]][1];
} else { } else {
zero_nhood = 2;
if (!vp56_rac_get_prob_branchy(c, token_prob[3])) { // DCT 2,3,4 if (!vp56_rac_get_prob_branchy(c, token_prob[3])) { // DCT 2,3,4
coeff = vp56_rac_get_prob(c, token_prob[4]); coeff = vp56_rac_get_prob(c, token_prob[4]);
if (coeff) if (coeff)
...@@ -858,6 +853,7 @@ skip_eob: ...@@ -858,6 +853,7 @@ skip_eob:
coeff += vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]); coeff += vp8_rac_get_coeff(c, vp8_dct_cat_prob[cat]);
} }
} }
token_prob = probs[vp8_coeff_band[i+1]][2];
} }
// todo: full [16] qmat? load into register? // todo: full [16] qmat? load into register?
......
...@@ -314,9 +314,10 @@ static const int8_t vp8_segmentid_tree[][2] = ...@@ -314,9 +314,10 @@ static const int8_t vp8_segmentid_tree[][2] =
{ -2, -3 }, // '10', '11' { -2, -3 }, // '10', '11'
}; };
static const uint8_t vp8_coeff_band[16] = /* Padded by one byte to allow overreads */
static const uint8_t vp8_coeff_band[17] =
{ {
0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 0
}; };
static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 }; static const uint8_t vp8_dct_cat1_prob[] = { 159, 0 };
......
Markdown is supported
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