Go to the documentation of this file.
27 #ifndef AVCODEC_RANGECODER_H
28 #define AVCODEC_RANGECODER_H
46 #define MAX_OVERREAD 2
65 if (
c->outstanding_byte < 0) {
66 c->outstanding_byte =
c->low >> 8;
67 }
else if (
c->low <= 0xFF00) {
68 *
c->bytestream++ =
c->outstanding_byte;
69 for (;
c->outstanding_count;
c->outstanding_count--)
70 *
c->bytestream++ = 0xFF;
71 c->outstanding_byte =
c->low >> 8;
72 }
else if (
c->low >= 0x10000) {
73 *
c->bytestream++ =
c->outstanding_byte + 1;
74 for (;
c->outstanding_count;
c->outstanding_count--)
75 *
c->bytestream++ = 0x00;
76 c->outstanding_byte = (
c->low >> 8) & 0xFF;
78 c->outstanding_count++;
81 c->low = (
c->low & 0xFF) << 8;
87 int x =
c->bytestream -
c->bytestream_start +
c->outstanding_count;
88 if (
c->outstanding_byte >= 0)
95 int range1 = (
c->range * (*state)) >> 8;
104 c->low +=
c->range - range1;
109 while (
c->range < 0x100)
115 if (
c->range < 0x100) {
118 if (
c->bytestream <
c->bytestream_end) {
119 c->low +=
c->bytestream[0];
128 int range1 = (
c->range * (*state)) >> 8;
131 if (
c->low <
c->range) {
#define bit(string, value)
static void refill(RangeCoder *c)
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
static void renorm_encoder(RangeCoder *c)
static int get_rac(RangeCoder *c, uint8_t *const state)
uint8_t * bytestream_start
void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size)
static int get_rac_count(RangeCoder *c)
static const int factor[16]
int ff_rac_terminate(RangeCoder *c, int version)
Terminates the range coder.
static void put_rac(RangeCoder *c, uint8_t *const state, int bit)