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_QUANT_TABLE_SIZE 256
49 #define MAX_QUANT_TABLE_MASK (MAX_QUANT_TABLE_SIZE - 1)
50 #define MAX_CONTEXT_INPUTS 5
51
52 #define AC_GOLOMB_RICE 0
53 #define AC_RANGE_DEFAULT_TAB 1
54 #define AC_RANGE_CUSTOM_TAB 2
55 #define AC_RANGE_DEFAULT_TAB_FORCE -2
56
63
70
71 #define MAX_SLICES 1024
72
76
82
88
89 // RefStruct reference, array of MAX_PLANES elements
93
95
96 union {
97 // decoder-only
98 struct {
101 };
102
103 // encoder-only
104 struct {
107 };
108 };
110
112 uint16_t *
fltmap [4];
//halffloat encode & decode
117 uint32_t
val;
//this is unneeded if you accept a dereference on each access
121
142
145 int ac;
///< 1=range coder <-> 0=golomb rice
155
157
163
166
169
174
176 /* RefStruct object, per-slice damage flags shared between frame threads.
177 *
178 * After a frame thread marks some slice as finished with
179 * ff_progress_frame_report(), the corresponding array element must not be
180 * accessed by this thread anymore, as from then on it is owned by the next
181 * thread.
182 */
184 /* Frame damage flag, used to delay announcing progress, since ER is
185 * applied after all the slices are decoded.
186 * NOT shared between frame threads.
187 */
190
206
207 /**
208 * This is intended for both width and height
209 */
211
213 {
216 else {
218 }
219
221 }
222
224 {
225 int drift =
state->drift;
226 int count =
state->count;
228 drift += v;
229
230 if (count == 128) { // FIXME: variable
231 count >>= 1;
232 drift >>= 1;
233 state->error_sum >>= 1;
234 }
235 count++;
236
237 if (drift <= -count) {
239
240 drift =
FFMAX(drift + count, -count + 1);
241 } else if (drift > 0) {
243
244 drift =
FFMIN(drift - count, 0);
245 }
246
247 state->drift = drift;
248 state->count = count;
249 }
250
251
253 int is_signed)
254 {
256 return 0;
257 else {
258 int e;
260 e = 0;
262 e++;
263 if (e > 31)
265 }
266
268 for (
int i = e - 1;
i >= 0;
i--)
270
273 }
274 }
275
276 #endif /* AVCODEC_FFV1_H */