40 return line + interleave *
stride;
42 *y = (*y + 1) & (interleave - 1);
44 return start + *y *
stride;
56 int depth = (bpp + 1) >> 3;
65 "Ran ouf of data before end-of-image\n");
68 type = bytestream2_get_byteu(&s->
gb);
69 count = (type & 0x7F) + 1;
73 int n =
FFMIN(count, w - x);
80 dst = line =
advance_line(start, line, stride, &y, h, interleave);
82 }
while (dst && count > 0);
87 int n =
FFMIN(count, w - x);
91 memcpy(dst, tmp, depth);
96 dst = line =
advance_line(start, line, stride, &y, h, interleave);
98 }
while (dst && count > 0);
111 void *
data,
int *got_frame,
119 int idlen, pal, compr,
y, w, h, bpp,
flags, ret;
120 int first_clr, colors, csize;
126 idlen = bytestream2_get_byte(&s->
gb);
127 pal = bytestream2_get_byte(&s->
gb);
128 compr = bytestream2_get_byte(&s->
gb);
129 first_clr = bytestream2_get_le16(&s->
gb);
130 colors = bytestream2_get_le16(&s->
gb);
131 csize = bytestream2_get_byte(&s->
gb);
133 w = bytestream2_get_le16(&s->
gb);
134 h = bytestream2_get_le16(&s->
gb);
135 bpp = bytestream2_get_byte(&s->
gb);
139 "Not enough data to read header\n");
143 flags = bytestream2_get_byte(&s->
gb);
145 if (!pal && (first_clr || colors || csize)) {
148 first_clr = colors = csize = 0;
176 if (colors && (colors + first_clr) > 256) {
177 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
202 int pal_size, pal_sample_size;
205 case 32: pal_sample_size = 4;
break;
206 case 24: pal_sample_size = 3;
break;
208 case 15: pal_sample_size = 2;
break;
213 pal_size = colors * pal_sample_size;
218 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
222 "Not enough data to read palette\n");
225 switch (pal_sample_size) {
227 for (t = 0; t < colors; t++)
228 *pal++ = bytestream2_get_le32u(&s->
gb);
232 for (t = 0; t < colors; t++)
233 *pal++ = (0xffU<<24) | bytestream2_get_le24u(&s->
gb);
237 for (t = 0; t < colors; t++) {
238 uint32_t
v = bytestream2_get_le16u(&s->
gb);
239 v = ((v & 0x7C00) << 9) |
240 ((v & 0x03E0) << 6) |
243 v |= (v & 0xE0E0E0
U) >> 5;
244 *pal++ = (0xff
U<<24) | v;
260 size_t img_size = w * ((bpp + 1) >> 3);
264 "Not enough data available for image\n");
272 line =
advance_line(dst, line, stride, &y, h, interleave);
279 for (y = 0; y < h; y++) {
281 for (x = 0; x < w >> 1; x++) {
284 FFSWAP(uint32_t, ((uint32_t *)line)[x], ((uint32_t *)line)[w - x - 1]);
292 FFSWAP(uint16_t, ((uint16_t *)line)[x], ((uint16_t *)line)[w - x - 1]);