29 void *
data,
int *got_frame,
33 int buf_size = avpkt->
size;
35 unsigned int fsize, hsize;
40 int i, j,
n, linesize,
ret;
41 uint32_t rgb[3] = {0};
53 if (bytestream_get_byte(&buf) !=
'B' ||
54 bytestream_get_byte(&buf) !=
'M') {
59 fsize = bytestream_get_le32(&buf);
60 if (buf_size < fsize) {
69 hsize = bytestream_get_le32(&buf);
70 ihsize = bytestream_get_le32(&buf);
71 if (ihsize + 14 > hsize) {
77 if (fsize == 14 || fsize == ihsize + 14)
92 width = bytestream_get_le32(&buf);
93 height = bytestream_get_le32(&buf);
96 width = bytestream_get_le16(&buf);
97 height = bytestream_get_le16(&buf);
105 if (bytestream_get_le16(&buf) != 1) {
110 depth = bytestream_get_le16(&buf);
113 comp = bytestream_get_le32(&buf);
125 rgb[0] = bytestream_get_le32(&buf);
126 rgb[1] = bytestream_get_le32(&buf);
127 rgb[2] = bytestream_get_le32(&buf);
128 alpha = bytestream_get_le32(&buf);
139 if (rgb[0] == 0xFF000000 && rgb[1] == 0x00FF0000 && rgb[2] == 0x0000FF00)
141 else if (rgb[0] == 0x00FF0000 && rgb[1] == 0x0000FF00 && rgb[2] == 0x000000FF)
143 else if (rgb[0] == 0x0000FF00 && rgb[1] == 0x00FF0000 && rgb[2] == 0xFF000000)
145 else if (rgb[0] == 0x000000FF && rgb[1] == 0x0000FF00 && rgb[2] == 0x00FF0000)
148 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
162 if (rgb[0] == 0xF800 && rgb[1] == 0x07E0 && rgb[2] == 0x001F)
164 else if (rgb[0] == 0x7C00 && rgb[1] == 0x03E0 && rgb[2] == 0x001F)
166 else if (rgb[0] == 0x0F00 && rgb[1] == 0x00F0 && rgb[2] == 0x000F)
169 av_log(avctx,
AV_LOG_ERROR,
"Unknown bitfields %0X %0X %0X\n", rgb[0], rgb[1], rgb[2]);
175 if (hsize - ihsize - 14 > 0)
182 if (hsize - ihsize - 14 > 0) {
205 dsize = buf_size - hsize;
208 n = ((avctx->
width * depth + 31) / 8) & ~3;
212 dsize, n * avctx->
height);
229 int colors = 1 <<
depth;
231 memset(p->
data[1], 0, 1024);
236 t = bytestream_get_le32(&buf);
237 if (t < 0 || t > (1 << depth)) {
238 av_log(avctx,
AV_LOG_ERROR,
"Incorrect number of colors - %X for bitdepth %d\n", t, depth);
243 buf = buf0 + 14 + ihsize;
245 if ((hsize-ihsize-14) < (colors << 2)) {
246 if ((hsize-ihsize-14) < colors * 3) {
250 for (i = 0; i < colors; i++)
251 ((uint32_t*)p->
data[1])[i] = (0xFF
U<<24) | bytestream_get_le24(&buf);
253 for (i = 0; i < colors; i++)
254 ((uint32_t*)p->
data[1])[i] = 0xFFU << 24 | bytestream_get_le32(&buf);
272 for (i = 0; i < avctx->
height; i++) {
274 for (j = 0; j <
n; j++) {
275 ptr[j*8+0] = buf[j] >> 7;
276 ptr[j*8+1] = (buf[j] >> 6) & 1;
277 ptr[j*8+2] = (buf[j] >> 5) & 1;
278 ptr[j*8+3] = (buf[j] >> 4) & 1;
279 ptr[j*8+4] = (buf[j] >> 3) & 1;
280 ptr[j*8+5] = (buf[j] >> 2) & 1;
281 ptr[j*8+6] = (buf[j] >> 1) & 1;
282 ptr[j*8+7] = buf[j] & 1;
291 for (i = 0; i < avctx->
height; i++) {
298 for (i = 0; i < avctx->
height; i++) {
300 for (j = 0; j <
n; j++) {
301 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
302 ptr[j*2+1] = buf[j] & 0xF;
309 for (i = 0; i < avctx->
height; i++) {
310 const uint16_t *
src = (
const uint16_t *) buf;
311 uint16_t *dst = (uint16_t *) ptr;
313 for (j = 0; j < avctx->
width; j++)