From e61abe2d73297e0b6dc1e179b717afc00c32af98 Mon Sep 17 00:00:00 2001 From: Jun Zhao Date: Wed, 14 Jun 2017 10:35:20 +0800 Subject: [PATCH] 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 Reviewed-by: Michael Niedermayer Signed-off-by: Jun Zhao Signed-off-by: Michael Niedermayer --- libavcodec/golomb.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index 1e834f9327..efb1eff8aa 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -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. */