FFmpeg  4.4.9
vmnc.c
Go to the documentation of this file.
1 /*
2  * VMware Screen Codec (VMnc) 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  * VMware Screen Codec (VMnc) decoder
25  * As Alex Beregszaszi discovered, this is effectively RFB data dump
26  */
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 
31 #include "libavutil/common.h"
32 #include "libavutil/intreadwrite.h"
33 #include "avcodec.h"
34 #include "internal.h"
35 #include "bytestream.h"
36 
37 enum EncTypes {
38  MAGIC_WMVd = 0x574D5664,
45 };
46 
48  HT_RAW = 1, // tile is raw
49  HT_BKG = 2, // background color is present
50  HT_FG = 4, // foreground color is present
51  HT_SUB = 8, // subrects are present
52  HT_CLR = 16 // each subrect has own color
53 };
54 
55 /*
56  * Decoder context
57  */
58 typedef struct VmncContext {
61 
62  int bpp;
63  int bpp2;
64  int bigendian;
65  uint8_t pal[768];
66  int width, height;
68 
69  /* cursor data */
70  int cur_w, cur_h;
71  int cur_x, cur_y;
72  int cur_hx, cur_hy;
76 } VmncContext;
77 
78 /* read pixel value from stream */
79 static av_always_inline int vmnc_get_pixel(GetByteContext *gb, int bpp, int be)
80 {
81  switch (bpp * 2 + be) {
82  case 2:
83  case 3:
84  return bytestream2_get_byte(gb);
85  case 4:
86  return bytestream2_get_le16(gb);
87  case 5:
88  return bytestream2_get_be16(gb);
89  case 8:
90  return bytestream2_get_le32(gb);
91  case 9:
92  return bytestream2_get_be32(gb);
93  default: return 0;
94  }
95 }
96 
97 static void load_cursor(VmncContext *c)
98 {
99  int i, j, p;
100  const int bpp = c->bpp2;
101  uint8_t *dst8 = c->curbits;
102  uint16_t *dst16 = (uint16_t *)c->curbits;
103  uint32_t *dst32 = (uint32_t *)c->curbits;
104 
105  for (j = 0; j < c->cur_h; j++) {
106  for (i = 0; i < c->cur_w; i++) {
107  p = vmnc_get_pixel(&c->gb, bpp, c->bigendian);
108  if (bpp == 1)
109  *dst8++ = p;
110  if (bpp == 2)
111  *dst16++ = p;
112  if (bpp == 4)
113  *dst32++ = p;
114  }
115  }
116  dst8 = c->curmask;
117  dst16 = (uint16_t*)c->curmask;
118  dst32 = (uint32_t*)c->curmask;
119  for (j = 0; j < c->cur_h; j++) {
120  for (i = 0; i < c->cur_w; i++) {
121  p = vmnc_get_pixel(&c->gb, bpp, c->bigendian);
122  if (bpp == 1)
123  *dst8++ = p;
124  if (bpp == 2)
125  *dst16++ = p;
126  if (bpp == 4)
127  *dst32++ = p;
128  }
129  }
130 }
131 
132 static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
133 {
134  int i, j;
135  int w, h, x, y;
136  w = c->cur_w;
137  if (c->width < c->cur_x + c->cur_w)
138  w = c->width - c->cur_x;
139  h = c->cur_h;
140  if (c->height < c->cur_y + c->cur_h)
141  h = c->height - c->cur_y;
142  x = c->cur_x;
143  y = c->cur_y;
144  if (x < 0) {
145  w += x;
146  x = 0;
147  }
148  if (y < 0) {
149  h += y;
150  y = 0;
151  }
152 
153  if ((w < 1) || (h < 1))
154  return;
155  dst += x * c->bpp2 + y * stride;
156 
157  if (c->bpp2 == 1) {
158  uint8_t *cd = c->curbits, *msk = c->curmask;
159  for (j = 0; j < h; j++) {
160  for (i = 0; i < w; i++)
161  dst[i] = (dst[i] & cd[i]) ^ msk[i];
162  msk += c->cur_w;
163  cd += c->cur_w;
164  dst += stride;
165  }
166  } else if (c->bpp2 == 2) {
167  uint16_t *cd = (uint16_t*)c->curbits, *msk = (uint16_t*)c->curmask;
168  uint16_t *dst2;
169  for (j = 0; j < h; j++) {
170  dst2 = (uint16_t*)dst;
171  for (i = 0; i < w; i++)
172  dst2[i] = (dst2[i] & cd[i]) ^ msk[i];
173  msk += c->cur_w;
174  cd += c->cur_w;
175  dst += stride;
176  }
177  } else if (c->bpp2 == 4) {
178  uint32_t *cd = (uint32_t*)c->curbits, *msk = (uint32_t*)c->curmask;
179  uint32_t *dst2;
180  for (j = 0; j < h; j++) {
181  dst2 = (uint32_t*)dst;
182  for (i = 0; i < w; i++)
183  dst2[i] = (dst2[i] & cd[i]) ^ msk[i];
184  msk += c->cur_w;
185  cd += c->cur_w;
186  dst += stride;
187  }
188  }
189 }
190 
191 /* fill rectangle with given color */
192 static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy,
193  int w, int h, int color,
194  int bpp, int stride)
195 {
196  int i, j;
197  dst += dx * bpp + dy * stride;
198  if (bpp == 1) {
199  for (j = 0; j < h; j++) {
200  memset(dst, color, w);
201  dst += stride;
202  }
203  } else if (bpp == 2) {
204  uint16_t *dst2;
205  for (j = 0; j < h; j++) {
206  dst2 = (uint16_t*)dst;
207  for (i = 0; i < w; i++)
208  *dst2++ = color;
209  dst += stride;
210  }
211  } else if (bpp == 4) {
212  uint32_t *dst2;
213  for (j = 0; j < h; j++) {
214  dst2 = (uint32_t*)dst;
215  for (i = 0; i < w; i++)
216  dst2[i] = color;
217  dst += stride;
218  }
219  }
220 }
221 
222 static av_always_inline void paint_raw(uint8_t *dst, int w, int h,
223  GetByteContext *gb, int bpp,
224  int be, int stride)
225 {
226  int i, j, p;
227  for (j = 0; j < h; j++) {
228  for (i = 0; i < w; i++) {
229  p = vmnc_get_pixel(gb, bpp, be);
230  switch (bpp) {
231  case 1:
232  dst[i] = p;
233  break;
234  case 2:
235  ((uint16_t*)dst)[i] = p;
236  break;
237  case 4:
238  ((uint32_t*)dst)[i] = p;
239  break;
240  }
241  }
242  dst += stride;
243  }
244 }
245 
247  int w, int h, int stride)
248 {
249  int i, j, k;
250  int bg = 0, fg = 0, rects, color, flags, xy, wh;
251  const int bpp = c->bpp2;
252  uint8_t *dst2;
253  int bw = 16, bh = 16;
254 
255  for (j = 0; j < h; j += 16) {
256  dst2 = dst;
257  bw = 16;
258  if (j + 16 > h)
259  bh = h - j;
260  for (i = 0; i < w; i += 16, dst2 += 16 * bpp) {
261  if (bytestream2_get_bytes_left(gb) <= 0) {
262  av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
263  return AVERROR_INVALIDDATA;
264  }
265  if (i + 16 > w)
266  bw = w - i;
267  flags = bytestream2_get_byte(gb);
268  if (flags & HT_RAW) {
269  if (bytestream2_get_bytes_left(gb) < bw * bh * bpp) {
270  av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
271  return AVERROR_INVALIDDATA;
272  }
273  paint_raw(dst2, bw, bh, gb, bpp, c->bigendian, stride);
274  } else {
275  if (flags & HT_BKG)
276  bg = vmnc_get_pixel(gb, bpp, c->bigendian);
277  if (flags & HT_FG)
278  fg = vmnc_get_pixel(gb, bpp, c->bigendian);
279  rects = 0;
280  if (flags & HT_SUB)
281  rects = bytestream2_get_byte(gb);
282  color = !!(flags & HT_CLR);
283 
284  paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
285 
286  if (bytestream2_get_bytes_left(gb) < rects * (color * bpp + 2)) {
287  av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
288  return AVERROR_INVALIDDATA;
289  }
290  for (k = 0; k < rects; k++) {
291  int rect_x, rect_y, rect_w, rect_h;
292  if (color)
293  fg = vmnc_get_pixel(gb, bpp, c->bigendian);
294  xy = bytestream2_get_byte(gb);
295  wh = bytestream2_get_byte(gb);
296 
297  rect_x = xy >> 4;
298  rect_y = xy & 0xF;
299  rect_w = (wh >> 4) + 1;
300  rect_h = (wh & 0xF) + 1;
301 
302  if (rect_x + rect_w > w - i || rect_y + rect_h > h - j) {
303  av_log(c->avctx, AV_LOG_ERROR, "Rectangle outside picture\n");
304  return AVERROR_INVALIDDATA;
305  }
306 
307  paint_rect(dst2, rect_x, rect_y,
308  rect_w, rect_h, fg, bpp, stride);
309  }
310  }
311  }
312  dst += stride * 16;
313  }
314  return 0;
315 }
316 
318 {
319  av_freep(&c->curbits);
320  av_freep(&c->curmask);
321  av_freep(&c->screendta);
322  c->cur_w = c->cur_h = 0;
323  c->cur_hx = c->cur_hy = 0;
324 
325 }
326 
327 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
328  AVPacket *avpkt)
329 {
330  const uint8_t *buf = avpkt->data;
331  int buf_size = avpkt->size;
332  VmncContext * const c = avctx->priv_data;
333  GetByteContext *gb = &c->gb;
334  uint8_t *outptr;
335  int dx, dy, w, h, depth, enc, chunks, res, size_left, ret;
336 
337  bytestream2_init(gb, buf, buf_size);
338  bytestream2_skip(gb, 2);
339  chunks = bytestream2_get_be16(gb);
340  if (12LL * chunks > bytestream2_get_bytes_left(gb))
341  return AVERROR_INVALIDDATA;
342 
343  if ((ret = ff_reget_buffer(avctx, c->pic, 0)) < 0)
344  return ret;
345 
346  c->pic->key_frame = 0;
347  c->pic->pict_type = AV_PICTURE_TYPE_P;
348 
349  // restore screen after cursor
350  if (c->cursor_painted) {
351  int i;
352  w = c->cur_w;
353  if (c->width < c->cur_x + w)
354  w = c->width - c->cur_x;
355  h = c->cur_h;
356  if (c->height < c->cur_y + h)
357  h = c->height - c->cur_y;
358  dx = c->cur_x;
359  if (dx < 0) {
360  w += dx;
361  dx = 0;
362  }
363  dy = c->cur_y;
364  if (dy < 0) {
365  h += dy;
366  dy = 0;
367  }
368  if ((w > 0) && (h > 0)) {
369  outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0];
370  for (i = 0; i < h; i++) {
371  memcpy(outptr, c->screendta + i * c->cur_w * c->bpp2,
372  w * c->bpp2);
373  outptr += c->pic->linesize[0];
374  }
375  }
376  c->cursor_painted = 0;
377  }
378 
379  while (chunks--) {
380  if (bytestream2_get_bytes_left(gb) < 12) {
381  av_log(avctx, AV_LOG_ERROR, "Premature end of data!\n");
382  return -1;
383  }
384  dx = bytestream2_get_be16(gb);
385  dy = bytestream2_get_be16(gb);
386  w = bytestream2_get_be16(gb);
387  h = bytestream2_get_be16(gb);
388  enc = bytestream2_get_be32(gb);
389  if ((dx + w > c->width) || (dy + h > c->height)) {
390  av_log(avctx, AV_LOG_ERROR,
391  "Incorrect frame size: %ix%i+%ix%i of %ix%i\n",
392  w, h, dx, dy, c->width, c->height);
393  return AVERROR_INVALIDDATA;
394  }
395  outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0];
396  size_left = bytestream2_get_bytes_left(gb);
397  switch (enc) {
398  case MAGIC_WMVd: // cursor
399  if (w*(int64_t)h*c->bpp2 > INT_MAX/2 - 2) {
400  av_log(avctx, AV_LOG_ERROR, "dimensions too large\n");
401  return AVERROR_INVALIDDATA;
402  }
403  if (size_left < 2 + w * h * c->bpp2 * 2) {
404  av_log(avctx, AV_LOG_ERROR,
405  "Premature end of data! (need %i got %i)\n",
406  2 + w * h * c->bpp2 * 2, size_left);
407  return AVERROR_INVALIDDATA;
408  }
409  bytestream2_skip(gb, 2);
410  c->cur_w = w;
411  c->cur_h = h;
412  c->cur_hx = dx;
413  c->cur_hy = dy;
414  if ((c->cur_hx > c->cur_w) || (c->cur_hy > c->cur_h)) {
415  av_log(avctx, AV_LOG_ERROR,
416  "Cursor hot spot is not in image: "
417  "%ix%i of %ix%i cursor size\n",
418  c->cur_hx, c->cur_hy, c->cur_w, c->cur_h);
419  c->cur_hx = c->cur_hy = 0;
420  }
421  if (c->cur_w * c->cur_h >= INT_MAX / c->bpp2) {
422  reset_buffers(c);
423  return AVERROR(EINVAL);
424  } else {
425  int screen_size = c->cur_w * c->cur_h * c->bpp2;
426  if ((ret = av_reallocp(&c->curbits, screen_size)) < 0 ||
427  (ret = av_reallocp(&c->curmask, screen_size)) < 0 ||
428  (ret = av_reallocp(&c->screendta, screen_size)) < 0) {
429  reset_buffers(c);
430  return ret;
431  }
432  }
433  load_cursor(c);
434  break;
435  case MAGIC_WMVe: // unknown
436  bytestream2_skip(gb, 2);
437  break;
438  case MAGIC_WMVf: // update cursor position
439  c->cur_x = dx - c->cur_hx;
440  c->cur_y = dy - c->cur_hy;
441  break;
442  case MAGIC_WMVg: // unknown
443  bytestream2_skip(gb, 10);
444  break;
445  case MAGIC_WMVh: // unknown
446  bytestream2_skip(gb, 4);
447  break;
448  case MAGIC_WMVi: // ServerInitialization struct
449  c->pic->key_frame = 1;
450  c->pic->pict_type = AV_PICTURE_TYPE_I;
451  depth = bytestream2_get_byte(gb);
452  if (depth != c->bpp) {
453  av_log(avctx, AV_LOG_INFO,
454  "Depth mismatch. Container %i bpp, "
455  "Frame data: %i bpp\n",
456  c->bpp, depth);
457  }
458  bytestream2_skip(gb, 1);
459  c->bigendian = bytestream2_get_byte(gb);
460  if (c->bigendian & (~1)) {
461  av_log(avctx, AV_LOG_INFO,
462  "Invalid header: bigendian flag = %i\n", c->bigendian);
463  return AVERROR_INVALIDDATA;
464  }
465  //skip the rest of pixel format data
466  bytestream2_skip(gb, 13);
467  break;
468  case MAGIC_WMVj: // unknown
469  bytestream2_skip(gb, 2);
470  break;
471  case 0x00000000: // raw rectangle data
472  if (size_left < w * h * c->bpp2) {
473  av_log(avctx, AV_LOG_ERROR,
474  "Premature end of data! (need %i got %i)\n",
475  w * h * c->bpp2, size_left);
476  return AVERROR_INVALIDDATA;
477  }
478  paint_raw(outptr, w, h, gb, c->bpp2, c->bigendian,
479  c->pic->linesize[0]);
480  break;
481  case 0x00000005: // HexTile encoded rectangle
482  res = decode_hextile(c, outptr, gb, w, h, c->pic->linesize[0]);
483  if (res < 0)
484  return res;
485  break;
486  default:
487  av_log(avctx, AV_LOG_ERROR, "Unsupported block type 0x%08X\n", enc);
488  chunks = 0; // leave chunks decoding loop
489  }
490  }
491  if (c->screendta) {
492  int i;
493  // save screen data before painting cursor
494  w = c->cur_w;
495  if (c->width < c->cur_x + w)
496  w = c->width - c->cur_x;
497  h = c->cur_h;
498  if (c->height < c->cur_y + h)
499  h = c->height - c->cur_y;
500  dx = c->cur_x;
501  if (dx < 0) {
502  w += dx;
503  dx = 0;
504  }
505  dy = c->cur_y;
506  if (dy < 0) {
507  h += dy;
508  dy = 0;
509  }
510  if ((w > 0) && (h > 0)) {
511  outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0];
512  for (i = 0; i < h; i++) {
513  memcpy(c->screendta + i * c->cur_w * c->bpp2, outptr,
514  w * c->bpp2);
515  outptr += c->pic->linesize[0];
516  }
517  outptr = c->pic->data[0];
518  put_cursor(outptr, c->pic->linesize[0], c, c->cur_x, c->cur_y);
519  c->cursor_painted = 1;
520  }
521  }
522  *got_frame = 1;
523  if ((ret = av_frame_ref(data, c->pic)) < 0)
524  return ret;
525 
526  /* always report that the buffer was completely consumed */
527  return buf_size;
528 }
529 
531 {
532  VmncContext * const c = avctx->priv_data;
533 
534  c->avctx = avctx;
535  c->width = avctx->width;
536  c->height = avctx->height;
537  c->bpp = avctx->bits_per_coded_sample;
538 
539  switch (c->bpp) {
540  case 8:
541  avctx->pix_fmt = AV_PIX_FMT_PAL8;
542  break;
543  case 16:
544  avctx->pix_fmt = AV_PIX_FMT_RGB555;
545  break;
546  case 24:
547  /* 24 bits is not technically supported, but some clients might
548  * mistakenly set it, so let's assume they actually meant 32 bits */
549  c->bpp = 32;
550  case 32:
551  avctx->pix_fmt = AV_PIX_FMT_0RGB32;
552  break;
553  default:
554  av_log(avctx, AV_LOG_ERROR, "Unsupported bitdepth %i\n", c->bpp);
555  return AVERROR_INVALIDDATA;
556  }
557  c->bpp2 = c->bpp / 8;
558 
559  c->pic = av_frame_alloc();
560  if (!c->pic)
561  return AVERROR(ENOMEM);
562 
563  return 0;
564 }
565 
567 {
568  VmncContext * const c = avctx->priv_data;
569 
570  av_frame_free(&c->pic);
571 
572  av_freep(&c->curbits);
573  av_freep(&c->curmask);
574  av_freep(&c->screendta);
575  return 0;
576 }
577 
579  .name = "vmnc",
580  .long_name = NULL_IF_CONFIG_SMALL("VMware Screen Codec / VMware Video"),
581  .type = AVMEDIA_TYPE_VIDEO,
582  .id = AV_CODEC_ID_VMNC,
583  .priv_data_size = sizeof(VmncContext),
584  .init = decode_init,
585  .close = decode_end,
586  .decode = decode_frame,
587  .capabilities = AV_CODEC_CAP_DR1,
588 };
#define av_always_inline
Definition: attributes.h:45
#define av_cold
Definition: attributes.h:88
uint8_t
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
#define flags(name, subs,...)
Definition: cbs_av1.c:572
common internal and external API header
long long int64_t
Definition: coverity.c:34
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
Definition: decode.c:2018
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
@ AV_CODEC_ID_VMNC
Definition: codec_id.h:138
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AVERROR(e)
Definition: error.h:43
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:443
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:190
#define AV_LOG_INFO
Standard information.
Definition: log.h:205
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Definition: mem.c:161
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
int i
Definition: input.c:407
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
uint8_t w
Definition: llviddspenc.c:39
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:92
int stride
Definition: mace.c:144
const char data[16]
Definition: mxf.c:142
#define AV_PIX_FMT_0RGB32
Definition: pixfmt.h:376
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:387
main external API structure.
Definition: avcodec.h:536
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
int width
picture width / height.
Definition: avcodec.h:709
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1744
void * priv_data
Definition: avcodec.h:563
AVCodec.
Definition: codec.h:197
const char * name
Name of the codec implementation.
Definition: codec.h:204
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
This structure stores compressed data.
Definition: packet.h:346
int size
Definition: packet.h:370
uint8_t * data
Definition: packet.h:369
uint8_t * screendta
Definition: vmnc.c:74
int cur_w
Definition: vmnc.c:70
int cur_h
Definition: vmnc.c:70
GetByteContext gb
Definition: vmnc.c:67
uint8_t * curbits
Definition: vmnc.c:73
uint8_t * curmask
Definition: vmnc.c:73
uint8_t pal[768]
Definition: vmnc.c:65
int cursor_painted
Definition: vmnc.c:75
int height
Definition: vmnc.c:66
int cur_x
Definition: vmnc.c:71
int bpp2
Definition: vmnc.c:63
int bpp
Definition: vmnc.c:62
int cur_hx
Definition: vmnc.c:72
AVFrame * pic
Definition: vmnc.c:60
AVCodecContext * avctx
Definition: vmnc.c:59
int width
Definition: vmnc.c:66
int cur_y
Definition: vmnc.c:71
int cur_hy
Definition: vmnc.c:72
int bigendian
Definition: vmnc.c:64
#define av_freep(p)
#define av_log(a,...)
static void load_cursor(VmncContext *c)
Definition: vmnc.c:97
EncTypes
Definition: vmnc.c:37
@ MAGIC_WMVf
Definition: vmnc.c:40
@ MAGIC_WMVi
Definition: vmnc.c:43
@ MAGIC_WMVj
Definition: vmnc.c:44
@ MAGIC_WMVh
Definition: vmnc.c:42
@ MAGIC_WMVd
Definition: vmnc.c:38
@ MAGIC_WMVe
Definition: vmnc.c:39
@ MAGIC_WMVg
Definition: vmnc.c:41
static av_always_inline int vmnc_get_pixel(GetByteContext *gb, int bpp, int be)
Definition: vmnc.c:79
static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
Definition: vmnc.c:132
static av_cold int decode_init(AVCodecContext *avctx)
Definition: vmnc.c:530
static av_cold int decode_end(AVCodecContext *avctx)
Definition: vmnc.c:566
static av_always_inline void paint_raw(uint8_t *dst, int w, int h, GetByteContext *gb, int bpp, int be, int stride)
Definition: vmnc.c:222
static int decode_hextile(VmncContext *c, uint8_t *dst, GetByteContext *gb, int w, int h, int stride)
Definition: vmnc.c:246
static void reset_buffers(VmncContext *c)
Definition: vmnc.c:317
static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
Definition: vmnc.c:192
HexTile_Flags
Definition: vmnc.c:47
@ HT_FG
Definition: vmnc.c:50
@ HT_RAW
Definition: vmnc.c:48
@ HT_SUB
Definition: vmnc.c:51
@ HT_BKG
Definition: vmnc.c:49
@ HT_CLR
Definition: vmnc.c:52
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: vmnc.c:327
AVCodec ff_vmnc_decoder
Definition: vmnc.c:578
static double c[64]