71 const AVFrame *pict,
int *got_packet)
74 int n_bytes_image, n_bytes_per_row, n_bytes, i,
n, hsize,
ret;
75 const uint32_t *pal =
NULL;
76 uint32_t palette256[256];
77 int pad_bytes_per_row, pal_entries = 0, compression =
BMP_RGB;
104 pal = (uint32_t *)p->
data[1];
110 if (pal && !pal_entries) pal_entries = 1 << bit_count;
111 n_bytes_per_row = ((int64_t)avctx->
width * (int64_t)bit_count + 7LL) >> 3LL;
112 pad_bytes_per_row = (4 - n_bytes_per_row) & 3;
113 n_bytes_image = avctx->
height * (n_bytes_per_row + pad_bytes_per_row);
117 #define SIZE_BITMAPFILEHEADER 14
118 #define SIZE_BITMAPINFOHEADER 40
120 n_bytes = n_bytes_image + hsize;
124 bytestream_put_byte(&buf,
'B');
125 bytestream_put_byte(&buf,
'M');
126 bytestream_put_le32(&buf, n_bytes);
127 bytestream_put_le16(&buf, 0);
128 bytestream_put_le16(&buf, 0);
129 bytestream_put_le32(&buf, hsize);
131 bytestream_put_le32(&buf, avctx->
width);
132 bytestream_put_le32(&buf, avctx->
height);
133 bytestream_put_le16(&buf, 1);
134 bytestream_put_le16(&buf, bit_count);
135 bytestream_put_le32(&buf, compression);
136 bytestream_put_le32(&buf, n_bytes_image);
137 bytestream_put_le32(&buf, 0);
138 bytestream_put_le32(&buf, 0);
139 bytestream_put_le32(&buf, 0);
140 bytestream_put_le32(&buf, 0);
141 for (i = 0; i < pal_entries; i++)
142 bytestream_put_le32(&buf, pal[i] & 0xFFFFFF);
145 buf = pkt->
data + hsize;
146 for(i = 0; i < avctx->
height; i++) {
147 if (bit_count == 16) {
148 const uint16_t *
src = (
const uint16_t *) ptr;
149 uint16_t *dst = (uint16_t *) buf;
150 for(n = 0; n < avctx->
width; n++)
153 memcpy(buf, ptr, n_bytes_per_row);
155 buf += n_bytes_per_row;
156 memset(buf, 0, pad_bytes_per_row);
157 buf += pad_bytes_per_row;