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 || nb_moves > avctx->
width * avctx->
height)
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 if (w * h * s->
bpp * 3 < uncompressed_size)
358 ret =
decode_zlib(avctx, avpkt, size, uncompressed_size);
362 }
else if (compression == 0) {
367 }
else if (compression == 2) {
381 int type = bytestream2_get_byte(&dc);
382 int len = bytestream2_get_byte(&dc);
387 while (len > 0 && cy > 0) {
393 while (len > 0 && cy > 0) {
404 while (len > 0 && cy > 0) {
405 fill = bytestream2_get_byte(&dc);
413 fill = bytestream2_get_byte(&dc);
414 while (len > 0 && cy > 0) {
422 fill = bytestream2_get_le32(&dc);
423 while (len > 0 && cy > 0) {
431 while (len > 0 && cy > 0) {
437 while (len > 0 && cy > 0) {
449 while (len > 0 && cy > 0) {
450 fill = bytestream2_get_le32(&dc);
478 if (bytestream2_peek_le32(gb) == 0x65) {
487 zret = inflateReset(&s->
zstream);
502 if (zret != Z_OK && zret != Z_STREAM_END) {
504 "Inflate failed with return code: %d.\n", zret);
517 if (zret != Z_OK && zret != Z_STREAM_END) {
519 "Inflate failed with return code: %d.\n", zret);
536 unsigned w,
h, pos, uncompressed_size;
541 w = bytestream2_get_le32(gb);
542 h = bytestream2_get_le32(gb);
544 uncompressed_size = bytestream2_get_le32(gb);
549 if (uncompressed_size != 3 * w * h)
580 s->
cursor_x = bytestream2_get_le32(gb);
581 s->
cursor_y = bytestream2_get_le32(gb);
606 for (
int j = 0; j < s->
cursor_w; j++) {
618 for (
int k = 0; k < 256; k++) {
619 int pr = pal[k * 4 + 0];
620 int pg = pal[k * 4 + 1];
621 int pb = pal[k * 4 + 2];
634 for (
int j = 0; j < s->
cursor_w; j++) {
642 cr >>= 3; cg >>=3; cb >>= 3;
644 AV_WL16(dst, cr | cg << 5 | cb << 10);
649 for (
int j = 0; j < s->
cursor_w; j++) {
667 void *
data,
int *got_frame,
677 if (bytestream2_peek_le32(gb) ==
EMPT)
688 type = bytestream2_get_le32(gb);
690 intra = type ==
KBND;
691 type = bytestream2_get_le32(gb);
694 size = bytestream2_get_le32(gb);
754 zret = inflateInit(&s->
zstream);
816 .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)
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)
#define avpriv_request_sample(...)
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)
#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 i(width, name, range_min, range_max)
#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)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;} return ac;} 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;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> dc
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
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.
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.