From d9e6a6c629c073e3432e76a320245ce3616b4f3f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 13 Jul 2003 11:06:45 +0000 Subject: golomb rice code cleanup / simplify (~0.5% compression gain and slightly faster) jpegls style golomb rice coder Originally committed as revision 2040 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/golomb.h | 90 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 14 deletions(-) (limited to 'libavcodec/golomb.h') diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 9861b18d1a..7c73f3bae6 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -179,7 +179,7 @@ static inline int svq3_get_se_golomb(GetBitContext *gb){ } /** - * read unsigned golomb rice code. + * read unsigned golomb rice code (ffv1). */ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len){ unsigned int buf; @@ -190,7 +190,7 @@ static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len buf=GET_CACHE(re, gb); log= av_log2(buf); -//printf("buf:%X log:%d\n", buf, log); + if(log > 31-limit){ buf >>= log - k; buf += (30-log)<>= log - esc_len; - buf -= 1<>= 32 - limit - esc_len; + LAST_SKIP_BITS(re, gb, esc_len + limit); CLOSE_READER(re, gb); - return buf + 1; - }else - return -1; + return buf + limit - 1; + } +} + +/** + * read unsigned golomb rice code (jpegls). + */ +static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len){ + unsigned int buf; + int log; + + OPEN_READER(re, gb); + UPDATE_CACHE(re, gb); + buf=GET_CACHE(re, gb); + + log= av_log2(buf); + + if(log > 31-12){ + buf >>= log - k; + buf += (30-log)<=0); + + e= (i>>k) + 1; + if(e