1 /*
2 * Range coder
3 * Copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * Range coder.
25 */
26
27 #ifndef AVCODEC_RANGECODER_H
28 #define AVCODEC_RANGECODER_H
29
30 #include <stdint.h>
31
34
46 #define MAX_OVERREAD 2
48
53
55 {
56 // FIXME: optimize
57 while (c->
range < 0x100) {
60 }
else if (c->
low <= 0xFF00) {
65 }
else if (c->
low >= 0x10000) {
70 } else {
72 }
73
74 c->
low = (c->
low & 0xFF) << 8;
76 }
77 }
78
80 {
83 x++;
85 }
86
88 {
89 int range1 = (c->
range * (*state)) >> 8;
90
94 if (!bit) {
97 } else {
101 }
102
104 }
105
107 {
108 if (c->
range < 0x100) {
114 } else
116 }
117 }
118
120 {
121 int range1 = (c->
range * (*state)) >> 8;
122
127 return 0;
128 } else {
133 return 1;
134 }
135 }
136
137 #endif /* AVCODEC_RANGECODER_H */
static int get_rac(RangeCoder *c, uint8_t *const state)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
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)
static void put_rac(RangeCoder *c, uint8_t *const state, int bit)
static void renorm_encoder(RangeCoder *c)
simple assert() macros that are a bit more flexible than ISO C assert().
static void refill(RangeCoder *c)
void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
int ff_rac_terminate(RangeCoder *c)
static int get_rac_count(RangeCoder *c)
static const int factor[16]
common internal and external API header
uint8_t * bytestream_start