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
45
46 #ifdef __INTEL_COMPILER
47 #undef av_flatten
48 #define av_flatten
49 #endif
50
52 #define CONTEXT_SIZE 32
53
54 #define MAX_QUANT_TABLES 8
55 #define MAX_CONTEXT_INPUTS 5
56
58
65
74
75 #define MAX_SLICES 256
76
95
98 int ac;
///< 1=range coder <-> 0=golomb rice
109
114
117
120
122
132
140
142 {
143 if (bits == 8)
144 diff = (int8_t)diff;
145 else {
146 diff += 1 << (bits - 1);
147 diff &= (1 <<
bits) - 1;
148 diff -= 1 << (bits - 1);
149 }
150
152 }
153
155 {
156 const int LT = last[-1];
157 const int T = last[0];
158 const int L = src[-1];
159
161 }
162
164 int16_t *last, int16_t *last2)
165 {
166 const int LT = last[-1];
167 const int T = last[0];
168 const int RT = last[1];
169 const int L = src[-1];
170
172 const int TT = last2[0];
173 const int LL = src[-2];
179 } else
183 }
184
186 {
187 int drift = state->
drift;
191
192 if (count == 128) { // FIXME: variable
193 count >>= 1;
194 drift >>= 1;
196 }
197 count++;
198
199 if (drift <= -count) {
200 if (state->
bias > -128)
202
204 if (drift <= -count)
205 drift = -count + 1;
206 } else if (drift > 0) {
207 if (state->
bias < 127)
209
211 if (drift > 0)
212 drift = 0;
213 }
214
215 state->
drift = drift;
217 }
218
219 #endif /* AVCODEC_FFV1_H */