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