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);
259 if (comp ==
BMP_RLE8 && height < 0) {
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++)
#define AVERROR_PATCHWELCOME
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)
packed RGB 8:8:8, 32bpp, RGB0RGB0...
packed BGR 8:8:8, 32bpp, 0BGR0BGR...
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
static double alpha(void *priv, double x, double y)
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.
packed BGR 8:8:8, 32bpp, BGR0BGR0...
#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.
main external API structure.
#define AV_PIX_FMT_RGB565
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
BYTE int const BYTE int int int height
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define AV_PIX_FMT_RGB444
common internal api header.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int ff_msrle_decode(AVCodecContext *avctx, AVPicture *pic, int depth, GetByteContext *gb)
Decode stream in MS RLE format into frame.
#define AVERROR_INVALIDDATA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int key_frame
1 -> keyframe, 0-> not
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
8 bit with PIX_FMT_RGB32 palette
packed RGB 8:8:8, 32bpp, 0RGB0RGB...
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.