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;
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++) {
117 for (j = 0; j < c->
cur_h; j++) {
118 for (i = 0; i < c->
cur_w; i++) {
151 if ((w < 1) || (h < 1))
157 for (j = 0; j < h; j++) {
158 for (i = 0; i < w; i++)
159 dst[i] = (dst[i] & cd[i]) ^ msk[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];
191 int w,
int h,
int color,
195 dst += dx * bpp + dy *
stride;
197 for (j = 0; j < h; j++) {
198 memset(dst, color, w);
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);
280 color = !!(flags &
HT_CLR);
282 paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);
288 for (k = 0; k < rects; k++) {
291 xy = bytestream2_get_byte(gb);
292 wh = bytestream2_get_byte(gb);
294 (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
315 int buf_size = avpkt->
size;
319 int dx, dy, w, h, depth, enc, chunks, res, size_left;
352 if ((w > 0) && (h > 0)) {
354 for (i = 0; i < h; i++) {
362 chunks = bytestream2_get_be16(gb);
364 dx = bytestream2_get_be16(gb);
365 dy = bytestream2_get_be16(gb);
366 w = bytestream2_get_be16(gb);
367 h = bytestream2_get_be16(gb);
368 enc = bytestream2_get_be32(gb);
373 if (size_left < 2 + w * h * c->bpp2 * 2) {
375 "Premature end of data! (need %i got %i)\n",
376 2 + w * h * c->
bpp2 * 2, size_left);
386 "Cursor hot spot is not in image: "
387 "%ix%i of %ix%i cursor size\n",
400 return screen_size ?
AVERROR(ENOMEM) : 0;
421 depth = bytestream2_get_byte(gb);
422 if (depth != c->
bpp) {
424 "Depth mismatch. Container %i bpp, "
425 "Frame data: %i bpp\n",
432 "Invalid header: bigendian flag = %i\n", c->
bigendian);
444 "Incorrect frame size: %ix%i+%ix%i of %ix%i\n",
448 if (size_left < w * h * c->bpp2) {
450 "Premature end of data! (need %i got %i)\n",
451 w * h * c->
bpp2, size_left);
460 "Incorrect frame size: %ix%i+%ix%i of %ix%i\n",
492 if ((w > 0) && (h > 0)) {
494 for (i = 0; i < h; i++) {
struct VmncContext VmncContext
This structure describes decoded (raw) audio or video data.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
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)
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
8 bit with PIX_FMT_RGB32 palette
#define AV_PIX_FMT_RGB555
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).
static int init(AVCodecParserContext *s)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
static av_cold int decode_end(AVCodecContext *avctx)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#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)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
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)
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define FF_BUFFER_HINTS_REUSABLE
static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
#define FF_BUFFER_HINTS_PRESERVE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int decode_init(AVCodecContext *avctx)
common internal and external API header
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AVERROR_INVALIDDATA
static const uint8_t color[]
int key_frame
1 -> keyframe, 0-> not
#define FF_BUFFER_HINTS_VALID
This structure stores compressed data.