69 int mask = 0x10000, bitbuf = 0;
70 int v,
count, segments;
73 segments = bytestream2_get_le32(gb);
74 offset = bytestream2_get_le32(gb);
75 if (segments == 0 && offset == frame_end - frame)
77 if (frame_end - frame <= offset)
83 if (mask == 0x10000) {
84 bitbuf = bytestream2_get_le16u(gb);
87 if (frame_end - frame < 2)
90 v = bytestream2_get_le16(gb);
91 offset = (v & 0x1FFF) << 1;
92 count = ((v >> 13) + 2) << 1;
93 if (frame - frame_start < offset || frame_end - frame < count)
98 *frame++ = bytestream2_get_byte(gb);
99 *frame++ = bytestream2_get_byte(gb);
111 int mask = 0x10000, bitbuf = 0;
114 segments = bytestream2_get_le16(gb);
118 if (mask == 0x10000) {
119 bitbuf = bytestream2_get_le16u(gb);
122 if (frame_end - frame < 2)
125 v = bytestream2_get_le16(gb);
126 offset = (v & 0x1FFF) << 1;
127 count = ((v >> 13) + 2) << 1;
128 if (frame - frame_start < offset || frame_end - frame < count)
132 }
else if (bitbuf & (mask << 1)) {
133 frame += bytestream2_get_le16(gb);
135 *frame++ = bytestream2_get_byte(gb);
136 *frame++ = bytestream2_get_byte(gb);
148 int mask = 0x10000, bitbuf = 0;
151 segments = bytestream2_get_le16(gb);
155 if (mask == 0x10000) {
156 bitbuf = bytestream2_get_le16u(gb);
161 v = bytestream2_get_le16(gb);
162 offset = (v & 0x1FFF) << 2;
163 count = ((v >> 13) + 2) << 1;
164 if (frame - frame_start < offset || frame_end - frame < count*2 + width)
166 for (i = 0; i <
count; i++) {
167 frame[0] = frame[1] =
172 }
else if (bitbuf & (mask << 1)) {
173 v = bytestream2_get_le16(gb)*2;
174 if (frame - frame_end < v)
178 if (frame_end - frame < width + 3)
180 frame[0] = frame[1] =
181 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
183 frame[0] = frame[1] =
184 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
196 int count, lines, segments;
198 count = bytestream2_get_le16(gb);
201 frame += width *
count;
202 lines = bytestream2_get_le16(gb);
203 if (count + lines > height)
211 segments = bytestream2_get_byteu(gb);
213 if (frame - line_ptr <= bytestream2_peek_byte(gb))
215 line_ptr += bytestream2_get_byte(gb);
216 count = (int8_t)bytestream2_get_byte(gb);
218 if (frame - line_ptr < count)
224 if (frame - line_ptr < count)
226 memset(line_ptr, bytestream2_get_byte(gb), count);
239 int count, i, v, lines, segments;
242 lines = bytestream2_get_le16(gb);
249 segments = bytestream2_get_le16u(gb);
250 while ((segments & 0xC000) == 0xC000) {
251 unsigned skip_lines = -(int16_t)segments;
252 unsigned delta = -((int16_t)segments * width);
253 if (frame_end - frame <= delta || y + lines + skip_lines > height)
257 segments = bytestream2_get_le16(gb);
260 if (frame_end <= frame)
262 if (segments & 0x8000) {
263 frame[width - 1] = segments & 0xFF;
264 segments = bytestream2_get_le16(gb);
267 if (frame_end - frame < width)
272 if (frame - line_ptr <= bytestream2_peek_byte(gb))
274 line_ptr += bytestream2_get_byte(gb);
275 count = (int8_t)bytestream2_get_byte(gb);
277 if (frame - line_ptr < count * 2)
281 line_ptr += count * 2;
284 if (frame - line_ptr < count * 2)
286 v = bytestream2_get_le16(gb);
287 for (i = 0; i <
count; i++)
288 bytestream_put_le16(&line_ptr, v);
299 uint32_t segments = bytestream2_get_le32(gb);
305 copy = bytestream2_get_byteu(gb) * 2;
306 skip = bytestream2_get_byteu(gb) * 2;
307 if (frame_end - frame < copy + skip ||
320 memset(frame, 0, width * height);
333 "COPY",
"TSW1",
"BDLT",
"WDLT",
"TDLT",
"DSW1",
"BLCK",
"DDS1"
337 void *
data,
int *got_frame,
344 uint32_t chunk_type, chunk_size;
356 chunk_size = bytestream2_get_le32(&gb);
357 chunk_type = bytestream2_get_le32(&gb);
360 if (chunk_type == 1) {
361 pal_elems =
FFMIN(chunk_size / 3, 256);
362 for (i = 0; i < pal_elems; i++) {
363 s->
pal[i] = bytestream2_get_be24(&gb) << 2;
364 s->
pal[i] |= 0xFF
U << 24 | (s->
pal[i] >> 6) & 0x30303;
367 }
else if (chunk_type <= 9) {
375 "Ignoring unknown chunk type %"PRIu32
"\n",
382 dst = frame->
data[0];
383 for (i = 0; i < avctx->
height; i++) {
384 if(version == 0x100) {
386 for(j = 0; j < avctx->
width; j++) {
387 dst[j] = buf[ (i&3)*(avctx->
width /4) + (j/4) +
391 memcpy(dst, buf, avctx->
width);
396 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.
ptrdiff_t const GLvoid * data
static const char * chunk_name[8]
#define AV_LOG_WARNING
Something somehow does not look correct.
memory handling functions
static av_cold int init(AVCodecContext *avctx)
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)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
#define av_assert0(cond)
assert() equivalent, that is always enabled.
8 bits with AV_PIX_FMT_RGB32 palette
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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)
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
static const uint8_t offset[127][2]
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.
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.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
common internal api header.
static int decode_tsw1(GetByteContext *gb, uint8_t *frame, int width, int height)
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 ...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.