31 #define PCX_HEADER_SIZE 128
35 unsigned int bytes_per_scanline,
47 value = bytestream2_get_byte(gb);
50 value = bytestream2_get_byte(gb);
52 while (i < bytes_per_scanline && run--)
66 for (i = 0; i < pallen; i++)
67 *dst++ = 0xFF000000 | bytestream2_get_be24u(gb);
69 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
77 int compressed, xmin, ymin, xmax, ymax;
79 unsigned int w,
h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
90 if (bytestream2_get_byteu(&gb) != 0x0a || bytestream2_get_byteu(&gb) > 5) {
95 compressed = bytestream2_get_byteu(&gb);
96 bits_per_pixel = bytestream2_get_byteu(&gb);
97 xmin = bytestream2_get_le16u(&gb);
98 ymin = bytestream2_get_le16u(&gb);
99 xmax = bytestream2_get_le16u(&gb);
100 ymax = bytestream2_get_le16u(&gb);
104 if (xmax < xmin || ymax < ymin) {
113 nplanes = bytestream2_get_byteu(&gb);
114 bytes_per_line = bytestream2_get_le16u(&gb);
115 bytes_per_scanline = nplanes * bytes_per_line;
117 if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
123 switch ((nplanes << 8) + bits_per_pixel) {
158 if (nplanes == 3 && bits_per_pixel == 8) {
159 for (y = 0; y <
h; y++) {
160 ret =
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
164 for (x = 0; x <
w; x++) {
165 ptr[3 * x] = scanline[x];
166 ptr[3 * x + 1] = scanline[x + bytes_per_line];
167 ptr[3 * x + 2] = scanline[x + (bytes_per_line << 1)];
172 }
else if (nplanes == 1 && bits_per_pixel == 8) {
173 int palstart = avpkt->
size - 769;
175 if (avpkt->
size < 769) {
182 for (y = 0; y <
h; y++, ptr +=
stride) {
183 ret =
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
186 memcpy(ptr, scanline, w);
193 if (bytestream2_get_byte(&gb) != 12) {
199 }
else if (nplanes == 1) {
202 for (y = 0; y <
h; y++) {
205 ret =
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
209 for (x = 0; x <
w; x++)
210 ptr[x] =
get_bits(&s, bits_per_pixel);
216 for (y = 0; y <
h; y++) {
217 ret =
pcx_rle_decode(&gb, scanline, bytes_per_scanline, compressed);
221 for (x = 0; x <
w; x++) {
222 int m = 0x80 >> (x & 7), v = 0;
223 for (i = nplanes - 1; i >= 0; i--) {
225 v += !!(scanline[i * bytes_per_line + (x >> 3)] & m);
234 if (nplanes == 1 && bits_per_pixel == 8) {
237 }
else if (bits_per_pixel * nplanes == 1) {
240 }
else if (bits_per_pixel < 8) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * 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.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
8 bits with AV_PIX_FMT_RGB32 palette
static av_cold int end(AVCodecContext *avctx)
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
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.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
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.
static void pcx_palette(GetByteContext *gb, uint32_t *dst, int pallen)
GLsizei GLboolean const GLfloat * value
#define AV_EF_EXPLODE
abort decoding on minor error detection
static av_always_inline int bytestream2_tell(GetByteContext *g)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static int pcx_rle_decode(GetByteContext *gb, uint8_t *dst, unsigned int bytes_per_scanline, int compressed)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.