Generate G4 tables from strings of ones and zeros.
This commit is contained in:
13
Makefile
13
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.15 2003/02/21 04:29:16 eric Exp $
|
||||
# $Id: Makefile,v 1.16 2003/02/22 02:02:06 eric Exp $
|
||||
# Copyright 2001 Eric Smith <eric@brouhaha.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -43,10 +43,10 @@ PACKAGE = t2p
|
||||
TARGETS = t2p bitblt_test
|
||||
|
||||
CSRCS = t2p.c semantics.c bitblt.c bitblt_test.c bitblt_table_gen.c \
|
||||
pdf.c pdf_util.c pdf_prim.c pdf_g4.c
|
||||
pdf.c pdf_util.c pdf_prim.c pdf_g4.c pdf_g4_table_gen.c
|
||||
OSRCS = scanner.l parser.y
|
||||
HDRS = t2p.h semantics.h bitblt.h \
|
||||
pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_g4_codes.h
|
||||
pdf.h pdf_private.h pdf_util.h pdf_prim.h
|
||||
MISC = COPYING Makefile
|
||||
|
||||
DISTFILES = $(MISC) $(HDRS) $(CSRCS) $(OSRCS)
|
||||
@@ -54,7 +54,7 @@ DISTNAME = $(PACKAGE)-$(VERSION)
|
||||
|
||||
|
||||
AUTO_CSRCS = scanner.c parser.tab.c
|
||||
AUTO_HDRS = parser.tab.h bitblt_tables.h
|
||||
AUTO_HDRS = parser.tab.h bitblt_tables.h pdf_g4_tables.h
|
||||
AUTO_MISC = parser.output
|
||||
|
||||
|
||||
@@ -71,6 +71,11 @@ bitblt_table_gen: bitblt_table_gen.o
|
||||
|
||||
bitblt_test: bitblt_test.o bitblt.o
|
||||
|
||||
pdf_g4_tables.h: pdf_g4_table_gen
|
||||
./pdf_g4_table_gen >pdf_g4_tables.h
|
||||
|
||||
pdf_g4_table_gen: pdf_g4_table_gen.o
|
||||
|
||||
|
||||
dist: $(DISTFILES)
|
||||
-rm -rf $(DISTNAME)
|
||||
|
||||
284
g4_table_gen.c
Normal file
284
g4_table_gen.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* t2p: Create a PDF file from the contents of one or more TIFF
|
||||
* bilevel image files. The images in the resulting PDF file
|
||||
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
||||
*
|
||||
* G4 table generator
|
||||
* $Id: g4_table_gen.c,v 1.1 2003/02/22 02:02:06 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. Note that permission is
|
||||
* not granted to redistribute this program under the terms of any
|
||||
* other version of the General Public License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void emit_code (int indent, char *code, int last, bool comment, int cval)
|
||||
{
|
||||
int i;
|
||||
int count = 0;
|
||||
uint32_t val = 0;
|
||||
|
||||
printf ("%*s{ ", indent, "");
|
||||
|
||||
printf ("%d, ", strlen (code));
|
||||
|
||||
for (i = 0; i < strlen (code); i++)
|
||||
switch (code [i])
|
||||
{
|
||||
case '0': val = (val << 1); count++; break;
|
||||
case '1': val = (val << 1) + 1; count++; break;
|
||||
case ' ': break;
|
||||
default:
|
||||
fprintf (stderr, "internal error\n");
|
||||
exit (2);
|
||||
}
|
||||
|
||||
printf ("0x%0*x", (count + 3)/4, val);
|
||||
|
||||
printf (" }");
|
||||
if (! last)
|
||||
printf (",");
|
||||
if (comment)
|
||||
printf (" /* %d */", cval);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
||||
char *long_makeup_code [12] =
|
||||
{
|
||||
/* 1792 */ "00000001000",
|
||||
/* 1856 */ "00000001100",
|
||||
/* 1920 */ "00000001101",
|
||||
/* 1984 */ "000000010010",
|
||||
/* 2048 */ "000000010011",
|
||||
/* 2112 */ "000000010100",
|
||||
/* 2176 */ "000000010101",
|
||||
/* 2240 */ "000000010110",
|
||||
/* 2304 */ "000000010111",
|
||||
/* 2368 */ "000000011100",
|
||||
/* 2432 */ "000000011101",
|
||||
/* 2496 */ "000000011110"
|
||||
/* 2560 "000000011111" hard-coded, doesn't need to be in table */
|
||||
};
|
||||
|
||||
|
||||
void print_long_makeup_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_long_makeup_code [12] =\n");
|
||||
printf (" {\n");
|
||||
for (i = 0; i < 12; i++)
|
||||
emit_code (4, long_makeup_code [i], i == 11, 1, i * 64 + 1792);
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
char *makeup_code [64][2] =
|
||||
{
|
||||
{ /* 64 */ "11011", "0000001111" },
|
||||
{ /* 128 */ "10010", "000011001000" },
|
||||
{ /* 192 */ "010111", "000011001001" },
|
||||
{ /* 256 */ "0110111", "000001011011" },
|
||||
{ /* 320 */ "00110110", "000000110011" },
|
||||
{ /* 384 */ "00110111", "000000110100" },
|
||||
{ /* 448 */ "01100100", "000000110101" },
|
||||
{ /* 512 */ "01100101", "0000001101100" },
|
||||
{ /* 576 */ "01101000", "0000001101101" },
|
||||
{ /* 640 */ "01100111", "0000001001010" },
|
||||
{ /* 704 */ "011001100", "0000001001011" },
|
||||
{ /* 768 */ "011001101", "0000001001100" },
|
||||
{ /* 832 */ "011010010", "0000001001101" },
|
||||
{ /* 896 */ "011010011", "0000001110010" },
|
||||
{ /* 960 */ "011010100", "0000001110011" },
|
||||
{ /* 1024 */ "011010101", "0000001110100" },
|
||||
{ /* 1088 */ "011010110", "0000001110101" },
|
||||
{ /* 1152 */ "011010111", "0000001110110" },
|
||||
{ /* 1216 */ "011011000", "0000001110111" },
|
||||
{ /* 1280 */ "011011001", "0000001010010" },
|
||||
{ /* 1344 */ "011011010", "0000001010011" },
|
||||
{ /* 1408 */ "011011011", "0000001010100" },
|
||||
{ /* 1472 */ "010011000", "0000001010101" },
|
||||
{ /* 1536 */ "010011001", "0000001011010" },
|
||||
{ /* 1600 */ "010011010", "0000001011011" },
|
||||
{ /* 1664 */ "011000", "0000001100100" },
|
||||
{ /* 1728 */ "010011011", "0000001100101" }
|
||||
};
|
||||
|
||||
|
||||
void print_makeup_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_makeup_code [2] [27] =\n");
|
||||
printf (" {\n");
|
||||
printf (" {\n");
|
||||
printf (" /* white */\n");
|
||||
for (i = 0; i <= 26; i++)
|
||||
emit_code (6, makeup_code [i][0], i == 26, 1, (i + 1) * 64);
|
||||
printf (" },\n");
|
||||
printf (" {\n");
|
||||
printf (" /* black */\n");
|
||||
for (i = 0; i <= 26; i++)
|
||||
emit_code (6, makeup_code [i][1], i == 26, 1, (i + 1) * 64);
|
||||
printf (" }\n");
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
char *h_code [64][2] =
|
||||
{
|
||||
{ /* 0 */ "00110101", "0000110111" },
|
||||
{ /* 1 */ "000111", "010" },
|
||||
{ /* 2 */ "0111", "11" },
|
||||
{ /* 3 */ "1000", "10" },
|
||||
{ /* 4 */ "1011", "011" },
|
||||
{ /* 5 */ "1100", "0011" },
|
||||
{ /* 6 */ "1110", "0010" },
|
||||
{ /* 7 */ "1111", "00011" },
|
||||
{ /* 8 */ "10011", "000101" },
|
||||
{ /* 9 */ "10100", "000100" },
|
||||
{ /* 10 */ "00111", "0000100" },
|
||||
{ /* 11 */ "01000", "0000101" },
|
||||
{ /* 12 */ "001000", "0000111" },
|
||||
{ /* 13 */ "000011", "00000100" },
|
||||
{ /* 14 */ "110100", "00000111" },
|
||||
{ /* 15 */ "110101", "000011000" },
|
||||
{ /* 16 */ "101010", "0000010111" },
|
||||
{ /* 17 */ "101011", "0000011000" },
|
||||
{ /* 18 */ "0100111", "0000001000" },
|
||||
{ /* 19 */ "0001100", "00001100111" },
|
||||
{ /* 20 */ "0001000", "00001101000" },
|
||||
{ /* 21 */ "0010111", "00001101100" },
|
||||
{ /* 22 */ "0000011", "00000110111" },
|
||||
{ /* 23 */ "0000100", "00000101000" },
|
||||
{ /* 24 */ "0101000", "00000010111" },
|
||||
{ /* 25 */ "0101011", "00000011000" },
|
||||
{ /* 26 */ "0010011", "000011001010" },
|
||||
{ /* 27 */ "0100100", "000011001011" },
|
||||
{ /* 28 */ "0011000", "000011001100" },
|
||||
{ /* 29 */ "00000010", "000011001101" },
|
||||
{ /* 30 */ "00000011", "000001101000" },
|
||||
{ /* 31 */ "00011010", "000001101001" },
|
||||
{ /* 32 */ "00011011", "000001101010" },
|
||||
{ /* 33 */ "00010010", "000001101011" },
|
||||
{ /* 34 */ "00010011", "000011010010" },
|
||||
{ /* 35 */ "00010100", "000011010011" },
|
||||
{ /* 36 */ "00010101", "000011010100" },
|
||||
{ /* 37 */ "00010110", "000011010101" },
|
||||
{ /* 38 */ "00010111", "000011010110" },
|
||||
{ /* 39 */ "00101000", "000011010111" },
|
||||
{ /* 40 */ "00101001", "000001101100" },
|
||||
{ /* 41 */ "00101010", "000001101101" },
|
||||
{ /* 42 */ "00101011", "000011011010" },
|
||||
{ /* 43 */ "00101100", "000011011011" },
|
||||
{ /* 44 */ "00101101", "000001010100" },
|
||||
{ /* 45 */ "00000100", "000001010101" },
|
||||
{ /* 46 */ "00000101", "000001010110" },
|
||||
{ /* 47 */ "00001010", "000001010111" },
|
||||
{ /* 48 */ "00001011", "000001100100" },
|
||||
{ /* 49 */ "01010010", "000001100101" },
|
||||
{ /* 50 */ "01010011", "000001010010" },
|
||||
{ /* 51 */ "01010100", "000001010011" },
|
||||
{ /* 52 */ "01010101", "000000100100" },
|
||||
{ /* 53 */ "00100100", "000000110111" },
|
||||
{ /* 54 */ "00100101", "000000111000" },
|
||||
{ /* 55 */ "01011000", "000000100111" },
|
||||
{ /* 56 */ "01011001", "000000101000" },
|
||||
{ /* 57 */ "01011010", "000001011000" },
|
||||
{ /* 58 */ "01011011", "000001011001" },
|
||||
{ /* 59 */ "01001010", "000000101011" },
|
||||
{ /* 60 */ "01001011", "000000101100" },
|
||||
{ /* 61 */ "00110010", "000001011010" },
|
||||
{ /* 62 */ "00110011", "000001100110" },
|
||||
{ /* 63 */ "00110100", "000001100111" }
|
||||
};
|
||||
|
||||
|
||||
void print_h_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_h_code [2] [64] =\n");
|
||||
printf (" {\n");
|
||||
printf (" {\n");
|
||||
printf (" /* white */\n");
|
||||
for (i = 0; i <= 63; i++)
|
||||
emit_code (6, h_code [i][0], i == 63, 1, i);
|
||||
printf (" },\n");
|
||||
printf (" {\n");
|
||||
printf (" /* black */\n");
|
||||
for (i = 0; i <= 63; i++)
|
||||
emit_code (6, h_code [i][1], i == 63, 1, i);
|
||||
printf (" }\n");
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
char *v_code [7] =
|
||||
{
|
||||
/* -3 */ "0000010",
|
||||
/* -2 */ "000010",
|
||||
/* -1 */ "010",
|
||||
/* 0 */ "1",
|
||||
/* 1 */ "011",
|
||||
/* 2 */ "000011",
|
||||
/* 3 */ "0000011"
|
||||
};
|
||||
|
||||
|
||||
void print_v_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_vert_code [7] =\n");
|
||||
printf (" {\n");
|
||||
for (i = 0; i <= 6; i++)
|
||||
emit_code (4, v_code [i], i == 6, 1, i - 3);
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
printf ("/* This file is automatically generated; do not edit */\n");
|
||||
printf ("\n");
|
||||
printf ("typedef struct\n");
|
||||
printf ("{\n");
|
||||
printf (" uint32_t count;\n");
|
||||
printf (" uint32_t bits;\n");
|
||||
printf ("} g4_bits;\n");
|
||||
printf ("\n");
|
||||
|
||||
print_long_makeup_code ();
|
||||
printf ("\n");
|
||||
|
||||
print_makeup_code ();
|
||||
printf ("\n");
|
||||
|
||||
print_h_code ();
|
||||
printf ("\n");
|
||||
|
||||
print_v_code ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
284
pdf_g4_table_gen.c
Normal file
284
pdf_g4_table_gen.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* t2p: Create a PDF file from the contents of one or more TIFF
|
||||
* bilevel image files. The images in the resulting PDF file
|
||||
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
||||
*
|
||||
* G4 table generator
|
||||
* $Id: pdf_g4_table_gen.c,v 1.1 2003/02/22 02:02:06 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. Note that permission is
|
||||
* not granted to redistribute this program under the terms of any
|
||||
* other version of the General Public License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void emit_code (int indent, char *code, int last, bool comment, int cval)
|
||||
{
|
||||
int i;
|
||||
int count = 0;
|
||||
uint32_t val = 0;
|
||||
|
||||
printf ("%*s{ ", indent, "");
|
||||
|
||||
printf ("%d, ", strlen (code));
|
||||
|
||||
for (i = 0; i < strlen (code); i++)
|
||||
switch (code [i])
|
||||
{
|
||||
case '0': val = (val << 1); count++; break;
|
||||
case '1': val = (val << 1) + 1; count++; break;
|
||||
case ' ': break;
|
||||
default:
|
||||
fprintf (stderr, "internal error\n");
|
||||
exit (2);
|
||||
}
|
||||
|
||||
printf ("0x%0*x", (count + 3)/4, val);
|
||||
|
||||
printf (" }");
|
||||
if (! last)
|
||||
printf (",");
|
||||
if (comment)
|
||||
printf (" /* %d */", cval);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
||||
char *long_makeup_code [12] =
|
||||
{
|
||||
/* 1792 */ "00000001000",
|
||||
/* 1856 */ "00000001100",
|
||||
/* 1920 */ "00000001101",
|
||||
/* 1984 */ "000000010010",
|
||||
/* 2048 */ "000000010011",
|
||||
/* 2112 */ "000000010100",
|
||||
/* 2176 */ "000000010101",
|
||||
/* 2240 */ "000000010110",
|
||||
/* 2304 */ "000000010111",
|
||||
/* 2368 */ "000000011100",
|
||||
/* 2432 */ "000000011101",
|
||||
/* 2496 */ "000000011110"
|
||||
/* 2560 "000000011111" hard-coded, doesn't need to be in table */
|
||||
};
|
||||
|
||||
|
||||
void print_long_makeup_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_long_makeup_code [12] =\n");
|
||||
printf (" {\n");
|
||||
for (i = 0; i < 12; i++)
|
||||
emit_code (4, long_makeup_code [i], i == 11, 1, i * 64 + 1792);
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
char *makeup_code [64][2] =
|
||||
{
|
||||
{ /* 64 */ "11011", "0000001111" },
|
||||
{ /* 128 */ "10010", "000011001000" },
|
||||
{ /* 192 */ "010111", "000011001001" },
|
||||
{ /* 256 */ "0110111", "000001011011" },
|
||||
{ /* 320 */ "00110110", "000000110011" },
|
||||
{ /* 384 */ "00110111", "000000110100" },
|
||||
{ /* 448 */ "01100100", "000000110101" },
|
||||
{ /* 512 */ "01100101", "0000001101100" },
|
||||
{ /* 576 */ "01101000", "0000001101101" },
|
||||
{ /* 640 */ "01100111", "0000001001010" },
|
||||
{ /* 704 */ "011001100", "0000001001011" },
|
||||
{ /* 768 */ "011001101", "0000001001100" },
|
||||
{ /* 832 */ "011010010", "0000001001101" },
|
||||
{ /* 896 */ "011010011", "0000001110010" },
|
||||
{ /* 960 */ "011010100", "0000001110011" },
|
||||
{ /* 1024 */ "011010101", "0000001110100" },
|
||||
{ /* 1088 */ "011010110", "0000001110101" },
|
||||
{ /* 1152 */ "011010111", "0000001110110" },
|
||||
{ /* 1216 */ "011011000", "0000001110111" },
|
||||
{ /* 1280 */ "011011001", "0000001010010" },
|
||||
{ /* 1344 */ "011011010", "0000001010011" },
|
||||
{ /* 1408 */ "011011011", "0000001010100" },
|
||||
{ /* 1472 */ "010011000", "0000001010101" },
|
||||
{ /* 1536 */ "010011001", "0000001011010" },
|
||||
{ /* 1600 */ "010011010", "0000001011011" },
|
||||
{ /* 1664 */ "011000", "0000001100100" },
|
||||
{ /* 1728 */ "010011011", "0000001100101" }
|
||||
};
|
||||
|
||||
|
||||
void print_makeup_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_makeup_code [2] [27] =\n");
|
||||
printf (" {\n");
|
||||
printf (" {\n");
|
||||
printf (" /* white */\n");
|
||||
for (i = 0; i <= 26; i++)
|
||||
emit_code (6, makeup_code [i][0], i == 26, 1, (i + 1) * 64);
|
||||
printf (" },\n");
|
||||
printf (" {\n");
|
||||
printf (" /* black */\n");
|
||||
for (i = 0; i <= 26; i++)
|
||||
emit_code (6, makeup_code [i][1], i == 26, 1, (i + 1) * 64);
|
||||
printf (" }\n");
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
char *h_code [64][2] =
|
||||
{
|
||||
{ /* 0 */ "00110101", "0000110111" },
|
||||
{ /* 1 */ "000111", "010" },
|
||||
{ /* 2 */ "0111", "11" },
|
||||
{ /* 3 */ "1000", "10" },
|
||||
{ /* 4 */ "1011", "011" },
|
||||
{ /* 5 */ "1100", "0011" },
|
||||
{ /* 6 */ "1110", "0010" },
|
||||
{ /* 7 */ "1111", "00011" },
|
||||
{ /* 8 */ "10011", "000101" },
|
||||
{ /* 9 */ "10100", "000100" },
|
||||
{ /* 10 */ "00111", "0000100" },
|
||||
{ /* 11 */ "01000", "0000101" },
|
||||
{ /* 12 */ "001000", "0000111" },
|
||||
{ /* 13 */ "000011", "00000100" },
|
||||
{ /* 14 */ "110100", "00000111" },
|
||||
{ /* 15 */ "110101", "000011000" },
|
||||
{ /* 16 */ "101010", "0000010111" },
|
||||
{ /* 17 */ "101011", "0000011000" },
|
||||
{ /* 18 */ "0100111", "0000001000" },
|
||||
{ /* 19 */ "0001100", "00001100111" },
|
||||
{ /* 20 */ "0001000", "00001101000" },
|
||||
{ /* 21 */ "0010111", "00001101100" },
|
||||
{ /* 22 */ "0000011", "00000110111" },
|
||||
{ /* 23 */ "0000100", "00000101000" },
|
||||
{ /* 24 */ "0101000", "00000010111" },
|
||||
{ /* 25 */ "0101011", "00000011000" },
|
||||
{ /* 26 */ "0010011", "000011001010" },
|
||||
{ /* 27 */ "0100100", "000011001011" },
|
||||
{ /* 28 */ "0011000", "000011001100" },
|
||||
{ /* 29 */ "00000010", "000011001101" },
|
||||
{ /* 30 */ "00000011", "000001101000" },
|
||||
{ /* 31 */ "00011010", "000001101001" },
|
||||
{ /* 32 */ "00011011", "000001101010" },
|
||||
{ /* 33 */ "00010010", "000001101011" },
|
||||
{ /* 34 */ "00010011", "000011010010" },
|
||||
{ /* 35 */ "00010100", "000011010011" },
|
||||
{ /* 36 */ "00010101", "000011010100" },
|
||||
{ /* 37 */ "00010110", "000011010101" },
|
||||
{ /* 38 */ "00010111", "000011010110" },
|
||||
{ /* 39 */ "00101000", "000011010111" },
|
||||
{ /* 40 */ "00101001", "000001101100" },
|
||||
{ /* 41 */ "00101010", "000001101101" },
|
||||
{ /* 42 */ "00101011", "000011011010" },
|
||||
{ /* 43 */ "00101100", "000011011011" },
|
||||
{ /* 44 */ "00101101", "000001010100" },
|
||||
{ /* 45 */ "00000100", "000001010101" },
|
||||
{ /* 46 */ "00000101", "000001010110" },
|
||||
{ /* 47 */ "00001010", "000001010111" },
|
||||
{ /* 48 */ "00001011", "000001100100" },
|
||||
{ /* 49 */ "01010010", "000001100101" },
|
||||
{ /* 50 */ "01010011", "000001010010" },
|
||||
{ /* 51 */ "01010100", "000001010011" },
|
||||
{ /* 52 */ "01010101", "000000100100" },
|
||||
{ /* 53 */ "00100100", "000000110111" },
|
||||
{ /* 54 */ "00100101", "000000111000" },
|
||||
{ /* 55 */ "01011000", "000000100111" },
|
||||
{ /* 56 */ "01011001", "000000101000" },
|
||||
{ /* 57 */ "01011010", "000001011000" },
|
||||
{ /* 58 */ "01011011", "000001011001" },
|
||||
{ /* 59 */ "01001010", "000000101011" },
|
||||
{ /* 60 */ "01001011", "000000101100" },
|
||||
{ /* 61 */ "00110010", "000001011010" },
|
||||
{ /* 62 */ "00110011", "000001100110" },
|
||||
{ /* 63 */ "00110100", "000001100111" }
|
||||
};
|
||||
|
||||
|
||||
void print_h_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_h_code [2] [64] =\n");
|
||||
printf (" {\n");
|
||||
printf (" {\n");
|
||||
printf (" /* white */\n");
|
||||
for (i = 0; i <= 63; i++)
|
||||
emit_code (6, h_code [i][0], i == 63, 1, i);
|
||||
printf (" },\n");
|
||||
printf (" {\n");
|
||||
printf (" /* black */\n");
|
||||
for (i = 0; i <= 63; i++)
|
||||
emit_code (6, h_code [i][1], i == 63, 1, i);
|
||||
printf (" }\n");
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
char *v_code [7] =
|
||||
{
|
||||
/* -3 */ "0000010",
|
||||
/* -2 */ "000010",
|
||||
/* -1 */ "010",
|
||||
/* 0 */ "1",
|
||||
/* 1 */ "011",
|
||||
/* 2 */ "000011",
|
||||
/* 3 */ "0000011"
|
||||
};
|
||||
|
||||
|
||||
void print_v_code (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf ("static g4_bits g4_vert_code [7] =\n");
|
||||
printf (" {\n");
|
||||
for (i = 0; i <= 6; i++)
|
||||
emit_code (4, v_code [i], i == 6, 1, i - 3);
|
||||
printf (" };\n");
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv [])
|
||||
{
|
||||
printf ("/* This file is automatically generated; do not edit */\n");
|
||||
printf ("\n");
|
||||
printf ("typedef struct\n");
|
||||
printf ("{\n");
|
||||
printf (" uint32_t count;\n");
|
||||
printf (" uint32_t bits;\n");
|
||||
printf ("} g4_bits;\n");
|
||||
printf ("\n");
|
||||
|
||||
print_long_makeup_code ();
|
||||
printf ("\n");
|
||||
|
||||
print_makeup_code ();
|
||||
printf ("\n");
|
||||
|
||||
print_h_code ();
|
||||
printf ("\n");
|
||||
|
||||
print_v_code ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
262
pdf_g4_tables.h
262
pdf_g4_tables.h
@@ -1,262 +0,0 @@
|
||||
/*
|
||||
* t2p: Create a PDF file from the contents of one or more TIFF
|
||||
* bilevel image files. The images in the resulting PDF file
|
||||
* will be compressed using ITU-T T.6 (G4) fax encoding.
|
||||
*
|
||||
* G4 encoding tables
|
||||
* $Id: pdf_g4_tables.h,v 1.2 2003/02/21 04:28:37 eric Exp $
|
||||
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. Note that permission is
|
||||
* not granted to redistribute this program under the terms of any
|
||||
* other version of the General Public License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
*/
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t count;
|
||||
uint32_t bits;
|
||||
} g4_bits;
|
||||
|
||||
static g4_bits g4_long_makeup_code [12] =
|
||||
{
|
||||
{ 11, 0x008 }, /* 1792 */
|
||||
{ 11, 0x00c }, /* 1856 */
|
||||
{ 11, 0x00d }, /* 1920 */
|
||||
{ 12, 0x012 }, /* 1984 */
|
||||
{ 12, 0x013 }, /* 2048 */
|
||||
{ 12, 0x014 }, /* 2112 */
|
||||
{ 12, 0x015 }, /* 2176 */
|
||||
{ 12, 0x016 }, /* 2240 */
|
||||
{ 12, 0x017 }, /* 2304 */
|
||||
{ 12, 0x01c }, /* 2368 */
|
||||
{ 12, 0x01d }, /* 2432 */
|
||||
{ 12, 0x01e } /* 2496 */
|
||||
};
|
||||
|
||||
static g4_bits g4_makeup_code [2] [27] =
|
||||
{
|
||||
{
|
||||
/* white */
|
||||
{ 5, 0x1b }, /* 64 */
|
||||
{ 5, 0x12 }, /* 128 */
|
||||
{ 6, 0x17 }, /* 192 */
|
||||
{ 7, 0x37 }, /* 256 */
|
||||
{ 8, 0x36 }, /* 320 */
|
||||
{ 8, 0x37 }, /* 384 */
|
||||
{ 8, 0x64 }, /* 448 */
|
||||
{ 8, 0x65 }, /* 512 */
|
||||
{ 8, 0x68 }, /* 576 */
|
||||
{ 8, 0x67 }, /* 640 */
|
||||
{ 9, 0x0cc }, /* 704 */
|
||||
{ 9, 0x0cd }, /* 768 */
|
||||
{ 9, 0x0d2 }, /* 832 */
|
||||
{ 9, 0x0d3 }, /* 896 */
|
||||
{ 9, 0x0d4 }, /* 960 */
|
||||
{ 9, 0x0d5 }, /* 1024 */
|
||||
{ 9, 0x0d6 }, /* 1088 */
|
||||
{ 9, 0x0d7 }, /* 1152 */
|
||||
{ 9, 0x0d8 }, /* 1216 */
|
||||
{ 9, 0x0d9 }, /* 1280 */
|
||||
{ 9, 0x0da }, /* 1344 */
|
||||
{ 9, 0x0db }, /* 1408 */
|
||||
{ 9, 0x098 }, /* 1472 */
|
||||
{ 9, 0x099 }, /* 1536 */
|
||||
{ 9, 0x09a }, /* 1600 */
|
||||
{ 6, 0x18 }, /* 1664 */
|
||||
{ 9, 0x09b } /* 1728 */
|
||||
},
|
||||
{
|
||||
/* black */
|
||||
{ 10, 0x00f }, /* 64 */
|
||||
{ 12, 0x0c8 }, /* 128 */
|
||||
{ 12, 0x0c9 }, /* 192 */
|
||||
{ 12, 0x05b }, /* 256 */
|
||||
{ 12, 0x033 }, /* 320 */
|
||||
{ 12, 0x034 }, /* 384 */
|
||||
{ 12, 0x035 }, /* 448 */
|
||||
{ 13, 0x006c }, /* 512 */
|
||||
{ 13, 0x006d }, /* 576 */
|
||||
{ 13, 0x004a }, /* 640 */
|
||||
{ 13, 0x004b }, /* 704 */
|
||||
{ 13, 0x004c }, /* 768 */
|
||||
{ 13, 0x004d }, /* 832 */
|
||||
{ 13, 0x0072 }, /* 896 */
|
||||
{ 13, 0x0073 }, /* 960 */
|
||||
{ 13, 0x0074 }, /* 1024 */
|
||||
{ 13, 0x0075 }, /* 1088 */
|
||||
{ 13, 0x0076 }, /* 1152 */
|
||||
{ 13, 0x0077 }, /* 1216 */
|
||||
{ 13, 0x0052 }, /* 1280 */
|
||||
{ 13, 0x0053 }, /* 1344 */
|
||||
{ 13, 0x0054 }, /* 1408 */
|
||||
{ 13, 0x0055 }, /* 1472 */
|
||||
{ 13, 0x005a }, /* 1536 */
|
||||
{ 13, 0x005b }, /* 1600 */
|
||||
{ 13, 0x0064 }, /* 1664 */
|
||||
{ 13, 0x0065 }, /* 1728 */
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static g4_bits g4_h_code [2] [64] =
|
||||
{
|
||||
{
|
||||
/* white */
|
||||
{ 8, 0x35 }, /* 0 */
|
||||
{ 6, 0x07 }, /* 1 */
|
||||
{ 4, 0x7 }, /* 2 */
|
||||
{ 4, 0x8 }, /* 3 */
|
||||
{ 4, 0xb }, /* 4 */
|
||||
{ 4, 0xc }, /* 5 */
|
||||
{ 4, 0xe }, /* 6 */
|
||||
{ 4, 0xf }, /* 7 */
|
||||
{ 5, 0x13 }, /* 8 */
|
||||
{ 5, 0x14 }, /* 9 */
|
||||
{ 5, 0x07 }, /* 10 */
|
||||
{ 5, 0x08 }, /* 11 */
|
||||
{ 6, 0x08 }, /* 12 */
|
||||
{ 6, 0x03 }, /* 13 */
|
||||
{ 6, 0x34 }, /* 14 */
|
||||
{ 6, 0x35 }, /* 15 */
|
||||
{ 6, 0x2a }, /* 16 */
|
||||
{ 6, 0x2b }, /* 17 */
|
||||
{ 7, 0x27 }, /* 18 */
|
||||
{ 7, 0x0c }, /* 19 */
|
||||
{ 7, 0x04 }, /* 20 */
|
||||
{ 7, 0x17 }, /* 21 */
|
||||
{ 7, 0x03 }, /* 22 */
|
||||
{ 7, 0x04 }, /* 23 */
|
||||
{ 7, 0x28 }, /* 24 */
|
||||
{ 7, 0x2b }, /* 25 */
|
||||
{ 7, 0x13 }, /* 26 */
|
||||
{ 7, 0x24 }, /* 27 */
|
||||
{ 7, 0x18 }, /* 28 */
|
||||
{ 8, 0x02 }, /* 29 */
|
||||
{ 8, 0x03 }, /* 30 */
|
||||
{ 8, 0x1a }, /* 31 */
|
||||
{ 8, 0x1b }, /* 32 */
|
||||
{ 8, 0x12 }, /* 33 */
|
||||
{ 8, 0x13 }, /* 34 */
|
||||
{ 8, 0x14 }, /* 35 */
|
||||
{ 8, 0x15 }, /* 36 */
|
||||
{ 8, 0x16 }, /* 37 */
|
||||
{ 8, 0x17 }, /* 38 */
|
||||
{ 8, 0x28 }, /* 39 */
|
||||
{ 8, 0x29 }, /* 40 */
|
||||
{ 8, 0x2a }, /* 41 */
|
||||
{ 8, 0x2b }, /* 42 */
|
||||
{ 8, 0x2c }, /* 43 */
|
||||
{ 8, 0x2d }, /* 44 */
|
||||
{ 8, 0x04 }, /* 45 */
|
||||
{ 8, 0x05 }, /* 46 */
|
||||
{ 8, 0x0a }, /* 47 */
|
||||
{ 8, 0x0b }, /* 48 */
|
||||
{ 8, 0x52 }, /* 49 */
|
||||
{ 8, 0x53 }, /* 50 */
|
||||
{ 8, 0x54 }, /* 51 */
|
||||
{ 8, 0x55 }, /* 52 */
|
||||
{ 8, 0x24 }, /* 53 */
|
||||
{ 8, 0x25 }, /* 54 */
|
||||
{ 8, 0x58 }, /* 55 */
|
||||
{ 8, 0x59 }, /* 56 */
|
||||
{ 8, 0x5a }, /* 57 */
|
||||
{ 8, 0x5b }, /* 58 */
|
||||
{ 8, 0x4a }, /* 59 */
|
||||
{ 8, 0x4b }, /* 60 */
|
||||
{ 8, 0x32 }, /* 61 */
|
||||
{ 8, 0x33 }, /* 62 */
|
||||
{ 8, 0x34 } /* 63 */
|
||||
},
|
||||
{
|
||||
/* black */
|
||||
{ 10, 0x037 }, /* 0 */
|
||||
{ 3, 0x2 }, /* 1 */
|
||||
{ 2, 0x3 }, /* 2 */
|
||||
{ 2, 0x2 }, /* 3 */
|
||||
{ 3, 0x3 }, /* 4 */
|
||||
{ 4, 0x3 }, /* 5 */
|
||||
{ 4, 0x2 }, /* 6 */
|
||||
{ 5, 0x03 }, /* 7 */
|
||||
{ 6, 0x05 }, /* 8 */
|
||||
{ 6, 0x04 }, /* 9 */
|
||||
{ 7, 0x04 }, /* 10 */
|
||||
{ 7, 0x05 }, /* 11 */
|
||||
{ 7, 0x07 }, /* 12 */
|
||||
{ 8, 0x04 }, /* 13 */
|
||||
{ 8, 0x07 }, /* 14 */
|
||||
{ 9, 0x018 }, /* 15 */
|
||||
{ 10, 0x017 }, /* 16 */
|
||||
{ 10, 0x018 }, /* 17 */
|
||||
{ 10, 0x008 }, /* 18 */
|
||||
{ 11, 0x067 }, /* 19 */
|
||||
{ 11, 0x068 }, /* 20 */
|
||||
{ 11, 0x06c }, /* 21 */
|
||||
{ 11, 0x037 }, /* 22 */
|
||||
{ 11, 0x028 }, /* 23 */
|
||||
{ 11, 0x017 }, /* 24 */
|
||||
{ 11, 0x018 }, /* 25 */
|
||||
{ 12, 0x0ca }, /* 26 */
|
||||
{ 12, 0x0cb }, /* 27 */
|
||||
{ 12, 0x0cc }, /* 28 */
|
||||
{ 12, 0x0cd }, /* 29 */
|
||||
{ 12, 0x068 }, /* 30 */
|
||||
{ 12, 0x069 }, /* 31 */
|
||||
{ 12, 0x06a }, /* 32 */
|
||||
{ 12, 0x06b }, /* 33 */
|
||||
{ 12, 0x0d2 }, /* 34 */
|
||||
{ 12, 0x0d3 }, /* 35 */
|
||||
{ 12, 0x0d4 }, /* 36 */
|
||||
{ 12, 0x0d5 }, /* 37 */
|
||||
{ 12, 0x0d6 }, /* 38 */
|
||||
{ 12, 0x0d7 }, /* 39 */
|
||||
{ 12, 0x06c }, /* 40 */
|
||||
{ 12, 0x06d }, /* 41 */
|
||||
{ 12, 0x0da }, /* 42 */
|
||||
{ 12, 0x0db }, /* 43 */
|
||||
{ 12, 0x054 }, /* 44 */
|
||||
{ 12, 0x055 }, /* 45 */
|
||||
{ 12, 0x056 }, /* 46 */
|
||||
{ 12, 0x057 }, /* 47 */
|
||||
{ 12, 0x064 }, /* 48 */
|
||||
{ 12, 0x065 }, /* 49 */
|
||||
{ 12, 0x052 }, /* 50 */
|
||||
{ 12, 0x053 }, /* 51 */
|
||||
{ 12, 0x024 }, /* 52 */
|
||||
{ 12, 0x037 }, /* 53 */
|
||||
{ 12, 0x038 }, /* 54 */
|
||||
{ 12, 0x027 }, /* 55 */
|
||||
{ 12, 0x028 }, /* 56 */
|
||||
{ 12, 0x058 }, /* 57 */
|
||||
{ 12, 0x059 }, /* 58 */
|
||||
{ 12, 0x02b }, /* 59 */
|
||||
{ 12, 0x02c }, /* 60 */
|
||||
{ 12, 0x05a }, /* 61 */
|
||||
{ 12, 0x066 }, /* 62 */
|
||||
{ 12, 0x067 } /* 63 */
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static g4_bits g4_vert_code [7] =
|
||||
{
|
||||
{ 7, 0x02 },
|
||||
{ 6, 0x02 },
|
||||
{ 3, 0x02 },
|
||||
{ 1, 0x01 },
|
||||
{ 3, 0x03 },
|
||||
{ 6, 0x03 },
|
||||
{ 7, 0x03 }
|
||||
};
|
||||
Reference in New Issue
Block a user