37 #define KBND MKTAG('K', 'B', 'N', 'D')
38 #define FINT MKTAG('F', 'I', 'N', 'T')
39 #define INIT MKTAG('I', 'N', 'I', 'T')
40 #define BNDL MKTAG('B', 'N', 'D', 'L')
41 #define KFRM MKTAG('K', 'F', 'R', 'M')
42 #define DLTA MKTAG('D', 'L', 'T', 'A')
43 #define MOUS MKTAG('M', 'O', 'U', 'S')
44 #define MPOS MKTAG('M', 'P', 'O', 'S')
45 #define MOVE MKTAG('M', 'O', 'V', 'E')
46 #define EMPT MKTAG('E', 'M', 'P', 'T')
73 for (
int y = 0; y < avctx->
height; y++) {
74 memset(dst, 0, avctx->
width * s->
bpp);
85 for (
int y = 0; y < avctx->
height; y++) {
86 memcpy(dstp, srcp, s->
stride);
119 if (bytestream2_peek_le32(gb) != 0x65) {
129 w = bytestream2_get_le32(gb);
130 h = bytestream2_get_le32(gb);
132 fmt = bytestream2_get_le16(gb);
139 case 16: s->
stride = w * 2;
142 case 32: s->
stride = w * 4;
160 uint32_t *pal = (uint32_t *)s->
frame2->
data[1];
162 for (
int i = 0; i < 256; i++)
163 pal[i] = bytestream2_get_le32(gb) | 0xFF000000
u;
170 unsigned size,
unsigned uncompressed_size)
176 zret = inflateReset(&s->
zstream);
193 if (zret != Z_STREAM_END) {
195 "Inflate failed with return code: %d.\n", zret);
208 unsigned pos, compression, nb_moves;
209 unsigned uncompressed_size;
214 nb_moves = bytestream2_get_le32(gb);
216 compression = bytestream2_get_le32(gb);
218 if (nb_moves > INT32_MAX / 16)
221 uncompressed_size = 16 * nb_moves;
223 if (compression == 1) {
230 }
else if (compression == 0) {
233 }
else if (compression == 2) {
243 for (
int i = 0; i < nb_moves; i++) {
244 int type, start_x, start_y, end_x, end_y, mov_x, mov_y;
248 type = bytestream2_get_le16(&mc);
249 start_x = bytestream2_get_le16(&mc);
250 start_y = bytestream2_get_le16(&mc);
251 end_x = bytestream2_get_le16(&mc);
252 end_y = bytestream2_get_le16(&mc);
253 mov_x = bytestream2_get_le16(&mc);
254 mov_y = bytestream2_get_le16(&mc);
257 if (start_x >= avctx->
width || start_y >= avctx->
height ||
263 if (start_x >= end_x || start_y >= end_y)
269 if (mov_x + w > avctx->
width || mov_y + h > avctx->
height)
280 for (
int j = 0; j <
h; j++) {
281 memcpy(b1, b2, w * s->
bpp);
285 }
else if (type == 1) {
286 for (
int j = 0; j <
h; j++) {
287 memset(b2, 0, w * s->
bpp);
290 }
else if (type == 0) {
298 for (
int j = 0; j <
h; j++) {
299 memcpy(buffer + j * w * s->
bpp, e2, w * s->
bpp);
303 for (
int j = 0; j <
h; j++) {
304 memcpy(b2, buffer + j * w * s->
bpp, w * s->
bpp);
318 if (cx >= w * s->bpp) { \
321 b1 -= s->frame1->linesize[0]; \
322 b2 -= s->frame2->linesize[0]; \
332 unsigned uncompressed_size, pos;
334 int ret, cx, cy, compression;
339 uncompressed_size = bytestream2_get_le32(gb);
340 x = bytestream2_get_le32(gb);
341 y = bytestream2_get_le32(gb);
342 w = bytestream2_get_le32(gb);
343 h = bytestream2_get_le32(gb);
353 compression = bytestream2_get_le32(gb);
355 if (compression == 1) {
356 ret =
decode_zlib(avctx, avpkt, size, uncompressed_size);
360 }
else if (compression == 0) {
365 }
else if (compression == 2) {
379 int type = bytestream2_get_byte(&dc);
380 int len = bytestream2_get_byte(&dc);
385 while (len > 0 && cy > 0) {
391 while (len > 0 && cy > 0) {
402 while (len > 0 && cy > 0) {
403 fill = bytestream2_get_byte(&dc);
411 fill = bytestream2_get_byte(&dc);
412 while (len > 0 && cy > 0) {
420 fill = bytestream2_get_le32(&dc);
421 while (len > 0 && cy > 0) {
429 while (len > 0 && cy > 0) {
435 while (len > 0 && cy > 0) {
447 while (len > 0 && cy > 0) {
448 fill = bytestream2_get_le32(&dc);
476 if (bytestream2_peek_le32(gb) == 0x65) {
485 zret = inflateReset(&s->
zstream);
495 for (
int i = 0; i < avctx->
height; i++) {
500 if (zret != Z_OK && zret != Z_STREAM_END) {
502 "Inflate failed with return code: %d.\n", zret);
510 for (
int i = 0; i < avctx->
height; i++) {
515 if (zret != Z_OK && zret != Z_STREAM_END) {
517 "Inflate failed with return code: %d.\n", zret);
534 unsigned w,
h, pos, uncompressed_size;
539 w = bytestream2_get_le32(gb);
540 h = bytestream2_get_le32(gb);
542 uncompressed_size = bytestream2_get_le32(gb);
547 if (uncompressed_size != 3 * w * h)
578 s->
cursor_x = bytestream2_get_le32(gb);
579 s->
cursor_y = bytestream2_get_le32(gb);
603 for (
int i = 0; i < s->
cursor_h; i++) {
604 for (
int j = 0; j < s->
cursor_w; j++) {
616 for (
int k = 0; k < 256; k++) {
617 int pr = pal[k * 4 + 0];
618 int pg = pal[k * 4 + 1];
619 int pb = pal[k * 4 + 2];
631 for (
int i = 0; i < s->
cursor_h; i++) {
632 for (
int j = 0; j < s->
cursor_w; j++) {
640 cr >>= 3; cg >>=3; cb >>= 3;
642 AV_WL16(dst, cr | cg << 5 | cb << 10);
646 for (
int i = 0; i < s->
cursor_h; i++) {
647 for (
int j = 0; j < s->
cursor_w; j++) {
665 void *
data,
int *got_frame,
675 if (bytestream2_peek_le32(gb) ==
EMPT)
683 type = bytestream2_get_le32(gb);
685 intra = type ==
KBND;
686 type = bytestream2_get_le32(gb);
689 size = bytestream2_get_le32(gb);
749 zret = inflateInit(&s->
zstream);
811 .priv_class = &rasc_decoder_class,
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static void draw_cursor(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static av_cold int decode_close(AVCodecContext *avctx)
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
#define LIBAVUTIL_VERSION_INT
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static const AVClass rasc_decoder_class
static av_cold int init(AVCodecContext *avctx)
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
const char * av_default_item_name(void *ptr)
Return the context name.
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)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static int decode_dlta(AVCodecContext *avctx, AVPacket *avpkt, unsigned size)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
BYTE int const BYTE * srcp
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static void clear_plane(AVCodecContext *avctx, AVFrame *frame)
static double cb(void *priv, double x, double y)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
8 bits with AV_PIX_FMT_RGB32 palette
#define u(width, name, range_min, range_max)
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
static av_cold int decode_init(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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)
simple assert() macros that are a bit more flexible than ISO C assert().
static int decode_kfrm(AVCodecContext *avctx, AVPacket *avpkt, unsigned size)
const char * name
Name of the codec implementation.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static int decode_zlib(AVCodecContext *avctx, AVPacket *avpkt, unsigned size, unsigned uncompressed_size)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static av_always_inline int bytestream2_tell(GetByteContext *g)
Libavcodec external API header.
static int decode_move(AVCodecContext *avctx, AVPacket *avpkt, unsigned size)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define AV_OPT_FLAG_VIDEO_PARAM
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void copy_plane(AVCodecContext *avctx, AVFrame *src, AVFrame *dst)
Describe the class of an AVClass context structure.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
static int init_frames(AVCodecContext *avctx)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void decode_flush(AVCodecContext *avctx)
static int decode_mous(AVCodecContext *avctx, AVPacket *avpkt, unsigned size)
static int decode_fint(AVCodecContext *avctx, AVPacket *avpkt, unsigned size)
common internal api header.
static const AVOption options[]
int key_frame
1 -> keyframe, 0-> not
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> dc
static int decode_mpos(AVCodecContext *avctx, AVPacket *avpkt, unsigned size)
static double cr(void *priv, double x, double y)
#define AVERROR_EXTERNAL
Generic error in an external library.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.