49 for (
i = 0;
i < 3; ++
i)
57 for (
i = 0;
i < 3; ++
i) {
94 unsigned char *dst,
int dst_size)
97 unsigned char huff_code_table[15];
98 unsigned char *dst_cur = dst;
99 unsigned char *dst_end = dst + dst_size;
100 const unsigned char *src_end =
src + src_size;
102 memcpy(huff_code_table,
src, 15);
105 while (
src < src_end) {
107 if ((huff_code >> 4) == 15) {
110 *dst_cur++ =
b | (huff_code >> 4);
112 *dst_cur++ = huff_code_table[huff_code >> 4];
113 if (dst_cur >= dst_end)
117 if (huff_code == 15) {
120 *dst_cur++ = huff_code_table[huff_code];
121 if (dst_cur >= dst_end)
125 return dst_cur - dst;
129 unsigned char *dst,
int dst_size)
133 unsigned char *dst_end = dst + dst_size, *dst_start = dst;
134 const unsigned char *src_end =
src + src_size;
136 while (
src < src_end && dst < dst_end) {
138 for (
i = 0;
i < 8 &&
src < src_end && dst < dst_end; ++
i) {
139 if (
code & (1 <<
i)) {
145 if ((
int)(dst - dst_start) <
offset + 1)
147 sz = (cmd & 0xF) + 2;
151 sz =
FFMIN(sz, dst_end - dst);
153 *dst = *(dst -
offset - 1);
160 if (dst_end - dst > dst_size - dst_size/10)
167 unsigned char *dst,
int dst_size)
170 unsigned char *dst_end = dst + dst_size;
171 const unsigned char *src_end =
src + src_size;
173 while (
src + 1 < src_end && dst < dst_end) {
190 if (dst_end - dst > dst_size - dst_size/10)
197 void *
data,
int *got_frame,
201 int buf_size = avpkt->
size;
203 int i, y, palette_type, palette_colors_count,
204 bitmap_frame_type, bitmap_frame_size, res = 0;
206 palette_type = buf[0];
207 palette_colors_count =
AV_RL16(buf + 1);
208 bitmap_frame_type = buf[3];
211 bitmap_frame_size = buf_size - 4;
214 if (bitmap_frame_size < palette_colors_count * (3 + (palette_type != 0)))
216 if (palette_type == 0) {
217 if (palette_colors_count > 256)
219 for (
i = 0;
i < palette_colors_count; ++
i) {
220 cin->
palette[
i] = 0xFFU << 24 | bytestream_get_le24(&buf);
221 bitmap_frame_size -= 3;
224 for (
i = 0;
i < palette_colors_count; ++
i) {
227 bitmap_frame_size -= 4;
233 switch (bitmap_frame_type) {
325 .
name =
"dsicinvideo",
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
#define FFSWAP(type, a, b)
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.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static av_cold void destroy_buffers(CinVideoContext *cin)
AVCodec ff_dsicinvideo_decoder
static int cin_decode_lzss(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
static int cin_decode_huffman(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
static av_cold int allocate_buffers(CinVideoContext *cin)
static int cinvideo_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static void cin_apply_delta_data(const unsigned char *src, unsigned char *dst, int size)
static av_cold int cinvideo_decode_end(AVCodecContext *avctx)
static av_cold int cinvideo_decode_init(AVCodecContext *avctx)
static int cin_decode_rle(const unsigned char *src, int src_size, unsigned char *dst, int dst_size)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_CODEC_ID_DSICINVIDEO
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int palette_has_changed
Tell user application that palette has changed from previous frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
This structure stores compressed data.
uint8_t * bitmap_table[3]
static const uint8_t offset[127][2]