80 switch (bpp * 2 + be) {
83 return bytestream2_get_byte(gb);
85 return bytestream2_get_le16(gb);
87 return bytestream2_get_be16(gb);
89 return bytestream2_get_le32(gb);
91 return bytestream2_get_be32(gb);
99 const int bpp = c->
bpp2;
101 uint16_t *dst16 = (uint16_t *)c->
curbits;
102 uint32_t *dst32 = (uint32_t *)c->
curbits;
104 for (j = 0; j < c->
cur_h; j++) {
105 for (i = 0; i < c->
cur_w; i++) {
118 for (j = 0; j < c->
cur_h; j++) {
119 for (i = 0; i < c->
cur_w; i++) {
152 if ((w < 1) || (h < 1))
158 for (j = 0; j <
h; j++) {
159 for (i = 0; i < w; i++)
160 dst[i] = (dst[i] & cd[i]) ^ msk[i];
165 }
else if (c->
bpp2 == 2) {
166 uint16_t *cd = (uint16_t*)c->
curbits, *msk = (uint16_t*)c->
curmask;
168 for (j = 0; j <
h; j++) {
169 dst2 = (uint16_t*)dst;
170 for (i = 0; i < w; i++)
171 dst2[i] = (dst2[i] & cd[i]) ^ msk[i];
176 }
else if (c->
bpp2 == 4) {
177 uint32_t *cd = (uint32_t*)c->
curbits, *msk = (uint32_t*)c->
curmask;
179 for (j = 0; j <
h; j++) {
180 dst2 = (uint32_t*)dst;
181 for (i = 0; i < w; i++)
182 dst2[i] = (dst2[i] & cd[i]) ^ msk[i];
196 dst += dx * bpp + dy *
stride;
198 for (j = 0; j <
h; j++) {
199 memset(dst, color, w);
202 }
else if (bpp == 2) {
204 for (j = 0; j <
h; j++) {
205 dst2 = (uint16_t*)dst;
206 for (i = 0; i < w; i++)
210 }
else if (bpp == 4) {
212 for (j = 0; j <
h; j++) {
213 dst2 = (uint32_t*)dst;
214 for (i = 0; i < w; i++)
226 for (j = 0; j <
h; j++) {
227 for (i = 0; i < w; i++) {
234 ((uint16_t*)dst)[i] = p;
237 ((uint32_t*)dst)[i] = p;
249 int bg = 0, fg = 0, rects,
color,
flags, xy, wh;
250 const int bpp = c->
bpp2;
252 int bw = 16, bh = 16;
254 for (j = 0; j <
h; j += 16) {
259 for (i = 0; i < w; i += 16, dst2 += 16 * bpp) {
266 flags = bytestream2_get_byte(gb);
280 rects = bytestream2_get_byte(gb);
281 color = !!(flags &
HT_CLR);
283 paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
289 for (k = 0; k < rects; k++) {
290 int rect_x, rect_y, rect_w, rect_h;
293 xy = bytestream2_get_byte(gb);
294 wh = bytestream2_get_byte(gb);
298 rect_w = (wh >> 4) + 1;
299 rect_h = (wh & 0xF) + 1;
301 if (rect_x + rect_w > w - i || rect_y + rect_h > h - j) {
307 rect_w, rect_h, fg, bpp, stride);
330 int buf_size = avpkt->
size;
334 int dx, dy, w,
h,
depth, enc, chunks, res, size_left, ret;
363 if ((w > 0) && (h > 0)) {
365 for (i = 0; i <
h; i++) {
373 chunks = bytestream2_get_be16(gb);
379 dx = bytestream2_get_be16(gb);
380 dy = bytestream2_get_be16(gb);
381 w = bytestream2_get_be16(gb);
382 h = bytestream2_get_be16(gb);
383 enc = bytestream2_get_be32(gb);
386 "Incorrect frame size: %ix%i+%ix%i of %ix%i\n",
394 if (w*(int64_t)h*c->
bpp2 > INT_MAX/2 - 2) {
398 if (size_left < 2 + w * h * c->bpp2 * 2) {
400 "Premature end of data! (need %i got %i)\n",
401 2 + w * h * c->
bpp2 * 2, size_left);
411 "Cursor hot spot is not in image: "
412 "%ix%i of %ix%i cursor size\n",
446 depth = bytestream2_get_byte(gb);
447 if (depth != c->
bpp) {
449 "Depth mismatch. Container %i bpp, "
450 "Frame data: %i bpp\n",
457 "Invalid header: bigendian flag = %i\n", c->
bigendian);
467 if (size_left < w * h * c->bpp2) {
469 "Premature end of data! (need %i got %i)\n",
470 w * h * c->
bpp2, size_left);
505 if ((w > 0) && (h > 0)) {
507 for (i = 0; i <
h; i++) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
ptrdiff_t const GLvoid * data
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
8 bits with AV_PIX_FMT_RGB32 palette
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static av_always_inline void paint_raw(uint8_t *dst, int w, int h, GetByteContext *gb, int bpp, int be, int stride)
static av_always_inline int vmnc_get_pixel(GetByteContext *gb, int bpp, int be)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold int decode_end(AVCodecContext *avctx)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
enum AVPictureType pict_type
Picture type of the frame.
static void load_cursor(VmncContext *c)
int width
picture width / height.
static void reset_buffers(VmncContext *c)
static int decode_hextile(VmncContext *c, uint8_t *dst, GetByteContext *gb, int w, int h, int stride)
#define AV_LOG_INFO
Standard information.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int decode_init(AVCodecContext *avctx)
GLint GLenum GLboolean GLsizei stride
common internal api header.
common internal and external API header
#define AV_PIX_FMT_RGB555
int key_frame
1 -> keyframe, 0-> not
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define AV_PIX_FMT_0RGB32