Commit ccad34e3 authored by zhaoxiu.zeng's avatar zhaoxiu.zeng Committed by Michael Niedermayer

avcodec/vc1_block: Simplify dcdiff initialization

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent bd55f01c
...@@ -571,16 +571,12 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, ...@@ -571,16 +571,12 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n,
return -1; return -1;
} }
if (dcdiff) { if (dcdiff) {
const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0;
if (dcdiff == 119 /* ESC index value */) { if (dcdiff == 119 /* ESC index value */) {
/* TODO: Optimize */ dcdiff = get_bits(gb, 8 + m);
if (v->pq == 1) dcdiff = get_bits(gb, 10);
else if (v->pq == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
} else { } else {
if (v->pq == 1) if (m)
dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
else if (v->pq == 2)
dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
} }
if (get_bits1(gb)) if (get_bits1(gb))
dcdiff = -dcdiff; dcdiff = -dcdiff;
...@@ -739,16 +735,12 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, ...@@ -739,16 +735,12 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
return -1; return -1;
} }
if (dcdiff) { if (dcdiff) {
const int m = (mquant == 1 || mquant == 2) ? 3 - mquant : 0;
if (dcdiff == 119 /* ESC index value */) { if (dcdiff == 119 /* ESC index value */) {
/* TODO: Optimize */ dcdiff = get_bits(gb, 8 + m);
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
} else { } else {
if (mquant == 1) if (m)
dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
else if (mquant == 2)
dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
} }
if (get_bits1(gb)) if (get_bits1(gb))
dcdiff = -dcdiff; dcdiff = -dcdiff;
...@@ -960,16 +952,12 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, ...@@ -960,16 +952,12 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,
return -1; return -1;
} }
if (dcdiff) { if (dcdiff) {
const int m = (mquant == 1 || mquant == 2) ? 3 - mquant : 0;
if (dcdiff == 119 /* ESC index value */) { if (dcdiff == 119 /* ESC index value */) {
/* TODO: Optimize */ dcdiff = get_bits(gb, 8 + m);
if (mquant == 1) dcdiff = get_bits(gb, 10);
else if (mquant == 2) dcdiff = get_bits(gb, 9);
else dcdiff = get_bits(gb, 8);
} else { } else {
if (mquant == 1) if (m)
dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
else if (mquant == 2)
dcdiff = (dcdiff << 1) + get_bits1(gb) - 1;
} }
if (get_bits1(gb)) if (get_bits1(gb))
dcdiff = -dcdiff; dcdiff = -dcdiff;
......
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