diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-04-20 02:40:25 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2017-04-20 02:40:25 +0000 |
commit | a35cb3047edcfb17d6b45275a38a51cb38c81158 (patch) | |
tree | b36b2e516a22844be449fe45b7ed06f0cc1e4292 /converter/pbm/g3.h | |
parent | 7c605e807606003cfe752c195762467dfe6398bc (diff) | |
download | netpbm-mirror-a35cb3047edcfb17d6b45275a38a51cb38c81158.tar.gz netpbm-mirror-a35cb3047edcfb17d6b45275a38a51cb38c81158.tar.xz netpbm-mirror-a35cb3047edcfb17d6b45275a38a51cb38c81158.zip |
New algorithm for pbmtog3, add -align8, -align16, don't use wordint anymore
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2956 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pbm/g3.h')
-rw-r--r-- | converter/pbm/g3.h | 297 |
1 files changed, 292 insertions, 5 deletions
diff --git a/converter/pbm/g3.h b/converter/pbm/g3.h index e982f2da..42ba91c5 100644 --- a/converter/pbm/g3.h +++ b/converter/pbm/g3.h @@ -24,12 +24,30 @@ There is also the newer G4. */ -typedef struct g3TableEntry { - short int code; - short int length; -} g3TableEntry; +typedef struct G3TableEntry { + unsigned short int code; + unsigned short int length; +} G3TableEntry; -static struct g3TableEntry ttable[] = { + +struct BitString { + /* A string of bits, up to as many fit in 32 bits. */ + uint32_t intBuffer; + /* The bits are in the 'bitCount' least significant bit positions + of this number. The rest of the bits of this number are always + zero. + */ + unsigned int bitCount; + /* The length of the bit string */ + + /* Example: The bit string 010100 would be represented by + bitCount = 6, intBuffer = 20 + (N.B. 20 = 00000000 00000000 00000000 00010100 in binary) + */ +}; + + +static struct G3TableEntry ttable[] = { /* TERMWHITE TERMBLACK */ { 0x35, 8 }, { 0x37, 10 }, /* white 0 , black 0 */ { 0x07, 6 }, { 0x02, 3 }, @@ -143,4 +161,273 @@ static struct g3TableEntry ttable[] = { #define mtable ((ttable)+64*2) + +struct PrefabCode { + unsigned int leadBits; + unsigned int trailBits; + struct BitString activeBits; +}; + + +struct PrefabCode const prefabCode[256] = +{ +{ 0, 8, { 0x0000, 0}}, /* 000 */ +{ 7, 1, { 0x0000, 0}}, /* 001 */ +{ 6, 1, { 0x0002, 3}}, /* 002 */ +{ 6, 2, { 0x0000, 0}}, /* 003 */ +{ 5, 2, { 0x0002, 3}}, /* 004 */ +{ 5, 1, { 0x0087, 9}}, /* 005 */ +{ 5, 1, { 0x0003, 2}}, /* 006 */ +{ 5, 3, { 0x0000, 0}}, /* 007 */ +{ 4, 3, { 0x0002, 3}}, /* 008 */ +{ 4, 1, { 0x0027, 7}}, /* 009 */ +{ 4, 1, { 0x043a, 12}}, /* 010 */ +{ 4, 2, { 0x0087, 9}}, /* 011 */ +{ 4, 2, { 0x0003, 2}}, /* 012 */ +{ 4, 1, { 0x00c7, 8}}, /* 013 */ +{ 4, 1, { 0x0002, 2}}, /* 014 */ +{ 4, 4, { 0x0000, 0}}, /* 015 */ +{ 3, 4, { 0x0002, 3}}, /* 016 */ +{ 3, 1, { 0x0028, 7}}, /* 017 */ +{ 3, 1, { 0x013a, 10}}, /* 018 */ +{ 3, 2, { 0x0027, 7}}, /* 019 */ +{ 3, 2, { 0x043a, 12}}, /* 020 */ +{ 3, 1, { 0x10e87, 18}}, /* 021 */ +{ 3, 1, { 0x021f, 11}}, /* 022 */ +{ 3, 3, { 0x0087, 9}}, /* 023 */ +{ 3, 3, { 0x0003, 2}}, /* 024 */ +{ 3, 1, { 0x0037, 6}}, /* 025 */ +{ 3, 1, { 0x063a, 11}}, /* 026 */ +{ 3, 2, { 0x00c7, 8}}, /* 027 */ +{ 3, 2, { 0x0002, 2}}, /* 028 */ +{ 3, 1, { 0x0087, 8}}, /* 029 */ +{ 3, 1, { 0x0003, 3}}, /* 030 */ +{ 3, 5, { 0x0000, 0}}, /* 031 */ +{ 2, 5, { 0x0002, 3}}, /* 032 */ +{ 2, 1, { 0x002b, 7}}, /* 033 */ +{ 2, 1, { 0x0142, 10}}, /* 034 */ +{ 2, 2, { 0x0028, 7}}, /* 035 */ +{ 2, 2, { 0x013a, 10}}, /* 036 */ +{ 2, 1, { 0x4e87, 16}}, /* 037 */ +{ 2, 1, { 0x009f, 9}}, /* 038 */ +{ 2, 3, { 0x0027, 7}}, /* 039 */ +{ 2, 3, { 0x043a, 12}}, /* 040 */ +{ 2, 1, { 0x43a7, 16}}, /* 041 */ +{ 2, 1, { 0x8743a, 21}}, /* 042 */ +{ 2, 2, { 0x10e87, 18}}, /* 043 */ +{ 2, 2, { 0x021f, 11}}, /* 044 */ +{ 2, 1, { 0x87c7, 17}}, /* 045 */ +{ 2, 1, { 0x021e, 11}}, /* 046 */ +{ 2, 4, { 0x0087, 9}}, /* 047 */ +{ 2, 4, { 0x0003, 2}}, /* 048 */ +{ 2, 1, { 0x0038, 6}}, /* 049 */ +{ 2, 1, { 0x01ba, 9}}, /* 050 */ +{ 2, 2, { 0x0037, 6}}, /* 051 */ +{ 2, 2, { 0x063a, 11}}, /* 052 */ +{ 2, 1, { 0x18e87, 17}}, /* 053 */ +{ 2, 1, { 0x031f, 10}}, /* 054 */ +{ 2, 3, { 0x00c7, 8}}, /* 055 */ +{ 2, 3, { 0x0002, 2}}, /* 056 */ +{ 2, 1, { 0x0027, 6}}, /* 057 */ +{ 2, 1, { 0x043a, 11}}, /* 058 */ +{ 2, 2, { 0x0087, 8}}, /* 059 */ +{ 2, 2, { 0x0003, 3}}, /* 060 */ +{ 2, 1, { 0x00c7, 9}}, /* 061 */ +{ 2, 1, { 0x0003, 4}}, /* 062 */ +{ 2, 6, { 0x0000, 0}}, /* 063 */ +{ 1, 6, { 0x0002, 3}}, /* 064 */ +{ 1, 1, { 0x002c, 7}}, /* 065 */ +{ 1, 1, { 0x015a, 10}}, /* 066 */ +{ 1, 2, { 0x002b, 7}}, /* 067 */ +{ 1, 2, { 0x0142, 10}}, /* 068 */ +{ 1, 1, { 0x5087, 16}}, /* 069 */ +{ 1, 1, { 0x00a3, 9}}, /* 070 */ +{ 1, 3, { 0x0028, 7}}, /* 071 */ +{ 1, 3, { 0x013a, 10}}, /* 072 */ +{ 1, 1, { 0x13a7, 14}}, /* 073 */ +{ 1, 1, { 0x2743a, 19}}, /* 074 */ +{ 1, 2, { 0x4e87, 16}}, /* 075 */ +{ 1, 2, { 0x009f, 9}}, /* 076 */ +{ 1, 1, { 0x27c7, 15}}, /* 077 */ +{ 1, 1, { 0x009e, 9}}, /* 078 */ +{ 1, 4, { 0x0027, 7}}, /* 079 */ +{ 1, 4, { 0x043a, 12}}, /* 080 */ +{ 1, 1, { 0x43a8, 16}}, /* 081 */ +{ 1, 1, { 0x21d3a, 19}}, /* 082 */ +{ 1, 2, { 0x43a7, 16}}, /* 083 */ +{ 1, 2, { 0x8743a, 21}}, /* 084 */ +{ 1, 1, {0x21d0e87, 27}}, /* 085 */ +{ 1, 1, { 0x43a1f, 20}}, /* 086 */ +{ 1, 3, { 0x10e87, 18}}, /* 087 */ +{ 1, 3, { 0x021f, 11}}, /* 088 */ +{ 1, 1, { 0x21f7, 15}}, /* 089 */ +{ 1, 1, { 0x43e3a, 20}}, /* 090 */ +{ 1, 2, { 0x87c7, 17}}, /* 091 */ +{ 1, 2, { 0x021e, 11}}, /* 092 */ +{ 1, 1, { 0x8787, 17}}, /* 093 */ +{ 1, 1, { 0x043b, 12}}, /* 094 */ +{ 1, 5, { 0x0087, 9}}, /* 095 */ +{ 1, 5, { 0x0003, 2}}, /* 096 */ +{ 1, 1, { 0x003b, 6}}, /* 097 */ +{ 1, 1, { 0x01c2, 9}}, /* 098 */ +{ 1, 2, { 0x0038, 6}}, /* 099 */ +{ 1, 2, { 0x01ba, 9}}, /* 100 */ +{ 1, 1, { 0x6e87, 15}}, /* 101 */ +{ 1, 1, { 0x00df, 8}}, /* 102 */ +{ 1, 3, { 0x0037, 6}}, /* 103 */ +{ 1, 3, { 0x063a, 11}}, /* 104 */ +{ 1, 1, { 0x63a7, 15}}, /* 105 */ +{ 1, 1, { 0xc743a, 20}}, /* 106 */ +{ 1, 2, { 0x18e87, 17}}, /* 107 */ +{ 1, 2, { 0x031f, 10}}, /* 108 */ +{ 1, 1, { 0xc7c7, 16}}, /* 109 */ +{ 1, 1, { 0x031e, 10}}, /* 110 */ +{ 1, 4, { 0x00c7, 8}}, /* 111 */ +{ 1, 4, { 0x0002, 2}}, /* 112 */ +{ 1, 1, { 0x0028, 6}}, /* 113 */ +{ 1, 1, { 0x013a, 9}}, /* 114 */ +{ 1, 2, { 0x0027, 6}}, /* 115 */ +{ 1, 2, { 0x043a, 11}}, /* 116 */ +{ 1, 1, { 0x10e87, 17}}, /* 117 */ +{ 1, 1, { 0x021f, 10}}, /* 118 */ +{ 1, 3, { 0x0087, 8}}, /* 119 */ +{ 1, 3, { 0x0003, 3}}, /* 120 */ +{ 1, 1, { 0x0037, 7}}, /* 121 */ +{ 1, 1, { 0x063a, 12}}, /* 122 */ +{ 1, 2, { 0x00c7, 9}}, /* 123 */ +{ 1, 2, { 0x0003, 4}}, /* 124 */ +{ 1, 1, { 0x00c7, 10}}, /* 125 */ +{ 1, 1, { 0x0002, 4}}, /* 126 */ +{ 1, 7, { 0x0000, 0}}, /* 127 */ +{ 1, 7, { 0x0000, 0}}, /* 128 */ +{ 1, 1, { 0x000e, 4}}, /* 129 */ +{ 1, 1, { 0x0062, 7}}, /* 130 */ +{ 1, 2, { 0x000c, 4}}, /* 131 */ +{ 1, 2, { 0x005a, 7}}, /* 132 */ +{ 1, 1, { 0x1687, 13}}, /* 133 */ +{ 1, 1, { 0x002f, 6}}, /* 134 */ +{ 1, 3, { 0x000b, 4}}, /* 135 */ +{ 1, 3, { 0x0042, 7}}, /* 136 */ +{ 1, 1, { 0x0427, 11}}, /* 137 */ +{ 1, 1, { 0x843a, 16}}, /* 138 */ +{ 1, 2, { 0x1087, 13}}, /* 139 */ +{ 1, 2, { 0x0023, 6}}, /* 140 */ +{ 1, 1, { 0x08c7, 12}}, /* 141 */ +{ 1, 1, { 0x0022, 6}}, /* 142 */ +{ 1, 4, { 0x0008, 4}}, /* 143 */ +{ 1, 4, { 0x003a, 7}}, /* 144 */ +{ 1, 1, { 0x03a8, 11}}, /* 145 */ +{ 1, 1, { 0x1d3a, 14}}, /* 146 */ +{ 1, 2, { 0x03a7, 11}}, /* 147 */ +{ 1, 2, { 0x743a, 16}}, /* 148 */ +{ 1, 1, { 0x1d0e87, 22}}, /* 149 */ +{ 1, 1, { 0x3a1f, 15}}, /* 150 */ +{ 1, 3, { 0x0e87, 13}}, /* 151 */ +{ 1, 3, { 0x001f, 6}}, /* 152 */ +{ 1, 1, { 0x01f7, 10}}, /* 153 */ +{ 1, 1, { 0x3e3a, 15}}, /* 154 */ +{ 1, 2, { 0x07c7, 12}}, /* 155 */ +{ 1, 2, { 0x001e, 6}}, /* 156 */ +{ 1, 1, { 0x0787, 12}}, /* 157 */ +{ 1, 1, { 0x003b, 7}}, /* 158 */ +{ 1, 5, { 0x0007, 4}}, /* 159 */ +{ 1, 5, { 0x003a, 9}}, /* 160 */ +{ 1, 1, { 0x03ab, 13}}, /* 161 */ +{ 1, 1, { 0x1d42, 16}}, /* 162 */ +{ 1, 2, { 0x03a8, 13}}, /* 163 */ +{ 1, 2, { 0x1d3a, 16}}, /* 164 */ +{ 1, 1, { 0x74e87, 22}}, /* 165 */ +{ 1, 1, { 0x0e9f, 15}}, /* 166 */ +{ 1, 3, { 0x03a7, 13}}, /* 167 */ +{ 1, 3, { 0x743a, 18}}, /* 168 */ +{ 1, 1, { 0x743a7, 22}}, /* 169 */ +{ 1, 1, { 0xe8743a, 27}}, /* 170 */ +{ 1, 2, { 0x1d0e87, 24}}, /* 171 */ +{ 1, 2, { 0x3a1f, 17}}, /* 172 */ +{ 1, 1, { 0xe87c7, 23}}, /* 173 */ +{ 1, 1, { 0x3a1e, 17}}, /* 174 */ +{ 1, 4, { 0x0e87, 15}}, /* 175 */ +{ 1, 4, { 0x001f, 8}}, /* 176 */ +{ 1, 1, { 0x01f8, 12}}, /* 177 */ +{ 1, 1, { 0x0fba, 15}}, /* 178 */ +{ 1, 2, { 0x01f7, 12}}, /* 179 */ +{ 1, 2, { 0x3e3a, 17}}, /* 180 */ +{ 1, 1, { 0xf8e87, 23}}, /* 181 */ +{ 1, 1, { 0x1f1f, 16}}, /* 182 */ +{ 1, 3, { 0x07c7, 14}}, /* 183 */ +{ 1, 3, { 0x001e, 8}}, /* 184 */ +{ 1, 1, { 0x01e7, 12}}, /* 185 */ +{ 1, 1, { 0x3c3a, 17}}, /* 186 */ +{ 1, 2, { 0x0787, 14}}, /* 187 */ +{ 1, 2, { 0x003b, 9}}, /* 188 */ +{ 1, 1, { 0x0ec7, 15}}, /* 189 */ +{ 1, 1, { 0x0073, 10}}, /* 190 */ +{ 1, 6, { 0x0007, 6}}, /* 191 */ +{ 2, 6, { 0x0000, 0}}, /* 192 */ +{ 2, 1, { 0x000c, 4}}, /* 193 */ +{ 2, 1, { 0x005a, 7}}, /* 194 */ +{ 2, 2, { 0x000b, 4}}, /* 195 */ +{ 2, 2, { 0x0042, 7}}, /* 196 */ +{ 2, 1, { 0x1087, 13}}, /* 197 */ +{ 2, 1, { 0x0023, 6}}, /* 198 */ +{ 2, 3, { 0x0008, 4}}, /* 199 */ +{ 2, 3, { 0x003a, 7}}, /* 200 */ +{ 2, 1, { 0x03a7, 11}}, /* 201 */ +{ 2, 1, { 0x743a, 16}}, /* 202 */ +{ 2, 2, { 0x0e87, 13}}, /* 203 */ +{ 2, 2, { 0x001f, 6}}, /* 204 */ +{ 2, 1, { 0x07c7, 12}}, /* 205 */ +{ 2, 1, { 0x001e, 6}}, /* 206 */ +{ 2, 4, { 0x0007, 4}}, /* 207 */ +{ 2, 4, { 0x003a, 9}}, /* 208 */ +{ 2, 1, { 0x03a8, 13}}, /* 209 */ +{ 2, 1, { 0x1d3a, 16}}, /* 210 */ +{ 2, 2, { 0x03a7, 13}}, /* 211 */ +{ 2, 2, { 0x743a, 18}}, /* 212 */ +{ 2, 1, { 0x1d0e87, 24}}, /* 213 */ +{ 2, 1, { 0x3a1f, 17}}, /* 214 */ +{ 2, 3, { 0x0e87, 15}}, /* 215 */ +{ 2, 3, { 0x001f, 8}}, /* 216 */ +{ 2, 1, { 0x01f7, 12}}, /* 217 */ +{ 2, 1, { 0x3e3a, 17}}, /* 218 */ +{ 2, 2, { 0x07c7, 14}}, /* 219 */ +{ 2, 2, { 0x001e, 8}}, /* 220 */ +{ 2, 1, { 0x0787, 14}}, /* 221 */ +{ 2, 1, { 0x003b, 9}}, /* 222 */ +{ 2, 5, { 0x0007, 6}}, /* 223 */ +{ 3, 5, { 0x0000, 0}}, /* 224 */ +{ 3, 1, { 0x000b, 4}}, /* 225 */ +{ 3, 1, { 0x0042, 7}}, /* 226 */ +{ 3, 2, { 0x0008, 4}}, /* 227 */ +{ 3, 2, { 0x003a, 7}}, /* 228 */ +{ 3, 1, { 0x0e87, 13}}, /* 229 */ +{ 3, 1, { 0x001f, 6}}, /* 230 */ +{ 3, 3, { 0x0007, 4}}, /* 231 */ +{ 3, 3, { 0x003a, 9}}, /* 232 */ +{ 3, 1, { 0x03a7, 13}}, /* 233 */ +{ 3, 1, { 0x743a, 18}}, /* 234 */ +{ 3, 2, { 0x0e87, 15}}, /* 235 */ +{ 3, 2, { 0x001f, 8}}, /* 236 */ +{ 3, 1, { 0x07c7, 14}}, /* 237 */ +{ 3, 1, { 0x001e, 8}}, /* 238 */ +{ 3, 4, { 0x0007, 6}}, /* 239 */ +{ 4, 4, { 0x0000, 0}}, /* 240 */ +{ 4, 1, { 0x0008, 4}}, /* 241 */ +{ 4, 1, { 0x003a, 7}}, /* 242 */ +{ 4, 2, { 0x0007, 4}}, /* 243 */ +{ 4, 2, { 0x003a, 9}}, /* 244 */ +{ 4, 1, { 0x0e87, 15}}, /* 245 */ +{ 4, 1, { 0x001f, 8}}, /* 246 */ +{ 4, 3, { 0x0007, 6}}, /* 247 */ +{ 5, 3, { 0x0000, 0}}, /* 248 */ +{ 5, 1, { 0x0007, 4}}, /* 249 */ +{ 5, 1, { 0x003a, 9}}, /* 250 */ +{ 5, 2, { 0x0007, 6}}, /* 251 */ +{ 6, 2, { 0x0000, 0}}, /* 252 */ +{ 6, 1, { 0x0007, 6}}, /* 253 */ +{ 7, 1, { 0x0000, 0}}, /* 254 */ +{ 0, 8, { 0x0000, 0}}, /* 255 */ + }; + #endif + |