Go to the documentation of this file.
67 const AVFrame *pict,
int *got_packet)
70 int n_bytes_image, n_bytes_per_row, n_bytes,
i, n, hsize,
ret;
71 const uint32_t *pal =
NULL;
72 uint32_t palette256[256];
73 int pad_bytes_per_row, pal_entries = 0, compression =
BMP_RGB;
99 pal = (uint32_t *)p->
data[1];
105 if (pal && !pal_entries) pal_entries = 1 << bit_count;
107 pad_bytes_per_row = (4 - n_bytes_per_row) & 3;
108 n_bytes_image = avctx->
height * (n_bytes_per_row + pad_bytes_per_row);
112 #define SIZE_BITMAPFILEHEADER 14
113 #define SIZE_BITMAPINFOHEADER 40
115 n_bytes = n_bytes_image + hsize;
119 bytestream_put_byte(&buf,
'B');
120 bytestream_put_byte(&buf,
'M');
121 bytestream_put_le32(&buf, n_bytes);
122 bytestream_put_le16(&buf, 0);
123 bytestream_put_le16(&buf, 0);
124 bytestream_put_le32(&buf, hsize);
126 bytestream_put_le32(&buf, avctx->
width);
127 bytestream_put_le32(&buf, avctx->
height);
128 bytestream_put_le16(&buf, 1);
129 bytestream_put_le16(&buf, bit_count);
130 bytestream_put_le32(&buf, compression);
131 bytestream_put_le32(&buf, n_bytes_image);
132 bytestream_put_le32(&buf, 0);
133 bytestream_put_le32(&buf, 0);
134 bytestream_put_le32(&buf, 0);
135 bytestream_put_le32(&buf, 0);
136 for (
i = 0;
i < pal_entries;
i++)
137 bytestream_put_le32(&buf, pal[
i] & 0xFFFFFF);
141 for(
i = 0; i < avctx->
height;
i++) {
142 if (HAVE_BIGENDIAN && bit_count == 16) {
143 const uint16_t *
src = (
const uint16_t *) ptr;
144 for(n = 0; n < avctx->
width; n++)
147 memcpy(buf, ptr, n_bytes_per_row);
149 buf += n_bytes_per_row;
150 memset(buf, 0, pad_bytes_per_row);
151 buf += pad_bytes_per_row;
static const uint32_t rgb444_masks[]
AVPixelFormat
Pixel format.
const FFCodec ff_bmp_encoder
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...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec p
The public AVCodec.
#define FF_CODEC_ENCODE_CB(func)
#define SIZE_BITMAPINFOHEADER
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
static av_cold int bmp_encode_init(AVCodecContext *avctx)
static const uint32_t monoblack_pal[]
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
#define i(width, name, range_min, range_max)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define AV_PIX_FMT_RGB555
#define SIZE_BITMAPFILEHEADER
const char * name
Name of the codec implementation.
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
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
main external API structure.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static const uint32_t rgb565_masks[]
#define AV_PIX_FMT_RGB444