31 void *
data,
int *got_frame,
35 int buf_size = avpkt->
size;
37 unsigned int fsize, hsize;
42 int i, j, n, linesize, ret;
54 if (bytestream_get_byte(&buf) !=
'B' ||
55 bytestream_get_byte(&buf) !=
'M') {
60 fsize = bytestream_get_le32(&buf);
61 if (buf_size < fsize) {
70 hsize = bytestream_get_le32(&buf);
71 ihsize = bytestream_get_le32(&buf);
72 if (ihsize + 14 > hsize) {
78 if (fsize == 14 || fsize == ihsize + 14)
83 "Declared file size is less than header size (%u < %u)\n",
93 width = bytestream_get_le32(&buf);
94 height = bytestream_get_le32(&buf);
97 width = bytestream_get_le16(&buf);
98 height = bytestream_get_le16(&buf);
106 if (bytestream_get_le16(&buf) != 1) {
111 depth = bytestream_get_le16(&buf);
114 comp = bytestream_get_le32(&buf);
126 rgb[0] = bytestream_get_le32(&buf);
127 rgb[1] = bytestream_get_le32(&buf);
128 rgb[2] = bytestream_get_le32(&buf);
139 rgb[0] = (rgb[0] >> 15) & 3;
140 rgb[1] = (rgb[1] >> 15) & 3;
141 rgb[2] = (rgb[2] >> 15) & 3;
143 if (rgb[0] + rgb[1] + rgb[2] != 3 ||
144 rgb[0] == rgb[1] || rgb[0] == rgb[2] || 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)
170 "Unknown bitfields %0"PRIX32
" %0"PRIX32
" %0"PRIX32
"\n",
171 rgb[0], rgb[1], rgb[2]);
177 if (hsize - ihsize - 14 > 0)
184 if (hsize - ihsize - 14 > 0) {
210 dsize = buf_size - hsize;
213 n = ((avctx->
width * depth) / 8 + 3) & ~3;
217 dsize, n * avctx->
height);
234 int colors = 1 << depth;
236 memset(p->
data[1], 0, 1024);
241 t = bytestream_get_le32(&buf);
242 if (t < 0 || t > (1 << depth)) {
244 "Incorrect number of colors - %X for bitdepth %u\n",
250 buf = buf0 + 14 + ihsize;
252 if ((hsize-ihsize-14) < (colors << 2)) {
253 for (i = 0; i < colors; i++)
254 ((uint32_t*)p->
data[1])[i] = bytestream_get_le24(&buf);
256 for (i = 0; i < colors; i++)
257 ((uint32_t*)p->
data[1])[i] = bytestream_get_le32(&buf);
275 for (i = 0; i < avctx->
height; i++) {
277 for (j = 0; j < n; j++) {
278 ptr[j*8+0] = buf[j] >> 7;
279 ptr[j*8+1] = (buf[j] >> 6) & 1;
280 ptr[j*8+2] = (buf[j] >> 5) & 1;
281 ptr[j*8+3] = (buf[j] >> 4) & 1;
282 ptr[j*8+4] = (buf[j] >> 3) & 1;
283 ptr[j*8+5] = (buf[j] >> 2) & 1;
284 ptr[j*8+6] = (buf[j] >> 1) & 1;
285 ptr[j*8+7] = buf[j] & 1;
293 for (i = 0; i < avctx->
height; i++) {
300 for (i = 0; i < avctx->
height; i++) {
302 for (j = 0; j < n; j++) {
303 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
304 ptr[j*2+1] = buf[j] & 0xF;
311 for (i = 0; i < avctx->
height; i++) {
312 const uint16_t *src = (
const uint16_t *) buf;
313 uint16_t *dst = (uint16_t *) ptr;
315 for (j = 0; j < avctx->
width; j++)
323 for (i = 0; i < avctx->
height; i++) {
327 for (j = 0; j < avctx->
width; j++) {
328 dst[0] = src[rgb[2]];
329 dst[1] = src[rgb[1]];
330 dst[2] = src[rgb[0]];
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
four components are given, that's all.
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int bmp_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Libavcodec external API header.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
8 bit with PIX_FMT_RGB32 palette
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
#define AV_PIX_FMT_RGB555
main external API structure.
packed RGB 8:8:8, 24bpp, BGRBGR...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_PIX_FMT_RGB444
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define AV_PIX_FMT_RGB565
common internal api header.
int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic, int depth, GetByteContext *gb)
Decode stream in MS RLE format into frame.
int key_frame
1 -> keyframe, 0-> not
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.