37 unsigned int bytes_per_scanline,
41 unsigned char run, value;
44 while (i < bytes_per_scanline && src < end) {
47 if (value >= 0xc0 && src < end) {
51 while (i < bytes_per_scanline && run--)
55 memcpy(dst, src, bytes_per_scanline);
56 src += bytes_per_scanline;
67 for (i = 0; i < pallen; i++)
68 *dst++ = bytestream_get_be24(src);
70 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
77 int buf_size = avpkt->
size;
79 int compressed, xmin, ymin, xmax, ymax;
80 unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
83 const uint8_t *buf_end = buf + buf_size;
88 if (buf[0] != 0x0a || buf[1] > 5) {
99 if (xmax < xmin || ymax < ymin) {
107 bits_per_pixel = buf[3];
108 bytes_per_line =
AV_RL16(buf + 66);
110 bytes_per_scanline = nplanes * bytes_per_line;
112 if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
113 (!compressed && bytes_per_scanline > buf_size / h)) {
118 switch ((nplanes << 8) + bits_per_pixel) {
151 scanline =
av_malloc(bytes_per_scanline);
155 if (nplanes == 3 && bits_per_pixel == 8) {
156 for (y = 0; y < h; y++) {
158 scanline, bytes_per_scanline, compressed);
160 for (x = 0; x < w; x++) {
161 ptr[3 * x] = scanline[x];
162 ptr[3 * x + 1] = scanline[x + bytes_per_line];
163 ptr[3 * x + 2] = scanline[x + (bytes_per_line << 1)];
168 }
else if (nplanes == 1 && bits_per_pixel == 8) {
169 const uint8_t *palstart = bufstart + buf_size - 769;
171 if (buf_size < 769) {
178 for (y = 0; y < h; y++, ptr +=
stride) {
180 scanline, bytes_per_scanline, compressed);
181 memcpy(ptr, scanline, w);
184 if (buf != palstart) {
194 }
else if (nplanes == 1) {
197 for (y = 0; y < h; y++) {
201 scanline, bytes_per_scanline, compressed);
203 for (x = 0; x < w; x++)
204 ptr[x] =
get_bits(&s, bits_per_pixel);
210 for (y = 0; y < h; y++) {
212 scanline, bytes_per_scanline, compressed);
214 for (x = 0; x < w; x++) {
215 int m = 0x80 >> (x & 7), v = 0;
216 for (i = nplanes - 1; i >= 0; i--) {
218 v += !!(scanline[i * bytes_per_line + (x >> 3)] & m);
226 if (nplanes == 1 && bits_per_pixel == 8) {
228 }
else if (bits_per_pixel < 8) {
229 const uint8_t *palette = bufstart + 16;
235 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 ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
8 bit with PIX_FMT_RGB32 palette
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
bitstream reader API header.
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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.