50 unsigned int bytes_per_scanline,
53 unsigned char run, value;
56 while (i < bytes_per_scanline && src < end) {
59 if (value >= 0xc0 && src < end) {
63 while (i<bytes_per_scanline && run--)
67 memcpy(dst, src, bytes_per_scanline);
68 src += bytes_per_scanline;
77 for (i=0; i<pallen; i++)
78 *dst++ = bytestream_get_be24(src);
80 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
86 int buf_size = avpkt->
size;
90 int compressed, xmin, ymin, xmax, ymax;
91 unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
94 const uint8_t *buf_end = buf + buf_size;
99 if (buf[0] != 0x0a || buf[1] > 5) {
110 if (xmax < xmin || ymax < ymin) {
118 bits_per_pixel = buf[3];
119 bytes_per_line =
AV_RL16(buf+66);
121 bytes_per_scanline = nplanes * bytes_per_line;
123 if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
124 (!compressed && bytes_per_scanline > buf_size / h)) {
129 switch ((nplanes<<8) + bits_per_pixel) {
166 scanline =
av_malloc(bytes_per_scanline);
170 if (nplanes == 3 && bits_per_pixel == 8) {
171 for (y=0; y<h; y++) {
173 scanline, bytes_per_scanline, compressed);
175 for (x=0; x<w; x++) {
176 ptr[3*x ] = scanline[x ];
177 ptr[3*x+1] = scanline[x+ bytes_per_line ];
178 ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
184 }
else if (nplanes == 1 && bits_per_pixel == 8) {
185 const uint8_t *palstart = bufstart + buf_size - 769;
187 if (buf_size < 769) {
193 for (y = 0; y < h; y++, ptr +=
stride) {
195 scanline, bytes_per_scanline, compressed);
196 memcpy(ptr, scanline, w);
199 if (buf != palstart) {
209 }
else if (nplanes == 1) {
212 for (y=0; y<h; y++) {
216 scanline, bytes_per_scanline, compressed);
219 ptr[x] =
get_bits(&s, bits_per_pixel);
226 for (y=0; y<h; y++) {
228 scanline, bytes_per_scanline, compressed);
230 for (x=0; x<w; x++) {
231 int m = 0x80 >> (x&7), v = 0;
232 for (i=nplanes - 1; i>=0; i--) {
234 v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
242 if (nplanes == 1 && bits_per_pixel == 8) {
244 }
else if (bits_per_pixel < 8) {
245 const uint8_t *palette = bufstart+16;
252 ret = buf - bufstart;
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
packed RGB 8:8:8, 24bpp, RGBRGB...
AVFrame * coded_frame
the picture in the bitstream
static av_cold int pcx_init(AVCodecContext *avctx)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_cold int pcx_end(AVCodecContext *avctx)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
8 bit with PIX_FMT_RGB32 palette
bitstream reader API header.
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int init(AVCodecParserContext *s)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
struct PCXContext PCXContext
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const uint8_t * pcx_rle_decode(const uint8_t *src, const uint8_t *end, uint8_t *dst, unsigned int bytes_per_scanline, int compressed)
common internal api header.
static void pcx_palette(const uint8_t **src, uint32_t *dst, unsigned int pallen)
This structure stores compressed data.