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