65 const uint8_t *frame_start = frame;
66 const uint8_t *frame_end = frame + width *
height;
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);
105 const uint8_t *frame_start = frame;
106 const uint8_t *frame_end = frame + width *
height;
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)
127 for (v = 0; v < count; v++)
128 frame[v] = frame[v - offset];
130 }
else if (bitbuf & (mask << 1)) {
131 frame += bytestream2_get_le16(gb);
133 *frame++ = bytestream2_get_byte(gb);
134 *frame++ = bytestream2_get_byte(gb);
144 const uint8_t *frame_start = frame;
145 const uint8_t *frame_end = frame + width *
height;
146 int mask = 0x10000, bitbuf = 0;
147 int i,
v, offset, count, segments;
149 segments = bytestream2_get_le16(gb);
153 if (mask == 0x10000) {
154 bitbuf = bytestream2_get_le16u(gb);
159 v = bytestream2_get_le16(gb);
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 v = bytestream2_get_le16(gb)*2;
172 if (frame - frame_end < v)
176 if (frame_end - frame < width + 3)
178 frame[0] = frame[1] =
179 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
181 frame[0] = frame[1] =
182 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
194 int count, lines, segments;
196 count = bytestream2_get_le16(gb);
199 frame += width * count;
200 lines = bytestream2_get_le16(gb);
201 if (count + lines > height)
209 segments = bytestream2_get_byteu(gb);
211 if (frame - line_ptr <= bytestream2_peek_byte(gb))
213 line_ptr += bytestream2_get_byte(gb);
214 count = (int8_t)bytestream2_get_byte(gb);
216 if (frame - line_ptr < count)
222 if (frame - line_ptr < count)
224 memset(line_ptr, bytestream2_get_byte(gb), count);
235 const uint8_t *frame_end = frame + width *
height;
237 int count, i,
v, lines, segments;
240 lines = bytestream2_get_le16(gb);
247 segments = bytestream2_get_le16u(gb);
248 while ((segments & 0xC000) == 0xC000) {
249 unsigned skip_lines = -(int16_t)segments;
250 unsigned delta = -((int16_t)segments * width);
251 if (frame_end - frame <= delta || y + lines + skip_lines > height)
255 segments = bytestream2_get_le16(gb);
257 if (segments & 0x8000) {
258 frame[width - 1] = segments & 0xFF;
259 segments = bytestream2_get_le16(gb);
262 if (frame_end - frame < width)
267 if (frame - line_ptr <= bytestream2_peek_byte(gb))
269 line_ptr += bytestream2_get_byte(gb);
270 count = (int8_t)bytestream2_get_byte(gb);
272 if (frame - line_ptr < count * 2)
276 line_ptr += count * 2;
279 if (frame - line_ptr < count * 2)
281 v = bytestream2_get_le16(gb);
282 for (i = 0; i < count; i++)
283 bytestream_put_le16(&line_ptr, v);
298 memset(frame, 0, width * height);
311 "COPY",
"TSW1",
"BDLT",
"WDLT",
"????",
"DSW1",
"BLCK",
"DDS1"
315 void *
data,
int *data_size,
320 const uint8_t *buf = avpkt->
data;
321 uint32_t chunk_type, chunk_size;
337 chunk_size = bytestream2_get_le32(&gb);
338 chunk_type = bytestream2_get_le32(&gb);
341 if (chunk_type == 1) {
342 pal_elems =
FFMIN(chunk_size / 3, 256);
343 for (i = 0; i < pal_elems; i++) {
344 s->
pal[i] = bytestream2_get_be24(&gb) << 2;
345 s->
pal[i] |= (s->
pal[i] >> 6) & 0x333;
348 }
else if (chunk_type <= 9) {
363 for (i = 0; i < avctx->
height; i++) {
364 memcpy(dst, buf, avctx->
width);