lavc/golobm: Add set_ue_golomb_long to support up to 2^32 -2.
authorJun Zhao <jun.zhao@intel.com>
Wed, 14 Jun 2017 02:35:20 +0000 (10:35 +0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 24 Jun 2017 20:17:15 +0000 (22:17 +0200)
add set_ue_golomb_long to support up to 2^32-2.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/golomb.h

index 1e834f9..efb1eff 100644 (file)
@@ -473,6 +473,21 @@ static inline void set_ue_golomb(PutBitContext *pb, int i)
     }
 }
 
+/**
+ * write unsigned exp golomb code. 2^32-2 at most.
+ */
+static inline void set_ue_golomb_long(PutBitContext *pb, uint32_t i)
+{
+    av_assert2(i <= (UINT32_MAX - 1));
+
+    if (i < 256)
+        put_bits(pb, ff_ue_golomb_len[i], i + 1);
+    else {
+        int e = av_log2(i + 1);
+        put_bits64(pb, 2 * e + 1, i + 1);
+    }
+}
+
 /**
  * write truncated unsigned exp golomb code.
  */