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