Commit 7fb55e0b authored by Reimar Döffinger's avatar Reimar Döffinger Committed by Anton Khirnov

rtjpeg: simplify get_block() by using get_bits_left.

Signed-off-by: 's avatarReimar Döffinger <Reimar.Doeffinger@gmx.de>
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 7a62ddb6
...@@ -56,7 +56,7 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc ...@@ -56,7 +56,7 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc
// number of non-zero coefficients // number of non-zero coefficients
coeff = get_bits(gb, 6); coeff = get_bits(gb, 6);
if (get_bits_count(gb) + (coeff << 1) >= gb->size_in_bits) if (get_bits_left(gb) < (coeff << 1))
return -1; return -1;
// normally we would only need to clear the (63 - coeff) last values, // normally we would only need to clear the (63 - coeff) last values,
...@@ -73,7 +73,7 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc ...@@ -73,7 +73,7 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc
// 4 bits per coefficient // 4 bits per coefficient
ALIGN(4); ALIGN(4);
if (get_bits_count(gb) + (coeff << 2) >= gb->size_in_bits) if (get_bits_left(gb) < (coeff << 2))
return -1; return -1;
while (coeff) { while (coeff) {
ac = get_sbits(gb, 4); ac = get_sbits(gb, 4);
...@@ -84,7 +84,7 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc ...@@ -84,7 +84,7 @@ static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *sc
// 8 bits per coefficient // 8 bits per coefficient
ALIGN(8); ALIGN(8);
if (get_bits_count(gb) + (coeff << 3) >= gb->size_in_bits) if (get_bits_left(gb) < (coeff << 3))
return -1; return -1;
while (coeff) { while (coeff) {
ac = get_sbits(gb, 8); ac = get_sbits(gb, 8);
......
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