diff options
author | trav90 <travawine@protonmail.ch> | 2018-04-26 16:49:15 -0500 |
---|---|---|
committer | trav90 <travawine@protonmail.ch> | 2018-04-26 16:49:15 -0500 |
commit | 8b37a1bc306c1d5a3cc92e9dc04fb95d5d9a0298 (patch) | |
tree | c37da5241afd7cda6f92d394e14cef7d5dcbb4e5 /media/ffvpx/libavcodec/golomb.h | |
parent | 56a2df6b25bc93ea9a59b8e0bf8029f752f68573 (diff) | |
download | UXP-8b37a1bc306c1d5a3cc92e9dc04fb95d5d9a0298.tar UXP-8b37a1bc306c1d5a3cc92e9dc04fb95d5d9a0298.tar.gz UXP-8b37a1bc306c1d5a3cc92e9dc04fb95d5d9a0298.tar.lz UXP-8b37a1bc306c1d5a3cc92e9dc04fb95d5d9a0298.tar.xz UXP-8b37a1bc306c1d5a3cc92e9dc04fb95d5d9a0298.zip |
[ffvpx] Update ffvp9/ffvp8 to 3.4.2-release
Structure of code was slightly modified so that it should be no longer necessary to re-generate the config_*.h files, greatly simplifying the resync process in the future.
Diffstat (limited to 'media/ffvpx/libavcodec/golomb.h')
-rw-r--r-- | media/ffvpx/libavcodec/golomb.h | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/media/ffvpx/libavcodec/golomb.h b/media/ffvpx/libavcodec/golomb.h index 917ea54e1..efb1eff8a 100644 --- a/media/ffvpx/libavcodec/golomb.h +++ b/media/ffvpx/libavcodec/golomb.h @@ -314,6 +314,8 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, log = av_log2(buf); + av_assert2(k <= 31); + if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) && 32 - log < limit) { buf >>= log - k; @@ -325,8 +327,10 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, } else { int i; for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) { - if (gb->size_in_bits <= re_index) + if (gb->size_in_bits <= re_index) { + CLOSE_READER(re, gb); return -1; + } LAST_SKIP_BITS(re, gb, 1); UPDATE_CACHE(re, gb); } @@ -348,16 +352,17 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, buf = 0; } - CLOSE_READER(re, gb); - return buf + (i << k); + buf += ((SUINT)i << k); } else if (i == limit - 1) { buf = SHOW_UBITS(re, gb, esc_len); LAST_SKIP_BITS(re, gb, esc_len); - CLOSE_READER(re, gb); - return buf + 1; - } else - return -1; + buf ++; + } else { + buf = -1; + } + CLOSE_READER(re, gb); + return buf; } } @@ -445,19 +450,20 @@ static inline int get_te(GetBitContext *s, int r, char *file, const char *func, return i; } -#define get_ue_golomb(a) get_ue(a, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_se_golomb(a) get_se(a, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_te_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_ue_golomb(a) get_ue(a, __FILE__, __func__, __LINE__) +#define get_se_golomb(a) get_se(a, __FILE__, __func__, __LINE__) +#define get_te_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__) +#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__) #endif /* TRACE */ /** - * write unsigned exp golomb code. + * write unsigned exp golomb code. 2^16 - 2 at most */ static inline void set_ue_golomb(PutBitContext *pb, int i) { av_assert2(i >= 0); + av_assert2(i <= 0xFFFE); if (i < 256) put_bits(pb, ff_ue_golomb_len[i], i + 1); @@ -468,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) @@ -486,19 +507,9 @@ static inline void set_te_golomb(PutBitContext *pb, int i, int range) */ static inline void set_se_golomb(PutBitContext *pb, int i) { -#if 0 - if (i <= 0) - i = -2 * i; - else - i = 2 * i - 1; -#elif 1 i = 2 * i - 1; if (i < 0) i ^= -1; //FIXME check if gcc does the right thing -#else - i = 2 * i - 1; - i ^= (i >> 31); -#endif set_ue_golomb(pb, i); } |