47 unsigned int bytes_per_scanline,
int compressed) {
49 unsigned char run, value;
52 while (i<bytes_per_scanline) {
59 while (i<bytes_per_scanline && run--)
63 memcpy(dst, src, bytes_per_scanline);
64 src += bytes_per_scanline;
70 static void pcx_palette(
const uint8_t **src, uint32_t *dst,
unsigned int pallen) {
73 for (i=0; i<pallen; i++)
74 *dst++ = bytestream_get_be24(src);
76 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
81 const uint8_t *buf = avpkt->
data;
82 int buf_size = avpkt->
size;
86 int compressed, xmin, ymin, xmax, ymax;
87 unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
90 uint8_t
const *bufstart = buf;
94 if (buf[0] != 0x0a || buf[1] > 5) {
105 if (xmax < xmin || ymax < ymin) {
113 bits_per_pixel = buf[3];
114 bytes_per_line =
AV_RL16(buf+66);
116 bytes_per_scanline = nplanes * bytes_per_line;
118 if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8) {
123 switch ((nplanes<<8) + bits_per_pixel) {
160 scanline =
av_malloc(bytes_per_scanline);
164 if (nplanes == 3 && bits_per_pixel == 8) {
165 for (y=0; y<h; y++) {
166 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
168 for (x=0; x<w; x++) {
169 ptr[3*x ] = scanline[x ];
170 ptr[3*x+1] = scanline[x+ bytes_per_line ];
171 ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
177 }
else if (nplanes == 1 && bits_per_pixel == 8) {
178 const uint8_t *palstart = bufstart + buf_size - 769;
180 for (y=0; y<h; y++, ptr+=
stride) {
181 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
182 memcpy(ptr, scanline, w);
185 if (buf != palstart) {
194 }
else if (nplanes == 1) {
197 for (y=0; y<h; y++) {
200 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
203 ptr[x] =
get_bits(&s, bits_per_pixel);
210 for (y=0; y<h; y++) {
211 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
213 for (x=0; x<w; x++) {
214 int m = 0x80 >> (x&7),
v = 0;
215 for (i=nplanes - 1; i>=0; i--) {
217 v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
225 if (nplanes == 1 && bits_per_pixel == 8) {
227 }
else if (bits_per_pixel < 8) {
228 const uint8_t *
palette = bufstart+16;
235 ret = buf - bufstart;