Sat, 22 Feb 2003 10:02:06 +0000
Generate G4 tables from strings of ones and zeros.
Makefile | file | annotate | diff | revisions | |
g4_table_gen.c | file | annotate | diff | revisions | |
pdf_g4_table_gen.c | file | annotate | diff | revisions | |
pdf_g4_tables.h | file | annotate | diff | revisions |
1.1 --- a/Makefile Fri Feb 21 12:29:16 2003 +0000 1.2 +++ b/Makefile Sat Feb 22 10:02:06 2003 +0000 1.3 @@ -1,6 +1,6 @@ 1.4 # t2p: build a PDF file out of one or more TIFF Class F Group 4 files 1.5 # Makefile 1.6 -# $Id: Makefile,v 1.15 2003/02/21 04:29:16 eric Exp $ 1.7 +# $Id: Makefile,v 1.16 2003/02/22 02:02:06 eric Exp $ 1.8 # Copyright 2001 Eric Smith <eric@brouhaha.com> 1.9 # 1.10 # This program is free software; you can redistribute it and/or modify 1.11 @@ -43,10 +43,10 @@ 1.12 TARGETS = t2p bitblt_test 1.13 1.14 CSRCS = t2p.c semantics.c bitblt.c bitblt_test.c bitblt_table_gen.c \ 1.15 - pdf.c pdf_util.c pdf_prim.c pdf_g4.c 1.16 + pdf.c pdf_util.c pdf_prim.c pdf_g4.c pdf_g4_table_gen.c 1.17 OSRCS = scanner.l parser.y 1.18 HDRS = t2p.h semantics.h bitblt.h \ 1.19 - pdf.h pdf_private.h pdf_util.h pdf_prim.h pdf_g4_codes.h 1.20 + pdf.h pdf_private.h pdf_util.h pdf_prim.h 1.21 MISC = COPYING Makefile 1.22 1.23 DISTFILES = $(MISC) $(HDRS) $(CSRCS) $(OSRCS) 1.24 @@ -54,7 +54,7 @@ 1.25 1.26 1.27 AUTO_CSRCS = scanner.c parser.tab.c 1.28 -AUTO_HDRS = parser.tab.h bitblt_tables.h 1.29 +AUTO_HDRS = parser.tab.h bitblt_tables.h pdf_g4_tables.h 1.30 AUTO_MISC = parser.output 1.31 1.32 1.33 @@ -71,6 +71,11 @@ 1.34 1.35 bitblt_test: bitblt_test.o bitblt.o 1.36 1.37 +pdf_g4_tables.h: pdf_g4_table_gen 1.38 + ./pdf_g4_table_gen >pdf_g4_tables.h 1.39 + 1.40 +pdf_g4_table_gen: pdf_g4_table_gen.o 1.41 + 1.42 1.43 dist: $(DISTFILES) 1.44 -rm -rf $(DISTNAME)
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/g4_table_gen.c Sat Feb 22 10:02:06 2003 +0000 2.3 @@ -0,0 +1,284 @@ 2.4 +/* 2.5 + * t2p: Create a PDF file from the contents of one or more TIFF 2.6 + * bilevel image files. The images in the resulting PDF file 2.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 2.8 + * 2.9 + * G4 table generator 2.10 + * $Id: g4_table_gen.c,v 1.1 2003/02/22 02:02:06 eric Exp $ 2.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 2.12 + * 2.13 + * This program is free software; you can redistribute it and/or modify 2.14 + * it under the terms of the GNU General Public License version 2 as 2.15 + * published by the Free Software Foundation. Note that permission is 2.16 + * not granted to redistribute this program under the terms of any 2.17 + * other version of the General Public License. 2.18 + * 2.19 + * This program is distributed in the hope that it will be useful, 2.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 2.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 2.22 + * GNU General Public License for more details. 2.23 + * 2.24 + * You should have received a copy of the GNU General Public License 2.25 + * along with this program; if not, write to the Free Software 2.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 2.27 + */ 2.28 + 2.29 + 2.30 +#include <stdbool.h> 2.31 +#include <stdint.h> 2.32 +#include <stdio.h> 2.33 +#include <stdlib.h> 2.34 +#include <string.h> 2.35 + 2.36 + 2.37 +void emit_code (int indent, char *code, int last, bool comment, int cval) 2.38 +{ 2.39 + int i; 2.40 + int count = 0; 2.41 + uint32_t val = 0; 2.42 + 2.43 + printf ("%*s{ ", indent, ""); 2.44 + 2.45 + printf ("%d, ", strlen (code)); 2.46 + 2.47 + for (i = 0; i < strlen (code); i++) 2.48 + switch (code [i]) 2.49 + { 2.50 + case '0': val = (val << 1); count++; break; 2.51 + case '1': val = (val << 1) + 1; count++; break; 2.52 + case ' ': break; 2.53 + default: 2.54 + fprintf (stderr, "internal error\n"); 2.55 + exit (2); 2.56 + } 2.57 + 2.58 + printf ("0x%0*x", (count + 3)/4, val); 2.59 + 2.60 + printf (" }"); 2.61 + if (! last) 2.62 + printf (","); 2.63 + if (comment) 2.64 + printf (" /* %d */", cval); 2.65 + printf ("\n"); 2.66 +} 2.67 + 2.68 + 2.69 +char *long_makeup_code [12] = 2.70 + { 2.71 + /* 1792 */ "00000001000", 2.72 + /* 1856 */ "00000001100", 2.73 + /* 1920 */ "00000001101", 2.74 + /* 1984 */ "000000010010", 2.75 + /* 2048 */ "000000010011", 2.76 + /* 2112 */ "000000010100", 2.77 + /* 2176 */ "000000010101", 2.78 + /* 2240 */ "000000010110", 2.79 + /* 2304 */ "000000010111", 2.80 + /* 2368 */ "000000011100", 2.81 + /* 2432 */ "000000011101", 2.82 + /* 2496 */ "000000011110" 2.83 + /* 2560 "000000011111" hard-coded, doesn't need to be in table */ 2.84 + }; 2.85 + 2.86 + 2.87 +void print_long_makeup_code (void) 2.88 +{ 2.89 + int i; 2.90 + 2.91 + printf ("static g4_bits g4_long_makeup_code [12] =\n"); 2.92 + printf (" {\n"); 2.93 + for (i = 0; i < 12; i++) 2.94 + emit_code (4, long_makeup_code [i], i == 11, 1, i * 64 + 1792); 2.95 + printf (" };\n"); 2.96 +} 2.97 + 2.98 + 2.99 +char *makeup_code [64][2] = 2.100 + { 2.101 + { /* 64 */ "11011", "0000001111" }, 2.102 + { /* 128 */ "10010", "000011001000" }, 2.103 + { /* 192 */ "010111", "000011001001" }, 2.104 + { /* 256 */ "0110111", "000001011011" }, 2.105 + { /* 320 */ "00110110", "000000110011" }, 2.106 + { /* 384 */ "00110111", "000000110100" }, 2.107 + { /* 448 */ "01100100", "000000110101" }, 2.108 + { /* 512 */ "01100101", "0000001101100" }, 2.109 + { /* 576 */ "01101000", "0000001101101" }, 2.110 + { /* 640 */ "01100111", "0000001001010" }, 2.111 + { /* 704 */ "011001100", "0000001001011" }, 2.112 + { /* 768 */ "011001101", "0000001001100" }, 2.113 + { /* 832 */ "011010010", "0000001001101" }, 2.114 + { /* 896 */ "011010011", "0000001110010" }, 2.115 + { /* 960 */ "011010100", "0000001110011" }, 2.116 + { /* 1024 */ "011010101", "0000001110100" }, 2.117 + { /* 1088 */ "011010110", "0000001110101" }, 2.118 + { /* 1152 */ "011010111", "0000001110110" }, 2.119 + { /* 1216 */ "011011000", "0000001110111" }, 2.120 + { /* 1280 */ "011011001", "0000001010010" }, 2.121 + { /* 1344 */ "011011010", "0000001010011" }, 2.122 + { /* 1408 */ "011011011", "0000001010100" }, 2.123 + { /* 1472 */ "010011000", "0000001010101" }, 2.124 + { /* 1536 */ "010011001", "0000001011010" }, 2.125 + { /* 1600 */ "010011010", "0000001011011" }, 2.126 + { /* 1664 */ "011000", "0000001100100" }, 2.127 + { /* 1728 */ "010011011", "0000001100101" } 2.128 + }; 2.129 + 2.130 + 2.131 +void print_makeup_code (void) 2.132 +{ 2.133 + int i; 2.134 + 2.135 + printf ("static g4_bits g4_makeup_code [2] [27] =\n"); 2.136 + printf (" {\n"); 2.137 + printf (" {\n"); 2.138 + printf (" /* white */\n"); 2.139 + for (i = 0; i <= 26; i++) 2.140 + emit_code (6, makeup_code [i][0], i == 26, 1, (i + 1) * 64); 2.141 + printf (" },\n"); 2.142 + printf (" {\n"); 2.143 + printf (" /* black */\n"); 2.144 + for (i = 0; i <= 26; i++) 2.145 + emit_code (6, makeup_code [i][1], i == 26, 1, (i + 1) * 64); 2.146 + printf (" }\n"); 2.147 + printf (" };\n"); 2.148 +} 2.149 + 2.150 + 2.151 +char *h_code [64][2] = 2.152 + { 2.153 + { /* 0 */ "00110101", "0000110111" }, 2.154 + { /* 1 */ "000111", "010" }, 2.155 + { /* 2 */ "0111", "11" }, 2.156 + { /* 3 */ "1000", "10" }, 2.157 + { /* 4 */ "1011", "011" }, 2.158 + { /* 5 */ "1100", "0011" }, 2.159 + { /* 6 */ "1110", "0010" }, 2.160 + { /* 7 */ "1111", "00011" }, 2.161 + { /* 8 */ "10011", "000101" }, 2.162 + { /* 9 */ "10100", "000100" }, 2.163 + { /* 10 */ "00111", "0000100" }, 2.164 + { /* 11 */ "01000", "0000101" }, 2.165 + { /* 12 */ "001000", "0000111" }, 2.166 + { /* 13 */ "000011", "00000100" }, 2.167 + { /* 14 */ "110100", "00000111" }, 2.168 + { /* 15 */ "110101", "000011000" }, 2.169 + { /* 16 */ "101010", "0000010111" }, 2.170 + { /* 17 */ "101011", "0000011000" }, 2.171 + { /* 18 */ "0100111", "0000001000" }, 2.172 + { /* 19 */ "0001100", "00001100111" }, 2.173 + { /* 20 */ "0001000", "00001101000" }, 2.174 + { /* 21 */ "0010111", "00001101100" }, 2.175 + { /* 22 */ "0000011", "00000110111" }, 2.176 + { /* 23 */ "0000100", "00000101000" }, 2.177 + { /* 24 */ "0101000", "00000010111" }, 2.178 + { /* 25 */ "0101011", "00000011000" }, 2.179 + { /* 26 */ "0010011", "000011001010" }, 2.180 + { /* 27 */ "0100100", "000011001011" }, 2.181 + { /* 28 */ "0011000", "000011001100" }, 2.182 + { /* 29 */ "00000010", "000011001101" }, 2.183 + { /* 30 */ "00000011", "000001101000" }, 2.184 + { /* 31 */ "00011010", "000001101001" }, 2.185 + { /* 32 */ "00011011", "000001101010" }, 2.186 + { /* 33 */ "00010010", "000001101011" }, 2.187 + { /* 34 */ "00010011", "000011010010" }, 2.188 + { /* 35 */ "00010100", "000011010011" }, 2.189 + { /* 36 */ "00010101", "000011010100" }, 2.190 + { /* 37 */ "00010110", "000011010101" }, 2.191 + { /* 38 */ "00010111", "000011010110" }, 2.192 + { /* 39 */ "00101000", "000011010111" }, 2.193 + { /* 40 */ "00101001", "000001101100" }, 2.194 + { /* 41 */ "00101010", "000001101101" }, 2.195 + { /* 42 */ "00101011", "000011011010" }, 2.196 + { /* 43 */ "00101100", "000011011011" }, 2.197 + { /* 44 */ "00101101", "000001010100" }, 2.198 + { /* 45 */ "00000100", "000001010101" }, 2.199 + { /* 46 */ "00000101", "000001010110" }, 2.200 + { /* 47 */ "00001010", "000001010111" }, 2.201 + { /* 48 */ "00001011", "000001100100" }, 2.202 + { /* 49 */ "01010010", "000001100101" }, 2.203 + { /* 50 */ "01010011", "000001010010" }, 2.204 + { /* 51 */ "01010100", "000001010011" }, 2.205 + { /* 52 */ "01010101", "000000100100" }, 2.206 + { /* 53 */ "00100100", "000000110111" }, 2.207 + { /* 54 */ "00100101", "000000111000" }, 2.208 + { /* 55 */ "01011000", "000000100111" }, 2.209 + { /* 56 */ "01011001", "000000101000" }, 2.210 + { /* 57 */ "01011010", "000001011000" }, 2.211 + { /* 58 */ "01011011", "000001011001" }, 2.212 + { /* 59 */ "01001010", "000000101011" }, 2.213 + { /* 60 */ "01001011", "000000101100" }, 2.214 + { /* 61 */ "00110010", "000001011010" }, 2.215 + { /* 62 */ "00110011", "000001100110" }, 2.216 + { /* 63 */ "00110100", "000001100111" } 2.217 + }; 2.218 + 2.219 + 2.220 +void print_h_code (void) 2.221 +{ 2.222 + int i; 2.223 + 2.224 + printf ("static g4_bits g4_h_code [2] [64] =\n"); 2.225 + printf (" {\n"); 2.226 + printf (" {\n"); 2.227 + printf (" /* white */\n"); 2.228 + for (i = 0; i <= 63; i++) 2.229 + emit_code (6, h_code [i][0], i == 63, 1, i); 2.230 + printf (" },\n"); 2.231 + printf (" {\n"); 2.232 + printf (" /* black */\n"); 2.233 + for (i = 0; i <= 63; i++) 2.234 + emit_code (6, h_code [i][1], i == 63, 1, i); 2.235 + printf (" }\n"); 2.236 + printf (" };\n"); 2.237 +} 2.238 + 2.239 + 2.240 +char *v_code [7] = 2.241 + { 2.242 + /* -3 */ "0000010", 2.243 + /* -2 */ "000010", 2.244 + /* -1 */ "010", 2.245 + /* 0 */ "1", 2.246 + /* 1 */ "011", 2.247 + /* 2 */ "000011", 2.248 + /* 3 */ "0000011" 2.249 + }; 2.250 + 2.251 + 2.252 +void print_v_code (void) 2.253 +{ 2.254 + int i; 2.255 + 2.256 + printf ("static g4_bits g4_vert_code [7] =\n"); 2.257 + printf (" {\n"); 2.258 + for (i = 0; i <= 6; i++) 2.259 + emit_code (4, v_code [i], i == 6, 1, i - 3); 2.260 + printf (" };\n"); 2.261 +} 2.262 + 2.263 + 2.264 +int main (int argc, char *argv []) 2.265 +{ 2.266 + printf ("/* This file is automatically generated; do not edit */\n"); 2.267 + printf ("\n"); 2.268 + printf ("typedef struct\n"); 2.269 + printf ("{\n"); 2.270 + printf (" uint32_t count;\n"); 2.271 + printf (" uint32_t bits;\n"); 2.272 + printf ("} g4_bits;\n"); 2.273 + printf ("\n"); 2.274 + 2.275 + print_long_makeup_code (); 2.276 + printf ("\n"); 2.277 + 2.278 + print_makeup_code (); 2.279 + printf ("\n"); 2.280 + 2.281 + print_h_code (); 2.282 + printf ("\n"); 2.283 + 2.284 + print_v_code (); 2.285 + 2.286 + exit (0); 2.287 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/pdf_g4_table_gen.c Sat Feb 22 10:02:06 2003 +0000 3.3 @@ -0,0 +1,284 @@ 3.4 +/* 3.5 + * t2p: Create a PDF file from the contents of one or more TIFF 3.6 + * bilevel image files. The images in the resulting PDF file 3.7 + * will be compressed using ITU-T T.6 (G4) fax encoding. 3.8 + * 3.9 + * G4 table generator 3.10 + * $Id: pdf_g4_table_gen.c,v 1.1 2003/02/22 02:02:06 eric Exp $ 3.11 + * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 3.12 + * 3.13 + * This program is free software; you can redistribute it and/or modify 3.14 + * it under the terms of the GNU General Public License version 2 as 3.15 + * published by the Free Software Foundation. Note that permission is 3.16 + * not granted to redistribute this program under the terms of any 3.17 + * other version of the General Public License. 3.18 + * 3.19 + * This program is distributed in the hope that it will be useful, 3.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 3.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 3.22 + * GNU General Public License for more details. 3.23 + * 3.24 + * You should have received a copy of the GNU General Public License 3.25 + * along with this program; if not, write to the Free Software 3.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 3.27 + */ 3.28 + 3.29 + 3.30 +#include <stdbool.h> 3.31 +#include <stdint.h> 3.32 +#include <stdio.h> 3.33 +#include <stdlib.h> 3.34 +#include <string.h> 3.35 + 3.36 + 3.37 +void emit_code (int indent, char *code, int last, bool comment, int cval) 3.38 +{ 3.39 + int i; 3.40 + int count = 0; 3.41 + uint32_t val = 0; 3.42 + 3.43 + printf ("%*s{ ", indent, ""); 3.44 + 3.45 + printf ("%d, ", strlen (code)); 3.46 + 3.47 + for (i = 0; i < strlen (code); i++) 3.48 + switch (code [i]) 3.49 + { 3.50 + case '0': val = (val << 1); count++; break; 3.51 + case '1': val = (val << 1) + 1; count++; break; 3.52 + case ' ': break; 3.53 + default: 3.54 + fprintf (stderr, "internal error\n"); 3.55 + exit (2); 3.56 + } 3.57 + 3.58 + printf ("0x%0*x", (count + 3)/4, val); 3.59 + 3.60 + printf (" }"); 3.61 + if (! last) 3.62 + printf (","); 3.63 + if (comment) 3.64 + printf (" /* %d */", cval); 3.65 + printf ("\n"); 3.66 +} 3.67 + 3.68 + 3.69 +char *long_makeup_code [12] = 3.70 + { 3.71 + /* 1792 */ "00000001000", 3.72 + /* 1856 */ "00000001100", 3.73 + /* 1920 */ "00000001101", 3.74 + /* 1984 */ "000000010010", 3.75 + /* 2048 */ "000000010011", 3.76 + /* 2112 */ "000000010100", 3.77 + /* 2176 */ "000000010101", 3.78 + /* 2240 */ "000000010110", 3.79 + /* 2304 */ "000000010111", 3.80 + /* 2368 */ "000000011100", 3.81 + /* 2432 */ "000000011101", 3.82 + /* 2496 */ "000000011110" 3.83 + /* 2560 "000000011111" hard-coded, doesn't need to be in table */ 3.84 + }; 3.85 + 3.86 + 3.87 +void print_long_makeup_code (void) 3.88 +{ 3.89 + int i; 3.90 + 3.91 + printf ("static g4_bits g4_long_makeup_code [12] =\n"); 3.92 + printf (" {\n"); 3.93 + for (i = 0; i < 12; i++) 3.94 + emit_code (4, long_makeup_code [i], i == 11, 1, i * 64 + 1792); 3.95 + printf (" };\n"); 3.96 +} 3.97 + 3.98 + 3.99 +char *makeup_code [64][2] = 3.100 + { 3.101 + { /* 64 */ "11011", "0000001111" }, 3.102 + { /* 128 */ "10010", "000011001000" }, 3.103 + { /* 192 */ "010111", "000011001001" }, 3.104 + { /* 256 */ "0110111", "000001011011" }, 3.105 + { /* 320 */ "00110110", "000000110011" }, 3.106 + { /* 384 */ "00110111", "000000110100" }, 3.107 + { /* 448 */ "01100100", "000000110101" }, 3.108 + { /* 512 */ "01100101", "0000001101100" }, 3.109 + { /* 576 */ "01101000", "0000001101101" }, 3.110 + { /* 640 */ "01100111", "0000001001010" }, 3.111 + { /* 704 */ "011001100", "0000001001011" }, 3.112 + { /* 768 */ "011001101", "0000001001100" }, 3.113 + { /* 832 */ "011010010", "0000001001101" }, 3.114 + { /* 896 */ "011010011", "0000001110010" }, 3.115 + { /* 960 */ "011010100", "0000001110011" }, 3.116 + { /* 1024 */ "011010101", "0000001110100" }, 3.117 + { /* 1088 */ "011010110", "0000001110101" }, 3.118 + { /* 1152 */ "011010111", "0000001110110" }, 3.119 + { /* 1216 */ "011011000", "0000001110111" }, 3.120 + { /* 1280 */ "011011001", "0000001010010" }, 3.121 + { /* 1344 */ "011011010", "0000001010011" }, 3.122 + { /* 1408 */ "011011011", "0000001010100" }, 3.123 + { /* 1472 */ "010011000", "0000001010101" }, 3.124 + { /* 1536 */ "010011001", "0000001011010" }, 3.125 + { /* 1600 */ "010011010", "0000001011011" }, 3.126 + { /* 1664 */ "011000", "0000001100100" }, 3.127 + { /* 1728 */ "010011011", "0000001100101" } 3.128 + }; 3.129 + 3.130 + 3.131 +void print_makeup_code (void) 3.132 +{ 3.133 + int i; 3.134 + 3.135 + printf ("static g4_bits g4_makeup_code [2] [27] =\n"); 3.136 + printf (" {\n"); 3.137 + printf (" {\n"); 3.138 + printf (" /* white */\n"); 3.139 + for (i = 0; i <= 26; i++) 3.140 + emit_code (6, makeup_code [i][0], i == 26, 1, (i + 1) * 64); 3.141 + printf (" },\n"); 3.142 + printf (" {\n"); 3.143 + printf (" /* black */\n"); 3.144 + for (i = 0; i <= 26; i++) 3.145 + emit_code (6, makeup_code [i][1], i == 26, 1, (i + 1) * 64); 3.146 + printf (" }\n"); 3.147 + printf (" };\n"); 3.148 +} 3.149 + 3.150 + 3.151 +char *h_code [64][2] = 3.152 + { 3.153 + { /* 0 */ "00110101", "0000110111" }, 3.154 + { /* 1 */ "000111", "010" }, 3.155 + { /* 2 */ "0111", "11" }, 3.156 + { /* 3 */ "1000", "10" }, 3.157 + { /* 4 */ "1011", "011" }, 3.158 + { /* 5 */ "1100", "0011" }, 3.159 + { /* 6 */ "1110", "0010" }, 3.160 + { /* 7 */ "1111", "00011" }, 3.161 + { /* 8 */ "10011", "000101" }, 3.162 + { /* 9 */ "10100", "000100" }, 3.163 + { /* 10 */ "00111", "0000100" }, 3.164 + { /* 11 */ "01000", "0000101" }, 3.165 + { /* 12 */ "001000", "0000111" }, 3.166 + { /* 13 */ "000011", "00000100" }, 3.167 + { /* 14 */ "110100", "00000111" }, 3.168 + { /* 15 */ "110101", "000011000" }, 3.169 + { /* 16 */ "101010", "0000010111" }, 3.170 + { /* 17 */ "101011", "0000011000" }, 3.171 + { /* 18 */ "0100111", "0000001000" }, 3.172 + { /* 19 */ "0001100", "00001100111" }, 3.173 + { /* 20 */ "0001000", "00001101000" }, 3.174 + { /* 21 */ "0010111", "00001101100" }, 3.175 + { /* 22 */ "0000011", "00000110111" }, 3.176 + { /* 23 */ "0000100", "00000101000" }, 3.177 + { /* 24 */ "0101000", "00000010111" }, 3.178 + { /* 25 */ "0101011", "00000011000" }, 3.179 + { /* 26 */ "0010011", "000011001010" }, 3.180 + { /* 27 */ "0100100", "000011001011" }, 3.181 + { /* 28 */ "0011000", "000011001100" }, 3.182 + { /* 29 */ "00000010", "000011001101" }, 3.183 + { /* 30 */ "00000011", "000001101000" }, 3.184 + { /* 31 */ "00011010", "000001101001" }, 3.185 + { /* 32 */ "00011011", "000001101010" }, 3.186 + { /* 33 */ "00010010", "000001101011" }, 3.187 + { /* 34 */ "00010011", "000011010010" }, 3.188 + { /* 35 */ "00010100", "000011010011" }, 3.189 + { /* 36 */ "00010101", "000011010100" }, 3.190 + { /* 37 */ "00010110", "000011010101" }, 3.191 + { /* 38 */ "00010111", "000011010110" }, 3.192 + { /* 39 */ "00101000", "000011010111" }, 3.193 + { /* 40 */ "00101001", "000001101100" }, 3.194 + { /* 41 */ "00101010", "000001101101" }, 3.195 + { /* 42 */ "00101011", "000011011010" }, 3.196 + { /* 43 */ "00101100", "000011011011" }, 3.197 + { /* 44 */ "00101101", "000001010100" }, 3.198 + { /* 45 */ "00000100", "000001010101" }, 3.199 + { /* 46 */ "00000101", "000001010110" }, 3.200 + { /* 47 */ "00001010", "000001010111" }, 3.201 + { /* 48 */ "00001011", "000001100100" }, 3.202 + { /* 49 */ "01010010", "000001100101" }, 3.203 + { /* 50 */ "01010011", "000001010010" }, 3.204 + { /* 51 */ "01010100", "000001010011" }, 3.205 + { /* 52 */ "01010101", "000000100100" }, 3.206 + { /* 53 */ "00100100", "000000110111" }, 3.207 + { /* 54 */ "00100101", "000000111000" }, 3.208 + { /* 55 */ "01011000", "000000100111" }, 3.209 + { /* 56 */ "01011001", "000000101000" }, 3.210 + { /* 57 */ "01011010", "000001011000" }, 3.211 + { /* 58 */ "01011011", "000001011001" }, 3.212 + { /* 59 */ "01001010", "000000101011" }, 3.213 + { /* 60 */ "01001011", "000000101100" }, 3.214 + { /* 61 */ "00110010", "000001011010" }, 3.215 + { /* 62 */ "00110011", "000001100110" }, 3.216 + { /* 63 */ "00110100", "000001100111" } 3.217 + }; 3.218 + 3.219 + 3.220 +void print_h_code (void) 3.221 +{ 3.222 + int i; 3.223 + 3.224 + printf ("static g4_bits g4_h_code [2] [64] =\n"); 3.225 + printf (" {\n"); 3.226 + printf (" {\n"); 3.227 + printf (" /* white */\n"); 3.228 + for (i = 0; i <= 63; i++) 3.229 + emit_code (6, h_code [i][0], i == 63, 1, i); 3.230 + printf (" },\n"); 3.231 + printf (" {\n"); 3.232 + printf (" /* black */\n"); 3.233 + for (i = 0; i <= 63; i++) 3.234 + emit_code (6, h_code [i][1], i == 63, 1, i); 3.235 + printf (" }\n"); 3.236 + printf (" };\n"); 3.237 +} 3.238 + 3.239 + 3.240 +char *v_code [7] = 3.241 + { 3.242 + /* -3 */ "0000010", 3.243 + /* -2 */ "000010", 3.244 + /* -1 */ "010", 3.245 + /* 0 */ "1", 3.246 + /* 1 */ "011", 3.247 + /* 2 */ "000011", 3.248 + /* 3 */ "0000011" 3.249 + }; 3.250 + 3.251 + 3.252 +void print_v_code (void) 3.253 +{ 3.254 + int i; 3.255 + 3.256 + printf ("static g4_bits g4_vert_code [7] =\n"); 3.257 + printf (" {\n"); 3.258 + for (i = 0; i <= 6; i++) 3.259 + emit_code (4, v_code [i], i == 6, 1, i - 3); 3.260 + printf (" };\n"); 3.261 +} 3.262 + 3.263 + 3.264 +int main (int argc, char *argv []) 3.265 +{ 3.266 + printf ("/* This file is automatically generated; do not edit */\n"); 3.267 + printf ("\n"); 3.268 + printf ("typedef struct\n"); 3.269 + printf ("{\n"); 3.270 + printf (" uint32_t count;\n"); 3.271 + printf (" uint32_t bits;\n"); 3.272 + printf ("} g4_bits;\n"); 3.273 + printf ("\n"); 3.274 + 3.275 + print_long_makeup_code (); 3.276 + printf ("\n"); 3.277 + 3.278 + print_makeup_code (); 3.279 + printf ("\n"); 3.280 + 3.281 + print_h_code (); 3.282 + printf ("\n"); 3.283 + 3.284 + print_v_code (); 3.285 + 3.286 + exit (0); 3.287 +}
4.1 --- a/pdf_g4_tables.h Fri Feb 21 12:29:16 2003 +0000 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,262 +0,0 @@ 4.4 -/* 4.5 - * t2p: Create a PDF file from the contents of one or more TIFF 4.6 - * bilevel image files. The images in the resulting PDF file 4.7 - * will be compressed using ITU-T T.6 (G4) fax encoding. 4.8 - * 4.9 - * G4 encoding tables 4.10 - * $Id: pdf_g4_tables.h,v 1.2 2003/02/21 04:28:37 eric Exp $ 4.11 - * Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com> 4.12 - * 4.13 - * This program is free software; you can redistribute it and/or modify 4.14 - * it under the terms of the GNU General Public License version 2 as 4.15 - * published by the Free Software Foundation. Note that permission is 4.16 - * not granted to redistribute this program under the terms of any 4.17 - * other version of the General Public License. 4.18 - * 4.19 - * This program is distributed in the hope that it will be useful, 4.20 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.21 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.22 - * GNU General Public License for more details. 4.23 - * 4.24 - * You should have received a copy of the GNU General Public License 4.25 - * along with this program; if not, write to the Free Software 4.26 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA 4.27 - */ 4.28 - 4.29 - 4.30 -typedef struct 4.31 -{ 4.32 - uint32_t count; 4.33 - uint32_t bits; 4.34 -} g4_bits; 4.35 - 4.36 -static g4_bits g4_long_makeup_code [12] = 4.37 - { 4.38 - { 11, 0x008 }, /* 1792 */ 4.39 - { 11, 0x00c }, /* 1856 */ 4.40 - { 11, 0x00d }, /* 1920 */ 4.41 - { 12, 0x012 }, /* 1984 */ 4.42 - { 12, 0x013 }, /* 2048 */ 4.43 - { 12, 0x014 }, /* 2112 */ 4.44 - { 12, 0x015 }, /* 2176 */ 4.45 - { 12, 0x016 }, /* 2240 */ 4.46 - { 12, 0x017 }, /* 2304 */ 4.47 - { 12, 0x01c }, /* 2368 */ 4.48 - { 12, 0x01d }, /* 2432 */ 4.49 - { 12, 0x01e } /* 2496 */ 4.50 - }; 4.51 - 4.52 -static g4_bits g4_makeup_code [2] [27] = 4.53 - { 4.54 - { 4.55 - /* white */ 4.56 - { 5, 0x1b }, /* 64 */ 4.57 - { 5, 0x12 }, /* 128 */ 4.58 - { 6, 0x17 }, /* 192 */ 4.59 - { 7, 0x37 }, /* 256 */ 4.60 - { 8, 0x36 }, /* 320 */ 4.61 - { 8, 0x37 }, /* 384 */ 4.62 - { 8, 0x64 }, /* 448 */ 4.63 - { 8, 0x65 }, /* 512 */ 4.64 - { 8, 0x68 }, /* 576 */ 4.65 - { 8, 0x67 }, /* 640 */ 4.66 - { 9, 0x0cc }, /* 704 */ 4.67 - { 9, 0x0cd }, /* 768 */ 4.68 - { 9, 0x0d2 }, /* 832 */ 4.69 - { 9, 0x0d3 }, /* 896 */ 4.70 - { 9, 0x0d4 }, /* 960 */ 4.71 - { 9, 0x0d5 }, /* 1024 */ 4.72 - { 9, 0x0d6 }, /* 1088 */ 4.73 - { 9, 0x0d7 }, /* 1152 */ 4.74 - { 9, 0x0d8 }, /* 1216 */ 4.75 - { 9, 0x0d9 }, /* 1280 */ 4.76 - { 9, 0x0da }, /* 1344 */ 4.77 - { 9, 0x0db }, /* 1408 */ 4.78 - { 9, 0x098 }, /* 1472 */ 4.79 - { 9, 0x099 }, /* 1536 */ 4.80 - { 9, 0x09a }, /* 1600 */ 4.81 - { 6, 0x18 }, /* 1664 */ 4.82 - { 9, 0x09b } /* 1728 */ 4.83 - }, 4.84 - { 4.85 - /* black */ 4.86 - { 10, 0x00f }, /* 64 */ 4.87 - { 12, 0x0c8 }, /* 128 */ 4.88 - { 12, 0x0c9 }, /* 192 */ 4.89 - { 12, 0x05b }, /* 256 */ 4.90 - { 12, 0x033 }, /* 320 */ 4.91 - { 12, 0x034 }, /* 384 */ 4.92 - { 12, 0x035 }, /* 448 */ 4.93 - { 13, 0x006c }, /* 512 */ 4.94 - { 13, 0x006d }, /* 576 */ 4.95 - { 13, 0x004a }, /* 640 */ 4.96 - { 13, 0x004b }, /* 704 */ 4.97 - { 13, 0x004c }, /* 768 */ 4.98 - { 13, 0x004d }, /* 832 */ 4.99 - { 13, 0x0072 }, /* 896 */ 4.100 - { 13, 0x0073 }, /* 960 */ 4.101 - { 13, 0x0074 }, /* 1024 */ 4.102 - { 13, 0x0075 }, /* 1088 */ 4.103 - { 13, 0x0076 }, /* 1152 */ 4.104 - { 13, 0x0077 }, /* 1216 */ 4.105 - { 13, 0x0052 }, /* 1280 */ 4.106 - { 13, 0x0053 }, /* 1344 */ 4.107 - { 13, 0x0054 }, /* 1408 */ 4.108 - { 13, 0x0055 }, /* 1472 */ 4.109 - { 13, 0x005a }, /* 1536 */ 4.110 - { 13, 0x005b }, /* 1600 */ 4.111 - { 13, 0x0064 }, /* 1664 */ 4.112 - { 13, 0x0065 }, /* 1728 */ 4.113 - } 4.114 - }; 4.115 - 4.116 - 4.117 -static g4_bits g4_h_code [2] [64] = 4.118 - { 4.119 - { 4.120 - /* white */ 4.121 - { 8, 0x35 }, /* 0 */ 4.122 - { 6, 0x07 }, /* 1 */ 4.123 - { 4, 0x7 }, /* 2 */ 4.124 - { 4, 0x8 }, /* 3 */ 4.125 - { 4, 0xb }, /* 4 */ 4.126 - { 4, 0xc }, /* 5 */ 4.127 - { 4, 0xe }, /* 6 */ 4.128 - { 4, 0xf }, /* 7 */ 4.129 - { 5, 0x13 }, /* 8 */ 4.130 - { 5, 0x14 }, /* 9 */ 4.131 - { 5, 0x07 }, /* 10 */ 4.132 - { 5, 0x08 }, /* 11 */ 4.133 - { 6, 0x08 }, /* 12 */ 4.134 - { 6, 0x03 }, /* 13 */ 4.135 - { 6, 0x34 }, /* 14 */ 4.136 - { 6, 0x35 }, /* 15 */ 4.137 - { 6, 0x2a }, /* 16 */ 4.138 - { 6, 0x2b }, /* 17 */ 4.139 - { 7, 0x27 }, /* 18 */ 4.140 - { 7, 0x0c }, /* 19 */ 4.141 - { 7, 0x04 }, /* 20 */ 4.142 - { 7, 0x17 }, /* 21 */ 4.143 - { 7, 0x03 }, /* 22 */ 4.144 - { 7, 0x04 }, /* 23 */ 4.145 - { 7, 0x28 }, /* 24 */ 4.146 - { 7, 0x2b }, /* 25 */ 4.147 - { 7, 0x13 }, /* 26 */ 4.148 - { 7, 0x24 }, /* 27 */ 4.149 - { 7, 0x18 }, /* 28 */ 4.150 - { 8, 0x02 }, /* 29 */ 4.151 - { 8, 0x03 }, /* 30 */ 4.152 - { 8, 0x1a }, /* 31 */ 4.153 - { 8, 0x1b }, /* 32 */ 4.154 - { 8, 0x12 }, /* 33 */ 4.155 - { 8, 0x13 }, /* 34 */ 4.156 - { 8, 0x14 }, /* 35 */ 4.157 - { 8, 0x15 }, /* 36 */ 4.158 - { 8, 0x16 }, /* 37 */ 4.159 - { 8, 0x17 }, /* 38 */ 4.160 - { 8, 0x28 }, /* 39 */ 4.161 - { 8, 0x29 }, /* 40 */ 4.162 - { 8, 0x2a }, /* 41 */ 4.163 - { 8, 0x2b }, /* 42 */ 4.164 - { 8, 0x2c }, /* 43 */ 4.165 - { 8, 0x2d }, /* 44 */ 4.166 - { 8, 0x04 }, /* 45 */ 4.167 - { 8, 0x05 }, /* 46 */ 4.168 - { 8, 0x0a }, /* 47 */ 4.169 - { 8, 0x0b }, /* 48 */ 4.170 - { 8, 0x52 }, /* 49 */ 4.171 - { 8, 0x53 }, /* 50 */ 4.172 - { 8, 0x54 }, /* 51 */ 4.173 - { 8, 0x55 }, /* 52 */ 4.174 - { 8, 0x24 }, /* 53 */ 4.175 - { 8, 0x25 }, /* 54 */ 4.176 - { 8, 0x58 }, /* 55 */ 4.177 - { 8, 0x59 }, /* 56 */ 4.178 - { 8, 0x5a }, /* 57 */ 4.179 - { 8, 0x5b }, /* 58 */ 4.180 - { 8, 0x4a }, /* 59 */ 4.181 - { 8, 0x4b }, /* 60 */ 4.182 - { 8, 0x32 }, /* 61 */ 4.183 - { 8, 0x33 }, /* 62 */ 4.184 - { 8, 0x34 } /* 63 */ 4.185 - }, 4.186 - { 4.187 - /* black */ 4.188 - { 10, 0x037 }, /* 0 */ 4.189 - { 3, 0x2 }, /* 1 */ 4.190 - { 2, 0x3 }, /* 2 */ 4.191 - { 2, 0x2 }, /* 3 */ 4.192 - { 3, 0x3 }, /* 4 */ 4.193 - { 4, 0x3 }, /* 5 */ 4.194 - { 4, 0x2 }, /* 6 */ 4.195 - { 5, 0x03 }, /* 7 */ 4.196 - { 6, 0x05 }, /* 8 */ 4.197 - { 6, 0x04 }, /* 9 */ 4.198 - { 7, 0x04 }, /* 10 */ 4.199 - { 7, 0x05 }, /* 11 */ 4.200 - { 7, 0x07 }, /* 12 */ 4.201 - { 8, 0x04 }, /* 13 */ 4.202 - { 8, 0x07 }, /* 14 */ 4.203 - { 9, 0x018 }, /* 15 */ 4.204 - { 10, 0x017 }, /* 16 */ 4.205 - { 10, 0x018 }, /* 17 */ 4.206 - { 10, 0x008 }, /* 18 */ 4.207 - { 11, 0x067 }, /* 19 */ 4.208 - { 11, 0x068 }, /* 20 */ 4.209 - { 11, 0x06c }, /* 21 */ 4.210 - { 11, 0x037 }, /* 22 */ 4.211 - { 11, 0x028 }, /* 23 */ 4.212 - { 11, 0x017 }, /* 24 */ 4.213 - { 11, 0x018 }, /* 25 */ 4.214 - { 12, 0x0ca }, /* 26 */ 4.215 - { 12, 0x0cb }, /* 27 */ 4.216 - { 12, 0x0cc }, /* 28 */ 4.217 - { 12, 0x0cd }, /* 29 */ 4.218 - { 12, 0x068 }, /* 30 */ 4.219 - { 12, 0x069 }, /* 31 */ 4.220 - { 12, 0x06a }, /* 32 */ 4.221 - { 12, 0x06b }, /* 33 */ 4.222 - { 12, 0x0d2 }, /* 34 */ 4.223 - { 12, 0x0d3 }, /* 35 */ 4.224 - { 12, 0x0d4 }, /* 36 */ 4.225 - { 12, 0x0d5 }, /* 37 */ 4.226 - { 12, 0x0d6 }, /* 38 */ 4.227 - { 12, 0x0d7 }, /* 39 */ 4.228 - { 12, 0x06c }, /* 40 */ 4.229 - { 12, 0x06d }, /* 41 */ 4.230 - { 12, 0x0da }, /* 42 */ 4.231 - { 12, 0x0db }, /* 43 */ 4.232 - { 12, 0x054 }, /* 44 */ 4.233 - { 12, 0x055 }, /* 45 */ 4.234 - { 12, 0x056 }, /* 46 */ 4.235 - { 12, 0x057 }, /* 47 */ 4.236 - { 12, 0x064 }, /* 48 */ 4.237 - { 12, 0x065 }, /* 49 */ 4.238 - { 12, 0x052 }, /* 50 */ 4.239 - { 12, 0x053 }, /* 51 */ 4.240 - { 12, 0x024 }, /* 52 */ 4.241 - { 12, 0x037 }, /* 53 */ 4.242 - { 12, 0x038 }, /* 54 */ 4.243 - { 12, 0x027 }, /* 55 */ 4.244 - { 12, 0x028 }, /* 56 */ 4.245 - { 12, 0x058 }, /* 57 */ 4.246 - { 12, 0x059 }, /* 58 */ 4.247 - { 12, 0x02b }, /* 59 */ 4.248 - { 12, 0x02c }, /* 60 */ 4.249 - { 12, 0x05a }, /* 61 */ 4.250 - { 12, 0x066 }, /* 62 */ 4.251 - { 12, 0x067 } /* 63 */ 4.252 - } 4.253 - }; 4.254 - 4.255 - 4.256 -static g4_bits g4_vert_code [7] = 4.257 - { 4.258 - { 7, 0x02 }, 4.259 - { 6, 0x02 }, 4.260 - { 3, 0x02 }, 4.261 - { 1, 0x01 }, 4.262 - { 3, 0x03 }, 4.263 - { 6, 0x03 }, 4.264 - { 7, 0x03 } 4.265 - };