FFmpeg
Loading...
Searching...
No Matches
zmbv.c
Go to the documentation of this file.
1/*
2 * Zip Motion Blocks Video (ZMBV) decoder
3 * Copyright (c) 2006 Konstantin Shishkov
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 * @file
24 * Zip Motion Blocks Video decoder
25 */
26
27#include <stddef.h>
28
30#include "libavutil/common.h"
31#include "libavutil/imgutils.h"
33#include "libavutil/mem.h"
34#include "avcodec.h"
35#include "codec_internal.h"
36#include "decode.h"
37#include "zlib_wrapper.h"
38
39#include <zlib.h>
40
41#define ZMBV_KEYFRAME 1
42#define ZMBV_DELTAPAL 2
43
55
56/*
57 * Decoder context
58 */
59typedef struct ZmbvContext {
61
62 int bpp;
64 unsigned int decomp_size;
65 uint8_t* decomp_buf;
66 uint8_t pal[768];
67 uint8_t *prev, *cur;
69 int fmt;
70 int comp;
71 int flags;
72 int stride;
73 int bw, bh, bx, by;
77 int (*decode_xor)(struct ZmbvContext *c);
79
80/**
81 * Decode XOR'ed frame - 8bpp version
82 */
83
85{
86 uint8_t *src = c->decomp_buf;
87 uint8_t *output, *prev;
88 int8_t *mvec;
89 int x, y;
90 int d, dx, dy, bw2, bh2;
91 int block;
92 int i, j;
93 int mx, my;
94
95 output = c->cur;
96 prev = c->prev;
97
98 if (c->flags & ZMBV_DELTAPAL) {
99 for (i = 0; i < 768; i++)
100 c->pal[i] ^= *src++;
101 }
102
103 mvec = (int8_t*)src;
104 src += ((c->bx * c->by * 2 + 3) & ~3);
105
106 block = 0;
107 for (y = 0; y < c->height; y += c->bh) {
108 bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
109 for (x = 0; x < c->width; x += c->bw) {
110 uint8_t *out, *tprev;
111
112 d = mvec[block] & 1;
113 dx = mvec[block] >> 1;
114 dy = mvec[block + 1] >> 1;
115 block += 2;
116
117 bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
118
119 /* copy block - motion vectors out of bounds are used to zero blocks */
120 out = output + x;
121 tprev = prev + x + dx + dy * c->width;
122 mx = x + dx;
123 my = y + dy;
124 for (j = 0; j < bh2; j++) {
125 if (my + j < 0 || my + j >= c->height) {
126 memset(out, 0, bw2);
127 } else if (mx >= 0 && mx + bw2 <= c->width){
128 memcpy(out, tprev, sizeof(*out) * bw2);
129 } else {
130 for (i = 0; i < bw2; i++) {
131 if (mx + i < 0 || mx + i >= c->width)
132 out[i] = 0;
133 else
134 out[i] = tprev[i];
135 }
136 }
137 out += c->width;
138 tprev += c->width;
139 }
140
141 if (d) { /* apply XOR'ed difference */
142 if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2)
143 return AVERROR_INVALIDDATA;
144 out = output + x;
145 for (j = 0; j < bh2; j++) {
146 for (i = 0; i < bw2; i++)
147 out[i] ^= *src++;
148 out += c->width;
149 }
150 }
151 }
152 output += c->width * c->bh;
153 prev += c->width * c->bh;
154 }
155 if (src - c->decomp_buf != c->decomp_len)
156 av_log(c->avctx, AV_LOG_ERROR, "Used %td of %i bytes\n",
157 src-c->decomp_buf, c->decomp_len);
158 return 0;
159}
160
161/**
162 * Decode XOR'ed frame - 15bpp and 16bpp version
163 */
164
166{
167 uint8_t *src = c->decomp_buf;
168 uint16_t *output, *prev;
169 int8_t *mvec;
170 int x, y;
171 int d, dx, dy, bw2, bh2;
172 int block;
173 int i, j;
174 int mx, my;
175
176 output = (uint16_t*)c->cur;
177 prev = (uint16_t*)c->prev;
178
179 mvec = (int8_t*)src;
180 src += ((c->bx * c->by * 2 + 3) & ~3);
181
182 block = 0;
183 for (y = 0; y < c->height; y += c->bh) {
184 bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
185 for (x = 0; x < c->width; x += c->bw) {
186 uint16_t *out, *tprev;
187
188 d = mvec[block] & 1;
189 dx = mvec[block] >> 1;
190 dy = mvec[block + 1] >> 1;
191 block += 2;
192
193 bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
194
195 /* copy block - motion vectors out of bounds are used to zero blocks */
196 out = output + x;
197 tprev = prev + x + dx + dy * c->width;
198 mx = x + dx;
199 my = y + dy;
200 for (j = 0; j < bh2; j++) {
201 if (my + j < 0 || my + j >= c->height) {
202 memset(out, 0, bw2 * 2);
203 } else if (mx >= 0 && mx + bw2 <= c->width){
204 memcpy(out, tprev, sizeof(*out) * bw2);
205 } else {
206 for (i = 0; i < bw2; i++) {
207 if (mx + i < 0 || mx + i >= c->width)
208 out[i] = 0;
209 else
210 out[i] = tprev[i];
211 }
212 }
213 out += c->width;
214 tprev += c->width;
215 }
216
217 if (d) { /* apply XOR'ed difference */
218 if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 2)
219 return AVERROR_INVALIDDATA;
220 out = output + x;
221 for (j = 0; j < bh2; j++){
222 for (i = 0; i < bw2; i++) {
223 out[i] ^= *((uint16_t*)src);
224 src += 2;
225 }
226 out += c->width;
227 }
228 }
229 }
230 output += c->width * c->bh;
231 prev += c->width * c->bh;
232 }
233 if (src - c->decomp_buf != c->decomp_len)
234 av_log(c->avctx, AV_LOG_ERROR, "Used %td of %i bytes\n",
235 src-c->decomp_buf, c->decomp_len);
236 return 0;
237}
238
239#ifdef ZMBV_ENABLE_24BPP
240/**
241 * Decode XOR'ed frame - 24bpp version
242 */
243
244static int zmbv_decode_xor_24(ZmbvContext *c)
245{
246 uint8_t *src = c->decomp_buf;
247 uint8_t *output, *prev;
248 int8_t *mvec;
249 int x, y;
250 int d, dx, dy, bw2, bh2;
251 int block;
252 int i, j;
253 int mx, my;
254 int stride;
255
256 output = c->cur;
257 prev = c->prev;
258
259 stride = c->width * 3;
260 mvec = (int8_t*)src;
261 src += ((c->bx * c->by * 2 + 3) & ~3);
262
263 block = 0;
264 for (y = 0; y < c->height; y += c->bh) {
265 bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
266 for (x = 0; x < c->width; x += c->bw) {
267 uint8_t *out, *tprev;
268
269 d = mvec[block] & 1;
270 dx = mvec[block] >> 1;
271 dy = mvec[block + 1] >> 1;
272 block += 2;
273
274 bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
275
276 /* copy block - motion vectors out of bounds are used to zero blocks */
277 out = output + x * 3;
278 tprev = prev + (x + dx) * 3 + dy * stride;
279 mx = x + dx;
280 my = y + dy;
281 for (j = 0; j < bh2; j++) {
282 if (my + j < 0 || my + j >= c->height) {
283 memset(out, 0, bw2 * 3);
284 } else if (mx >= 0 && mx + bw2 <= c->width){
285 memcpy(out, tprev, 3 * bw2);
286 } else {
287 for (i = 0; i < bw2; i++){
288 if (mx + i < 0 || mx + i >= c->width) {
289 out[i * 3 + 0] = 0;
290 out[i * 3 + 1] = 0;
291 out[i * 3 + 2] = 0;
292 } else {
293 out[i * 3 + 0] = tprev[i * 3 + 0];
294 out[i * 3 + 1] = tprev[i * 3 + 1];
295 out[i * 3 + 2] = tprev[i * 3 + 2];
296 }
297 }
298 }
299 out += stride;
300 tprev += stride;
301 }
302
303 if (d) { /* apply XOR'ed difference */
304 if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 3)
305 return AVERROR_INVALIDDATA;
306 out = output + x * 3;
307 for (j = 0; j < bh2; j++) {
308 for (i = 0; i < bw2; i++) {
309 out[i * 3 + 0] ^= *src++;
310 out[i * 3 + 1] ^= *src++;
311 out[i * 3 + 2] ^= *src++;
312 }
313 out += stride;
314 }
315 }
316 }
317 output += stride * c->bh;
318 prev += stride * c->bh;
319 }
320 if (src - c->decomp_buf != c->decomp_len)
321 av_log(c->avctx, AV_LOG_ERROR, "Used %td of %i bytes\n",
322 src-c->decomp_buf, c->decomp_len);
323 return 0;
324}
325#endif //ZMBV_ENABLE_24BPP
326
327/**
328 * Decode XOR'ed frame - 32bpp version
329 */
330
332{
333 uint8_t *src = c->decomp_buf;
334 uint32_t *output, *prev;
335 int8_t *mvec;
336 int x, y;
337 int d, dx, dy, bw2, bh2;
338 int block;
339 int i, j;
340 int mx, my;
341
342 output = (uint32_t*)c->cur;
343 prev = (uint32_t*)c->prev;
344
345 mvec = (int8_t*)src;
346 src += ((c->bx * c->by * 2 + 3) & ~3);
347
348 block = 0;
349 for (y = 0; y < c->height; y += c->bh) {
350 bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
351 for (x = 0; x < c->width; x += c->bw) {
352 uint32_t *out, *tprev;
353
354 d = mvec[block] & 1;
355 dx = mvec[block] >> 1;
356 dy = mvec[block + 1] >> 1;
357 block += 2;
358
359 bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
360
361 /* copy block - motion vectors out of bounds are used to zero blocks */
362 out = output + x;
363 tprev = prev + x + dx + dy * c->width;
364 mx = x + dx;
365 my = y + dy;
366 for (j = 0; j < bh2; j++) {
367 if (my + j < 0 || my + j >= c->height) {
368 memset(out, 0, bw2 * 4);
369 } else if (mx >= 0 && mx + bw2 <= c->width){
370 memcpy(out, tprev, sizeof(*out) * bw2);
371 } else {
372 for (i = 0; i < bw2; i++){
373 if (mx + i < 0 || mx + i >= c->width)
374 out[i] = 0;
375 else
376 out[i] = tprev[i];
377 }
378 }
379 out += c->width;
380 tprev += c->width;
381 }
382
383 if (d) { /* apply XOR'ed difference */
384 if (c->decomp_len - (src - c->decomp_buf) < bw2 * bh2 * 4)
385 return AVERROR_INVALIDDATA;
386 out = output + x;
387 for (j = 0; j < bh2; j++){
388 for (i = 0; i < bw2; i++) {
389 out[i] ^= *((uint32_t *) src);
390 src += 4;
391 }
392 out += c->width;
393 }
394 }
395 }
396 output += c->width * c->bh;
397 prev += c->width * c->bh;
398 }
399 if (src - c->decomp_buf != c->decomp_len)
400 av_log(c->avctx, AV_LOG_ERROR, "Used %td of %i bytes\n",
401 src-c->decomp_buf, c->decomp_len);
402 return 0;
403}
404
405/**
406 * Decode intraframe
407 */
409{
410 uint8_t *src = c->decomp_buf;
411
412 /* make the palette available on the way out */
413 if (c->fmt == ZMBV_FMT_8BPP) {
414 memcpy(c->pal, src, 768);
415 src += 768;
416 }
417
418 memcpy(c->cur, src, c->width * c->height * (c->bpp / 8));
419 return 0;
420}
421
423 int *got_frame, AVPacket *avpkt)
424{
425 const uint8_t *buf = avpkt->data;
426 int buf_size = avpkt->size;
427 ZmbvContext * const c = avctx->priv_data;
428 int zret = Z_OK; // Zlib return code
429 int len = buf_size;
430 int hi_ver, lo_ver, ret;
431 int expected_size;
432
433 /* parse header */
434 if (len < 1)
435 return AVERROR_INVALIDDATA;
436 c->flags = buf[0];
437 buf++; len--;
438 if (c->flags & ZMBV_KEYFRAME) {
439 c->got_keyframe = 0;
440
441 if (len < 6)
442 return AVERROR_INVALIDDATA;
443 hi_ver = buf[0];
444 lo_ver = buf[1];
445 c->comp = buf[2];
446 c->fmt = buf[3];
447 c->bw = buf[4];
448 c->bh = buf[5];
449 c->decode_xor = NULL;
450
451 buf += 6;
452 len -= 6;
454 "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
455 c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
456 if (hi_ver != 0 || lo_ver != 1) {
457 avpriv_request_sample(avctx, "Version %i.%i", hi_ver, lo_ver);
459 }
460 if (c->bw == 0 || c->bh == 0) {
461 avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh);
463 }
464 if (c->comp != 0 && c->comp != 1) {
465 avpriv_request_sample(avctx, "Compression type %i", c->comp);
467 }
468
469 switch (c->fmt) {
470 case ZMBV_FMT_8BPP:
471 c->bpp = 8;
472 c->decode_xor = zmbv_decode_xor_8;
474 c->stride = c->width;
475 break;
476 case ZMBV_FMT_15BPP:
477 case ZMBV_FMT_16BPP:
478 c->bpp = 16;
479 c->decode_xor = zmbv_decode_xor_16;
480 if (c->fmt == ZMBV_FMT_15BPP)
482 else
484 c->stride = c->width * 2;
485 break;
486#ifdef ZMBV_ENABLE_24BPP
487 case ZMBV_FMT_24BPP:
488 c->bpp = 24;
489 c->decode_xor = zmbv_decode_xor_24;
491 c->stride = c->width * 3;
492 break;
493#endif //ZMBV_ENABLE_24BPP
494 case ZMBV_FMT_32BPP:
495 c->bpp = 32;
496 c->decode_xor = zmbv_decode_xor_32;
498 c->stride = c->width * 4;
499 break;
500 default:
501 c->decode_xor = NULL;
502 avpriv_request_sample(avctx, "Format %i", c->fmt);
504 }
505
506 zret = inflateReset(&c->zstream.zstream);
507 if (zret != Z_OK) {
508 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
509 return AVERROR_UNKNOWN;
510 }
511
512 if (c->alloc_bpp < c->bpp) {
513 c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
514 c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8));
515 c->alloc_bpp = c->bpp;
516 }
517 c->bx = (c->width + c->bw - 1) / c->bw;
518 c->by = (c->height+ c->bh - 1) / c->bh;
519 if (!c->cur || !c->prev) {
520 c->alloc_bpp = 0;
521 return AVERROR(ENOMEM);
522 }
523 memset(c->cur, 0, avctx->width * avctx->height * (c->bpp / 8));
524 memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
525 c->got_keyframe = 1;
526 }
527 if (c->flags & ZMBV_KEYFRAME) {
528 expected_size = avctx->width * avctx->height * (c->bpp / 8);
529 } else {
530 expected_size = (c->bx * c->by * 2 + 3) & ~3;
531 }
532 if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
533 (c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME)))
534 expected_size += 768;
535
536 if (!c->got_keyframe) {
537 av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
538 return AVERROR_INVALIDDATA;
539 }
540
541 if (c->comp == 0) { // uncompressed data
542 if (c->decomp_size < len) {
543 av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
544 return AVERROR_INVALIDDATA;
545 }
546 memcpy(c->decomp_buf, buf, len);
547 c->decomp_len = len;
548 } else { // ZLIB-compressed data
549 z_stream *const zstream = &c->zstream.zstream;
550
551 zstream->total_in = zstream->total_out = 0;
552 zstream->next_in = buf;
553 zstream->avail_in = len;
554 zstream->next_out = c->decomp_buf;
555 zstream->avail_out = c->decomp_size;
556 zret = inflate(zstream, Z_SYNC_FLUSH);
557 if (zret != Z_OK && zret != Z_STREAM_END) {
558 av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
559 return AVERROR_INVALIDDATA;
560 }
561 c->decomp_len = zstream->total_out;
562 }
563 if (expected_size > c->decomp_len ||
564 (c->flags & ZMBV_KEYFRAME) && expected_size < c->decomp_len) {
565 av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
566 return AVERROR_INVALIDDATA;
567 }
568 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
569 return ret;
570
571 if (c->flags & ZMBV_KEYFRAME) {
572 frame->flags |= AV_FRAME_FLAG_KEY;
573 frame->pict_type = AV_PICTURE_TYPE_I;
575 } else {
576 frame->flags &= ~AV_FRAME_FLAG_KEY;
577 frame->pict_type = AV_PICTURE_TYPE_P;
578 if (c->decomp_len < 2LL * ((c->width + c->bw - 1) / c->bw) * ((c->height + c->bh - 1) / c->bh))
579 return AVERROR_INVALIDDATA;
580 if (c->decomp_len) {
581 if ((ret = c->decode_xor(c)) < 0)
582 return ret;
583 }
584 }
585
586 /* update frames */
587 {
588 uint8_t *out, *src;
589 int j;
590
591 out = frame->data[0];
592 src = c->cur;
593 switch (c->fmt) {
594 case ZMBV_FMT_8BPP:
595 for (j = 0; j < 256; j++)
596 AV_WN32(&frame->data[1][j * 4], 0xFFU << 24 | AV_RB24(&c->pal[j * 3]));
598 case ZMBV_FMT_15BPP:
599 case ZMBV_FMT_16BPP:
600#ifdef ZMBV_ENABLE_24BPP
601 case ZMBV_FMT_24BPP:
602#endif
603 case ZMBV_FMT_32BPP:
604 av_image_copy_plane(out, frame->linesize[0], src, c->stride,
605 c->stride, c->height);
606 break;
607 default:
608 av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
609 }
610 FFSWAP(uint8_t *, c->cur, c->prev);
611 }
612 *got_frame = 1;
613
614 /* always report that the buffer was completely consumed */
615 return buf_size;
616}
617
619{
620 ZmbvContext * const c = avctx->priv_data;
621
622 c->avctx = avctx;
623
624 c->width = avctx->width;
625 c->height = avctx->height;
626
628
629 if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMIN(avctx->max_pixels, INT_MAX / 4) ) {
630 av_log(avctx, AV_LOG_ERROR, "Internal buffer (decomp_size) larger than max_pixels or too large\n");
631 return AVERROR_INVALIDDATA;
632 }
633
634 c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64);
635
636 /* Allocate decompression buffer */
637 c->decomp_buf = av_mallocz(c->decomp_size);
638 if (!c->decomp_buf) {
640 "Can't allocate decompression buffer.\n");
641 return AVERROR(ENOMEM);
642 }
643
644 return ff_inflate_init(&c->zstream, avctx);
645}
646
648{
649 ZmbvContext * const c = avctx->priv_data;
650
651 av_freep(&c->decomp_buf);
652
653 av_freep(&c->cur);
654 av_freep(&c->prev);
655 ff_inflate_end(&c->zstream);
656
657 return 0;
658}
659
661 .p.name = "zmbv",
662 CODEC_LONG_NAME("Zip Motion Blocks Video"),
663 .p.type = AVMEDIA_TYPE_VIDEO,
664 .p.id = AV_CODEC_ID_ZMBV,
665 .priv_data_size = sizeof(ZmbvContext),
666 .init = decode_init,
667 .close = decode_end,
669 .p.capabilities = AV_CODEC_CAP_DR1,
670 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
671};
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
Definition dsp.h:57
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Definition dsp.h:57
const FFCodec ff_zmbv_decoder
Definition zmbv.c:660
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
#define NULL
Definition coverity.c:32
static int16_t block[64]
Definition dct.c:125
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition decode.c:1777
static AVFrame * frame
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_ZMBV
Definition codec_id.h:131
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition error.h:73
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition error.h:64
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition frame.h:687
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition imgutils.c:374
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
@ AV_PICTURE_TYPE_P
Predicted.
Definition avutil.h:279
misc image utilities
#define AV_WN32(p, v)
#define AV_RB24(x)
static av_cold int decode_init(AVCodecContext *avctx)
Definition 4xm.c:998
static av_cold int decode_end(AVCodecContext *avctx)
Definition 4xm.c:980
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
Definition 4xm.c:837
Macro definitions for various function/variable attributes.
#define av_fallthrough
Definition attributes.h:67
#define av_cold
Definition attributes.h:117
#define FFSWAP(type, a, b)
Definition macros.h:52
#define FFMIN(a, b)
Definition macros.h:49
Memory handling functions.
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition pixfmt.h:265
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition pixfmt.h:113
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
Definition pixfmt.h:115
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition pixfmt.h:84
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition pixfmt.h:76
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:643
int width
picture width / height.
Definition avcodec.h:604
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition avcodec.h:1787
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition avcodec.h:1564
void * priv_data
Definition avcodec.h:470
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
This structure stores compressed data.
Definition packet.h:580
int size
Definition packet.h:604
uint8_t * data
Definition packet.h:603
AVCodecContext * avctx
Definition zmbv.c:60
int stride
Definition zmbv.c:72
unsigned int decomp_size
Definition zmbv.c:64
int bw
Definition zmbv.c:73
uint8_t * prev
Definition zmbv.c:67
uint8_t * decomp_buf
Definition zmbv.c:65
int by
Definition zmbv.c:73
uint8_t * cur
Definition zmbv.c:67
int(* decode_xor)(struct ZmbvContext *c)
Definition zmbv.c:77
int bh
Definition zmbv.c:73
int decomp_len
Definition zmbv.c:74
int height
Definition zmbv.c:68
int alloc_bpp
Definition zmbv.c:63
uint8_t pal[768]
Definition zmbv.c:66
int got_keyframe
Definition zmbv.c:75
int flags
Definition zmbv.c:71
FFZStream zstream
Definition zmbv.c:76
int fmt
Definition zmbv.c:69
int width
Definition zmbv.c:68
int bpp
Definition zmbv.c:62
int bx
Definition zmbv.c:73
int comp
Definition zmbv.c:70
#define stride
#define av_mallocz(s)
#define av_realloc_f(p, o, n)
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
static FILE * out
Definition movenc.c:55
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
int len
static double c[64]
void ff_inflate_end(FFZStream *zstream)
Wrapper around inflateEnd().
int ff_inflate_init(FFZStream *zstream, void *logctx)
Wrapper around inflateInit().
ZmbvFormat
Definition zmbv.c:44
@ ZMBV_FMT_24BPP
Definition zmbv.c:52
@ ZMBV_FMT_4BPP
Definition zmbv.c:48
@ ZMBV_FMT_32BPP
Definition zmbv.c:53
@ ZMBV_FMT_1BPP
Definition zmbv.c:46
@ ZMBV_FMT_16BPP
Definition zmbv.c:51
@ ZMBV_FMT_2BPP
Definition zmbv.c:47
@ ZMBV_FMT_NONE
Definition zmbv.c:45
@ ZMBV_FMT_8BPP
Definition zmbv.c:49
@ ZMBV_FMT_15BPP
Definition zmbv.c:50
#define ZMBV_KEYFRAME
Definition zmbv.c:41
static int zmbv_decode_xor_16(ZmbvContext *c)
Decode XOR'ed frame - 15bpp and 16bpp version.
Definition zmbv.c:165
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition zmbv.c:422
#define ZMBV_DELTAPAL
Definition zmbv.c:42
static av_cold int decode_init(AVCodecContext *avctx)
Definition zmbv.c:618
static int zmbv_decode_xor_32(ZmbvContext *c)
Decode XOR'ed frame - 32bpp version.
Definition zmbv.c:331
static av_cold int decode_end(AVCodecContext *avctx)
Definition zmbv.c:647
static int zmbv_decode_xor_8(ZmbvContext *c)
Decode XOR'ed frame - 8bpp version.
Definition zmbv.c:84
static int zmbv_decode_intra(ZmbvContext *c)
Decode intraframe.
Definition zmbv.c:408