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;
61 if(bytestream_get_byte(&buf) !=
'B' ||
62 bytestream_get_byte(&buf) !=
'M') {
67 fsize = bytestream_get_le32(&buf);
77 hsize = bytestream_get_le32(&buf);
78 ihsize = bytestream_get_le32(&buf);
79 if(ihsize + 14 > hsize){
85 if(fsize == 14 || fsize == ihsize + 14)
99 width = bytestream_get_le32(&buf);
100 height = bytestream_get_le32(&buf);
103 width = bytestream_get_le16(&buf);
104 height = bytestream_get_le16(&buf);
111 if(bytestream_get_le16(&buf) != 1){
116 depth = bytestream_get_le16(&buf);
119 comp = bytestream_get_le32(&buf);
130 rgb[0] = bytestream_get_le32(&buf);
131 rgb[1] = bytestream_get_le32(&buf);
132 rgb[2] = bytestream_get_le32(&buf);
143 rgb[0] = (rgb[0] >> 15) & 3;
144 rgb[1] = (rgb[1] >> 15) & 3;
145 rgb[2] = (rgb[2] >> 15) & 3;
147 if(rgb[0] + rgb[1] + rgb[2] != 3 ||
148 rgb[0] == rgb[1] || rgb[0] == rgb[2] || rgb[1] == rgb[2]){
166 if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
168 else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
170 else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
173 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
179 if(hsize - ihsize - 14 > 0)
186 if(hsize - ihsize - 14 > 0){
215 dsize = buf_size - hsize;
222 dsize, n * avctx->
height);
239 int colors = 1 <<
depth;
241 memset(p->
data[1], 0, 1024);
246 t = bytestream_get_le32(&buf);
247 if(t < 0 || t > (1 << depth)){
248 av_log(avctx,
AV_LOG_ERROR,
"Incorrect number of colors - %X for bitdepth %d\n", t, depth);
253 buf = buf0 + 14 + ihsize;
254 if((hsize-ihsize-14) < (colors << 2)){
255 for(i = 0; i < colors; i++)
256 ((uint32_t*)p->
data[1])[i] = bytestream_get_le24(&buf);
258 for(i = 0; i < colors; i++)
259 ((uint32_t*)p->
data[1])[i] = bytestream_get_le32(&buf);
276 for (i = 0; i < avctx->
height; i++) {
278 for (j = 0; j < n; j++) {
279 ptr[j*8+0] = buf[j] >> 7;
280 ptr[j*8+1] = (buf[j] >> 6) & 1;
281 ptr[j*8+2] = (buf[j] >> 5) & 1;
282 ptr[j*8+3] = (buf[j] >> 4) & 1;
283 ptr[j*8+4] = (buf[j] >> 3) & 1;
284 ptr[j*8+5] = (buf[j] >> 2) & 1;
285 ptr[j*8+6] = (buf[j] >> 1) & 1;
286 ptr[j*8+7] = buf[j] & 1;
294 for(i = 0; i < avctx->
height; i++){
301 for(i = 0; i < avctx->
height; i++){
303 for(j = 0; j < n; j++){
304 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
305 ptr[j*2+1] = buf[j] & 0xF;
312 for(i = 0; i < avctx->
height; i++){
313 const uint16_t *src = (
const uint16_t *) buf;
314 uint16_t *dst = (uint16_t *) ptr;
316 for(j = 0; j < avctx->
width; j++)
324 for(i = 0; i < avctx->
height; i++){
325 const uint8_t *src = buf;
328 for(j = 0; j < avctx->
width; j++){
329 dst[0] = src[rgb[2]];
330 dst[1] = src[rgb[1]];
331 dst[2] = src[rgb[0]];