1 /*
2 * MxPEG decoder
3 * Copyright (c) 2011 Anatoly Nenashev
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22
23 /**
24 * @file
25 * MxPEG decoder
26 */
27
31
44
46 {
48
51 }
52
54 const uint8_t *buf_ptr,
int buf_size)
55 {
57 if (buf_size < 2)
58 return 0;
61
62 return 0;
63 }
64
66 const uint8_t *buf_ptr,
int buf_size)
67 {
68 unsigned bitmask_size, mb_count;
69 int i;
70
74
75 bitmask_size = (mb_count + 7) >> 3;
76 if (bitmask_size > buf_size - 12) {
78 "MXM bitmask is not complete\n");
80 }
81
88 "MXM bitmask memory allocation error\n");
90 }
91
96 "Completion bitmask memory allocation error\n");
98 }
99
101 }
102
103 memcpy(s->
mxm_bitmask, buf_ptr + 12, bitmask_size);
105
107 uint8_t completion_check = 0xFF;
108 for (i = 0; i < bitmask_size; ++i) {
111 }
113 }
114
115 return 0;
116 }
117
119 const uint8_t *buf_ptr,
int buf_size)
120 {
122 if (buf_size < 2)
123 return 0;
125 if (len > 14 && len <= buf_size && !strncmp(buf_ptr + 2, "MXM", 3)) {
127 }
129
131 }
132
135 {
139 "Picture dimensions stored in SOF and MXM mismatch\n");
141 }
142
143 if (reference_ptr->
data[0]) {
144 int i;
149 "Dimensions of current and reference picture mismatch\n");
151 }
152 }
153 }
154
155 return 0;
156 }
157
159 void *
data,
int *got_frame,
161 {
163 int buf_size = avpkt->
size;
166 const uint8_t *buf_end, *buf_ptr;
167 const uint8_t *unescaped_buf_ptr;
168 int unescaped_buf_size;
169 int start_code;
171
173 buf_end = buf + buf_size;
176 while (buf_ptr < buf_end) {
178 &unescaped_buf_ptr, &unescaped_buf_size);
179 if (start_code < 0)
180 goto the_end;
181 {
183
184 if (start_code >=
APP0 && start_code <=
APP15) {
186 }
187
188 switch (start_code) {
191 goto the_end;
192 break;
194 goto the_end;
197 if (ret < 0) {
199 "quantization table decode error\n");
201 }
202 break;
205 if (ret < 0) {
207 "huffman table decode error\n");
209 }
210 break;
213 unescaped_buf_size);
214 if (ret < 0)
216 break;
220 if (ret < 0) {
222 "SOF data decode error\n");
224 }
227 "Interlaced mode not supported in MxPEG\n");
229 }
231 break;
235 "Can not process SOS without SOF data, skipping\n");
236 break;
237 }
241 "First picture has no SOF, skipping\n");
242 break;
243 }
246 "Non-key frame has no MXM, skipping\n");
247 break;
248 }
249 /* use stored SOF data to allocate current picture */
257 } else {
260 }
261
265 break;
266
267 /* allocate dummy reference picture if needed */
268 if (!reference_ptr->
data[0] &&
272
276 } else {
280 }
281
282 break;
283 }
284
286 }
287
288 }
289
290 the_end:
293 if (ret < 0)
295 *got_frame = 1;
296
299
303 else
304 *got_frame = 0;
305 }
306 }
307
308 return buf_ptr -
buf;
309 }
310
312 {
315 int i;
316
319
320 for (i = 0; i < 2; ++i)
322
325
326 return 0;
327 }
328
339 .max_lowres = 3,
340 };