X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fgolomb.h;h=d9db8310dc98a39566cb7f886e682c04df1e37a6;hb=c5c6e307812a72b7f4ecc5a88db221a9b9a003d2;hp=917ea54e14574c7e0a9ce645e55fcb5cfcbbd845;hpb=5a447edd475a7ae672f385ca0c76a5fc5a56ac1f;p=ffmpeg diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 917ea54e145..d9db8310dc9 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -325,8 +325,10 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, } else { int i; for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) { - if (gb->size_in_bits <= re_index) + if (gb->size_in_bits <= re_index) { + CLOSE_READER(re, gb); return -1; + } LAST_SKIP_BITS(re, gb, 1); UPDATE_CACHE(re, gb); } @@ -348,16 +350,17 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, buf = 0; } - CLOSE_READER(re, gb); - return buf + (i << k); + buf += (i << k); } else if (i == limit - 1) { buf = SHOW_UBITS(re, gb, esc_len); LAST_SKIP_BITS(re, gb, esc_len); - CLOSE_READER(re, gb); - return buf + 1; - } else - return -1; + buf ++; + } else { + buf = -1; + } + CLOSE_READER(re, gb); + return buf; } }