diff options
author | zhaoxiu.zeng <zhaoxiu.zeng@gmail.com> | 2015-02-25 00:28:45 +0800 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-28 15:14:36 +0100 |
commit | ccad34e3cae6447747ec2223cffea324123fa68a (patch) | |
tree | 9c675ec7cd7a58d81a8a7749c268355de1ec7b23 | |
parent | bd55f01c96b4a8e6dd01d2e8478d24f353550426 (diff) | |
download | ffmpeg-ccad34e3cae6447747ec2223cffea324123fa68a.tar.gz |
avcodec/vc1_block: Simplify dcdiff initialization
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/vc1_block.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c index 7f65744849..05361baa03 100644 --- a/libavcodec/vc1_block.c +++ b/libavcodec/vc1_block.c @@ -571,16 +571,12 @@ static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, return -1; } if (dcdiff) { + const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0; if (dcdiff == 119 /* ESC index value */) { - /* TODO: Optimize */ - 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); + dcdiff = get_bits(gb, 8 + m); } else { - if (v->pq == 1) - dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; - else if (v->pq == 2) - dcdiff = (dcdiff << 1) + get_bits1(gb) - 1; + if (m) + dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1); } if (get_bits1(gb)) dcdiff = -dcdiff; @@ -739,16 +735,12 @@ static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, return -1; } if (dcdiff) { + const int m = (mquant == 1 || mquant == 2) ? 3 - mquant : 0; if (dcdiff == 119 /* ESC index value */) { - /* TODO: Optimize */ - if (mquant == 1) dcdiff = get_bits(gb, 10); - else if (mquant == 2) dcdiff = get_bits(gb, 9); - else dcdiff = get_bits(gb, 8); + dcdiff = get_bits(gb, 8 + m); } else { - if (mquant == 1) - dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; - else if (mquant == 2) - dcdiff = (dcdiff << 1) + get_bits1(gb) - 1; + if (m) + dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1); } if (get_bits1(gb)) dcdiff = -dcdiff; @@ -960,16 +952,12 @@ static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, return -1; } if (dcdiff) { + const int m = (mquant == 1 || mquant == 2) ? 3 - mquant : 0; if (dcdiff == 119 /* ESC index value */) { - /* TODO: Optimize */ - if (mquant == 1) dcdiff = get_bits(gb, 10); - else if (mquant == 2) dcdiff = get_bits(gb, 9); - else dcdiff = get_bits(gb, 8); + dcdiff = get_bits(gb, 8 + m); } else { - if (mquant == 1) - dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; - else if (mquant == 2) - dcdiff = (dcdiff << 1) + get_bits1(gb) - 1; + if (m) + dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1); } if (get_bits1(gb)) dcdiff = -dcdiff; |