FFmpeg
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 {
51 };
52 
53 /*
54  * Decoder context
55  */
56 typedef struct ZmbvContext {
58 
60  int bpp;
61  int alloc_bpp;
62  unsigned int decomp_size;
63  uint8_t* decomp_buf;
64  uint8_t pal[768];
65  uint8_t *prev, *cur;
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  out = output + x;
141  for (j = 0; j < bh2; j++) {
142  for (i = 0; i < bw2; i++)
143  out[i] ^= *src++;
144  out += c->width;
145  }
146  }
147  }
148  output += c->width * c->bh;
149  prev += c->width * c->bh;
150  }
151  if (src - c->decomp_buf != c->decomp_len)
152  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
153  src-c->decomp_buf, c->decomp_len);
154  return 0;
155 }
156 
157 /**
158  * Decode XOR'ed frame - 15bpp and 16bpp version
159  */
160 
162 {
163  uint8_t *src = c->decomp_buf;
164  uint16_t *output, *prev;
165  int8_t *mvec;
166  int x, y;
167  int d, dx, dy, bw2, bh2;
168  int block;
169  int i, j;
170  int mx, my;
171 
172  output = (uint16_t*)c->cur;
173  prev = (uint16_t*)c->prev;
174 
175  mvec = (int8_t*)src;
176  src += ((c->bx * c->by * 2 + 3) & ~3);
177 
178  block = 0;
179  for (y = 0; y < c->height; y += c->bh) {
180  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
181  for (x = 0; x < c->width; x += c->bw) {
182  uint16_t *out, *tprev;
183 
184  d = mvec[block] & 1;
185  dx = mvec[block] >> 1;
186  dy = mvec[block + 1] >> 1;
187  block += 2;
188 
189  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
190 
191  /* copy block - motion vectors out of bounds are used to zero blocks */
192  out = output + x;
193  tprev = prev + x + dx + dy * c->width;
194  mx = x + dx;
195  my = y + dy;
196  for (j = 0; j < bh2; j++) {
197  if (my + j < 0 || my + j >= c->height) {
198  memset(out, 0, bw2 * 2);
199  } else if (mx >= 0 && mx + bw2 <= c->width){
200  memcpy(out, tprev, sizeof(*out) * bw2);
201  } else {
202  for (i = 0; i < bw2; i++) {
203  if (mx + i < 0 || mx + i >= c->width)
204  out[i] = 0;
205  else
206  out[i] = tprev[i];
207  }
208  }
209  out += c->width;
210  tprev += c->width;
211  }
212 
213  if (d) { /* apply XOR'ed difference */
214  out = output + x;
215  for (j = 0; j < bh2; j++){
216  for (i = 0; i < bw2; i++) {
217  out[i] ^= *((uint16_t*)src);
218  src += 2;
219  }
220  out += c->width;
221  }
222  }
223  }
224  output += c->width * c->bh;
225  prev += c->width * c->bh;
226  }
227  if (src - c->decomp_buf != c->decomp_len)
228  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
229  src-c->decomp_buf, c->decomp_len);
230  return 0;
231 }
232 
233 #ifdef ZMBV_ENABLE_24BPP
234 /**
235  * Decode XOR'ed frame - 24bpp version
236  */
237 
238 static int zmbv_decode_xor_24(ZmbvContext *c)
239 {
240  uint8_t *src = c->decomp_buf;
241  uint8_t *output, *prev;
242  int8_t *mvec;
243  int x, y;
244  int d, dx, dy, bw2, bh2;
245  int block;
246  int i, j;
247  int mx, my;
248  int stride;
249 
250  output = c->cur;
251  prev = c->prev;
252 
253  stride = c->width * 3;
254  mvec = (int8_t*)src;
255  src += ((c->bx * c->by * 2 + 3) & ~3);
256 
257  block = 0;
258  for (y = 0; y < c->height; y += c->bh) {
259  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
260  for (x = 0; x < c->width; x += c->bw) {
261  uint8_t *out, *tprev;
262 
263  d = mvec[block] & 1;
264  dx = mvec[block] >> 1;
265  dy = mvec[block + 1] >> 1;
266  block += 2;
267 
268  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
269 
270  /* copy block - motion vectors out of bounds are used to zero blocks */
271  out = output + x * 3;
272  tprev = prev + (x + dx) * 3 + dy * stride;
273  mx = x + dx;
274  my = y + dy;
275  for (j = 0; j < bh2; j++) {
276  if (my + j < 0 || my + j >= c->height) {
277  memset(out, 0, bw2 * 3);
278  } else if (mx >= 0 && mx + bw2 <= c->width){
279  memcpy(out, tprev, 3 * bw2);
280  } else {
281  for (i = 0; i < bw2; i++){
282  if (mx + i < 0 || mx + i >= c->width) {
283  out[i * 3 + 0] = 0;
284  out[i * 3 + 1] = 0;
285  out[i * 3 + 2] = 0;
286  } else {
287  out[i * 3 + 0] = tprev[i * 3 + 0];
288  out[i * 3 + 1] = tprev[i * 3 + 1];
289  out[i * 3 + 2] = tprev[i * 3 + 2];
290  }
291  }
292  }
293  out += stride;
294  tprev += stride;
295  }
296 
297  if (d) { /* apply XOR'ed difference */
298  out = output + x * 3;
299  for (j = 0; j < bh2; j++) {
300  for (i = 0; i < bw2; i++) {
301  out[i * 3 + 0] ^= *src++;
302  out[i * 3 + 1] ^= *src++;
303  out[i * 3 + 2] ^= *src++;
304  }
305  out += stride;
306  }
307  }
308  }
309  output += stride * c->bh;
310  prev += stride * c->bh;
311  }
312  if (src - c->decomp_buf != c->decomp_len)
313  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
314  src-c->decomp_buf, c->decomp_len);
315  return 0;
316 }
317 #endif //ZMBV_ENABLE_24BPP
318 
319 /**
320  * Decode XOR'ed frame - 32bpp version
321  */
322 
324 {
325  uint8_t *src = c->decomp_buf;
326  uint32_t *output, *prev;
327  int8_t *mvec;
328  int x, y;
329  int d, dx, dy, bw2, bh2;
330  int block;
331  int i, j;
332  int mx, my;
333 
334  output = (uint32_t*)c->cur;
335  prev = (uint32_t*)c->prev;
336 
337  mvec = (int8_t*)src;
338  src += ((c->bx * c->by * 2 + 3) & ~3);
339 
340  block = 0;
341  for (y = 0; y < c->height; y += c->bh) {
342  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
343  for (x = 0; x < c->width; x += c->bw) {
344  uint32_t *out, *tprev;
345 
346  d = mvec[block] & 1;
347  dx = mvec[block] >> 1;
348  dy = mvec[block + 1] >> 1;
349  block += 2;
350 
351  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
352 
353  /* copy block - motion vectors out of bounds are used to zero blocks */
354  out = output + x;
355  tprev = prev + x + dx + dy * c->width;
356  mx = x + dx;
357  my = y + dy;
358  for (j = 0; j < bh2; j++) {
359  if (my + j < 0 || my + j >= c->height) {
360  memset(out, 0, bw2 * 4);
361  } else if (mx >= 0 && mx + bw2 <= c->width){
362  memcpy(out, tprev, sizeof(*out) * bw2);
363  } else {
364  for (i = 0; i < bw2; i++){
365  if (mx + i < 0 || mx + i >= c->width)
366  out[i] = 0;
367  else
368  out[i] = tprev[i];
369  }
370  }
371  out += c->width;
372  tprev += c->width;
373  }
374 
375  if (d) { /* apply XOR'ed difference */
376  out = output + x;
377  for (j = 0; j < bh2; j++){
378  for (i = 0; i < bw2; i++) {
379  out[i] ^= *((uint32_t *) src);
380  src += 4;
381  }
382  out += c->width;
383  }
384  }
385  }
386  output += c->width * c->bh;
387  prev += c->width * c->bh;
388  }
389  if (src - c->decomp_buf != c->decomp_len)
390  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
391  src-c->decomp_buf, c->decomp_len);
392  return 0;
393 }
394 
395 /**
396  * Decode intraframe
397  */
399 {
400  uint8_t *src = c->decomp_buf;
401 
402  /* make the palette available on the way out */
403  if (c->fmt == ZMBV_FMT_8BPP) {
404  memcpy(c->pal, src, 768);
405  src += 768;
406  }
407 
408  memcpy(c->cur, src, c->width * c->height * (c->bpp / 8));
409  return 0;
410 }
411 
412 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
413 {
414  AVFrame *frame = data;
415  const uint8_t *buf = avpkt->data;
416  int buf_size = avpkt->size;
417  ZmbvContext * const c = avctx->priv_data;
418  int zret = Z_OK; // Zlib return code
419  int len = buf_size;
420  int hi_ver, lo_ver, ret;
421  int expected_size;
422 
423  /* parse header */
424  if (len < 1)
425  return AVERROR_INVALIDDATA;
426  c->flags = buf[0];
427  buf++; len--;
428  if (c->flags & ZMBV_KEYFRAME) {
429  c->got_keyframe = 0;
430 
431  if (len < 6)
432  return AVERROR_INVALIDDATA;
433  hi_ver = buf[0];
434  lo_ver = buf[1];
435  c->comp = buf[2];
436  c->fmt = buf[3];
437  c->bw = buf[4];
438  c->bh = buf[5];
439  c->decode_xor = NULL;
440 
441  buf += 6;
442  len -= 6;
444  "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
445  c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh);
446  if (hi_ver != 0 || lo_ver != 1) {
447  avpriv_request_sample(avctx, "Version %i.%i", hi_ver, lo_ver);
448  return AVERROR_PATCHWELCOME;
449  }
450  if (c->bw == 0 || c->bh == 0) {
451  avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh);
452  return AVERROR_PATCHWELCOME;
453  }
454  if (c->comp != 0 && c->comp != 1) {
455  avpriv_request_sample(avctx, "Compression type %i", c->comp);
456  return AVERROR_PATCHWELCOME;
457  }
458 
459  switch (c->fmt) {
460  case ZMBV_FMT_8BPP:
461  c->bpp = 8;
462  c->decode_xor = zmbv_decode_xor_8;
464  c->stride = c->width;
465  break;
466  case ZMBV_FMT_15BPP:
467  case ZMBV_FMT_16BPP:
468  c->bpp = 16;
469  c->decode_xor = zmbv_decode_xor_16;
470  if (c->fmt == ZMBV_FMT_15BPP)
472  else
474  c->stride = c->width * 2;
475  break;
476 #ifdef ZMBV_ENABLE_24BPP
477  case ZMBV_FMT_24BPP:
478  c->bpp = 24;
479  c->decode_xor = zmbv_decode_xor_24;
481  c->stride = c->width * 3;
482  break;
483 #endif //ZMBV_ENABLE_24BPP
484  case ZMBV_FMT_32BPP:
485  c->bpp = 32;
486  c->decode_xor = zmbv_decode_xor_32;
488  c->stride = c->width * 4;
489  break;
490  default:
491  c->decode_xor = NULL;
492  avpriv_request_sample(avctx, "Format %i", c->fmt);
493  return AVERROR_PATCHWELCOME;
494  }
495 
496  zret = inflateReset(&c->zstream);
497  if (zret != Z_OK) {
498  av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
499  return AVERROR_UNKNOWN;
500  }
501 
502  if (c->alloc_bpp < c->bpp) {
503  c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
504  c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8));
505  c->alloc_bpp = c->bpp;
506  }
507  c->bx = (c->width + c->bw - 1) / c->bw;
508  c->by = (c->height+ c->bh - 1) / c->bh;
509  if (!c->cur || !c->prev) {
510  c->alloc_bpp = 0;
511  return AVERROR(ENOMEM);
512  }
513  memset(c->cur, 0, avctx->width * avctx->height * (c->bpp / 8));
514  memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
515  c->got_keyframe = 1;
516  }
517  if (c->flags & ZMBV_KEYFRAME) {
518  expected_size = avctx->width * avctx->height * (c->bpp / 8);
519  } else {
520  expected_size = (c->bx * c->by * 2 + 3) & ~3;
521  }
522  if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
523  (c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME)))
524  expected_size += 768;
525 
526  if (!c->got_keyframe) {
527  av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
528  return AVERROR_INVALIDDATA;
529  }
530 
531  if (c->comp == 0) { // uncompressed data
532  if (c->decomp_size < len) {
533  av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
534  return AVERROR_INVALIDDATA;
535  }
536  memcpy(c->decomp_buf, buf, len);
537  c->decomp_len = len;
538  } else { // ZLIB-compressed data
539  c->zstream.total_in = c->zstream.total_out = 0;
540  c->zstream.next_in = buf;
541  c->zstream.avail_in = len;
542  c->zstream.next_out = c->decomp_buf;
543  c->zstream.avail_out = c->decomp_size;
544  zret = inflate(&c->zstream, Z_SYNC_FLUSH);
545  if (zret != Z_OK && zret != Z_STREAM_END) {
546  av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
547  return AVERROR_INVALIDDATA;
548  }
549  c->decomp_len = c->zstream.total_out;
550  }
551  if (expected_size > c->decomp_len ||
552  (c->flags & ZMBV_KEYFRAME) && expected_size < c->decomp_len) {
553  av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
554  return AVERROR_INVALIDDATA;
555  }
556  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
557  return ret;
558 
559  if (c->flags & ZMBV_KEYFRAME) {
560  frame->key_frame = 1;
561  frame->pict_type = AV_PICTURE_TYPE_I;
563  } else {
564  frame->key_frame = 0;
565  frame->pict_type = AV_PICTURE_TYPE_P;
566  if (c->decomp_len < 2LL * ((c->width + c->bw - 1) / c->bw) * ((c->height + c->bh - 1) / c->bh))
567  return AVERROR_INVALIDDATA;
568  if (c->decomp_len)
569  c->decode_xor(c);
570  }
571 
572  /* update frames */
573  {
574  uint8_t *out, *src;
575  int j;
576 
577  out = frame->data[0];
578  src = c->cur;
579  switch (c->fmt) {
580  case ZMBV_FMT_8BPP:
581  for (j = 0; j < 256; j++)
582  AV_WN32(&frame->data[1][j * 4], 0xFFU << 24 | AV_RB24(&c->pal[j * 3]));
583  case ZMBV_FMT_15BPP:
584  case ZMBV_FMT_16BPP:
585 #ifdef ZMBV_ENABLE_24BPP
586  case ZMBV_FMT_24BPP:
587 #endif
588  case ZMBV_FMT_32BPP:
589  av_image_copy_plane(out, frame->linesize[0], src, c->stride,
590  c->stride, c->height);
591  break;
592  default:
593  av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
594  }
595  FFSWAP(uint8_t *, c->cur, c->prev);
596  }
597  *got_frame = 1;
598 
599  /* always report that the buffer was completely consumed */
600  return buf_size;
601 }
602 
604 {
605  ZmbvContext * const c = avctx->priv_data;
606  int zret; // Zlib return code
607 
608  c->avctx = avctx;
609 
610  c->width = avctx->width;
611  c->height = avctx->height;
612 
613  c->bpp = avctx->bits_per_coded_sample;
614 
615  if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMIN(avctx->max_pixels, INT_MAX / 4) ) {
616  av_log(avctx, AV_LOG_ERROR, "Internal buffer (decomp_size) larger than max_pixels or too large\n");
617  return AVERROR_INVALIDDATA;
618  }
619 
620  c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64);
621 
622  /* Allocate decompression buffer */
623  c->decomp_buf = av_mallocz(c->decomp_size);
624  if (!c->decomp_buf) {
626  "Can't allocate decompression buffer.\n");
627  return AVERROR(ENOMEM);
628  }
629 
630  c->zstream.zalloc = Z_NULL;
631  c->zstream.zfree = Z_NULL;
632  c->zstream.opaque = Z_NULL;
633  zret = inflateInit(&c->zstream);
634  if (zret != Z_OK) {
635  av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
636  return AVERROR_UNKNOWN;
637  }
638  c->zlib_init_ok = 1;
639 
640  return 0;
641 }
642 
644 {
645  ZmbvContext * const c = avctx->priv_data;
646 
647  av_freep(&c->decomp_buf);
648 
649  av_freep(&c->cur);
650  av_freep(&c->prev);
651  if (c->zlib_init_ok)
652  inflateEnd(&c->zstream);
653 
654  return 0;
655 }
656 
658  .name = "zmbv",
659  .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
660  .type = AVMEDIA_TYPE_VIDEO,
661  .id = AV_CODEC_ID_ZMBV,
662  .priv_data_size = sizeof(ZmbvContext),
663  .init = decode_init,
664  .close = decode_end,
665  .decode = decode_frame,
666  .capabilities = AV_CODEC_CAP_DR1,
668 };
AVCodec
AVCodec.
Definition: codec.h:197
stride
int stride
Definition: mace.c:144
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:41
ZmbvContext
Definition: zmbv.c:56
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
out
FILE * out
Definition: movenc.c:54
FFSWAP
#define FFSWAP(type, a, b)
Definition: common.h:108
AV_CODEC_ID_ZMBV
@ AV_CODEC_ID_ZMBV
Definition: codec_id.h:131
ZmbvContext::by
int by
Definition: zmbv.c:71
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
ZMBV_FMT_15BPP
@ ZMBV_FMT_15BPP
Definition: zmbv.c:47
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:365
ZMBV_DELTAPAL
#define ZMBV_DELTAPAL
Definition: zmbv.c:39
data
const char data[16]
Definition: mxf.c:142
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
ZmbvContext::flags
int flags
Definition: zmbv.c:69
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
av_image_copy_plane
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
inflate
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:198
ZmbvContext::width
int width
Definition: zmbv.c:66
zmbv_decode_xor_8
static int zmbv_decode_xor_8(ZmbvContext *c)
Decode XOR'ed frame - 8bpp version.
Definition: zmbv.c:82
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: zmbv.c:603
ZmbvContext::decode_xor
int(* decode_xor)(struct ZmbvContext *c)
Definition: zmbv.c:75
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:181
av_cold
#define av_cold
Definition: attributes.h:90
ZMBV_FMT_8BPP
@ ZMBV_FMT_8BPP
Definition: zmbv.c:46
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
width
#define width
intreadwrite.h
ZMBV_FMT_NONE
@ ZMBV_FMT_NONE
Definition: zmbv.c:42
ZmbvContext::fmt
int fmt
Definition: zmbv.c:67
ZMBV_FMT_2BPP
@ ZMBV_FMT_2BPP
Definition: zmbv.c:44
ZMBV_FMT_16BPP
@ ZMBV_FMT_16BPP
Definition: zmbv.c:48
ff_zmbv_decoder
const AVCodec ff_zmbv_decoder
Definition: zmbv.c:657
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:202
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1873
ZmbvContext::zlib_init_ok
int zlib_init_ok
Definition: zmbv.c:59
ZmbvContext::cur
uint8_t * cur
Definition: zmbv.c:65
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:33
ZmbvContext::height
int height
Definition: zmbv.c:66
AV_PIX_FMT_RGB565LE
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:106
ZmbvContext::decomp_buf
uint8_t * decomp_buf
Definition: zmbv.c:63
PTRDIFF_SPECIFIER
#define PTRDIFF_SPECIFIER
Definition: internal.h:192
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
ZMBV_FMT_32BPP
@ ZMBV_FMT_32BPP
Definition: zmbv.c:50
ZmbvContext::stride
int stride
Definition: zmbv.c:70
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
src
#define src
Definition: vp8dsp.c:255
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:230
ZmbvContext::decomp_size
unsigned int decomp_size
Definition: zmbv.c:62
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ZmbvContext::bh
int bh
Definition: zmbv.c:71
ZmbvFormat
ZmbvFormat
Definition: zmbv.c:41
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1645
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:366
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
ZmbvContext::bw
int bw
Definition: zmbv.c:71
ZmbvContext::prev
uint8_t * prev
Definition: zmbv.c:65
zmbv_decode_xor_32
static int zmbv_decode_xor_32(ZmbvContext *c)
Decode XOR'ed frame - 32bpp version.
Definition: zmbv.c:323
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1407
ZmbvContext::bx
int bx
Definition: zmbv.c:71
AV_PIX_FMT_RGB555LE
@ 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
i
int i
Definition: input.c:407
FF_CODEC_CAP_INIT_CLEANUP
#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.h
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:244
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:204
len
int len
Definition: vorbis_enc_data.h:426
ZMBV_FMT_4BPP
@ ZMBV_FMT_4BPP
Definition: zmbv.c:45
AVCodecContext::height
int height
Definition: avcodec.h:557
ZMBV_FMT_1BPP
@ ZMBV_FMT_1BPP
Definition: zmbv.c:43
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:594
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ZmbvContext::decomp_len
int decomp_len
Definition: zmbv.c:72
ret
ret
Definition: filter_design.txt:187
ZmbvContext::got_keyframe
int got_keyframe
Definition: zmbv.c:73
ZmbvContext::comp
int comp
Definition: zmbv.c:68
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
decode_frame
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: zmbv.c:412
ZmbvContext::pal
uint8_t pal[768]
Definition: zmbv.c:64
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: zmbv.c:643
AVCodecContext
main external API structure.
Definition: avcodec.h:384
ZMBV_KEYFRAME
#define ZMBV_KEYFRAME
Definition: zmbv.c:38
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:39
zmbv_decode_xor_16
static int zmbv_decode_xor_16(ZmbvContext *c)
Decode XOR'ed frame - 15bpp and 16bpp version.
Definition: zmbv.c:161
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:411
AVPacket
This structure stores compressed data.
Definition: packet.h:342
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
d
d
Definition: ffmpeg_filter.c:156
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:557
zmbv_decode_intra
static int zmbv_decode_intra(ZmbvContext *c)
Decode intraframe.
Definition: zmbv.c:398
imgutils.h
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
ZmbvContext::alloc_bpp
int alloc_bpp
Definition: zmbv.c:61
ZmbvContext::bpp
int bpp
Definition: zmbv.c:60
AV_RB24
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:97
int
int
Definition: ffmpeg_filter.c:156
ZMBV_FMT_24BPP
@ ZMBV_FMT_24BPP
Definition: zmbv.c:49
ZmbvContext::zstream
z_stream zstream
Definition: zmbv.c:74
ZmbvContext::avctx
AVCodecContext * avctx
Definition: zmbv.c:57