- CHECK_BUFFER_SIZE(buf, buf_end, 18, "header");
- idlen = *buf++;
- buf++; /* pal */
- compr = *buf++;
- first_clr = AV_RL16(buf); buf += 2;
- colors = AV_RL16(buf); buf += 2;
- csize = *buf++;
- buf += 2; /* x */
- y = AV_RL16(buf); buf += 2;
- w = AV_RL16(buf); buf += 2;
- h = AV_RL16(buf); buf += 2;
- bpp = *buf++;
- flags = *buf++;
- //skip identifier if any
- CHECK_BUFFER_SIZE(buf, buf_end, idlen, "identifiers");
- buf += idlen;
- s->bpp = bpp;
- s->width = w;
- s->height = h;
- switch(s->bpp){
+ idlen = bytestream2_get_byte(&s->gb);
+ bytestream2_skip(&s->gb, 1); /* pal */
+ compr = bytestream2_get_byte(&s->gb);
+ first_clr = bytestream2_get_le16(&s->gb);
+ colors = bytestream2_get_le16(&s->gb);
+ csize = bytestream2_get_byte(&s->gb);
+ bytestream2_skip(&s->gb, 4); /* 2: x, 2: y */
+ w = bytestream2_get_le16(&s->gb);
+ h = bytestream2_get_le16(&s->gb);
+ bpp = bytestream2_get_byte(&s->gb);
+ flags = bytestream2_get_byte(&s->gb);
+ // skip identifier if any
+ bytestream2_skip(&s->gb, idlen);
+
+ switch(bpp){