48 #define PBRUN the_hdr->priv.put.brun
99 register rle_hdr * the_hdr;
114 the_hdr->priv.put.nblank += rowlen;
124 PBRUN = (
short (*)[2])malloc(
125 (
unsigned)((rowlen/3 + 1) * 2 *
sizeof(
short)) );
128 fprintf( stderr,
"%s: Malloc failed in rle_putrow, writing %s\n",
135 bits[i] =
RLE_BIT( *the_hdr, i );
136 bits[255] =
RLE_BIT( *the_hdr, -1 );
162 PBRUN[0][1] = rowlen-1;
166 if (the_hdr->background)
169 for (i=0; i<rowlen; i++)
170 if (!same_color( i, rows, the_hdr->bg_color,
171 the_hdr->ncolors, bits ) ||
172 (the_hdr->alpha && rows[-1][i] != 0))
174 if (j > 0 && i - PBRUN[j-1][1] <= 2)
180 ( !same_color( i, rows, the_hdr->bg_color,
181 the_hdr->ncolors, bits ) ||
182 (the_hdr->alpha && rows[-1][i] != 0) );
193 PBRUN[0][1] = rowlen-1;
203 for ( i = nrun - 1; i > 0; i-- )
209 for ( j = i; j < nrun - 1; j++ )
221 if (the_hdr->priv.put.nblank > 0)
224 the_hdr->priv.put.nblank = 0;
226 for ( mask = (the_hdr
->alpha ? -1 : 0);
230 if ( ! bits[mask & 0xff] )
240 for (j=0; j<nrun; j++)
243 dstart =
PBRUN[j][0];
245 for (i=dstart; i<=dend; i++)
250 if (i > dstart && runval == row[i])
254 if ( ((i - dstart) % 2) == 0)
267 if (runval == row[i])
275 if ( dend - i > 255 )
294 if (runval == row[i])
309 if (runval == row[i])
312 putdata(row + dstart, rstart - dstart);
316 i = dend - skpc( (
char *)row + i, dend + 1 - i,
319 while ( row[++i] == runval && i <= dend)
334 if (runval != row[i])
348 putdata(row + dstart, i - dstart);
352 PBRUN[j+1][0] - dend - 1,
356 if (rowlen - dend > 0)
369 the_hdr->priv.put.nblank++;
397 the_hdr->priv.put.nblank += nrow;
416 register rle_hdr *the_hdr;
422 the_hdr
->cmd =
"Urt";
425 the_hdr->priv.put.nblank = 0;
430 the_hdr->priv.put.fileptr = 0;
454 register rle_hdr * the_hdr;
475 register rle_hdr * the_hdr;
511 same_color( index, rows, bg_color, ncolors, bits )
512 register rle_pixel *rows[];
513 register int bg_color[];
518 for ( i = 0; i < ncolors; i++, bits++ )
520 rows[i][index] != bg_color[i] )
550 int rowlen, color, nrun;
553 int i = 0, lower, upper;
557 fprintf( stderr,
"findruns( " );
558 for ( s = 0; s < rowlen; s++ )
559 fprintf( stderr,
"%2x.%s", row[s], (s % 20 == 19) ?
"\n\t" :
"" );
561 fprintf( stderr,
"\n\t" );
562 fprintf( stderr,
"%d, %d, %d, \n\t", rowlen, color, nrun );
563 for ( j = 0; j < nrun; j++ )
564 fprintf( stderr,
"(%3d,%3d) %s", brun[j][0], brun[j][1],
565 (j % 6 == 5) ?
"\n\t" :
"" );
566 fprintf( stderr,
")\n" );
581 lower = brun[i-1][1] + 1;
586 upper = brun[i][0] - 1;
589 fprintf( stderr,
"Searching before run %d from %d to %d\n",
593 #if defined(LOCC)&defined(vax)
594 s = upper - skpc( (
char *)row + lower, upper - lower + 1, color ) + 1;
596 for ( s = lower; s <= upper; s++ )
597 if ( row[s] != color )
603 if ( s > lower + 1 || i == 0 )
606 fprintf( stderr,
"Found new run starting at %d\n", s );
609 for ( j = nrun; j > i; j-- )
611 brun[j][0] = brun[j-1][0];
612 brun[j][1] = brun[j-1][1];
621 fprintf( stderr,
"Adding to previous run\n" );
625 #if defined(LOCC)&defined(vax)
626 s = upper - locc( (
char *)row + s, upper - s + 1, color ) + 1;
628 for ( ; s <= upper; s++ )
629 if ( row[s] == color )
635 fprintf( stderr,
"Ends at %d", s - 1 );
637 if ( s >= upper && i < nrun - 1 )
639 brun[i][1] = brun[i+1][1];
641 for ( j = i + 2; j < nrun; j++ )
643 brun[j-1][0] = brun[j][0];
644 brun[j-1][1] = brun[j][1];
648 fprintf( stderr,
", add to next run" );
652 putc(
'\n', stderr );
689 for (x=0; x<rowlen; x++)
693 bw = 0.5 + .30*red_row[x] + .59*green_row[x] + .11*blue_row[x];
705 asm(
"locc r9,r10,(r11)" );
719 asm(
"skpc r9,r10,(r11)" );
#define SkipPixels(n, l, r)
static int findruns(rle_pixel *row, int rowlen, int color, int nrun, short *brun)
#define putrun(val, len, f)
void rgb_to_bw(rle_pixel *red_row, rle_pixel *green_row, rle_pixel *blue_row, rle_pixel *bw_row, int rowlen)
void rle_puteof(rle_hdr *the_hdr)
void rle_putrow(rows, int rowlen, rle_hdr *the_hdr)
enum rle_dispatch dispatch
void DefaultBlockHook(rle_hdr *the_hdr)
#define SkipBlankLines(n)
#define NewScanLine(flag)
void rle_skiprow(rle_hdr *the_hdr, int nrow)
#define RLE_CLR_BIT(glob, bit)
void rle_put_init(rle_hdr *the_hdr)
void rle_put_setup(rle_hdr *the_hdr)
#define putdata(buf, len)
#define RLE_BIT(glob, bit)