49 for (i = 0; i < 3; ++i)
57 for (i = 0; i < 3; ++i) {
95 unsigned char *dst,
int dst_size)
98 unsigned char huff_code_table[15];
99 unsigned char *dst_cur = dst;
100 unsigned char *dst_end = dst + dst_size;
101 const unsigned char *src_end = src + src_size;
103 memcpy(huff_code_table, src, 15);
106 while (src < src_end) {
108 if ((huff_code >> 4) == 15) {
111 *dst_cur++ = b | (huff_code >> 4);
113 *dst_cur++ = huff_code_table[huff_code >> 4];
114 if (dst_cur >= dst_end)
118 if (huff_code == 15) {
121 *dst_cur++ = huff_code_table[huff_code];
122 if (dst_cur >= dst_end)
126 return dst_cur - dst;
130 unsigned char *dst,
int dst_size)
134 unsigned char *dst_end = dst + dst_size, *dst_start = dst;
135 const unsigned char *src_end = src + src_size;
137 while (src < src_end && dst < dst_end) {
139 for (i = 0; i < 8 && src < src_end && dst < dst_end; ++i) {
140 if (code & (1 << i)) {
146 if ((
int)(dst - dst_start) < offset + 1)
148 sz = (cmd & 0xF) + 2;
152 sz =
FFMIN(sz, dst_end - dst);
154 *dst = *(dst - offset - 1);
161 if (dst_end - dst > dst_size - dst_size/10)
168 unsigned char *dst,
int dst_size)
171 unsigned char *dst_end = dst + dst_size;
172 const unsigned char *src_end = src + src_size;
174 while (src + 1 < src_end && dst < dst_end) {
178 memset(dst, *src++,
FFMIN(len, dst_end - dst));
181 if (len > src_end-src) {
185 memcpy(dst, src,
FFMIN3(len, dst_end - dst, src_end - src));
191 if (dst_end - dst > dst_size - dst_size/10)
198 void *
data,
int *got_frame,
202 int buf_size = avpkt->
size;
204 int i, y, palette_type, palette_colors_count,
205 bitmap_frame_type, bitmap_frame_size, res = 0;
207 palette_type = buf[0];
208 palette_colors_count =
AV_RL16(buf + 1);
209 bitmap_frame_type = buf[3];
212 bitmap_frame_size = buf_size - 4;
215 if (bitmap_frame_size < palette_colors_count * (3 + (palette_type != 0)))
217 if (palette_type == 0) {
218 if (palette_colors_count > 256)
220 for (i = 0; i < palette_colors_count; ++i) {
221 cin->
palette[i] = 0xFF
U << 24 | bytestream_get_le24(&buf);
222 bitmap_frame_size -= 3;
225 for (i = 0; i < palette_colors_count; ++i) {
228 bitmap_frame_size -= 4;
234 switch (bitmap_frame_type) {
323 .
name =
"dsicinvideo",
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst, int size)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
AVCodec ff_dsicinvideo_decoder
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...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
8 bits with AV_PIX_FMT_RGB32 palette
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static av_cold void destroy_buffers(CinVideoContext *cin)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned char *dst, int dst_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. ...
uint8_t * bitmap_table[3]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
static av_cold int cinvideo_decode_end(AVCodecContext *avctx)
int width
picture width / height.
static av_cold int allocate_buffers(CinVideoContext *cin)
static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int palette_has_changed
Tell user application that palette has changed from previous frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static int cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
#define FFSWAP(type, a, b)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int cinvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)