27 #ifndef AVCODEC_RANGECODER_H
28 #define AVCODEC_RANGECODER_H
46 #define MAX_OVERREAD 2
65 while (
c->range < 0x100) {
66 if (
c->outstanding_byte < 0) {
67 c->outstanding_byte =
c->low >> 8;
68 }
else if (
c->low <= 0xFF00) {
69 *
c->bytestream++ =
c->outstanding_byte;
70 for (;
c->outstanding_count;
c->outstanding_count--)
71 *
c->bytestream++ = 0xFF;
72 c->outstanding_byte =
c->low >> 8;
73 }
else if (
c->low >= 0x10000) {
74 *
c->bytestream++ =
c->outstanding_byte + 1;
75 for (;
c->outstanding_count;
c->outstanding_count--)
76 *
c->bytestream++ = 0x00;
77 c->outstanding_byte = (
c->low >> 8) & 0xFF;
79 c->outstanding_count++;
82 c->low = (
c->low & 0xFF) << 8;
89 int x =
c->bytestream -
c->bytestream_start +
c->outstanding_count;
90 if (
c->outstanding_byte >= 0)
97 int range1 = (
c->range * (*state)) >> 8;
106 c->low +=
c->range - range1;
116 if (
c->range < 0x100) {
119 if (
c->bytestream <
c->bytestream_end) {
120 c->low +=
c->bytestream[0];
129 int range1 = (
c->range * (*state)) >> 8;
132 if (
c->low <
c->range) {
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define bit(string, value)
common internal and external API header
int ff_rac_terminate(RangeCoder *c, int version)
Terminates the range coder.
static void put_rac(RangeCoder *c, uint8_t *const state, int bit)
static void renorm_encoder(RangeCoder *c)
void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
static void refill(RangeCoder *c)
static int get_rac_count(RangeCoder *c)
static int get_rac(RangeCoder *c, uint8_t *const state)
void ff_init_range_encoder(RangeCoder *c, uint8_t *buf, int buf_size)
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
uint8_t * bytestream_start
static const int factor[16]