49 unsigned int bytes_per_scanline,
52 unsigned char run, value;
55 while (i < bytes_per_scanline && src < end) {
58 if (value >= 0xc0 && src < end) {
62 while (i<bytes_per_scanline && run--)
66 memcpy(dst, src, bytes_per_scanline);
67 src += bytes_per_scanline;
73 static void pcx_palette(
const uint8_t **src, uint32_t *dst,
unsigned int pallen) {
76 for (i=0; i<pallen; i++)
77 *dst++ = bytestream_get_be24(src);
79 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
84 const uint8_t *buf = avpkt->
data;
85 int buf_size = avpkt->
size;
89 int compressed, xmin, ymin, xmax, ymax;
90 unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
93 const uint8_t *buf_end = buf + buf_size;
94 uint8_t
const *bufstart = buf;
98 if (buf[0] != 0x0a || buf[1] > 5) {
109 if (xmax < xmin || ymax < ymin) {
117 bits_per_pixel = buf[3];
118 bytes_per_line =
AV_RL16(buf+66);
120 bytes_per_scanline = nplanes * bytes_per_line;
122 if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8 ||
123 (!compressed && bytes_per_scanline > buf_size / h)) {
128 switch ((nplanes<<8) + bits_per_pixel) {
165 scanline =
av_malloc(bytes_per_scanline);
169 if (nplanes == 3 && bits_per_pixel == 8) {
170 for (y=0; y<h; y++) {
172 scanline, bytes_per_scanline, compressed);
174 for (x=0; x<w; x++) {
175 ptr[3*x ] = scanline[x ];
176 ptr[3*x+1] = scanline[x+ bytes_per_line ];
177 ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
183 }
else if (nplanes == 1 && bits_per_pixel == 8) {
184 const uint8_t *palstart = bufstart + buf_size - 769;
186 if (buf_size < 769) {
192 for (y = 0; y < h; y++, ptr +=
stride) {
194 scanline, bytes_per_scanline, compressed);
195 memcpy(ptr, scanline, w);
198 if (buf != palstart) {
208 }
else if (nplanes == 1) {
211 for (y=0; y<h; y++) {
215 scanline, bytes_per_scanline, compressed);
218 ptr[x] =
get_bits(&s, bits_per_pixel);
225 for (y=0; y<h; y++) {
227 scanline, bytes_per_scanline, compressed);
229 for (x=0; x<w; x++) {
230 int m = 0x80 >> (x&7),
v = 0;
231 for (i=nplanes - 1; i>=0; i--) {
233 v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
241 if (nplanes == 1 && bits_per_pixel == 8) {
243 }
else if (bits_per_pixel < 8) {
244 const uint8_t *
palette = bufstart+16;
251 ret = buf - bufstart;
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
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.
AVFrame * coded_frame
the picture in the bitstream
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold int pcx_init(AVCodecContext *avctx)
static av_cold int pcx_end(AVCodecContext *avctx)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
bitstream reader API header.
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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.
struct AVFrame AVFrame
Audio Video 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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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)
static void pcx_palette(const uint8_t **src, uint32_t *dst, unsigned int pallen)
8 bit with PIX_FMT_RGB32 palette
packed RGB 8:8:8, 24bpp, RGBRGB...
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.