49 const uint8_t *src,
const uint8_t *src_end)
53 if (src_end - src < size)
60 const uint8_t *src,
const uint8_t *src_end)
62 const uint8_t *frame_start = frame;
63 const uint8_t *frame_end = frame + width *
height;
64 int mask = 0x10000, bitbuf = 0;
65 int v, count, segments;
68 segments = bytestream_get_le32(&src);
69 offset = bytestream_get_le32(&src);
70 if (frame_end - frame <= offset)
74 if (mask == 0x10000) {
77 bitbuf = bytestream_get_le16(&src);
80 if (src_end - src < 2 || frame_end - frame < 2)
83 v = bytestream_get_le16(&src);
84 offset = (v & 0x1FFF) << 1;
85 count = ((v >> 13) + 2) << 1;
86 if (frame - frame_start < offset || frame_end - frame < count)
101 const uint8_t *src,
const uint8_t *src_end)
103 const uint8_t *frame_start = frame;
104 const uint8_t *frame_end = frame + width *
height;
105 int mask = 0x10000, bitbuf = 0;
106 int v, offset, count, segments;
108 segments = bytestream_get_le16(&src);
110 if (mask == 0x10000) {
113 bitbuf = bytestream_get_le16(&src);
116 if (src_end - src < 2 || frame_end - frame < 2)
119 v = bytestream_get_le16(&src);
120 offset = (v & 0x1FFF) << 1;
121 count = ((v >> 13) + 2) << 1;
122 if (frame - frame_start < offset || frame_end - frame < count)
125 for (v = 0; v < count; v++)
126 frame[v] = frame[v - offset];
128 }
else if (bitbuf & (mask << 1)) {
129 frame += bytestream_get_le16(&src);
141 const uint8_t *src,
const uint8_t *src_end)
143 const uint8_t *frame_start = frame;
144 const uint8_t *frame_end = frame + width *
height;
145 int mask = 0x10000, bitbuf = 0;
146 int i,
v, offset, count, segments;
148 segments = bytestream_get_le16(&src);
150 if (mask == 0x10000) {
153 bitbuf = bytestream_get_le16(&src);
156 if (src_end - src < 2 || frame_end - frame < 2)
159 v = bytestream_get_le16(&src);
160 offset = (v & 0x1FFF) << 2;
161 count = ((v >> 13) + 2) << 1;
162 if (frame - frame_start < offset || frame_end - frame < count*2 + width)
164 for (i = 0; i < count; i++) {
165 frame[0] = frame[1] =
166 frame[
width] = frame[width + 1] = frame[-offset];
170 }
else if (bitbuf & (mask << 1)) {
171 frame += bytestream_get_le16(&src) * 2;
173 frame[0] = frame[1] =
174 frame[
width] = frame[width + 1] = *src++;
176 frame[0] = frame[1] =
177 frame[
width] = frame[width + 1] = *src++;
187 const uint8_t *src,
const uint8_t *src_end)
190 int count, lines, segments;
192 count = bytestream_get_le16(&src);
195 frame += width * count;
196 lines = bytestream_get_le16(&src);
197 if (count + lines > height || src >= src_end)
205 if (src_end - src < 3)
207 if (frame - line_ptr <= *src)
210 count = (int8_t)*src++;
212 if (frame - line_ptr < count || src_end - src < count)
217 if (frame - line_ptr < count || src >= src_end)
219 memset(line_ptr, *src++, count);
229 const uint8_t *src,
const uint8_t *src_end)
231 const uint8_t *frame_end = frame + width *
height;
233 int count, i,
v, lines, segments;
235 lines = bytestream_get_le16(&src);
236 if (lines > height || src >= src_end)
240 segments = bytestream_get_le16(&src);
241 while ((segments & 0xC000) == 0xC000) {
242 unsigned delta = -((int16_t)segments * width);
243 if (frame_end - frame <= delta)
246 segments = bytestream_get_le16(&src);
248 if (segments & 0x8000) {
249 frame[width - 1] = segments & 0xFF;
250 segments = bytestream_get_le16(&src);
255 if (src_end - src < 2)
257 if (frame - line_ptr <= *src)
260 count = (int8_t)*src++;
262 if (frame - line_ptr < count*2 || src_end - src < count*2)
265 line_ptr += count * 2;
268 if (frame - line_ptr < count*2 || src_end - src < 2)
270 v = bytestream_get_le16(&src);
271 for (i = 0; i < count; i++)
272 bytestream_put_le16(&line_ptr, v);
281 const uint8_t *src,
const uint8_t *src_end)
287 const uint8_t *src,
const uint8_t *src_end)
289 memset(frame, 0, width * height);
295 const uint8_t *src,
const uint8_t *src_end);
303 "COPY",
"TSW1",
"BDLT",
"WDLT",
"????",
"DSW1",
"BLCK",
"DDS1"
307 void *
data,
int *data_size,
311 const uint8_t *buf = avpkt->
data;
312 const uint8_t *buf_end = avpkt->
data + avpkt->
size;
313 const uint8_t *tmp_buf;
314 uint32_t chunk_type, chunk_size;
327 while (buf < buf_end) {
331 if (buf_end - buf < chunk_size) {
337 if (chunk_type == 1) {
338 pal_elems =
FFMIN(chunk_size / 3, 256);
340 for (i = 0; i < pal_elems; i++) {
341 s->
pal[i] = bytestream_get_be24(&tmp_buf) << 2;
342 s->
pal[i] |= (s->
pal[i] >> 6) & 0x333;
345 }
else if (chunk_type <= 9) {
347 buf, buf + chunk_size)) {
361 for (i = 0; i < avctx->
height; i++) {
362 memcpy(dst, buf, avctx->
width);