summaryrefslogtreecommitdiff
path: root/libavcodec/golomb.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-06-13 21:31:28 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-06-13 21:31:28 +0000
commit11e659c203d534c3f6033003be5c2727e2291796 (patch)
treef3c7d9c020aeb7a4ba85419158c1563808cea0f6 /libavcodec/golomb.h
parent5dbafeb7ba02e01d4b59b840099d94bb3ee11341 (diff)
golomb rice codes
use gradients instead of prediction errors as context model store independant quantization tables for each point merge contexts with opposit sign Originally committed as revision 1957 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/golomb.h')
-rw-r--r--libavcodec/golomb.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index f1e6d6d987..9861b18d1a 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -178,6 +178,37 @@ static inline int svq3_get_se_golomb(GetBitContext *gb){
}
}
+/**
+ * read unsigned golomb rice code.
+ */
+static inline int get_ur_golomb(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);
+//printf("buf:%X log:%d\n", buf, log);
+ if(log > 31-limit){
+ buf >>= log - k;
+ buf += (30-log)<<k;
+ LAST_SKIP_BITS(re, gb, 32 + k - log);
+ CLOSE_READER(re, gb);
+
+ return buf;
+ }else if(log == 31-limit){
+ buf >>= log - esc_len;
+ buf -= 1<<esc_len;
+ LAST_SKIP_BITS(re, gb, esc_len + limit + 1);
+ CLOSE_READER(re, gb);
+
+ return buf + 1;
+ }else
+ return -1;
+}
+
#ifdef TRACE
static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
@@ -279,3 +310,22 @@ static inline void set_se_golomb(PutBitContext *pb, int i){
#endif
set_ue_golomb(pb, i);
}
+
+/**
+ * write unsigned golomb rice code.
+ */
+static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
+ int e;
+
+ assert(i>=0);
+
+ e= i>>k;
+ if(e<limit){
+ put_bits(pb, e + k + 1, (1<<k) + (i&((1<<k)-1)));
+ }else{
+// printf("set %08X, %d\n", (1<<esc_len) + i - 1, limit + esc_len + 1);
+ put_bits(pb, limit + esc_len + 1, (1<<esc_len) + i - 1);
+// put_bits(pb, 1, limit + 1);
+// put_bits(pb, i - 1, esc_len);
+ }
+}