79 switch (bpp * 2 + be) {
82 return bytestream2_get_byte(gb);
84 return bytestream2_get_le16(gb);
86 return bytestream2_get_be16(gb);
88 return bytestream2_get_le32(gb);
90 return bytestream2_get_be32(gb);
98 const int bpp =
c->bpp2;
99 uint8_t *dst8 =
c->curbits;
100 uint16_t *dst16 = (uint16_t *)
c->curbits;
101 uint32_t *dst32 = (uint32_t *)
c->curbits;
103 for (j = 0; j <
c->cur_h; j++) {
104 for (
i = 0;
i <
c->cur_w;
i++) {
115 dst16 = (uint16_t*)
c->curmask;
116 dst32 = (uint32_t*)
c->curmask;
117 for (j = 0; j <
c->cur_h; j++) {
118 for (
i = 0;
i <
c->cur_w;
i++) {
135 if (
c->width <
c->cur_x +
c->cur_w)
136 w =
c->width -
c->cur_x;
138 if (
c->height <
c->cur_y +
c->cur_h)
139 h =
c->height -
c->cur_y;
151 if ((
w < 1) || (
h < 1))
156 uint8_t *cd =
c->curbits, *msk =
c->curmask;
157 for (j = 0; j <
h; j++) {
158 for (
i = 0;
i <
w;
i++)
164 }
else if (
c->bpp2 == 2) {
165 uint16_t *cd = (uint16_t*)
c->curbits, *msk = (uint16_t*)
c->curmask;
167 for (j = 0; j <
h; j++) {
168 dst2 = (uint16_t*)
dst;
169 for (
i = 0;
i <
w;
i++)
170 dst2[
i] = (dst2[
i] & cd[
i]) ^ msk[
i];
175 }
else if (
c->bpp2 == 4) {
176 uint32_t *cd = (uint32_t*)
c->curbits, *msk = (uint32_t*)
c->curmask;
178 for (j = 0; j <
h; j++) {
179 dst2 = (uint32_t*)
dst;
180 for (
i = 0;
i <
w;
i++)
181 dst2[
i] = (dst2[
i] & cd[
i]) ^ msk[
i];
197 for (j = 0; j <
h; j++) {
201 }
else if (bpp == 2) {
203 for (j = 0; j <
h; j++) {
204 dst2 = (uint16_t*)
dst;
205 for (
i = 0;
i <
w;
i++)
209 }
else if (bpp == 4) {
211 for (j = 0; j <
h; j++) {
212 dst2 = (uint32_t*)
dst;
213 for (
i = 0;
i <
w;
i++)
225 for (j = 0; j <
h; j++) {
226 for (
i = 0;
i <
w;
i++) {
233 ((uint16_t*)
dst)[
i] = p;
236 ((uint32_t*)
dst)[
i] = p;
248 int bg = 0, fg = 0, rects,
color,
flags, xy, wh;
249 const int bpp =
c->bpp2;
251 int bw = 16, bh = 16;
253 for (j = 0; j <
h; j += 16) {
258 for (
i = 0;
i <
w;
i += 16, dst2 += 16 * bpp) {
265 flags = bytestream2_get_byte(gb);
279 rects = bytestream2_get_byte(gb);
288 for (k = 0; k < rects; k++) {
289 int rect_x, rect_y, rect_w, rect_h;
292 xy = bytestream2_get_byte(gb);
293 wh = bytestream2_get_byte(gb);
297 rect_w = (wh >> 4) + 1;
298 rect_h = (wh & 0xF) + 1;
300 if (rect_x + rect_w >
w -
i || rect_y + rect_h >
h - j) {
306 rect_w, rect_h, fg, bpp,
stride);
320 c->cur_w =
c->cur_h = 0;
321 c->cur_hx =
c->cur_hy = 0;
328 const uint8_t *buf = avpkt->
data;
329 int buf_size = avpkt->
size;
333 int dx, dy,
w,
h, depth, enc, chunks, res, size_left, ret;
337 chunks = bytestream2_get_be16(gb);
351 if (
c->width <
c->cur_x +
w)
352 w =
c->width -
c->cur_x;
354 if (
c->height <
c->cur_y +
h)
355 h =
c->height -
c->cur_y;
366 if ((
w > 0) && (
h > 0)) {
367 outptr =
c->pic->data[0] + dx *
c->bpp2 + dy *
c->pic->linesize[0];
368 for (
i = 0;
i <
h;
i++) {
369 memcpy(outptr,
c->screendta +
i *
c->cur_w *
c->bpp2,
371 outptr +=
c->pic->linesize[0];
381 dx = bytestream2_get_be16(gb);
382 dy = bytestream2_get_be16(gb);
383 w = bytestream2_get_be16(gb);
384 h = bytestream2_get_be16(gb);
385 enc = bytestream2_get_be32(gb);
386 if ((dx +
w >
c->width) || (dy +
h >
c->height)) {
388 "Incorrect frame size: %ix%i+%ix%i of %ix%i\n",
389 w,
h, dx, dy,
c->width,
c->height);
392 outptr =
c->pic->data[0] + dx *
c->bpp2 + dy *
c->pic->linesize[0];
400 if (size_left < 2 + w * h * c->bpp2 * 2) {
402 "Premature end of data! (need %i got %i)\n",
403 2 +
w *
h *
c->bpp2 * 2, size_left);
411 if ((
c->cur_hx >
c->cur_w) || (
c->cur_hy >
c->cur_h)) {
413 "Cursor hot spot is not in image: "
414 "%ix%i of %ix%i cursor size\n",
415 c->cur_hx,
c->cur_hy,
c->cur_w,
c->cur_h);
416 c->cur_hx =
c->cur_hy = 0;
418 if (
c->cur_w *
c->cur_h >= INT_MAX /
c->bpp2) {
422 int screen_size =
c->cur_w *
c->cur_h *
c->bpp2;
423 if ((ret =
av_reallocp(&
c->curbits, screen_size)) < 0 ||
436 c->cur_x = dx -
c->cur_hx;
437 c->cur_y = dy -
c->cur_hy;
448 depth = bytestream2_get_byte(gb);
449 if (depth !=
c->bpp) {
451 "Depth mismatch. Container %i bpp, "
452 "Frame data: %i bpp\n",
456 c->bigendian = bytestream2_get_byte(gb);
457 if (
c->bigendian & (~1)) {
459 "Invalid header: bigendian flag = %i\n",
c->bigendian);
469 if (size_left < w * h * c->bpp2) {
471 "Premature end of data! (need %i got %i)\n",
472 w *
h *
c->bpp2, size_left);
476 c->pic->linesize[0]);
492 if (
c->width <
c->cur_x +
w)
493 w =
c->width -
c->cur_x;
495 if (
c->height <
c->cur_y +
h)
496 h =
c->height -
c->cur_y;
507 if ((
w > 0) && (
h > 0)) {
508 outptr =
c->pic->data[0] + dx *
c->bpp2 + dy *
c->pic->linesize[0];
509 for (
i = 0;
i <
h;
i++) {
510 memcpy(
c->screendta +
i *
c->cur_w *
c->bpp2, outptr,
512 outptr +=
c->pic->linesize[0];
514 outptr =
c->pic->data[0];
554 c->bpp2 =
c->bpp / 8;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_vmnc_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
common internal and external API header
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.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
Macro definitions for various function/variable attributes.
Memory handling functions.
#define AV_PIX_FMT_0RGB32
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
#define AV_PIX_FMT_RGB555
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
static void load_cursor(VmncContext *c)
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static av_always_inline int vmnc_get_pixel(GetByteContext *gb, int bpp, int be)
static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
static av_always_inline void paint_raw(uint8_t *dst, int w, int h, GetByteContext *gb, int bpp, int be, int stride)
static int decode_hextile(VmncContext *c, uint8_t *dst, GetByteContext *gb, int w, int h, int stride)
static void reset_buffers(VmncContext *c)
static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)