30 #ifndef AVCODEC_GOLOMB_H
31 #define AVCODEC_GOLOMB_H
38 #define INVALID_VLC 0x80000000
57 #if CACHED_BITSTREAM_READER
60 if (buf >= (1 << 27)) {
66 int log = 2 *
av_log2(buf) - 31;
78 if (buf >= (1 << 27)) {
85 int log = 2 *
av_log2(buf) - 31;
122 #if CACHED_BITSTREAM_READER
145 #if CACHED_BITSTREAM_READER
148 if (buf & 0xAA800000) {
176 if (buf & 0xAA800000) {
241 #if CACHED_BITSTREAM_READER
244 if (buf >= (1 << 27)) {
250 int log = 2 *
av_log2(buf) - 31;
267 if (buf >= (1 << 27)) {
285 buf = ((buf >> 1) ^ sign) - sign;
295 int sign = (buf & 1) - 1;
296 return ((buf >> 1) ^ sign) + 1;
303 #if CACHED_BITSTREAM_READER
306 if (buf & 0xAA800000) {
316 if ((buf & 0xAAAAAAAA) == 0)
319 for (log = 31; (buf & 0x80000000) == 0; log--)
320 buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
324 return (
signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
331 if (buf & 0xAA800000) {
343 if ((buf & 0xAAAAAAAA) == 0)
346 for (log = 31; (buf & 0x80000000) == 0; log--)
347 buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
352 return (
signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
363 ret = (ret ^ sign) - sign;
378 #if CACHED_BITSTREAM_READER
383 if (log > 31 - limit) {
385 buf += (30 - log) << k;
393 return buf + limit - 1;
402 if (log > 31 - limit) {
404 buf += (30
U - log) << k;
418 return buf + limit - 1;
432 #if CACHED_BITSTREAM_READER
437 if (log - k >= 1 && 32 - log < limit) {
439 buf += (30 - log) << k;
446 i < limit && get_bits1(gb) == 0 && get_bits_left(gb) > 0;
452 return buf + (i << k);
453 }
else if (i == limit - 1) {
472 buf += (30
U - log) << k;
479 for (i = 0; i < limit &&
SHOW_UBITS(
re, gb, 1) == 0; i++) {
505 buf += ((
SUINT)i << k);
506 }
else if (i == limit - 1) {
527 return (v >> 1) ^ -(v & 1);
537 return (v >> 1) ^ -(v & 1);
554 return (uvar >> 1) ^ -(uvar & 1);
566 int bits = show >> (24 -
len);
569 bits, len, i, pos, file, func, line);
581 int bits = show >> (24 -
len);
584 bits, len, i, pos, file, func, line);
596 int bits = show >> (24 -
len);
599 bits, len, i, pos, file, func, line);
604 #define get_ue_golomb(a) get_ue(a, __FILE__, __func__, __LINE__)
605 #define get_se_golomb(a) get_se(a, __FILE__, __func__, __LINE__)
606 #define get_te_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__)
607 #define get_te0_golomb(a, r) get_te(a, r, __FILE__, __func__, __LINE__)
679 put_bits(pb, e + k + 1, (1 << k) + av_mod_uintp2(i, k));
681 put_bits(pb, limit + esc_len, i - limit + 1);
688 int limit,
int esc_len)
731 int limit,
int esc_len)
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
static int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (flac).
static void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (ffv1).
#define BITS_AVAILABLE(name, gb)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
const uint8_t ff_ue_golomb_vlc_code[512]
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static void set_ue_golomb(PutBitContext *pb, int i)
write unsigned exp golomb code.
const int8_t ff_interleaved_se_golomb_vlc_code[256]
const uint8_t ff_interleaved_golomb_vlc_len[256]
static int get_te0_golomb(GetBitContext *gb, int range)
read unsigned truncated exp golomb code.
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static void set_te_golomb(PutBitContext *pb, int i, int range)
write truncated unsigned exp golomb code.
static int dirac_get_se_golomb(GetBitContext *gb)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
const uint8_t ff_golomb_vlc_len[512]
static int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (ffv1).
static void put_bits64(PutBitContext *s, int n, uint64_t value)
Write up to 64 bits into a bitstream.
static int get_bits_left(GetBitContext *gb)
#define UPDATE_CACHE(name, gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int get_interleaved_se_golomb(GetBitContext *gb)
const int8_t ff_se_golomb_vlc_code[512]
#define CLOSE_READER(name, gb)
#define SKIP_BITS(name, gb, num)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define LAST_SKIP_BITS(name, gb, num)
static void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (jpegls).
#define SHOW_UBITS(name, gb, num)
static void set_sr_golomb_flac(PutBitContext *pb, int i, int k, int limit, int esc_len)
write signed golomb rice code (flac).
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
static int get_se_golomb_long(GetBitContext *gb)
static void set_se_golomb(PutBitContext *pb, int i)
write signed exp golomb code.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
static void set_ue_golomb_long(PutBitContext *pb, uint32_t i)
write unsigned exp golomb code.
#define OPEN_READER(name, gb)
static unsigned int get_bits1(GetBitContext *s)
const uint8_t ff_interleaved_ue_golomb_vlc_code[256]
static void skip_bits(GetBitContext *s, int n)
static void set_sr_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len)
write signed golomb rice code (ffv1).
#define GET_CACHE(name, gb)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_te_golomb(GetBitContext *gb, int range)
read unsigned truncated exp golomb code.
const uint8_t ff_ue_golomb_len[256]
static unsigned get_interleaved_ue_golomb(GetBitContext *gb)
static unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
read unsigned golomb rice code (shorten).
static int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (ffv1).
static int get_sr_golomb_shorten(GetBitContext *gb, int k)
read signed golomb rice code (shorten).