X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fgolomb.h;h=fcc78f44c14b37bc4a8a163c956512bcad325861;hb=7f22a4ebc97817fd0968f5ea8295c9a59a6292e0;hp=5c25883626356ebe90018ca98274ebb7ab934073;hpb=ff44c2d4f483cda53859ce019f3815c69239a7e0;p=ffmpeg diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 5c258836263..fcc78f44c14 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -476,15 +476,19 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, return buf; } else { int i; - for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) { + for (i = 0; i + MIN_CACHE_BITS <= limit && SHOW_UBITS(re, gb, MIN_CACHE_BITS) == 0; i += MIN_CACHE_BITS) { if (gb->size_in_bits <= re_index) { CLOSE_READER(re, gb); return -1; } - LAST_SKIP_BITS(re, gb, 1); + LAST_SKIP_BITS(re, gb, MIN_CACHE_BITS); UPDATE_CACHE(re, gb); } - SKIP_BITS(re, gb, 1); + for (; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) { + SKIP_BITS(re, gb, 1); + } + LAST_SKIP_BITS(re, gb, 1); + UPDATE_CACHE(re, gb); if (i < limit - 1) { if (k) {