61 const uint8_t *src,
int src_plane_size,
int nplanes)
67 if (dst_size < 2LL * src_plane_size * nplanes || src_plane_size <= 0)
70 for (p = 0; p < nplanes; p++) {
72 const uint8_t *src_plane = src + p;
73 const uint8_t *src_plane_end = src_plane + src_plane_size * nplanes;
77 for (; ; src_plane += nplanes) {
78 if (src_plane < src_plane_end && *src_plane == prev && count < 0x3F) {
83 if (count != 1 || prev >= 0xC0)
84 *dst++ = 0xC0 | count;
87 if (src_plane == src_plane_end)
97 return dst - dst_start;
108 int bpp, nplanes, i, y, line_bytes, written, ret, max_pkt_size, sw, sh;
109 const uint32_t *pal =
NULL;
110 uint32_t palette256[256];
117 if (avctx->
width > 65535 || avctx->
height > 65535) {
140 pal = (uint32_t *)pict->
data[1];
152 line_bytes = (avctx->
width * bpp + 7) >> 3;
153 line_bytes = (line_bytes + 1) & ~1;
155 max_pkt_size = 128 + avctx->
height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0);
163 if (sw > 0xFFFFu || sh > 0xFFFFu)
166 bytestream_put_byte(&buf, 10);
167 bytestream_put_byte(&buf, 5);
168 bytestream_put_byte(&buf, 1);
169 bytestream_put_byte(&buf, bpp);
170 bytestream_put_le16(&buf, 0);
171 bytestream_put_le16(&buf, 0);
172 bytestream_put_le16(&buf, avctx->
width - 1);
173 bytestream_put_le16(&buf, avctx->
height - 1);
174 bytestream_put_le16(&buf, sw);
175 bytestream_put_le16(&buf, sh);
176 for (i = 0; i < 16; i++)
177 bytestream_put_be24(&buf, pal ? pal[i] : 0);
178 bytestream_put_byte(&buf, 0);
179 bytestream_put_byte(&buf, nplanes);
180 bytestream_put_le16(&buf, line_bytes);
182 while (buf - pkt->
data < 128)
187 for (y = 0; y < avctx->
height; y++) {
189 src, line_bytes, nplanes)) < 0) {
197 if (nplanes == 1 && bpp == 8) {
198 if (buf_end - buf < 257) {
202 bytestream_put_byte(&buf, 12);
203 for (i = 0; i < 256; i++) {
204 bytestream_put_be24(&buf, pal[i]);