37 #define CHECK_BUFFER_SIZE(buf, buf_end, needed, where) \
38 if(needed > buf_end - buf){ \
39 av_log(avctx, AV_LOG_ERROR, "Problem: unexpected end of data while reading " where "\n"); \
46 int depth = (bpp + 1) >> 3;
49 const uint8_t *src_end = src + src_size;
51 diff = stride - w *
depth;
56 count = (type & 0x7F) + 1;
58 if((x + count > w) && (x + count + 1 > (h - y) * w)){
59 av_log(avctx,
AV_LOG_ERROR,
"Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);
67 for(i = 0; i < count; i++){
73 *((uint16_t*)dst) =
AV_RL16(src);
81 *((uint32_t*)dst) =
AV_RL32(src);
102 void *
data,
int *data_size,
105 const uint8_t *buf = avpkt->
data;
106 const uint8_t *buf_end = avpkt->
data + avpkt->
size;
112 int idlen, compr, y, w, h, bpp,
flags;
113 int first_clr, colors, csize;
120 first_clr =
AV_RL16(buf); buf += 2;
121 colors =
AV_RL16(buf); buf += 2;
176 int pal_size, pal_sample_size;
177 if((colors + first_clr) > 256){
178 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
182 case 24: pal_sample_size = 3;
break;
184 case 15: pal_sample_size = 2;
break;
189 pal_size = colors * pal_sample_size;
195 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
197 switch (pal_sample_size) {
200 for (t = 0; t < colors; t++)
201 *pal++ = bytestream_get_le24(&buf);
205 for (t = 0; t < colors; t++) {
206 uint32_t
v = bytestream_get_le16(&buf);
207 v = ((v & 0x7C00) << 9) |
208 ((v & 0x03E0) << 6) |
211 v |= (v & 0xE0E0E0
U) >> 5;
228 size_t img_size = s->
width * ((s->
bpp + 1) >> 3);
230 for(y = 0; y < s->
height; y++){
233 if((s->
bpp + 1) >> 3 == 2){
234 uint16_t *dst16 = (uint16_t*)dst;
235 for(x = 0; x < s->
width; x++)
236 dst16[x] =
AV_RL16(buf + x * 2);
237 }
else if((s->
bpp + 1) >> 3 == 4){
238 uint32_t *dst32 = (uint32_t*)dst;
239 for(x = 0; x < s->
width; x++)
240 dst32[x] =
AV_RL32(buf + x * 4);
243 memcpy(dst, buf, img_size);