64 const uint8_t *frame_start = frame;
65 const uint8_t *frame_end = frame + width *
height;
66 int mask = 0x10000, bitbuf = 0;
67 int v, count, segments;
70 segments = bytestream2_get_le32(gb);
71 offset = bytestream2_get_le32(gb);
72 if (frame_end - frame <= offset)
78 if (mask == 0x10000) {
79 bitbuf = bytestream2_get_le16u(gb);
82 if (frame_end - frame < 2)
85 v = bytestream2_get_le16(gb);
86 offset = (v & 0x1FFF) << 1;
87 count = ((v >> 13) + 2) << 1;
88 if (frame - frame_start < offset || frame_end - frame < count)
93 *frame++ = bytestream2_get_byte(gb);
94 *frame++ = bytestream2_get_byte(gb);
104 const uint8_t *frame_start = frame;
105 const uint8_t *frame_end = frame + width *
height;
106 int mask = 0x10000, bitbuf = 0;
107 int v, offset, count, segments;
109 segments = bytestream2_get_le16(gb);
113 if (mask == 0x10000) {
114 bitbuf = bytestream2_get_le16u(gb);
117 if (frame_end - frame < 2)
120 v = bytestream2_get_le16(gb);
121 offset = (v & 0x1FFF) << 1;
122 count = ((v >> 13) + 2) << 1;
123 if (frame - frame_start < offset || frame_end - frame < count)
126 for (v = 0; v < count; v++)
127 frame[v] = frame[v - offset];
129 }
else if (bitbuf & (mask << 1)) {
130 frame += bytestream2_get_le16(gb);
132 *frame++ = bytestream2_get_byte(gb);
133 *frame++ = bytestream2_get_byte(gb);
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 = bytestream2_get_le16(gb);
152 if (mask == 0x10000) {
153 bitbuf = bytestream2_get_le16u(gb);
158 v = bytestream2_get_le16(gb);
159 offset = (v & 0x1FFF) << 2;
160 count = ((v >> 13) + 2) << 1;
161 if (frame - frame_start < offset || frame_end - frame < count*2 + width)
163 for (i = 0; i < count; i++) {
164 frame[0] = frame[1] =
165 frame[
width] = frame[width + 1] = frame[-offset];
169 }
else if (bitbuf & (mask << 1)) {
170 v = bytestream2_get_le16(gb)*2;
171 if (frame - frame_end < v)
175 if (frame_end - frame < width + 3)
177 frame[0] = frame[1] =
178 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
180 frame[0] = frame[1] =
181 frame[
width] = frame[width + 1] = bytestream2_get_byte(gb);
193 int count, lines, segments;
195 count = bytestream2_get_le16(gb);
198 frame += width * count;
199 lines = bytestream2_get_le16(gb);
200 if (count + lines > height)
208 segments = bytestream2_get_byteu(gb);
210 if (frame - line_ptr <= bytestream2_peek_byte(gb))
212 line_ptr += bytestream2_get_byte(gb);
213 count = (int8_t)bytestream2_get_byte(gb);
215 if (frame - line_ptr < count)
221 if (frame - line_ptr < count)
223 memset(line_ptr, bytestream2_get_byte(gb), count);
234 const uint8_t *frame_end = frame + width *
height;
236 int count, i,
v, lines, segments;
239 lines = bytestream2_get_le16(gb);
246 segments = bytestream2_get_le16u(gb);
247 while ((segments & 0xC000) == 0xC000) {
248 unsigned skip_lines = -(int16_t)segments;
249 unsigned delta = -((int16_t)segments * width);
250 if (frame_end - frame <= delta || y + lines + skip_lines > height)
254 segments = bytestream2_get_le16(gb);
256 if (segments & 0x8000) {
257 frame[width - 1] = segments & 0xFF;
258 segments = bytestream2_get_le16(gb);
264 if (frame - line_ptr <= bytestream2_peek_byte(gb))
266 line_ptr += bytestream2_get_byte(gb);
267 count = (int8_t)bytestream2_get_byte(gb);
269 if (frame - line_ptr < count * 2)
273 line_ptr += count * 2;
276 if (frame - line_ptr < count * 2)
278 v = bytestream2_get_le16(gb);
279 for (i = 0; i < count; i++)
280 bytestream_put_le16(&line_ptr, v);
295 memset(frame, 0, width * height);
308 "COPY",
"TSW1",
"BDLT",
"WDLT",
"????",
"DSW1",
"BLCK",
"DDS1"
312 void *
data,
int *data_size,
317 const uint8_t *buf = avpkt->
data;
318 uint32_t chunk_type, chunk_size;
334 chunk_size = bytestream2_get_le32(&gb);
335 chunk_type = bytestream2_get_le32(&gb);
338 if (chunk_type == 1) {
339 pal_elems =
FFMIN(chunk_size / 3, 256);
340 for (i = 0; i < pal_elems; i++) {
341 s->
pal[i] = bytestream2_get_be24(&gb) << 2;
342 s->
pal[i] |= (s->
pal[i] >> 6) & 0x333;
345 }
else if (chunk_type <= 9) {
360 for (i = 0; i < avctx->
height; i++) {
361 memcpy(dst, buf, avctx->
width);