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
38
39 #ifdef __INTEL_COMPILER
40 #undef av_flatten
41 #define av_flatten
42 #endif
43
45 #define CONTEXT_SIZE 32
46
47 #define MAX_QUANT_TABLES 8
48 #define MAX_CONTEXT_INPUTS 5
49
50 #define AC_GOLOMB_RICE 0
51 #define AC_RANGE_DEFAULT_TAB 1
52 #define AC_RANGE_CUSTOM_TAB 2
53 #define AC_RANGE_DEFAULT_TAB_FORCE -2
54
61
70
71 #define MAX_SLICES 1024
72
92
96 int ac;
///< 1=range coder <-> 0=golomb rice
108
110
116
119
122
137
145
147 {
150 else {
152 }
153
155 }
156
158 {
159 int drift =
state->drift;
160 int count =
state->count;
162 drift += v;
163
164 if (count == 128) { // FIXME: variable
165 count >>= 1;
166 drift >>= 1;
167 state->error_sum >>= 1;
168 }
169 count++;
170
171 if (drift <= -count) {
173
174 drift =
FFMAX(drift + count, -count + 1);
175 } else if (drift > 0) {
177
178 drift =
FFMIN(drift - count, 0);
179 }
180
181 state->drift = drift;
182 state->count = count;
183 }
184
185 #endif /* AVCODEC_FFV1_H */