69 int mask = 0x10000, bitbuf = 0;
74 segments = bytestream2_get_le32(gb);
75 offset = bytestream2_get_le32(gb);
76 if (segments == 0 && offset == frame_end - frame)
78 if (frame_end - frame <= offset)
84 if (mask == 0x10000) {
85 bitbuf = bytestream2_get_le16u(gb);
88 if (frame_end - frame < 2)
91 v = bytestream2_get_le16(gb);
92 offset = (v & 0x1FFF) << 1;
93 count = ((v >> 13) + 2) << 1;
94 if (frame - frame_start < offset || frame_end - frame < count)
99 *frame++ = bytestream2_get_byte(gb);
100 *frame++ = bytestream2_get_byte(gb);
112 int mask = 0x10000, bitbuf = 0;
115 segments = bytestream2_get_le16(gb);
119 if (mask == 0x10000) {
120 bitbuf = bytestream2_get_le16u(gb);
123 if (frame_end - frame < 2)
126 v = bytestream2_get_le16(gb);
127 offset = (v & 0x1FFF) << 1;
128 count = ((v >> 13) + 2) << 1;
129 if (frame - frame_start < offset || frame_end - frame < count)
133 }
else if (bitbuf & (mask << 1)) {
134 frame += bytestream2_get_le16(gb);
136 *frame++ = bytestream2_get_byte(gb);
137 *frame++ = bytestream2_get_byte(gb);
149 int mask = 0x10000, bitbuf = 0;
152 segments = bytestream2_get_le16(gb);
156 if (mask == 0x10000) {
157 bitbuf = bytestream2_get_le16u(gb);
162 v = bytestream2_get_le16(gb);
163 offset = (v & 0x1FFF) << 2;
164 count = ((v >> 13) + 2) << 1;
165 if (frame - frame_start < offset || frame_end - frame < count*2 + width)
167 for (i = 0; i <
count; i++) {
168 frame[0] = frame[1] =
173 }
else if (bitbuf & (mask << 1)) {
174 v = bytestream2_get_le16(gb)*2;
175 if (frame - frame_end < v)
179 if (frame_end - frame < width + 4)
181 frame[0] = frame[1] =
182 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
184 frame[0] = frame[1] =
185 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
197 int count, lines, segments;
199 count = bytestream2_get_le16(gb);
202 frame += width *
count;
203 lines = bytestream2_get_le16(gb);
204 if (count + lines > height)
212 segments = bytestream2_get_byteu(gb);
214 if (frame - line_ptr <= bytestream2_peek_byte(gb))
216 line_ptr += bytestream2_get_byte(gb);
217 count = (int8_t)bytestream2_get_byte(gb);
219 if (frame - line_ptr < count)
225 if (frame - line_ptr < count)
227 memset(line_ptr, bytestream2_get_byte(gb), count);
240 int count, i, v, lines, segments;
243 lines = bytestream2_get_le16(gb);
250 segments = bytestream2_get_le16u(gb);
251 while ((segments & 0xC000) == 0xC000) {
252 unsigned skip_lines = -(int16_t)segments;
253 int64_t
delta = -((int16_t)segments * (int64_t)
width);
254 if (frame_end - frame <= delta || y + lines + skip_lines > height)
258 segments = bytestream2_get_le16(gb);
261 if (frame_end <= frame)
263 if (segments & 0x8000) {
264 frame[width - 1] = segments & 0xFF;
265 segments = bytestream2_get_le16(gb);
268 if (frame_end - frame < width)
273 if (frame - line_ptr <= bytestream2_peek_byte(gb))
275 line_ptr += bytestream2_get_byte(gb);
276 count = (int8_t)bytestream2_get_byte(gb);
278 if (frame - line_ptr < count * 2)
282 line_ptr += count * 2;
285 if (frame - line_ptr < count * 2)
287 v = bytestream2_get_le16(gb);
288 for (i = 0; i <
count; i++)
289 bytestream_put_le16(&line_ptr, v);
300 uint32_t segments = bytestream2_get_le32(gb);
306 copy = bytestream2_get_byteu(gb) * 2;
307 skip = bytestream2_get_byteu(gb) * 2;
308 if (frame_end - frame < copy + skip ||
321 memset(frame, 0, width * height);
334 "COPY",
"TSW1",
"BDLT",
"WDLT",
"TDLT",
"DSW1",
"BLCK",
"DDS1"
338 void *
data,
int *got_frame,
345 uint32_t chunk_type, chunk_size;
357 chunk_size = bytestream2_get_le32(&gb);
358 chunk_type = bytestream2_get_le32(&gb);
361 if (chunk_type == 1) {
362 pal_elems =
FFMIN(chunk_size / 3, 256);
363 for (i = 0; i < pal_elems; i++) {
364 s->
pal[i] = bytestream2_get_be24(&gb) << 2;
365 s->
pal[i] |= 0xFF
U << 24 | (s->
pal[i] >> 6) & 0x30303;
368 }
else if (chunk_type <= 9) {
376 "Ignoring unknown chunk type %"PRIu32
"\n",
383 dst = frame->
data[0];
384 for (i = 0; i < avctx->
height; i++) {
385 if(version == 0x100) {
387 for(j = 0; j < avctx->
width; j++) {
388 dst[j] = buf[ (i&3)*(avctx->
width /4) + (j/4) +
392 memcpy(dst, buf, avctx->
width);
397 memcpy(frame->
data[1], s->
pal,
sizeof(s->
pal));
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void copy(const float *p1, float *p2, const int length)
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)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
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.
common internal api header.
static int decode_tsw1(GetByteContext *gb, uint8_t *frame, int width, int height)
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
int(* chunk_decoder)(GetByteContext *gb, uint8_t *frame, int width, int height)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.