1 /*
2 * FFV1 codec for libavcodec
3 *
4 * Copyright (c) 2003-2012 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef AVCODEC_FFV1_H
24 #define AVCODEC_FFV1_H
25
26 /**
27 * @file
28 * FF Video Codec 1 (a lossless codec)
29 */
30
42
43 #ifdef __INTEL_COMPILER
44 #undef av_flatten
45 #define av_flatten
46 #endif
47
49 #define CONTEXT_SIZE 32
50
51 #define MAX_QUANT_TABLES 8
52 #define MAX_CONTEXT_INPUTS 5
53
54 #define AC_GOLOMB_RICE 0
55 #define AC_RANGE_DEFAULT_TAB 1
56 #define AC_RANGE_CUSTOM_TAB 2
57 #define AC_RANGE_DEFAULT_TAB_FORCE -2
58
65
74
75 #define MAX_SLICES 1024
76
96
99 int ac;
///< 1=range coder <-> 0=golomb rice
111
113
119
122
125
140
148
150 {
153 else {
155 }
156
158 }
159
161 {
162 int drift =
state->drift;
163 int count =
state->count;
165 drift += v;
166
167 if (count == 128) { // FIXME: variable
168 count >>= 1;
169 drift >>= 1;
170 state->error_sum >>= 1;
171 }
172 count++;
173
174 if (drift <= -count) {
176
177 drift =
FFMAX(drift + count, -count + 1);
178 } else if (drift > 0) {
180
181 drift =
FFMIN(drift - count, 0);
182 }
183
184 state->drift = drift;
185 state->count = count;
186 }
187
188 #define TYPE int16_t
189 #define RENAME(name) name
191 #undef TYPE
192 #undef RENAME
193
195 #define RENAME(name) name ## 32
197 #undef TYPE
198 #undef RENAME
199
200 #endif /* AVCODEC_FFV1_H */