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 <stddef.h>
28 
29 #include "libavutil/attributes.h"
30 #include "libavutil/common.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/intreadwrite.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 
44 enum ZmbvFormat {
54 };
55 
56 /*
57  * Decoder context
58  */
59 typedef struct ZmbvContext {
61 
62  int bpp;
63  int alloc_bpp;
64  unsigned int decomp_size;
65  uint8_t* decomp_buf;
66  uint8_t pal[768];
67  uint8_t *prev, *cur;
68  int width, height;
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);
78 } ZmbvContext;
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 
244 static 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);
458  return AVERROR_PATCHWELCOME;
459  }
460  if (c->bw == 0 || c->bh == 0) {
461  avpriv_request_sample(avctx, "Block size %ix%i", c->bw, c->bh);
462  return AVERROR_PATCHWELCOME;
463  }
464  if (c->comp != 0 && c->comp != 1) {
465  avpriv_request_sample(avctx, "Compression type %i", c->comp);
466  return AVERROR_PATCHWELCOME;
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);
503  return AVERROR_PATCHWELCOME;
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 
627  c->bpp = avctx->bits_per_coded_sample;
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 };
ZmbvContext
Definition: zmbv.c:59
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: codec_internal.h:43
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
static FILE * out
Definition: movenc.c:55
AV_CODEC_ID_ZMBV
@ AV_CODEC_ID_ZMBV
Definition: codec_id.h:133
ZmbvContext::by
int by
Definition: zmbv.c:73
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:226
ZMBV_FMT_15BPP
@ ZMBV_FMT_15BPP
Definition: zmbv.c:50
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:435
ff_zmbv_decoder
const FFCodec ff_zmbv_decoder
Definition: zmbv.c:660
AVPacket::data
uint8_t * data
Definition: packet.h:595
ZMBV_DELTAPAL
#define ZMBV_DELTAPAL
Definition: zmbv.c:42
FFCodec
Definition: codec_internal.h:127
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
ZmbvContext::flags
int flags
Definition: zmbv.c:71
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
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
close
static av_cold void close(AVCodecParserContext *s)
Definition: apv_parser.c:197
mx
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Definition: dsp.h:57
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: zmbv.c:422
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:194
ZmbvContext::width
int width
Definition: zmbv.c:68
zmbv_decode_xor_8
static int zmbv_decode_xor_8(ZmbvContext *c)
Decode XOR'ed frame - 8bpp version.
Definition: zmbv.c:84
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: zmbv.c:618
ZmbvContext::decode_xor
int(* decode_xor)(struct ZmbvContext *c)
Definition: zmbv.c:77
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
zlib_wrapper.h
av_cold
#define av_cold
Definition: attributes.h:119
ZMBV_FMT_8BPP
@ ZMBV_FMT_8BPP
Definition: zmbv.c:49
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:650
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:347
intreadwrite.h
ZMBV_FMT_NONE
@ ZMBV_FMT_NONE
Definition: zmbv.c:45
ZmbvContext::fmt
int fmt
Definition: zmbv.c:69
ZMBV_FMT_2BPP
@ ZMBV_FMT_2BPP
Definition: zmbv.c:47
ZMBV_FMT_16BPP
@ ZMBV_FMT_16BPP
Definition: zmbv.c:51
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
decode.h
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1794
av_mallocz
#define av_mallocz(s)
Definition: tableprint_vlc.h:31
av_fallthrough
#define av_fallthrough
Definition: attributes.h:67
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:332
my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
Definition: dsp.h:57
ZmbvContext::cur
uint8_t * cur
Definition: zmbv.c:67
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:33
ZmbvContext::zstream
FFZStream zstream
Definition: zmbv.c:76
ZmbvContext::height
int height
Definition: zmbv.c:68
AV_PIX_FMT_RGB565LE
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:113
ZmbvContext::decomp_buf
uint8_t * decomp_buf
Definition: zmbv.c:65
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
ZMBV_FMT_32BPP
@ ZMBV_FMT_32BPP
Definition: zmbv.c:53
ZmbvContext::stride
int stride
Definition: zmbv.c:72
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:278
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
ZmbvContext::decomp_size
unsigned int decomp_size
Definition: zmbv.c:64
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:73
ZmbvFormat
ZmbvFormat
Definition: zmbv.c:44
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1765
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:551
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:596
codec_internal.h
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:372
ZmbvContext::bw
int bw
Definition: zmbv.c:73
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
ZmbvContext::prev
uint8_t * prev
Definition: zmbv.c:67
zmbv_decode_xor_32
static int zmbv_decode_xor_32(ZmbvContext *c)
Decode XOR'ed frame - 32bpp version.
Definition: zmbv.c:331
attributes.h
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1558
ZmbvContext::bx
int bx
Definition: zmbv.c:73
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:115
common.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
len
int len
Definition: vorbis_enc_data.h:426
ff_inflate_end
void ff_inflate_end(FFZStream *zstream)
Wrapper around inflateEnd().
ZMBV_FMT_4BPP
@ ZMBV_FMT_4BPP
Definition: zmbv.c:48
AVCodecContext::height
int height
Definition: avcodec.h:600
ZMBV_FMT_1BPP
@ ZMBV_FMT_1BPP
Definition: zmbv.c:46
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:639
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
ZmbvContext::decomp_len
int decomp_len
Definition: zmbv.c:74
ret
ret
Definition: filter_design.txt:187
ZmbvContext::got_keyframe
int got_keyframe
Definition: zmbv.c:75
ZmbvContext::comp
int comp
Definition: zmbv.c:70
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
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:265
ZmbvContext::pal
uint8_t pal[768]
Definition: zmbv.c:66
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: zmbv.c:647
AVCodecContext
main external API structure.
Definition: avcodec.h:439
ZMBV_KEYFRAME
#define ZMBV_KEYFRAME
Definition: zmbv.c:41
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:279
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFZStream
Definition: zlib_wrapper.h:27
mem.h
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
zmbv_decode_xor_16
static int zmbv_decode_xor_16(ZmbvContext *c)
Decode XOR'ed frame - 15bpp and 16bpp version.
Definition: zmbv.c:165
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:466
AVPacket
This structure stores compressed data.
Definition: packet.h:572
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
ff_inflate_init
int ff_inflate_init(FFZStream *zstream, void *logctx)
Wrapper around inflateInit().
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:600
zmbv_decode_intra
static int zmbv_decode_intra(ZmbvContext *c)
Decode intraframe.
Definition: zmbv.c:408
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:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ZmbvContext::alloc_bpp
int alloc_bpp
Definition: zmbv.c:63
stride
#define stride
Definition: h264pred_template.c:536
ZmbvContext::bpp
int bpp
Definition: zmbv.c:62
width
#define width
Definition: dsp.h:89
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
ZMBV_FMT_24BPP
@ ZMBV_FMT_24BPP
Definition: zmbv.c:52
src
#define src
Definition: vp8dsp.c:248
ZmbvContext::avctx
AVCodecContext * avctx
Definition: zmbv.c:60