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 "avcodec.h"
33 #include "codec_internal.h"
34 #include "decode.h"
35 #include "zlib_wrapper.h"
36 
37 #include <zlib.h>
38 
39 #define ZMBV_KEYFRAME 1
40 #define ZMBV_DELTAPAL 2
41 
42 enum ZmbvFormat {
52 };
53 
54 /*
55  * Decoder context
56  */
57 typedef struct ZmbvContext {
59 
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;
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 
413  int *got_frame, AVPacket *avpkt)
414 {
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.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  z_stream *const zstream = &c->zstream.zstream;
540 
541  zstream->total_in = zstream->total_out = 0;
542  zstream->next_in = buf;
543  zstream->avail_in = len;
544  zstream->next_out = c->decomp_buf;
545  zstream->avail_out = c->decomp_size;
546  zret = inflate(zstream, Z_SYNC_FLUSH);
547  if (zret != Z_OK && zret != Z_STREAM_END) {
548  av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
549  return AVERROR_INVALIDDATA;
550  }
551  c->decomp_len = zstream->total_out;
552  }
553  if (expected_size > c->decomp_len ||
554  (c->flags & ZMBV_KEYFRAME) && expected_size < c->decomp_len) {
555  av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
556  return AVERROR_INVALIDDATA;
557  }
558  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
559  return ret;
560 
561  if (c->flags & ZMBV_KEYFRAME) {
565  } else {
568  if (c->decomp_len < 2LL * ((c->width + c->bw - 1) / c->bw) * ((c->height + c->bh - 1) / c->bh))
569  return AVERROR_INVALIDDATA;
570  if (c->decomp_len)
571  c->decode_xor(c);
572  }
573 
574  /* update frames */
575  {
576  uint8_t *out, *src;
577  int j;
578 
579  out = frame->data[0];
580  src = c->cur;
581  switch (c->fmt) {
582  case ZMBV_FMT_8BPP:
583  for (j = 0; j < 256; j++)
584  AV_WN32(&frame->data[1][j * 4], 0xFFU << 24 | AV_RB24(&c->pal[j * 3]));
585  case ZMBV_FMT_15BPP:
586  case ZMBV_FMT_16BPP:
587 #ifdef ZMBV_ENABLE_24BPP
588  case ZMBV_FMT_24BPP:
589 #endif
590  case ZMBV_FMT_32BPP:
591  av_image_copy_plane(out, frame->linesize[0], src, c->stride,
592  c->stride, c->height);
593  break;
594  default:
595  av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
596  }
597  FFSWAP(uint8_t *, c->cur, c->prev);
598  }
599  *got_frame = 1;
600 
601  /* always report that the buffer was completely consumed */
602  return buf_size;
603 }
604 
606 {
607  ZmbvContext * const c = avctx->priv_data;
608 
609  c->avctx = avctx;
610 
611  c->width = avctx->width;
612  c->height = avctx->height;
613 
614  c->bpp = avctx->bits_per_coded_sample;
615 
616  if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMIN(avctx->max_pixels, INT_MAX / 4) ) {
617  av_log(avctx, AV_LOG_ERROR, "Internal buffer (decomp_size) larger than max_pixels or too large\n");
618  return AVERROR_INVALIDDATA;
619  }
620 
621  c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64);
622 
623  /* Allocate decompression buffer */
624  c->decomp_buf = av_mallocz(c->decomp_size);
625  if (!c->decomp_buf) {
627  "Can't allocate decompression buffer.\n");
628  return AVERROR(ENOMEM);
629  }
630 
631  return ff_inflate_init(&c->zstream, avctx);
632 }
633 
635 {
636  ZmbvContext * const c = avctx->priv_data;
637 
638  av_freep(&c->decomp_buf);
639 
640  av_freep(&c->cur);
641  av_freep(&c->prev);
642  ff_inflate_end(&c->zstream);
643 
644  return 0;
645 }
646 
648  .p.name = "zmbv",
649  CODEC_LONG_NAME("Zip Motion Blocks Video"),
650  .p.type = AVMEDIA_TYPE_VIDEO,
651  .p.id = AV_CODEC_ID_ZMBV,
652  .priv_data_size = sizeof(ZmbvContext),
653  .init = decode_init,
654  .close = decode_end,
656  .p.capabilities = AV_CODEC_CAP_DR1,
657  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
658 };
ZmbvContext
Definition: zmbv.c:57
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
FILE * out
Definition: movenc.c:54
AV_CODEC_ID_ZMBV
@ AV_CODEC_ID_ZMBV
Definition: codec_id.h:133
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:48
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
ff_zmbv_decoder
const FFCodec ff_zmbv_decoder
Definition: zmbv.c:647
AVPacket::data
uint8_t * data
Definition: packet.h:491
ZMBV_DELTAPAL
#define ZMBV_DELTAPAL
Definition: zmbv.c:40
FFCodec
Definition: codec_internal.h:127
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:649
ZmbvContext::flags
int flags
Definition: zmbv.c:69
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:361
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
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:412
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: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:605
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:180
zlib_wrapper.h
av_cold
#define av_cold
Definition: attributes.h:90
ZMBV_FMT_8BPP
@ ZMBV_FMT_8BPP
Definition: zmbv.c:47
AV_FRAME_FLAG_KEY
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition: frame.h:628
width
#define width
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
intreadwrite.h
ZMBV_FMT_NONE
@ ZMBV_FMT_NONE
Definition: zmbv.c:43
ZmbvContext::fmt
int fmt
Definition: zmbv.c:67
ZMBV_FMT_2BPP
@ ZMBV_FMT_2BPP
Definition: zmbv.c:45
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
ZMBV_FMT_16BPP
@ ZMBV_FMT_16BPP
Definition: zmbv.c:49
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
decode.h
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:1959
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
frame
static AVFrame * frame
Definition: demux_decode.c:54
ZmbvContext::cur
uint8_t * cur
Definition: zmbv.c:65
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:32
ZmbvContext::zstream
FFZStream zstream
Definition: zmbv.c:74
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:140
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:51
ZmbvContext::stride
int stride
Definition: zmbv.c:70
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:279
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:258
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:42
AVFrame::pict_type
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:442
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1617
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:492
codec_internal.h
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:374
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
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1510
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
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
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:254
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
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:46
AVCodecContext::height
int height
Definition: avcodec.h:621
ZMBV_FMT_1BPP
@ ZMBV_FMT_1BPP
Definition: zmbv.c:44
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:658
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: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
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
ZmbvContext::pal
uint8_t pal[768]
Definition: zmbv.c:64
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: zmbv.c:634
AVCodecContext
main external API structure.
Definition: avcodec.h:441
ZMBV_KEYFRAME
#define ZMBV_KEYFRAME
Definition: zmbv.c:39
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:280
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:161
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:468
AVPacket
This structure stores compressed data.
Definition: packet.h:468
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:368
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:621
zmbv_decode_intra
static int zmbv_decode_intra(ZmbvContext *c)
Decode intraframe.
Definition: zmbv.c:398
imgutils.h
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:385
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: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:368
ZMBV_FMT_24BPP
@ ZMBV_FMT_24BPP
Definition: zmbv.c:50
ZmbvContext::avctx
AVCodecContext * avctx
Definition: zmbv.c:58