50 unsigned int bytes_per_scanline,
53 unsigned char run, value;
56 while (i < bytes_per_scanline && src < end) {
59 if (value >= 0xc0 && src < end) {
63 while (i<bytes_per_scanline && run--)
67 memcpy(dst, src, bytes_per_scanline);
68 src += bytes_per_scanline;
77 for (i=0; i<pallen; i++)
78 *dst++ = bytestream_get_be24(src);
80 memset(dst, 0, (256 - pallen) *
sizeof(*dst));
86 int buf_size = avpkt->
size;
90 int compressed, xmin, ymin, xmax, ymax;
91 unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes,
stride, y, x,
94 const uint8_t *buf_end = buf + buf_size;
99 if (buf[0] != 0x0a || buf[1] > 5) {
110 if (xmax < xmin || ymax < ymin) {
118 bits_per_pixel = buf[3];
119 bytes_per_line =
AV_RL16(buf+66);
121 bytes_per_scanline = nplanes * bytes_per_line;
123 if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
124 (!compressed && bytes_per_scanline > buf_size / h)) {
129 switch ((nplanes<<8) + bits_per_pixel) {
166 scanline =
av_malloc(bytes_per_scanline);
170 if (nplanes == 3 && bits_per_pixel == 8) {
171 for (y=0; y<h; y++) {
173 scanline, bytes_per_scanline, compressed);
175 for (x=0; x<w; x++) {
176 ptr[3*x ] = scanline[x ];
177 ptr[3*x+1] = scanline[x+ bytes_per_line ];
178 ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
184 }
else if (nplanes == 1 && bits_per_pixel == 8) {
185 const uint8_t *palstart = bufstart + buf_size - 769;
187 if (buf_size < 769) {
193 for (y = 0; y < h; y++, ptr +=
stride) {
195 scanline, bytes_per_scanline, compressed);
196 memcpy(ptr, scanline, w);
199 if (buf != palstart) {
209 }
else if (nplanes == 1) {
212 for (y=0; y<h; y++) {
216 scanline, bytes_per_scanline, compressed);
219 ptr[x] =
get_bits(&s, bits_per_pixel);
226 for (y=0; y<h; y++) {
228 scanline, bytes_per_scanline, compressed);
230 for (x=0; x<w; x++) {
231 int m = 0x80 >> (x&7), v = 0;
232 for (i=nplanes - 1; i>=0; i--) {
234 v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
242 if (nplanes == 1 && bits_per_pixel == 8) {
244 }
else if (bits_per_pixel < 8) {
245 const uint8_t *palette = bufstart+16;
252 ret = buf - bufstart;