67 int mask = 0x10000, bitbuf = 0;
68 int v, count, segments;
71 segments = bytestream2_get_le32(gb);
72 offset = bytestream2_get_le32(gb);
73 if (frame_end - frame <= offset)
79 if (mask == 0x10000) {
80 bitbuf = bytestream2_get_le16u(gb);
83 if (frame_end - frame < 2)
86 v = bytestream2_get_le16(gb);
87 offset = (v & 0x1FFF) << 1;
88 count = ((v >> 13) + 2) << 1;
89 if (frame - frame_start < offset || frame_end - frame < count)
94 *frame++ = bytestream2_get_byte(gb);
95 *frame++ = bytestream2_get_byte(gb);
107 int mask = 0x10000, bitbuf = 0;
108 int v, offset, count, segments;
110 segments = bytestream2_get_le16(gb);
114 if (mask == 0x10000) {
115 bitbuf = bytestream2_get_le16u(gb);
118 if (frame_end - frame < 2)
121 v = bytestream2_get_le16(gb);
122 offset = (v & 0x1FFF) << 1;
123 count = ((v >> 13) + 2) << 1;
124 if (frame - frame_start < offset || frame_end - frame < count)
128 }
else if (bitbuf & (mask << 1)) {
129 frame += bytestream2_get_le16(gb);
131 *frame++ = bytestream2_get_byte(gb);
132 *frame++ = bytestream2_get_byte(gb);
144 int mask = 0x10000, bitbuf = 0;
145 int i, v, offset, count, segments;
147 segments = bytestream2_get_le16(gb);
151 if (mask == 0x10000) {
152 bitbuf = bytestream2_get_le16u(gb);
157 v = bytestream2_get_le16(gb);
158 offset = (v & 0x1FFF) << 2;
159 count = ((v >> 13) + 2) << 1;
160 if (frame - frame_start < offset || frame_end - frame < count*2 + width)
162 for (i = 0; i < count; i++) {
163 frame[0] = frame[1] =
164 frame[
width] = frame[width + 1] = frame[-offset];
168 }
else if (bitbuf & (mask << 1)) {
169 v = bytestream2_get_le16(gb)*2;
170 if (frame - frame_end < v)
174 if (frame_end - frame < width + 3)
176 frame[0] = frame[1] =
177 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
179 frame[0] = frame[1] =
180 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
192 int count, lines, segments;
194 count = bytestream2_get_le16(gb);
197 frame += width * count;
198 lines = bytestream2_get_le16(gb);
199 if (count + lines > height)
207 segments = bytestream2_get_byteu(gb);
209 if (frame - line_ptr <= bytestream2_peek_byte(gb))
211 line_ptr += bytestream2_get_byte(gb);
212 count = (int8_t)bytestream2_get_byte(gb);
214 if (frame - line_ptr < count)
220 if (frame - line_ptr < count)
222 memset(line_ptr, bytestream2_get_byte(gb), count);
235 int count, i, v, lines, segments;
238 lines = bytestream2_get_le16(gb);
245 segments = bytestream2_get_le16u(gb);
246 while ((segments & 0xC000) == 0xC000) {
247 unsigned skip_lines = -(int16_t)segments;
248 unsigned delta = -((int16_t)segments * width);
249 if (frame_end - frame <= delta || y + lines + skip_lines > height)
253 segments = bytestream2_get_le16(gb);
255 if (segments & 0x8000) {
256 frame[width - 1] = segments & 0xFF;
257 segments = bytestream2_get_le16(gb);
260 if (frame_end - frame < width)
265 if (frame - line_ptr <= bytestream2_peek_byte(gb))
267 line_ptr += bytestream2_get_byte(gb);
268 count = (int8_t)bytestream2_get_byte(gb);
270 if (frame - line_ptr < count * 2)
274 line_ptr += count * 2;
277 if (frame - line_ptr < count * 2)
279 v = bytestream2_get_le16(gb);
280 for (i = 0; i < count; i++)
281 bytestream_put_le16(&line_ptr, v);
292 int segments = bytestream2_get_le32(gb);
298 copy = bytestream2_get_byteu(gb) * 2;
299 skip = bytestream2_get_byteu(gb) * 2;
300 if (frame_end - frame < copy + skip ||
313 memset(frame, 0, width * height);
326 "COPY",
"TSW1",
"BDLT",
"WDLT",
"TDLT",
"DSW1",
"BLCK",
"DDS1"
330 void *
data,
int *got_frame,
337 uint32_t chunk_type, chunk_size;
350 chunk_size = bytestream2_get_le32(&gb);
351 chunk_type = bytestream2_get_le32(&gb);
354 if (chunk_type == 1) {
355 pal_elems =
FFMIN(chunk_size / 3, 256);
356 for (i = 0; i < pal_elems; i++) {
357 s->
pal[i] = bytestream2_get_be24(&gb) << 2;
358 s->
pal[i] |= (s->
pal[i] >> 6) & 0x333;
361 }
else if (chunk_type <= 9) {
369 "Ignoring unknown chunk type %"PRIu32
"\n",
376 dst = frame->
data[0];
377 for (i = 0; i < avctx->
height; i++) {
378 memcpy(dst, buf, avctx->
width);
382 memcpy(frame->
data[1], s->
pal,
sizeof(s->
pal));
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static const char * chunk_name[8]
#define AV_LOG_WARNING
Something somehow does not look correct.
memory handling functions
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)
static av_cold int dfa_decode_end(AVCodecContext *avctx)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
8 bit with PIX_FMT_RGB32 palette
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static void copy(LZOContext *c, int cnt)
Copies bytes from input to output buffer with checking.
static int decode_blck(GetByteContext *gb, uint8_t *frame, int width, int height)
static int dfa_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int decode_tdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
static int decode_dsw1(GetByteContext *gb, uint8_t *frame, int width, int height)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#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_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int decode_copy(GetByteContext *gb, uint8_t *frame, int width, int height)
static void frame_end(MpegEncContext *s)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
static const chunk_decoder decoder[8]
int width
picture width / height.
static av_cold int dfa_decode_init(AVCodecContext *avctx)
static int decode_bdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
static int decode_dds1(GetByteContext *gb, uint8_t *frame, int width, int height)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static int frame_start(MpegEncContext *s)
int palette_has_changed
Tell user application that palette has changed from previous frame.
static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static int decode_tsw1(GetByteContext *gb, uint8_t *frame, int width, int height)
static av_cold int init(AVCodecParserContext *s)
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
int(* chunk_decoder)(GetByteContext *gb, uint8_t *frame, int width, int height)
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...