changed bitblt_table_gen.c to generate both a header and a C source file (bitblt_tables.[ch]).
This commit is contained in:
18
Makefile
18
Makefile
@@ -1,6 +1,6 @@
|
||||
# t2p: build a PDF file out of one or more TIFF Class F Group 4 files
|
||||
# Makefile
|
||||
# $Id: Makefile,v 1.21 2003/03/10 01:49:49 eric Exp $
|
||||
# $Id: Makefile,v 1.22 2003/03/11 22:39:22 eric Exp $
|
||||
# Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -65,7 +65,7 @@ CSRCS = t2p.c semantics.c \
|
||||
bitblt.c bitblt_table_gen.c bitblt_g4.c g4_table_gen.c \
|
||||
pdf.c pdf_util.c pdf_prim.c pdf_bookmark.c pdf_name_tree.c pdf_g4.c
|
||||
OSRCS = scanner.l parser.y
|
||||
HDRS = t2p.h semantics.h bitblt.h \
|
||||
HDRS = t2p.h semantics.h bitblt.h bitblt_tables.h \
|
||||
pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_name_tree.h
|
||||
MISC = COPYING Makefile
|
||||
|
||||
@@ -73,9 +73,9 @@ DISTFILES = $(MISC) $(HDRS) $(CSRCS) $(OSRCS)
|
||||
DISTNAME = $(PACKAGE)-$(VERSION)
|
||||
|
||||
|
||||
AUTO_CSRCS = scanner.c parser.tab.c
|
||||
AUTO_HDRS = parser.tab.h bitblt_tables.h g4_tables.h
|
||||
AUTO_MISC = parser.output
|
||||
AUTO_CSRCS = scanner.c parser.tab.c bitblt_tables.c
|
||||
AUTO_HDRS = parser.tab.h g4_tables.h
|
||||
AUTO_MISC = parser.output bitblt_tables.h
|
||||
|
||||
|
||||
-include Maketest
|
||||
@@ -84,7 +84,8 @@ AUTO_MISC = parser.output
|
||||
all: $(TARGETS) $(TEST_TARGETS)
|
||||
|
||||
|
||||
t2p: t2p.o scanner.o semantics.o parser.tab.o bitblt.o bitblt_g4.o \
|
||||
t2p: t2p.o scanner.o semantics.o parser.tab.o \
|
||||
bitblt.o bitblt_g4.o bitblt_tables.o \
|
||||
pdf.o pdf_util.o pdf_prim.o pdf_bookmark.o pdf_name_tree.o \
|
||||
pdf_g4.o
|
||||
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
|
||||
@@ -94,7 +95,10 @@ endif
|
||||
|
||||
|
||||
bitblt_tables.h: bitblt_table_gen
|
||||
./bitblt_table_gen >bitblt_tables.h
|
||||
./bitblt_table_gen -h >bitblt_tables.h
|
||||
|
||||
bitblt_tables.c: bitblt_table_gen
|
||||
./bitblt_table_gen -c >bitblt_tables.c
|
||||
|
||||
bitblt_table_gen: bitblt_table_gen.o
|
||||
|
||||
|
||||
@@ -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.4 2003/03/05 12:44:33 eric Exp $
|
||||
* $Id: bitblt_table_gen.c,v 1.5 2003/03/11 22:39:22 eric Exp $
|
||||
* Copyright 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -24,13 +24,23 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void gen_bit_reverse_table (void)
|
||||
void gen_bit_reverse_table (bool header)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
printf ("static const uint8_t bit_reverse_byte [0x100] =\n");
|
||||
if (header)
|
||||
printf ("extern ");
|
||||
printf ("const uint8_t bit_reverse_byte [0x100]");
|
||||
if (header)
|
||||
{
|
||||
printf (";\n");
|
||||
return;
|
||||
}
|
||||
printf (" =\n");
|
||||
printf ("{\n");
|
||||
for (i = 0; i < 0x100; i++)
|
||||
{
|
||||
@@ -73,11 +83,19 @@ int count_run (int byte, int start_bit, int desired_val)
|
||||
}
|
||||
|
||||
|
||||
void gen_run_length_table (int val, char *name)
|
||||
void gen_run_length_table (bool header, int val, char *name)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
printf ("static const uint8_t %s [8][256] =\n", name);
|
||||
if (header)
|
||||
printf ("extern ");
|
||||
printf ("const uint8_t %s [8][256]", name);
|
||||
if (header)
|
||||
{
|
||||
printf (";\n");
|
||||
return;
|
||||
}
|
||||
printf (" =\n");
|
||||
printf ("{\n");
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
@@ -105,15 +123,38 @@ void gen_run_length_table (int val, char *name)
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
bool header;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf (stderr, "wrong arg count\n");
|
||||
exit (2);
|
||||
}
|
||||
if (strcmp (argv [1], "-h") == 0)
|
||||
header = 1;
|
||||
else if (strcmp (argv [1], "-c") == 0)
|
||||
header = 0;
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "wrong args\n");
|
||||
exit (2);
|
||||
}
|
||||
|
||||
printf ("/* This file is automatically generated; do not edit */\n");
|
||||
printf ("\n");
|
||||
|
||||
gen_bit_reverse_table ();
|
||||
if (! header)
|
||||
{
|
||||
printf ("#include <stdint.h>\n");
|
||||
printf ("#include \"bitblt_tables.h\"\n");
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
gen_bit_reverse_table (header);
|
||||
printf ("\n");
|
||||
|
||||
gen_run_length_table (0, "rle_tab");
|
||||
gen_run_length_table (header, 0, "rle_tab");
|
||||
printf ("\n");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user