59 const uint8_t *src,
int src_plane_size,
int nplanes)
62 const uint8_t *dst_start = dst;
65 if (dst_size < 2LL * src_plane_size * nplanes || src_plane_size <= 0)
68 for (p = 0; p < nplanes; p++) {
70 const uint8_t *src_plane = src + p;
71 const uint8_t *src_plane_end = src_plane + src_plane_size * nplanes;
72 uint8_t prev = *src_plane;
75 for (; ; src_plane += nplanes) {
76 if (src_plane < src_plane_end && *src_plane == prev && count < 0x3F) {
81 if (count != 1 || prev >= 0xC0)
82 *dst++ = 0xC0 | count;
85 if (src_plane == src_plane_end)
95 return dst - dst_start;
99 unsigned char *buf,
int buf_size,
void *
data)
103 const uint8_t *buf_start = buf;
104 const uint8_t *buf_end = buf + buf_size;
106 int bpp, nplanes, i, y, line_bytes, written;
107 const uint32_t *pal =
NULL;
114 if (avctx->
width > 65535 || avctx->
height > 65535) {
132 pal = (uint32_t *)pict->
data[1];
144 line_bytes = (avctx->
width * bpp + 7) >> 3;
145 line_bytes = (line_bytes + 1) & ~1;
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, 0);
156 bytestream_put_le16(&buf, 0);
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 - buf_start < 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 return buf - buf_start;
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
AVFrame * coded_frame
the picture in the bitstream
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb...
static int init(AVCodecParserContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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.
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int pcx_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
struct PCXContext PCXContext
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
8 bit with PIX_FMT_RGB32 palette
packed RGB 8:8:8, 24bpp, RGBRGB...
int key_frame
1 -> keyframe, 0-> not
static const uint32_t monoblack_pal[16]
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
static av_cold int pcx_encode_init(AVCodecContext *avctx)