72 const AVFrame *pict,
int *got_packet)
76 int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize, ret;
77 const uint32_t *pal =
NULL;
78 uint32_t palette256[256];
79 int pad_bytes_per_row, pal_entries = 0, compression =
BMP_RGB;
106 pal = (uint32_t *)p->
data[1];
112 if (pal && !pal_entries) pal_entries = 1 << bit_count;
113 n_bytes_per_row = ((int64_t)avctx->
width * (int64_t)bit_count + 7LL) >> 3LL;
114 pad_bytes_per_row = (4 - n_bytes_per_row) & 3;
115 n_bytes_image = avctx->
height * (n_bytes_per_row + pad_bytes_per_row);
119 #define SIZE_BITMAPFILEHEADER 14
120 #define SIZE_BITMAPINFOHEADER 40
122 n_bytes = n_bytes_image + hsize;
126 bytestream_put_byte(&buf,
'B');
127 bytestream_put_byte(&buf,
'M');
128 bytestream_put_le32(&buf, n_bytes);
129 bytestream_put_le16(&buf, 0);
130 bytestream_put_le16(&buf, 0);
131 bytestream_put_le32(&buf, hsize);
133 bytestream_put_le32(&buf, avctx->
width);
134 bytestream_put_le32(&buf, avctx->
height);
135 bytestream_put_le16(&buf, 1);
136 bytestream_put_le16(&buf, bit_count);
137 bytestream_put_le32(&buf, compression);
138 bytestream_put_le32(&buf, n_bytes_image);
139 bytestream_put_le32(&buf, 0);
140 bytestream_put_le32(&buf, 0);
141 bytestream_put_le32(&buf, 0);
142 bytestream_put_le32(&buf, 0);
143 for (i = 0; i < pal_entries; i++)
144 bytestream_put_le32(&buf, pal[i] & 0xFFFFFF);
147 buf = pkt->
data + hsize;
148 for(i = 0; i < avctx->
height; i++) {
149 if (bit_count == 16) {
150 const uint16_t *src = (
const uint16_t *) ptr;
151 uint16_t *
dst = (uint16_t *) buf;
152 for(n = 0; n < avctx->
width; n++)
155 memcpy(buf, ptr, n_bytes_per_row);
157 buf += n_bytes_per_row;
158 memset(buf, 0, pad_bytes_per_row);
159 buf += pad_bytes_per_row;