23 #include "libavutil/imgutils.h"
24 #include "libavutil/avassert.h"
67 const AVFrame *pict,
int *got_packet)
69 int n_bytes_image, n_bytes_per_row, n_bytes, i,
n, hsize,
ret;
70 const uint32_t *pal = NULL;
71 uint32_t palette256[256];
72 int pad_bytes_per_row, pal_entries = 0, compression =
BMP_RGB;
100 pal = (uint32_t *)p->
data[1];
106 if (pal && !pal_entries) pal_entries = 1 << bit_count;
107 n_bytes_per_row = ((int64_t)avctx->
width * (int64_t)bit_count + 7LL) >> 3LL;
108 pad_bytes_per_row = (4 - n_bytes_per_row) & 3;
109 n_bytes_image = avctx->
height * (n_bytes_per_row + pad_bytes_per_row);
113 #define SIZE_BITMAPFILEHEADER 14
114 #define SIZE_BITMAPINFOHEADER 40
116 n_bytes = n_bytes_image + hsize;
120 bytestream_put_byte(&buf,
'B');
121 bytestream_put_byte(&buf,
'M');
122 bytestream_put_le32(&buf, n_bytes);
123 bytestream_put_le16(&buf, 0);
124 bytestream_put_le16(&buf, 0);
125 bytestream_put_le32(&buf, hsize);
127 bytestream_put_le32(&buf, avctx->
width);
128 bytestream_put_le32(&buf, avctx->
height);
129 bytestream_put_le16(&buf, 1);
130 bytestream_put_le16(&buf, bit_count);
131 bytestream_put_le32(&buf, compression);
132 bytestream_put_le32(&buf, n_bytes_image);
133 bytestream_put_le32(&buf, 0);
134 bytestream_put_le32(&buf, 0);
135 bytestream_put_le32(&buf, 0);
136 bytestream_put_le32(&buf, 0);
137 for (i = 0; i < pal_entries; i++)
138 bytestream_put_le32(&buf, pal[i] & 0xFFFFFF);
141 buf = pkt->
data + hsize;
142 for(i = 0; i < avctx->
height; i++) {
143 if (bit_count == 16) {
144 const uint16_t *
src = (
const uint16_t *) ptr;
145 uint16_t *dst = (uint16_t *) buf;
146 for(n = 0; n < avctx->
width; n++)
149 memcpy(buf, ptr, n_bytes_per_row);
151 buf += n_bytes_per_row;
152 memset(buf, 0, pad_bytes_per_row);
153 buf += pad_bytes_per_row;
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
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.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
#define SIZE_BITMAPINFOHEADER
static const uint32_t rgb565_masks[]
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AV_PIX_FMT_RGB555
const char * name
Name of the codec implementation.
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define SIZE_BITMAPFILEHEADER
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const uint32_t monoblack_pal[]
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
Libavcodec external API header.
AVPixelFormat
Pixel format.
int flags
A combination of AV_PKT_FLAG values.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
#define AV_LOG_INFO
Standard information.
static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
main external API structure.
#define AV_PIX_FMT_RGB565
static av_cold int bmp_encode_init(AVCodecContext *avctx)
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
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
common internal api header.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
int key_frame
1 -> keyframe, 0-> not
8 bit with PIX_FMT_RGB32 palette
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const uint32_t rgb444_masks[]