37 void *
data,
int *data_size,
40 const uint8_t *buf = avpkt->
data;
41 int buf_size = avpkt->
size;
45 unsigned int fsize, hsize;
50 int i, j, n, linesize;
54 const uint8_t *buf0 = buf;
62 if(bytestream_get_byte(&buf) !=
'B' ||
63 bytestream_get_byte(&buf) !=
'M') {
68 fsize = bytestream_get_le32(&buf);
78 hsize = bytestream_get_le32(&buf);
79 ihsize = bytestream_get_le32(&buf);
80 if(ihsize + 14 > hsize){
86 if(fsize == 14 || fsize == ihsize + 14)
100 width = bytestream_get_le32(&buf);
101 height = bytestream_get_le32(&buf);
104 width = bytestream_get_le16(&buf);
105 height = bytestream_get_le16(&buf);
112 if(bytestream_get_le16(&buf) != 1){
117 depth = bytestream_get_le16(&buf);
120 comp = bytestream_get_le32(&buf);
131 rgb[0] = bytestream_get_le32(&buf);
132 rgb[1] = bytestream_get_le32(&buf);
133 rgb[2] = bytestream_get_le32(&buf);
144 rgb[0] = (rgb[0] >> 15) & 3;
145 rgb[1] = (rgb[1] >> 15) & 3;
146 rgb[2] = (rgb[2] >> 15) & 3;
148 if(rgb[0] + rgb[1] + rgb[2] != 3 ||
149 rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
167 if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
169 else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
171 else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
174 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
180 if(hsize - ihsize - 14 > 0)
187 if(hsize - ihsize - 14 > 0){
216 dsize = buf_size - hsize;
223 dsize, n * avctx->
height);
240 int colors = 1 <<
depth;
242 memset(p->
data[1], 0, 1024);
247 t = bytestream_get_le32(&buf);
248 if(t < 0 || t > (1 << depth)){
249 av_log(avctx,
AV_LOG_ERROR,
"Incorrect number of colors - %X for bitdepth %d\n", t, depth);
254 buf = buf0 + 14 + ihsize;
255 if((hsize-ihsize-14) < (colors << 2)){
256 for(i = 0; i < colors; i++)
257 ((uint32_t*)p->
data[1])[i] = bytestream_get_le24(&buf);
259 for(i = 0; i < colors; i++)
260 ((uint32_t*)p->
data[1])[i] = bytestream_get_le32(&buf);
278 for (i = 0; i < avctx->
height; i++) {
280 for (j = 0; j < n; j++) {
281 ptr[j*8+0] = buf[j] >> 7;
282 ptr[j*8+1] = (buf[j] >> 6) & 1;
283 ptr[j*8+2] = (buf[j] >> 5) & 1;
284 ptr[j*8+3] = (buf[j] >> 4) & 1;
285 ptr[j*8+4] = (buf[j] >> 3) & 1;
286 ptr[j*8+5] = (buf[j] >> 2) & 1;
287 ptr[j*8+6] = (buf[j] >> 1) & 1;
288 ptr[j*8+7] = buf[j] & 1;
296 for(i = 0; i < avctx->
height; i++){
303 for(i = 0; i < avctx->
height; i++){
305 for(j = 0; j < n; j++){
306 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
307 ptr[j*2+1] = buf[j] & 0xF;
314 for(i = 0; i < avctx->
height; i++){
315 const uint16_t *src = (
const uint16_t *) buf;
316 uint16_t *dst = (uint16_t *) ptr;
318 for(j = 0; j < avctx->
width; j++)
326 for(i = 0; i < avctx->
height; i++){
327 const uint8_t *src = buf;
330 for(j = 0; j < avctx->
width; j++){
331 dst[0] = src[rgb[2]];
332 dst[1] = src[rgb[1]];
333 dst[2] = src[rgb[0]];