1 /*
2 * FFV1 codec for libavcodec
3 *
4 * Copyright (c) 2003-2013 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 /**
24 * @file
25 * FF Video Codec 1 (a lossless codec)
26 */
27
30
35
37 {
39
42
45
48
49 // defaults
52
53 return 0;
54 }
55
57 {
59
60 fs->plane_count =
f->plane_count;
61 fs->transparency =
f->transparency;
62 for (j = 0; j <
f->plane_count; j++) {
64
68 sizeof(uint8_t));
71 } else {
79 }
80 }
81 }
82 }
83
85 //FIXME only redo if state_transition changed
86 for (j = 1; j < 256; j++) {
87 fs->c. one_state[ j] =
f->state_transition[j];
88 fs->c.zero_state[256 - j] = 256 -
fs->c.one_state[j];
89 }
90 }
91
92 return 0;
93 }
94
96 {
98 for (
i = 0;
i <
f->max_slice_count;
i++) {
102 }
103 return 0;
104 }
105
107 {
108 int i, max_slice_count =
f->num_h_slices *
f->num_v_slices;
109
111
112 for (
i = 0;
i < max_slice_count;) {
113 int sx =
i %
f->num_h_slices;
114 int sy =
i /
f->num_h_slices;
115 int sxs =
f->avctx->width * sx /
f->num_h_slices;
116 int sxe =
f->avctx->width * (sx + 1) /
f->num_h_slices;
117 int sys =
f->avctx->height * sy /
f->num_v_slices;
118 int sye =
f->avctx->height * (sy + 1) /
f->num_v_slices;
120
122 goto memfail;
123
124 f->slice_context[
i++] =
fs;
125 memcpy(
fs,
f,
sizeof(*
fs));
126 memset(
fs->rc_stat2, 0,
sizeof(
fs->rc_stat2));
127
128 fs->slice_width = sxe - sxs;
129 fs->slice_height = sye - sys;
132
134 sizeof(*
fs->sample_buffer));
136 sizeof(*
fs->sample_buffer32));
137 if (!
fs->sample_buffer || !
fs->sample_buffer32)
138 goto memfail;
139 }
140 f->max_slice_count = max_slice_count;
141 return 0;
142
143 memfail:
144 f->max_slice_count =
i;
146 }
147
149 {
151
152 for (
i = 0;
i <
f->quant_table_count;
i++) {
154 sizeof(*
f->initial_states[
i]));
155 if (!
f->initial_states[
i])
157 memset(
f->initial_states[
i], 128,
158 f->context_count[
i] *
sizeof(*
f->initial_states[
i]));
159 }
160 return 0;
161 }
162
164 {
166
167 for (
i = 0;
i <
f->plane_count;
i++) {
169
172
177 } else
179 } else {
185 }
186 }
187 }
188 }
189
190
192 {
195
196 for (j = 0; j <
s->max_slice_count; j++) {
198 for (
i = 0;
i <
s->plane_count;
i++) {
200
203 }
206 }
207
209 for (j = 0; j <
s->quant_table_count; j++) {
211 for (
i = 0;
i <
s->max_slice_count;
i++) {
214 }
216 }
217
218 for (
i = 0;
i <
s->max_slice_count;
i++)
220
221 return 0;
222 }