39 if (count != 1 ||
value >= 0xC0)
40 *
dst++ = 0xC0 | count;
57 const uint8_t *
src,
int src_plane_size,
int nplanes)
60 const uint8_t *dst_start =
dst;
61 int pad = src_plane_size & 1;
64 if (dst_size < 2LL * (src_plane_size + pad) * nplanes || src_plane_size <= 0)
67 for (p = 0; p < nplanes; p++) {
68 int count = 1,
i, zero_pad = pad;
69 const uint8_t *src_plane =
src + p;
70 uint8_t prev = *src_plane;
72 for (
i = 1;
i < src_plane_size;
i++) {
73 uint8_t cur = src_plane[
i * nplanes];
75 if (cur == prev && count < 0x3F) {
83 if (zero_pad && !prev && count < 0x3F) {
92 return dst - dst_start;
98 const uint8_t *buf_end;
101 int bpp, nplanes,
i, y, line_bytes, src_plane_size, written,
ret, max_pkt_size, sw, sh;
102 const uint32_t *pal =
NULL;
103 uint32_t palette256[256];
106 if (avctx->
width > 65535 || avctx->
height > 65535) {
129 pal = (uint32_t *)
frame->data[1];
141 src_plane_size = (avctx->
width * bpp + 7) >> 3;
142 line_bytes = (src_plane_size + 1) & ~1;
144 max_pkt_size = 128 + avctx->
height * 2 * line_bytes * nplanes + (pal ? 256*3 + 1 : 0);
148 buf_end =
pkt->data +
pkt->size;
152 if (sw > 0xFFFFu || sh > 0xFFFFu)
155 bytestream_put_byte(&buf, 10);
156 bytestream_put_byte(&buf, 5);
157 bytestream_put_byte(&buf, 1);
158 bytestream_put_byte(&buf, bpp);
159 bytestream_put_le16(&buf, 0);
160 bytestream_put_le16(&buf, 0);
161 bytestream_put_le16(&buf, avctx->
width - 1);
162 bytestream_put_le16(&buf, avctx->
height - 1);
163 bytestream_put_le16(&buf, sw);
164 bytestream_put_le16(&buf, sh);
165 for (
i = 0;
i < 16;
i++)
166 bytestream_put_be24(&buf, pal ? pal[
i] : 0);
167 bytestream_put_byte(&buf, 0);
168 bytestream_put_byte(&buf, nplanes);
169 bytestream_put_le16(&buf, line_bytes);
171 while (buf -
pkt->data < 128)
176 for (y = 0; y < avctx->
height; y++) {
178 src, src_plane_size, nplanes)) < 0) {
186 if (nplanes == 1 && bpp == 8) {
187 if (buf_end - buf < 257) {
191 bytestream_put_byte(&buf, 12);
192 for (
i = 0;
i < 256;
i++) {
193 bytestream_put_be24(&buf, pal[
i]);
197 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)
static uint8_t * put_run(uint8_t *dst, uint8_t value, int count)
@ 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.