Go to the documentation of this file.
78 switch (bpp * 2 +
be) {
81 return bytestream2_get_byte(gb);
83 return bytestream2_get_le16(gb);
85 return bytestream2_get_be16(gb);
87 return bytestream2_get_le32(gb);
89 return bytestream2_get_be32(gb);
97 const int bpp =
c->bpp2;
98 uint8_t *dst8 =
c->curbits;
99 uint16_t *dst16 = (uint16_t *)
c->curbits;
100 uint32_t *dst32 = (uint32_t *)
c->curbits;
102 for (j = 0; j <
c->cur_h; j++) {
103 for (
i = 0;
i <
c->cur_w;
i++) {
114 dst16 = (uint16_t*)
c->curmask;
115 dst32 = (uint32_t*)
c->curmask;
116 for (j = 0; j <
c->cur_h; j++) {
117 for (
i = 0;
i <
c->cur_w;
i++) {
134 if (
c->width <
c->cur_x +
c->cur_w)
135 w =
c->width -
c->cur_x;
137 if (
c->height <
c->cur_y +
c->cur_h)
138 h =
c->height -
c->cur_y;
150 if ((
w < 1) || (
h < 1))
155 uint8_t *cd =
c->curbits, *msk =
c->curmask;
156 for (j = 0; j <
h; j++) {
157 for (
i = 0;
i <
w;
i++)
163 }
else if (
c->bpp2 == 2) {
164 uint16_t *cd = (uint16_t*)
c->curbits, *msk = (uint16_t*)
c->curmask;
166 for (j = 0; j <
h; j++) {
167 dst2 = (uint16_t*)
dst;
168 for (
i = 0;
i <
w;
i++)
169 dst2[
i] = (dst2[
i] & cd[
i]) ^ msk[
i];
174 }
else if (
c->bpp2 == 4) {
175 uint32_t *cd = (uint32_t*)
c->curbits, *msk = (uint32_t*)
c->curmask;
177 for (j = 0; j <
h; j++) {
178 dst2 = (uint32_t*)
dst;
179 for (
i = 0;
i <
w;
i++)
180 dst2[
i] = (dst2[
i] & cd[
i]) ^ msk[
i];
196 for (j = 0; j <
h; j++) {
200 }
else if (bpp == 2) {
202 for (j = 0; j <
h; j++) {
203 dst2 = (uint16_t*)
dst;
204 for (
i = 0;
i <
w;
i++)
208 }
else if (bpp == 4) {
210 for (j = 0; j <
h; j++) {
211 dst2 = (uint32_t*)
dst;
212 for (
i = 0;
i <
w;
i++)
224 for (j = 0; j <
h; j++) {
225 for (
i = 0;
i <
w;
i++) {
232 ((uint16_t*)
dst)[
i] = p;
235 ((uint32_t*)
dst)[
i] = p;
247 int bg = 0, fg = 0, rects,
color,
flags, xy, wh;
248 const int bpp =
c->bpp2;
250 int bw = 16, bh = 16;
252 for (j = 0; j <
h; j += 16) {
257 for (
i = 0;
i <
w;
i += 16, dst2 += 16 * bpp) {
264 flags = bytestream2_get_byte(gb);
278 rects = bytestream2_get_byte(gb);
287 for (k = 0; k < rects; k++) {
288 int rect_x, rect_y, rect_w, rect_h;
291 xy = bytestream2_get_byte(gb);
292 wh = bytestream2_get_byte(gb);
296 rect_w = (wh >> 4) + 1;
297 rect_h = (wh & 0xF) + 1;
299 if (rect_x + rect_w >
w -
i || rect_y + rect_h >
h - j) {
305 rect_w, rect_h, fg, bpp,
stride);
319 c->cur_w =
c->cur_h = 0;
320 c->cur_hx =
c->cur_hy = 0;
327 const uint8_t *buf = avpkt->
data;
328 int buf_size = avpkt->
size;
332 int dx, dy,
w,
h, depth, enc, chunks, res, size_left,
ret;
336 chunks = bytestream2_get_be16(gb);
350 if (
c->width <
c->cur_x +
w)
351 w =
c->width -
c->cur_x;
353 if (
c->height <
c->cur_y +
h)
354 h =
c->height -
c->cur_y;
365 if ((
w > 0) && (
h > 0)) {
366 outptr =
c->pic->data[0] + dx *
c->bpp2 + dy *
c->pic->linesize[0];
367 for (
i = 0;
i <
h;
i++) {
368 memcpy(outptr,
c->screendta +
i *
c->cur_w *
c->bpp2,
370 outptr +=
c->pic->linesize[0];
380 dx = bytestream2_get_be16(gb);
381 dy = bytestream2_get_be16(gb);
382 w = bytestream2_get_be16(gb);
383 h = bytestream2_get_be16(gb);
384 enc = bytestream2_get_be32(gb);
385 if ((dx +
w >
c->width) || (dy +
h >
c->height)) {
387 "Incorrect frame size: %ix%i+%ix%i of %ix%i\n",
388 w,
h, dx, dy,
c->width,
c->height);
391 outptr =
c->pic->data[0] + dx *
c->bpp2 + dy *
c->pic->linesize[0];
399 if (size_left < 2 + w * h * c->bpp2 * 2) {
401 "Premature end of data! (need %i got %i)\n",
402 2 +
w *
h *
c->bpp2 * 2, size_left);
410 if ((
c->cur_hx >
c->cur_w) || (
c->cur_hy >
c->cur_h)) {
412 "Cursor hot spot is not in image: "
413 "%ix%i of %ix%i cursor size\n",
414 c->cur_hx,
c->cur_hy,
c->cur_w,
c->cur_h);
415 c->cur_hx =
c->cur_hy = 0;
417 if (
c->cur_w *
c->cur_h >= INT_MAX /
c->bpp2) {
421 int screen_size =
c->cur_w *
c->cur_h *
c->bpp2;
435 c->cur_x = dx -
c->cur_hx;
436 c->cur_y = dy -
c->cur_hy;
447 depth = bytestream2_get_byte(gb);
448 if (depth !=
c->bpp) {
450 "Depth mismatch. Container %i bpp, "
451 "Frame data: %i bpp\n",
455 c->bigendian = bytestream2_get_byte(gb);
456 if (
c->bigendian & (~1)) {
458 "Invalid header: bigendian flag = %i\n",
c->bigendian);
468 if (size_left < w * h * c->bpp2) {
470 "Premature end of data! (need %i got %i)\n",
471 w *
h *
c->bpp2, size_left);
475 c->pic->linesize[0]);
491 if (
c->width <
c->cur_x +
w)
492 w =
c->width -
c->cur_x;
494 if (
c->height <
c->cur_y +
h)
495 h =
c->height -
c->cur_y;
506 if ((
w > 0) && (
h > 0)) {
507 outptr =
c->pic->data[0] + dx *
c->bpp2 + dy *
c->pic->linesize[0];
508 for (
i = 0;
i <
h;
i++) {
509 memcpy(
c->screendta +
i *
c->cur_w *
c->bpp2, outptr,
511 outptr +=
c->pic->linesize[0];
513 outptr =
c->pic->data[0];
552 c->bpp2 =
c->bpp / 8;
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it be(in the first position) for now. Options ------- Then comes the options array. This is what will define the user accessible options. For example
static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride)
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int decode_init(AVCodecContext *avctx)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
AVCodec p
The public AVCodec.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int decode_hextile(VmncContext *c, uint8_t *dst, GetByteContext *gb, int w, int h, int stride)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define FF_CODEC_DECODE_CB(func)
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
#define CODEC_LONG_NAME(str)
@ AV_PICTURE_TYPE_I
Intra.
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
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void paint_raw(uint8_t *dst, int w, int h, GetByteContext *gb, int bpp, int be, int stride)
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
#define AV_LOG_INFO
Standard information.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define i(width, name, range_min, range_max)
static av_always_inline int vmnc_get_pixel(GetByteContext *gb, int bpp, int be)
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
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.
#define AV_PIX_FMT_0RGB32
static void put_cursor(uint8_t *dst, int stride, VmncContext *c, int dx, int dy)
main external API structure.
static void reset_buffers(VmncContext *c)
@ AV_PICTURE_TYPE_P
Predicted.
static void load_cursor(VmncContext *c)
const FFCodec ff_vmnc_decoder
This structure stores compressed data.
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.