added code to generate RLE tables.
This commit is contained in:
parent
0b0b2bca1e
commit
03e732c4b5
@ -4,7 +4,7 @@
|
||||
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
||||
*
|
||||
* bitblt table generator
|
||||
* $Id: bitblt_table_gen.c,v 1.1 2003/02/19 02:14:44 eric Exp $
|
||||
* $Id: bitblt_table_gen.c,v 1.2 2003/02/19 02:34:35 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -26,12 +26,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
void gen_bit_reverse_table (void)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
printf ("/* This file is automatically generated; do not edit */\n");
|
||||
printf ("\n");
|
||||
printf ("static const uint8_t bit_reverse_byte [0x100] =\n");
|
||||
printf ("{\n");
|
||||
for (i = 0; i < 0x100; i++)
|
||||
@ -55,5 +53,69 @@ int main (int argc, char *argv[])
|
||||
printf (" ");
|
||||
}
|
||||
printf ("};\n");
|
||||
}
|
||||
|
||||
|
||||
int count_run (int byte, int start_bit, int desired_val)
|
||||
{
|
||||
int count = 0;
|
||||
int i;
|
||||
|
||||
for (i = start_bit; i < 8; i++)
|
||||
{
|
||||
int bit = (byte >> i) & 1;
|
||||
if (bit == desired_val)
|
||||
count++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return (count);
|
||||
}
|
||||
|
||||
|
||||
void gen_run_length_table (int val, char *name)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
printf ("static const uint8_t %s [8][256] =\n", name);
|
||||
printf ("{\n");
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
printf (" {\n");
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
if ((j & 15) == 0)
|
||||
printf (" ");
|
||||
printf ("%d", count_run (j, i, val));
|
||||
if (j != 0xff)
|
||||
printf (",");
|
||||
if ((j & 15) == 15)
|
||||
printf ("\n");
|
||||
else
|
||||
printf (" ");
|
||||
}
|
||||
printf (" }");
|
||||
if (i != 7)
|
||||
printf (",");
|
||||
printf ("\n");
|
||||
}
|
||||
printf ("};\n");
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
printf ("/* This file is automatically generated; do not edit */\n");
|
||||
printf ("\n");
|
||||
|
||||
gen_bit_reverse_table ();
|
||||
printf ("\n");
|
||||
|
||||
gen_run_length_table (0, "white_rle_tab");
|
||||
printf ("\n");
|
||||
gen_run_length_table (1, "black_rle_tab");
|
||||
printf ("\n");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user