FFmpeg
zmbv.c
Go to the documentation of this file.
1 /*
2  * Zip Motion Blocks Video (ZMBV) decoder
3  * Copyright (c) 2006 Konstantin Shishkov
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Zip Motion Blocks Video decoder
25  */
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 
30 #include "libavutil/common.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/intreadwrite.h"
33 #include "avcodec.h"
34 #include "internal.h"
35 
36 #include <zlib.h>
37 
38 #define ZMBV_KEYFRAME 1
39 #define ZMBV_DELTAPAL 2
40 
41 enum ZmbvFormat {
51 };
52 
53 /*
54  * Decoder context
55  */
56 typedef struct ZmbvContext {
58 
59  int bpp;
60  int alloc_bpp;
61  unsigned int decomp_size;
63  uint8_t pal[768];
65  int width, height;
66  int fmt;
67  int comp;
68  int flags;
69  int stride;
70  int bw, bh, bx, by;
72  z_stream zstream;
74  int (*decode_xor)(struct ZmbvContext *c);
75 } ZmbvContext;
76 
77 /**
78  * Decode XOR'ed frame - 8bpp version
79  */
80 
82 {
83  uint8_t *src = c->decomp_buf;
84  uint8_t *output, *prev;
85  int8_t *mvec;
86  int x, y;
87  int d, dx, dy, bw2, bh2;
88  int block;
89  int i, j;
90  int mx, my;
91 
92  output = c->cur;
93  prev = c->prev;
94 
95  if (c->flags & ZMBV_DELTAPAL) {
96  for (i = 0; i < 768; i++)
97  c->pal[i] ^= *src++;
98  }
99 
100  mvec = (int8_t*)src;
101  src += ((c->bx * c->by * 2 + 3) & ~3);
102 
103  block = 0;
104  for (y = 0; y < c->height; y += c->bh) {
105  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
106  for (x = 0; x < c->width; x += c->bw) {
107  uint8_t *out, *tprev;
108 
109  d = mvec[block] & 1;
110  dx = mvec[block] >> 1;
111  dy = mvec[block + 1] >> 1;
112  block += 2;
113 
114  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
115 
116  /* copy block - motion vectors out of bounds are used to zero blocks */
117  out = output + x;
118  tprev = prev + x + dx + dy * c->width;
119  mx = x + dx;
120  my = y + dy;
121  for (j = 0; j < bh2; j++) {
122  if (my + j < 0 || my + j >= c->height) {
123  memset(out, 0, bw2);
124  } else if (mx >= 0 && mx + bw2 <= c->width){
125  memcpy(out, tprev, sizeof(*out) * bw2);
126  } else {
127  for (i = 0; i < bw2; i++) {
128  if (mx + i < 0 || mx + i >= c->width)
129  out[i] = 0;
130  else
131  out[i] = tprev[i];
132  }
133  }
134  out += c->width;
135  tprev += c->width;
136  }
137 
138  if (d) { /* apply XOR'ed difference */
139  out = output + x;
140  for (j = 0; j < bh2; j++) {
141  for (i = 0; i < bw2; i++)
142  out[i] ^= *src++;
143  out += c->width;
144  }
145  }
146  }
147  output += c->width * c->bh;
148  prev += c->width * c->bh;
149  }
150  if (src - c->decomp_buf != c->decomp_len)
151  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
152  src-c->decomp_buf, c->decomp_len);
153  return 0;
154 }
155 
156 /**
157  * Decode XOR'ed frame - 15bpp and 16bpp version
158  */
159 
161 {
162  uint8_t *src = c->decomp_buf;
163  uint16_t *output, *prev;
164  int8_t *mvec;
165  int x, y;
166  int d, dx, dy, bw2, bh2;
167  int block;
168  int i, j;
169  int mx, my;
170 
171  output = (uint16_t*)c->cur;
172  prev = (uint16_t*)c->prev;
173 
174  mvec = (int8_t*)src;
175  src += ((c->bx * c->by * 2 + 3) & ~3);
176 
177  block = 0;
178  for (y = 0; y < c->height; y += c->bh) {
179  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
180  for (x = 0; x < c->width; x += c->bw) {
181  uint16_t *out, *tprev;
182 
183  d = mvec[block] & 1;
184  dx = mvec[block] >> 1;
185  dy = mvec[block + 1] >> 1;
186  block += 2;
187 
188  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
189 
190  /* copy block - motion vectors out of bounds are used to zero blocks */
191  out = output + x;
192  tprev = prev + x + dx + dy * c->width;
193  mx = x + dx;
194  my = y + dy;
195  for (j = 0; j < bh2; j++) {
196  if (my + j < 0 || my + j >= c->height) {
197  memset(out, 0, bw2 * 2);
198  } else if (mx >= 0 && mx + bw2 <= c->width){
199  memcpy(out, tprev, sizeof(*out) * bw2);
200  } else {
201  for (i = 0; i < bw2; i++) {
202  if (mx + i < 0 || mx + i >= c->width)
203  out[i] = 0;
204  else
205  out[i] = tprev[i];
206  }
207  }
208  out += c->width;
209  tprev += c->width;
210  }
211 
212  if (d) { /* apply XOR'ed difference */
213  out = output + x;
214  for (j = 0; j < bh2; j++){
215  for (i = 0; i < bw2; i++) {
216  out[i] ^= *((uint16_t*)src);
217  src += 2;
218  }
219  out += c->width;
220  }
221  }
222  }
223  output += c->width * c->bh;
224  prev += c->width * c->bh;
225  }
226  if (src - c->decomp_buf != c->decomp_len)
227  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
228  src-c->decomp_buf, c->decomp_len);
229  return 0;
230 }
231 
232 #ifdef ZMBV_ENABLE_24BPP
233 /**
234  * Decode XOR'ed frame - 24bpp version
235  */
236 
237 static int zmbv_decode_xor_24(ZmbvContext *c)
238 {
239  uint8_t *src = c->decomp_buf;
240  uint8_t *output, *prev;
241  int8_t *mvec;
242  int x, y;
243  int d, dx, dy, bw2, bh2;
244  int block;
245  int i, j;
246  int mx, my;
247  int stride;
248 
249  output = c->cur;
250  prev = c->prev;
251 
252  stride = c->width * 3;
253  mvec = (int8_t*)src;
254  src += ((c->bx * c->by * 2 + 3) & ~3);
255 
256  block = 0;
257  for (y = 0; y < c->height; y += c->bh) {
258  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
259  for (x = 0; x < c->width; x += c->bw) {
260  uint8_t *out, *tprev;
261 
262  d = mvec[block] & 1;
263  dx = mvec[block] >> 1;
264  dy = mvec[block + 1] >> 1;
265  block += 2;
266 
267  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
268 
269  /* copy block - motion vectors out of bounds are used to zero blocks */
270  out = output + x * 3;
271  tprev = prev + (x + dx) * 3 + dy * stride;
272  mx = x + dx;
273  my = y + dy;
274  for (j = 0; j < bh2; j++) {
275  if (my + j < 0 || my + j >= c->height) {
276  memset(out, 0, bw2 * 3);
277  } else if (mx >= 0 && mx + bw2 <= c->width){
278  memcpy(out, tprev, 3 * bw2);
279  } else {
280  for (i = 0; i < bw2; i++){
281  if (mx + i < 0 || mx + i >= c->width) {
282  out[i * 3 + 0] = 0;
283  out[i * 3 + 1] = 0;
284  out[i * 3 + 2] = 0;
285  } else {
286  out[i * 3 + 0] = tprev[i * 3 + 0];
287  out[i * 3 + 1] = tprev[i * 3 + 1];
288  out[i * 3 + 2] = tprev[i * 3 + 2];
289  }
290  }
291  }
292  out += stride;
293  tprev += stride;
294  }
295 
296  if (d) { /* apply XOR'ed difference */
297  out = output + x * 3;
298  for (j = 0; j < bh2; j++) {
299  for (i = 0; i < bw2; i++) {
300  out[i * 3 + 0] ^= *src++;
301  out[i * 3 + 1] ^= *src++;
302  out[i * 3 + 2] ^= *src++;
303  }
304  out += stride;
305  }
306  }
307  }
308  output += stride * c->bh;
309  prev += stride * c->bh;
310  }
311  if (src - c->decomp_buf != c->decomp_len)
312  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
313  src-c->decomp_buf, c->decomp_len);
314  return 0;
315 }
316 #endif //ZMBV_ENABLE_24BPP
317 
318 /**
319  * Decode XOR'ed frame - 32bpp version
320  */
321 
323 {
324  uint8_t *src = c->decomp_buf;
325  uint32_t *output, *prev;
326  int8_t *mvec;
327  int x, y;
328  int d, dx, dy, bw2, bh2;
329  int block;
330  int i, j;
331  int mx, my;
332 
333  output = (uint32_t*)c->cur;
334  prev = (uint32_t*)c->prev;
335 
336  mvec = (int8_t*)src;
337  src += ((c->bx * c->by * 2 + 3) & ~3);
338 
339  block = 0;
340  for (y = 0; y < c->height; y += c->bh) {
341  bh2 = ((c->height - y) > c->bh) ? c->bh : (c->height - y);
342  for (x = 0; x < c->width; x += c->bw) {
343  uint32_t *out, *tprev;
344 
345  d = mvec[block] & 1;
346  dx = mvec[block] >> 1;
347  dy = mvec[block + 1] >> 1;
348  block += 2;
349 
350  bw2 = ((c->width - x) > c->bw) ? c->bw : (c->width - x);
351 
352  /* copy block - motion vectors out of bounds are used to zero blocks */
353  out = output + x;
354  tprev = prev + x + dx + dy * c->width;
355  mx = x + dx;
356  my = y + dy;
357  for (j = 0; j < bh2; j++) {
358  if (my + j < 0 || my + j >= c->height) {
359  memset(out, 0, bw2 * 4);
360  } else if (mx >= 0 && mx + bw2 <= c->width){
361  memcpy(out, tprev, sizeof(*out) * bw2);
362  } else {
363  for (i = 0; i < bw2; i++){
364  if (mx + i < 0 || mx + i >= c->width)
365  out[i] = 0;
366  else
367  out[i] = tprev[i];
368  }
369  }
370  out += c->width;
371  tprev += c->width;
372  }
373 
374  if (d) { /* apply XOR'ed difference */
375  out = output + x;
376  for (j = 0; j < bh2; j++){
377  for (i = 0; i < bw2; i++) {
378  out[i] ^= *((uint32_t *) src);
379  src += 4;
380  }
381  out += c->width;
382  }
383  }
384  }
385  output += c->width * c->bh;
386  prev += c->width * c->bh;
387  }
388  if (src - c->decomp_buf != c->decomp_len)
389  av_log(c->avctx, AV_LOG_ERROR, "Used %"PTRDIFF_SPECIFIER" of %i bytes\n",
390  src-c->decomp_buf, c->decomp_len);
391  return 0;
392 }
393 
394 /**
395  * Decode intraframe
396  */
398 {
399  uint8_t *src = c->decomp_buf;
400 
401  /* make the palette available on the way out */
402  if (c->fmt == ZMBV_FMT_8BPP) {
403  memcpy(c->pal, src, 768);
404  src += 768;
405  }
406 
407  memcpy(c->cur, src, c->width * c->height * (c->bpp / 8));
408  return 0;
409 }
410 
411 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
412 {
413  AVFrame *frame = data;
414  const uint8_t *buf = avpkt->data;
415  int buf_size = avpkt->size;
416  ZmbvContext * const c = avctx->priv_data;
417  int zret = Z_OK; // Zlib return code
418  int len = buf_size;
419  int hi_ver, lo_ver, ret;
420  int expected_size;
421 
422  /* parse header */
423  if (len < 1)
424  return AVERROR_INVALIDDATA;
425  c->flags = buf[0];
426  buf++; len--;
427  if (c->flags & ZMBV_KEYFRAME) {
428  void *decode_intra = NULL;
429  c->decode_intra= NULL;
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_intra = NULL;
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;
464  c->decode_xor = zmbv_decode_xor_8;
466  c->stride = c->width;
467  break;
468  case ZMBV_FMT_15BPP:
469  case ZMBV_FMT_16BPP:
470  c->bpp = 16;
472  c->decode_xor = zmbv_decode_xor_16;
473  if (c->fmt == ZMBV_FMT_15BPP)
475  else
477  c->stride = c->width * 2;
478  break;
479 #ifdef ZMBV_ENABLE_24BPP
480  case ZMBV_FMT_24BPP:
481  c->bpp = 24;
483  c->decode_xor = zmbv_decode_xor_24;
485  c->stride = c->width * 3;
486  break;
487 #endif //ZMBV_ENABLE_24BPP
488  case ZMBV_FMT_32BPP:
489  c->bpp = 32;
491  c->decode_xor = zmbv_decode_xor_32;
493  c->stride = c->width * 4;
494  break;
495  default:
496  c->decode_xor = NULL;
497  avpriv_request_sample(avctx, "Format %i", c->fmt);
498  return AVERROR_PATCHWELCOME;
499  }
500 
501  zret = inflateReset(&c->zstream);
502  if (zret != Z_OK) {
503  av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
504  return AVERROR_UNKNOWN;
505  }
506 
507  if (c->alloc_bpp < c->bpp) {
508  c->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8));
509  c->prev = av_realloc_f(c->prev, avctx->width * avctx->height, (c->bpp / 8));
510  c->alloc_bpp = c->bpp;
511  }
512  c->bx = (c->width + c->bw - 1) / c->bw;
513  c->by = (c->height+ c->bh - 1) / c->bh;
514  if (!c->cur || !c->prev) {
515  c->alloc_bpp = 0;
516  return AVERROR(ENOMEM);
517  }
518  memset(c->cur, 0, avctx->width * avctx->height * (c->bpp / 8));
519  memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
520  c->decode_intra= decode_intra;
521  }
522  if (c->flags & ZMBV_KEYFRAME) {
523  expected_size = avctx->width * avctx->height * (c->bpp / 8);
524  } else {
525  expected_size = (c->bx * c->by * 2 + 3) & ~3;
526  }
527  if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
528  (c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME)))
529  expected_size += 768;
530 
531  if (!c->decode_intra) {
532  av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
533  return AVERROR_INVALIDDATA;
534  }
535 
536  if (c->comp == 0) { // uncompressed data
537  if (c->decomp_size < len) {
538  av_log(avctx, AV_LOG_ERROR, "Buffer too small\n");
539  return AVERROR_INVALIDDATA;
540  }
541  memcpy(c->decomp_buf, buf, len);
542  c->decomp_len = len;
543  } else { // ZLIB-compressed data
544  c->zstream.total_in = c->zstream.total_out = 0;
545  c->zstream.next_in = (uint8_t*)buf;
546  c->zstream.avail_in = len;
547  c->zstream.next_out = c->decomp_buf;
548  c->zstream.avail_out = c->decomp_size;
549  zret = inflate(&c->zstream, Z_SYNC_FLUSH);
550  if (zret != Z_OK && zret != Z_STREAM_END) {
551  av_log(avctx, AV_LOG_ERROR, "inflate error %d\n", zret);
552  return AVERROR_INVALIDDATA;
553  }
554  c->decomp_len = c->zstream.total_out;
555  }
556  if (expected_size > c->decomp_len ||
557  (c->flags & ZMBV_KEYFRAME) && expected_size < c->decomp_len) {
558  av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, expected %d\n", c->decomp_len, expected_size);
559  return AVERROR_INVALIDDATA;
560  }
561  if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
562  return ret;
563 
564  if (c->flags & ZMBV_KEYFRAME) {
565  frame->key_frame = 1;
566  frame->pict_type = AV_PICTURE_TYPE_I;
567  c->decode_intra(c);
568  } else {
569  frame->key_frame = 0;
570  frame->pict_type = AV_PICTURE_TYPE_P;
571  if (c->decomp_len < 2LL * ((c->width + c->bw - 1) / c->bw) * ((c->height + c->bh - 1) / c->bh))
572  return AVERROR_INVALIDDATA;
573  if (c->decomp_len)
574  c->decode_xor(c);
575  }
576 
577  /* update frames */
578  {
579  uint8_t *out, *src;
580  int j;
581 
582  out = frame->data[0];
583  src = c->cur;
584  switch (c->fmt) {
585  case ZMBV_FMT_8BPP:
586  for (j = 0; j < 256; j++)
587  AV_WN32(&frame->data[1][j * 4], 0xFFU << 24 | AV_RB24(&c->pal[j * 3]));
588  case ZMBV_FMT_15BPP:
589  case ZMBV_FMT_16BPP:
590 #ifdef ZMBV_ENABLE_24BPP
591  case ZMBV_FMT_24BPP:
592 #endif
593  case ZMBV_FMT_32BPP:
594  av_image_copy_plane(out, frame->linesize[0], src, c->stride,
595  c->stride, c->height);
596  break;
597  default:
598  av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt);
599  }
600  FFSWAP(uint8_t *, c->cur, c->prev);
601  }
602  *got_frame = 1;
603 
604  /* always report that the buffer was completely consumed */
605  return buf_size;
606 }
607 
609 {
610  ZmbvContext * const c = avctx->priv_data;
611  int zret; // Zlib return code
612 
613  c->avctx = avctx;
614 
615  c->width = avctx->width;
616  c->height = avctx->height;
617 
618  c->bpp = avctx->bits_per_coded_sample;
619 
620  // Needed if zlib unused or init aborted before inflateInit
621  memset(&c->zstream, 0, sizeof(z_stream));
622 
623  if ((avctx->width + 255ULL) * (avctx->height + 64ULL) > FFMIN(avctx->max_pixels, INT_MAX / 4) ) {
624  av_log(avctx, AV_LOG_ERROR, "Internal buffer (decomp_size) larger than max_pixels or too large\n");
625  return AVERROR_INVALIDDATA;
626  }
627 
628  c->decomp_size = (avctx->width + 255) * 4 * (avctx->height + 64);
629 
630  /* Allocate decompression buffer */
631  c->decomp_buf = av_mallocz(c->decomp_size);
632  if (!c->decomp_buf) {
634  "Can't allocate decompression buffer.\n");
635  return AVERROR(ENOMEM);
636  }
637 
638  c->zstream.zalloc = Z_NULL;
639  c->zstream.zfree = Z_NULL;
640  c->zstream.opaque = Z_NULL;
641  zret = inflateInit(&c->zstream);
642  if (zret != Z_OK) {
643  av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
644  return AVERROR_UNKNOWN;
645  }
646 
647  return 0;
648 }
649 
651 {
652  ZmbvContext * const c = avctx->priv_data;
653 
654  av_freep(&c->decomp_buf);
655 
656  inflateEnd(&c->zstream);
657  av_freep(&c->cur);
658  av_freep(&c->prev);
659 
660  return 0;
661 }
662 
664  .name = "zmbv",
665  .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
666  .type = AVMEDIA_TYPE_VIDEO,
667  .id = AV_CODEC_ID_ZMBV,
668  .priv_data_size = sizeof(ZmbvContext),
669  .init = decode_init,
670  .close = decode_end,
671  .decode = decode_frame,
672  .capabilities = AV_CODEC_CAP_DR1,
673  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
674 };
AVCodec
AVCodec.
Definition: avcodec.h:3481
stride
int stride
Definition: mace.c:144
ZmbvContext::decode_intra
int(* decode_intra)(struct ZmbvContext *c)
Definition: zmbv.c:73
ZmbvContext
Definition: zmbv.c:56
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
out
FILE * out
Definition: movenc.c:54
FFSWAP
#define FFSWAP(type, a, b)
Definition: common.h:99
AV_CODEC_ID_ZMBV
@ AV_CODEC_ID_ZMBV
Definition: avcodec.h:299
ZmbvContext::by
int by
Definition: zmbv.c:70
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
ZMBV_FMT_15BPP
@ ZMBV_FMT_15BPP
Definition: zmbv.c:47
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
internal.h
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
ZMBV_DELTAPAL
#define ZMBV_DELTAPAL
Definition: zmbv.c:39
data
const char data[16]
Definition: mxf.c:91
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:68
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:71
av_image_copy_plane
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:338
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:197
ff_zmbv_decoder
AVCodec ff_zmbv_decoder
Definition: zmbv.c:663
ZmbvContext::width
int width
Definition: zmbv.c:65
src
#define src
Definition: vp8dsp.c:254
zmbv_decode_xor_8
static int zmbv_decode_xor_8(ZmbvContext *c)
Decode XOR'ed frame - 8bpp version.
Definition: zmbv.c:81
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: zmbv.c:608
ZmbvContext::decode_xor
int(* decode_xor)(struct ZmbvContext *c)
Definition: zmbv.c:74
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
buf
void * buf
Definition: avisynth_c.h:766
av_cold
#define av_cold
Definition: attributes.h:84
ZMBV_FMT_8BPP
@ ZMBV_FMT_8BPP
Definition: zmbv.c:46
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
width
#define width
intreadwrite.h
ZMBV_FMT_NONE
@ ZMBV_FMT_NONE
Definition: zmbv.c:42
ZmbvContext::fmt
int fmt
Definition: zmbv.c:66
ZMBV_FMT_2BPP
@ ZMBV_FMT_2BPP
Definition: zmbv.c:44
ZMBV_FMT_16BPP
@ ZMBV_FMT_16BPP
Definition: zmbv.c:48
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
AVCodecContext::max_pixels
int64_t max_pixels
The number of pixels per image to maximally accept.
Definition: avcodec.h:3292
ZmbvContext::cur
uint8_t * cur
Definition: zmbv.c:64
av_realloc_f
#define av_realloc_f(p, o, n)
Definition: tableprint_vlc.h:33
ZmbvContext::height
int height
Definition: zmbv.c:65
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:62
PTRDIFF_SPECIFIER
#define PTRDIFF_SPECIFIER
Definition: internal.h:263
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
ZMBV_FMT_32BPP
@ ZMBV_FMT_32BPP
Definition: zmbv.c:50
ZmbvContext::stride
int stride
Definition: zmbv.c:69
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:240
ZmbvContext::decomp_size
unsigned int decomp_size
Definition: zmbv.c:61
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:70
ZmbvFormat
ZmbvFormat
Definition: zmbv.c:41
ff_get_buffer
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: decode.c:1965
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:981
AVPacket::size
int size
Definition: avcodec.h:1478
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:188
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
ZmbvContext::bw
int bw
Definition: zmbv.c:70
ZmbvContext::prev
uint8_t * prev
Definition: zmbv.c:64
zmbv_decode_xor_32
static int zmbv_decode_xor_32(ZmbvContext *c)
Decode XOR'ed frame - 32bpp version.
Definition: zmbv.c:322
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:2789
ZmbvContext::bx
int bx
Definition: zmbv.c:70
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:259
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
common.h
uint8_t
uint8_t
Definition: audio_convert.c:194
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:236
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3488
len
int len
Definition: vorbis_enc_data.h:452
ZMBV_FMT_4BPP
@ ZMBV_FMT_4BPP
Definition: zmbv.c:45
AVCodecContext::height
int height
Definition: avcodec.h:1738
ZMBV_FMT_1BPP
@ ZMBV_FMT_1BPP
Definition: zmbv.c:43
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1775
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ZmbvContext::decomp_len
int decomp_len
Definition: zmbv.c:71
ret
ret
Definition: filter_design.txt:187
ZmbvContext::comp
int comp
Definition: zmbv.c:67
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
decode_frame
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: zmbv.c:411
ZmbvContext::pal
uint8_t pal[768]
Definition: zmbv.c:63
decode_end
static av_cold int decode_end(AVCodecContext *avctx)
Definition: zmbv.c:650
AVCodecContext
main external API structure.
Definition: avcodec.h:1565
ZMBV_KEYFRAME
#define ZMBV_KEYFRAME
Definition: zmbv.c:38
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:39
zmbv_decode_xor_16
static int zmbv_decode_xor_16(ZmbvContext *c)
Decode XOR'ed frame - 15bpp and 16bpp version.
Definition: zmbv.c:160
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1592
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:1738
zmbv_decode_intra
static int zmbv_decode_intra(ZmbvContext *c)
Decode intraframe.
Definition: zmbv.c:397
imgutils.h
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
ZmbvContext::alloc_bpp
int alloc_bpp
Definition: zmbv.c:60
ZmbvContext::bpp
int bpp
Definition: zmbv.c:59
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:93
int
int
Definition: ffmpeg_filter.c:191
ZMBV_FMT_24BPP
@ ZMBV_FMT_24BPP
Definition: zmbv.c:49
ZmbvContext::zstream
z_stream zstream
Definition: zmbv.c:72
decode_intra
static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame)
Definition: agm.c:795
ZmbvContext::avctx
AVCodecContext * avctx
Definition: zmbv.c:57