39 void *
data,
int *got_frame,
43 int buf_size = avpkt->
size;
47 unsigned int fsize, hsize;
52 int i, j, n, linesize, ret;
53 uint32_t rgb[3] = {0};
65 if (bytestream_get_byte(&buf) !=
'B' ||
66 bytestream_get_byte(&buf) !=
'M') {
71 fsize = bytestream_get_le32(&buf);
72 if (buf_size < fsize) {
81 hsize = bytestream_get_le32(&buf);
82 ihsize = bytestream_get_le32(&buf);
83 if (ihsize + 14 > hsize) {
89 if (fsize == 14 || fsize == ihsize + 14)
104 width = bytestream_get_le32(&buf);
105 height = bytestream_get_le32(&buf);
108 width = bytestream_get_le16(&buf);
109 height = bytestream_get_le16(&buf);
117 if (bytestream_get_le16(&buf) != 1) {
122 depth = bytestream_get_le16(&buf);
125 comp = bytestream_get_le32(&buf);
137 rgb[0] = bytestream_get_le32(&buf);
138 rgb[1] = bytestream_get_le32(&buf);
139 rgb[2] = bytestream_get_le32(&buf);
140 alpha = bytestream_get_le32(&buf);
151 if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00)
153 else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF)
155 else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000)
157 else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000)
160 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
174 if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
176 else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
178 else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
181 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
187 if (hsize - ihsize - 14 > 0)
194 if (hsize - ihsize - 14 > 0) {
223 dsize = buf_size - hsize;
226 n = ((avctx->
width * depth + 31) / 8) & ~3;
230 dsize, n * avctx->
height);
247 int colors = 1 <<
depth;
249 memset(p->
data[1], 0, 1024);
254 t = bytestream_get_le32(&buf);
255 if (t < 0 || t > (1 << depth)) {
256 av_log(avctx,
AV_LOG_ERROR,
"Incorrect number of colors - %X for bitdepth %d\n", t, depth);
261 buf = buf0 + 14 + ihsize;
263 if ((hsize-ihsize-14) < (colors << 2)) {
264 if ((hsize-ihsize-14) < colors * 3) {
268 for (i = 0; i < colors; i++)
269 ((uint32_t*)p->
data[1])[i] = (0xFF
U<<24) | bytestream_get_le24(&buf);
271 for (i = 0; i < colors; i++)
272 ((uint32_t*)p->
data[1])[i] = 0xFFU << 24 | bytestream_get_le32(&buf);
290 for (i = 0; i < avctx->
height; i++) {
292 for (j = 0; j < n; j++) {
293 ptr[j*8+0] = buf[j] >> 7;
294 ptr[j*8+1] = (buf[j] >> 6) & 1;
295 ptr[j*8+2] = (buf[j] >> 5) & 1;
296 ptr[j*8+3] = (buf[j] >> 4) & 1;
297 ptr[j*8+4] = (buf[j] >> 3) & 1;
298 ptr[j*8+5] = (buf[j] >> 2) & 1;
299 ptr[j*8+6] = (buf[j] >> 1) & 1;
300 ptr[j*8+7] = buf[j] & 1;
309 for (i = 0; i < avctx->
height; i++) {
316 for (i = 0; i < avctx->
height; i++) {
318 for (j = 0; j < n; j++) {
319 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
320 ptr[j*2+1] = buf[j] & 0xF;
327 for (i = 0; i < avctx->
height; i++) {
328 const uint16_t *src = (
const uint16_t *) buf;
329 uint16_t *
dst = (uint16_t *) ptr;
331 for (j = 0; j < avctx->
width; j++)