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
37
38 #ifdef __INTEL_COMPILER
39 #undef av_flatten
40 #define av_flatten
41 #endif
42
44 #define CONTEXT_SIZE 32
45
46 #define MAX_QUANT_TABLES 8
47 #define MAX_QUANT_TABLE_SIZE 256
48 #define MAX_QUANT_TABLE_MASK (MAX_QUANT_TABLE_SIZE - 1)
49 #define MAX_CONTEXT_INPUTS 5
50
51 #define AC_GOLOMB_RICE 0
52 #define AC_RANGE_DEFAULT_TAB 1
53 #define AC_RANGE_CUSTOM_TAB 2
54 #define AC_RANGE_DEFAULT_TAB_FORCE -2
55
62
69
70 #define MAX_SLICES 1024
71
75
81
86
87 // RefStruct reference, array of MAX_PLANES elements
91
93
94 union {
95 // decoder-only
96 struct {
99 };
100
101 // encoder-only
102 struct {
105 };
106 };
108
124
127 int ac;
///< 1=range coder <-> 0=golomb rice
133
135
140
143
146
151
153 /* RefStruct object, per-slice damage flags shared between frame threads.
154 *
155 * After a frame thread marks some slice as finished with
156 * ff_progress_frame_report(), the corresponding array element must not be
157 * accessed by this thread anymore, as from then on it is owned by the next
158 * thread.
159 */
161 /* Frame damage flag, used to delay announcing progress, since ER is
162 * applied after all the slices are decoded.
163 * NOT shared between frame threads.
164 */
167
177
179 {
182 else {
184 }
185
187 }
188
190 {
191 int drift =
state->drift;
192 int count =
state->count;
194 drift += v;
195
196 if (count == 128) { // FIXME: variable
197 count >>= 1;
198 drift >>= 1;
199 state->error_sum >>= 1;
200 }
201 count++;
202
203 if (drift <= -count) {
205
206 drift =
FFMAX(drift + count, -count + 1);
207 } else if (drift > 0) {
209
210 drift =
FFMIN(drift - count, 0);
211 }
212
213 state->drift = drift;
214 state->count = count;
215 }
216
217 #endif /* AVCODEC_FFV1_H */