Go to the documentation of this file.
34 const uint8_t *buf = avpkt->
data;
35 int buf_size = avpkt->
size;
36 unsigned int fsize, hsize;
41 int i, j, n, linesize,
ret;
42 uint32_t
rgb[3] = {0};
46 const uint8_t *buf0 = buf;
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 + 14LL > hsize) {
83 "Declared file size is less than header size (%u < %u)\n",
94 width = bytestream_get_le32(&buf);
95 height = bytestream_get_le32(&buf);
98 width = bytestream_get_le16(&buf);
99 height = bytestream_get_le16(&buf);
108 if (bytestream_get_le16(&buf) != 1) {
113 depth = bytestream_get_le16(&buf);
116 comp = bytestream_get_le32(&buf);
128 rgb[0] = bytestream_get_le32(&buf);
129 rgb[1] = bytestream_get_le32(&buf);
130 rgb[2] = bytestream_get_le32(&buf);
132 alpha = bytestream_get_le32(&buf);
146 if (
rgb[0] == 0xFF000000 &&
rgb[1] == 0x00FF0000 &&
rgb[2] == 0x0000FF00)
148 else if (
rgb[0] == 0x00FF0000 &&
rgb[1] == 0x0000FF00 &&
rgb[2] == 0x000000FF)
150 else if (
rgb[0] == 0x0000FF00 &&
rgb[1] == 0x00FF0000 &&
rgb[2] == 0xFF000000)
152 else if (
rgb[0] == 0x000000FF &&
rgb[1] == 0x0000FF00 &&
rgb[2] == 0x00FF0000)
156 "%0"PRIX32
" %0"PRIX32
" %0"PRIX32
"\n",
rgb[0],
rgb[1],
rgb[2]);
170 if (
rgb[0] == 0xF800 &&
rgb[1] == 0x07E0 &&
rgb[2] == 0x001F)
172 else if (
rgb[0] == 0x7C00 &&
rgb[1] == 0x03E0 &&
rgb[2] == 0x001F)
174 else if (
rgb[0] == 0x0F00 &&
rgb[1] == 0x00F0 &&
rgb[2] == 0x000F)
178 "Unknown bitfields %0"PRIX32
" %0"PRIX32
" %0"PRIX32
"\n",
185 if (hsize - ihsize - 14 > 0)
192 if (hsize - ihsize - 14 > 0) {
216 dsize = buf_size - hsize;
219 n = ((avctx->
width * depth + 31) / 8) & ~3;
222 n = (avctx->
width * depth + 7) / 8;
223 if (n * avctx->
height > dsize) {
225 dsize, n * avctx->
height);
228 av_log(avctx,
AV_LOG_ERROR,
"data size too small, assuming missing line alignment\n");
244 int colors = 1 << depth;
246 memset(p->
data[1], 0, 1024);
251 t = bytestream_get_le32(&buf);
252 if (t < 0 || t > (1 << depth)) {
254 "Incorrect number of colors - %X for bitdepth %u\n",
260 colors =
FFMIN(256, (hsize-ihsize-14) / 3);
262 buf = buf0 + 14 + ihsize;
264 if ((hsize-ihsize-14) < (colors << 2)) {
265 if ((hsize-ihsize-14) < colors * 3) {
269 for (
i = 0;
i < colors;
i++)
270 ((uint32_t*)p->
data[1])[
i] = (0xFF
U<<24) | bytestream_get_le24(&buf);
272 for (
i = 0;
i < colors;
i++)
273 ((uint32_t*)p->
data[1])[
i] = 0xFFU << 24 | bytestream_get_le32(&buf);
293 for (j = 0; j < avctx->
width >> 3; j++) {
294 ptr[j*8+0] = buf[j] >> 7;
295 ptr[j*8+1] = (buf[j] >> 6) & 1;
296 ptr[j*8+2] = (buf[j] >> 5) & 1;
297 ptr[j*8+3] = (buf[j] >> 4) & 1;
298 ptr[j*8+4] = (buf[j] >> 3) & 1;
299 ptr[j*8+5] = (buf[j] >> 2) & 1;
300 ptr[j*8+6] = (buf[j] >> 1) & 1;
301 ptr[j*8+7] = buf[j] & 1;
303 for (j = 0; j < (avctx->
width & 7); j++) {
304 ptr[avctx->
width - (avctx->
width & 7) + j] = buf[avctx->
width >> 3] >> (7 - j) & 1;
322 for (j = 0; j < n; j++) {
323 ptr[j*2+0] = (buf[j] >> 4) & 0xF;
324 ptr[j*2+1] = buf[j] & 0xF;
332 const uint16_t *
src = (
const uint16_t *) buf;
333 uint16_t *dst = (uint16_t *) ptr;
335 for (j = 0; j < avctx->
width; j++)
351 for (j = 0; j < avctx->
width; j++) {
355 if (j < avctx->
width)
const FFCodec ff_bmp_decoder
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
This structure describes decoded (raw) audio or video data.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec p
The public AVCodec.
static int bmp_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define FF_CODEC_DECODE_CB(func)
static int64_t fsize(FILE *f)
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
enum AVPictureType pict_type
Picture type of the frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define i(width, name, range_min, range_max)
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_PIX_FMT_RGB565
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
main external API structure.
int ff_msrle_decode(AVCodecContext *avctx, AVFrame *pic, int depth, GetByteContext *gb)
Decode stream in MS RLE format into frame.
static const int16_t alpha[]
This structure stores compressed data.
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_PIX_FMT_RGB444