diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c | 10 | ||||
-rw-r--r-- | src/gallium/auxiliary/vl/vl_vlc.h | 5 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c index db05b151f95..9e48bdb9ac5 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c @@ -806,11 +806,10 @@ decode_slice(struct vl_mpg12_bs *bs) while (vl_vlc_get_uimsbf(&bs->vlc, 9) & 1) vl_vlc_fillbits(&bs->vlc); + vl_vlc_fillbits(&bs->vlc); do { int inc = 0; - vl_vlc_fillbits(&bs->vlc); - while (vl_vlc_peekbits(&bs->vlc, 11) == 15) { vl_vlc_eatbits(&bs->vlc, 11); vl_vlc_fillbits(&bs->vlc); @@ -924,7 +923,8 @@ decode_slice(struct vl_mpg12_bs *bs) } else mb.coded_block_pattern = 0; - } while (vl_vlc_bytes_left(&bs->vlc) && vl_vlc_peekbits(&bs->vlc, 23)); + vl_vlc_fillbits(&bs->vlc); + } while (vl_vlc_bits_left(&bs->vlc) && vl_vlc_peekbits(&bs->vlc, 23)); mb.num_skipped_macroblocks = 0; bs->decoder->decode_macroblock(bs->decoder, &mb.base, 1); @@ -974,9 +974,7 @@ vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const uint8_t *bu if (!decode_slice(bs)) return; - /* it's possible for the vlc to consume up to eight extra bytes */ - consumed = num_bytes - vl_vlc_bytes_left(&bs->vlc); - consumed = consumed > 8 ? consumed - 8 : 0; + consumed = num_bytes - vl_vlc_bits_left(&bs->vlc) / 8; /* crap, this is a bug we have consumed more bytes than left in the buffer */ assert(consumed <= num_bytes); diff --git a/src/gallium/auxiliary/vl/vl_vlc.h b/src/gallium/auxiliary/vl/vl_vlc.h index 4db1334d6a4..e17eae83fb3 100644 --- a/src/gallium/auxiliary/vl/vl_vlc.h +++ b/src/gallium/auxiliary/vl/vl_vlc.h @@ -113,9 +113,10 @@ vl_vlc_init(struct vl_vlc *vlc, const uint8_t *data, unsigned len) } static INLINE unsigned -vl_vlc_bytes_left(struct vl_vlc *vlc) +vl_vlc_bits_left(struct vl_vlc *vlc) { - return ((uint8_t*)vlc->end)-((uint8_t*)vlc->data); + signed bytes_left = ((uint8_t*)vlc->end)-((uint8_t*)vlc->data); + return bytes_left * 8 + vlc->valid_bits; } static INLINE unsigned |