avcodec/huffyuvdec: assume vlcs can be 32 instead of 31 bits max

This should avoid a division as well

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-06-15 16:14:30 +02:00
parent 9dc1791977
commit e9c477059d

View File

@ -618,7 +618,7 @@ static void decode_422_bitstream(HYuvContext *s, int count)
OPEN_READER(re, &s->gb); OPEN_READER(re, &s->gb);
count /= 2; count /= 2;
if (count >= (get_bits_left(&s->gb)) / (31 * 4)) { if (count >= (get_bits_left(&s->gb)) / (32 * 4)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1); READ_2PIX(s->temp[0][2 * i ], s->temp[1][i], 1);
READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2); READ_2PIX(s->temp[0][2 * i + 1], s->temp[2][i], 2);
@ -658,7 +658,7 @@ static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
if (s->bps <= 8) { if (s->bps <= 8) {
OPEN_READER(re, &s->gb); OPEN_READER(re, &s->gb);
if (count >= (get_bits_left(&s->gb)) / (31 * 2)) { if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1], plane, OP8bits); READ_2PIX_PLANE(s->temp[0][2 * i], s->temp[0][2 * i + 1], plane, OP8bits);
} }
@ -670,7 +670,7 @@ static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
CLOSE_READER(re, &s->gb); CLOSE_READER(re, &s->gb);
} else if (s->bps <= 14) { } else if (s->bps <= 14) {
OPEN_READER(re, &s->gb); OPEN_READER(re, &s->gb);
if (count >= (get_bits_left(&s->gb)) / (31 * 2)) { if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX_PLANE(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane, OP14bits); READ_2PIX_PLANE(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane, OP14bits);
} }
@ -681,7 +681,7 @@ static void decode_plane_bitstream(HYuvContext *s, int count, int plane)
} }
CLOSE_READER(re, &s->gb); CLOSE_READER(re, &s->gb);
} else { } else {
if (count >= (get_bits_left(&s->gb)) / (31 * 2)) { if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX_PLANE16(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane); READ_2PIX_PLANE16(s->temp16[0][2 * i], s->temp16[0][2 * i + 1], plane);
} }
@ -699,7 +699,7 @@ static void decode_gray_bitstream(HYuvContext *s, int count)
OPEN_READER(re, &s->gb); OPEN_READER(re, &s->gb);
count/=2; count/=2;
if (count >= (get_bits_left(&s->gb)) / (31 * 2)) { if (count >= (get_bits_left(&s->gb)) / (32 * 2)) {
for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) { for (i = 0; i < count && get_bits_left(&s->gb) > 0; i++) {
READ_2PIX(s->temp[0][2 * i], s->temp[0][2 * i + 1], 0); READ_2PIX(s->temp[0][2 * i], s->temp[0][2 * i + 1], 0);
} }