60 const uint8_t *src,
int src_plane_size,
int nplanes)
66 if (dst_size < 2LL * src_plane_size * nplanes || src_plane_size <= 0)
69 for (p = 0; p < nplanes; p++) {
71 const uint8_t *src_plane = src + p;
72 const uint8_t *src_plane_end = src_plane + src_plane_size * nplanes;
76 for (; ; src_plane += nplanes) {
77 if (src_plane < src_plane_end && *src_plane == prev && count < 0x3F) {
82 if (count != 1 || prev >= 0xC0)
83 *dst++ = 0xC0 | count;
86 if (src_plane == src_plane_end)
96 return dst - dst_start;
100 const AVFrame *frame,
int *got_packet)
107 int bpp, nplanes, i, y, line_bytes, written, ret, max_pkt_size;
108 const uint32_t *pal =
NULL;
115 if (avctx->
width > 65535 || avctx->
height > 65535) {
133 pal = (uint32_t *)pict->
data[1];
145 line_bytes = (avctx->
width * bpp + 7) >> 3;
146 line_bytes = (line_bytes + 1) & ~1;
148 max_pkt_size = 128 + avctx->
height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0);
150 av_log(avctx,
AV_LOG_ERROR,
"Error getting output packet of size %d.\n", max_pkt_size);
156 bytestream_put_byte(&buf, 10);
157 bytestream_put_byte(&buf, 5);
158 bytestream_put_byte(&buf, 1);
159 bytestream_put_byte(&buf, bpp);
160 bytestream_put_le16(&buf, 0);
161 bytestream_put_le16(&buf, 0);
162 bytestream_put_le16(&buf, avctx->
width - 1);
163 bytestream_put_le16(&buf, avctx->
height - 1);
164 bytestream_put_le16(&buf, 0);
165 bytestream_put_le16(&buf, 0);
166 for (i = 0; i < 16; i++)
167 bytestream_put_be24(&buf, pal ? pal[i] : 0);
168 bytestream_put_byte(&buf, 0);
169 bytestream_put_byte(&buf, nplanes);
170 bytestream_put_le16(&buf, line_bytes);
172 while (buf - pkt->
data < 128)
177 for (y = 0; y < avctx->
height; y++) {
179 src, line_bytes, nplanes)) < 0) {
187 if (nplanes == 1 && bpp == 8) {
188 if (buf_end - buf < 257) {
192 bytestream_put_byte(&buf, 12);
193 for (i = 0; i < 256; i++) {
194 bytestream_put_be24(&buf, pal[i]);