48 const uint8_t *
src,
int src_plane_size,
int nplanes)
51 const uint8_t *dst_start =
dst;
54 if (dst_size < 2LL * src_plane_size * nplanes || src_plane_size <= 0)
57 for (p = 0; p < nplanes; p++) {
59 const uint8_t *src_plane =
src + p;
60 const uint8_t *src_plane_end = src_plane + src_plane_size * nplanes;
61 uint8_t prev = *src_plane;
64 for (; ; src_plane += nplanes) {
65 if (src_plane < src_plane_end && *src_plane == prev && count < 0x3F) {
70 if (count != 1 || prev >= 0xC0)
71 *
dst++ = 0xC0 | count;
74 if (src_plane == src_plane_end)
84 return dst - dst_start;
90 const uint8_t *buf_end;
93 int bpp, nplanes,
i, y, line_bytes, written, ret, max_pkt_size, sw, sh;
94 const uint32_t *pal =
NULL;
95 uint32_t palette256[256];
98 if (avctx->
width > 65535 || avctx->
height > 65535) {
121 pal = (uint32_t *)
frame->data[1];
133 line_bytes = (avctx->
width * bpp + 7) >> 3;
134 line_bytes = (line_bytes + 1) & ~1;
136 max_pkt_size = 128 + avctx->
height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0);
140 buf_end =
pkt->data +
pkt->size;
144 if (sw > 0xFFFFu || sh > 0xFFFFu)
147 bytestream_put_byte(&buf, 10);
148 bytestream_put_byte(&buf, 5);
149 bytestream_put_byte(&buf, 1);
150 bytestream_put_byte(&buf, bpp);
151 bytestream_put_le16(&buf, 0);
152 bytestream_put_le16(&buf, 0);
153 bytestream_put_le16(&buf, avctx->
width - 1);
154 bytestream_put_le16(&buf, avctx->
height - 1);
155 bytestream_put_le16(&buf, sw);
156 bytestream_put_le16(&buf, sh);
157 for (
i = 0;
i < 16;
i++)
158 bytestream_put_be24(&buf, pal ? pal[
i] : 0);
159 bytestream_put_byte(&buf, 0);
160 bytestream_put_byte(&buf, nplanes);
161 bytestream_put_le16(&buf, line_bytes);
163 while (buf -
pkt->data < 128)
168 for (y = 0; y < avctx->
height; y++) {
170 src, line_bytes, nplanes)) < 0) {
178 if (nplanes == 1 && bpp == 8) {
179 if (buf_end - buf < 257) {
183 bytestream_put_byte(&buf, 12);
184 for (
i = 0;
i < 256;
i++) {
185 bytestream_put_be24(&buf, pal[
i]);
189 pkt->size = buf -
pkt->data;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_pcx_encoder
Libavcodec external API header.
static const uint32_t monoblack_pal[]
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
static int pcx_rle_encode(uint8_t *dst, int dst_size, const uint8_t *src, int src_plane_size, int nplanes)
PCX run-length encoder.
static int pcx_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_RGB8
packed RGB 3:3:2, 8bpp, (msb)3R 3G 2B(lsb)
@ AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
@ AV_PIX_FMT_RGB4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
@ AV_PIX_FMT_BGR4_BYTE
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.