[FFmpeg-devel,V5,3/4] lavc/golobm: Add set_ue_golomb_long to support up to 2^32 -2.

Submitted by Jun Zhao on June 14, 2017, 3:02 a.m.

Details

Message ID 5d5000a9-ba3a-d50d-e909-c5b599b8dea4@gmail.com
State Accepted
Commit e61abe2d73297e0b6dc1e179b717afc00c32af98
Headers show

Commit Message

Jun Zhao June 14, 2017, 3:02 a.m.
From e4ed2cf5a0282ca8bc24bf3d6535b8b445e23341 Mon Sep 17 00:00:00 2001
From: Jun Zhao <jun.zhao@intel.com>
Date: Wed, 14 Jun 2017 10:35:20 +0800
Subject: [PATCH V5 3/4] lavc/golobm: Add set_ue_golomb_long to support up to
 2^32 -2.

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>
---
 libavcodec/golomb.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 1e834f9327..efb1eff8aa 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -474,6 +474,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.
  */
 static inline void set_te_golomb(PutBitContext *pb, int i, int range)