48 unsigned int bytes_per_scanline,
int compressed) {
50 unsigned char run, value;
53 while (i<bytes_per_scanline) {
60 while (i<bytes_per_scanline && run--)
64 memcpy(dst, src, bytes_per_scanline);
65 src += bytes_per_scanline;
74 for (i=0; i<pallen; i++)
75 *dst++ = bytestream_get_be24(src);
77 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
83 int buf_size = avpkt->
size;
87 int compressed, xmin, ymin, xmax, ymax;
88 unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
95 if (buf[0] != 0x0a || buf[1] > 5) {
106 if (xmax < xmin || ymax < ymin) {
114 bits_per_pixel = buf[3];
115 bytes_per_line =
AV_RL16(buf+66);
117 bytes_per_scanline = nplanes * bytes_per_line;
119 if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8) {
124 switch ((nplanes<<8) + bits_per_pixel) {
161 scanline =
av_malloc(bytes_per_scanline);
165 if (nplanes == 3 && bits_per_pixel == 8) {
166 for (y=0; y<h; y++) {
167 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
169 for (x=0; x<w; x++) {
170 ptr[3*x ] = scanline[x ];
171 ptr[3*x+1] = scanline[x+ bytes_per_line ];
172 ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
178 }
else if (nplanes == 1 && bits_per_pixel == 8) {
179 const uint8_t *palstart = bufstart + buf_size - 769;
181 for (y=0; y<h; y++, ptr+=
stride) {
182 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
183 memcpy(ptr, scanline, w);
186 if (buf != palstart) {
195 }
else if (nplanes == 1) {
198 for (y=0; y<h; y++) {
201 buf =
pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
204 ptr[x] =
get_bits(&s, bits_per_pixel);
211 for (y=0; y<h; y++) {
212 buf =
pcx_rle_decode(buf, 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;
236 ret = buf - bufstart;