001    /*
002     * TIFFFaxCodes
003     * 
004     * Copyright (c) 2002 Marco Schmidt <marcoschmidt@users.sourceforge.net>
005     * All rights reserved.
006     */
007    
008    package net.sourceforge.jiu.codecs.tiff;
009    
010    /**
011     * Information to be used to decode and encode TIFF files in one of the
012     * bilevel compression types Modified Huffman, CCITT Group 3 or CCITT Group 4.
013     * @author Marco Schmidt
014     * @since 0.9.0
015     */
016    public class TIFFFaxCodes
017    {
018            /**
019             * Index of the code word in the int[] value pairs.
020             */
021            public static final int INDEX_CODE_WORD = 0;
022    
023            /**
024             * Index of the code value in the int[] value pairs.
025             */
026            public static final int INDEX_CODE_VALUE = 1;
027    
028            /**
029             * Minimum code length in bits of black codes.
030             */
031            public static final int MIN_BLACK_CODE_SIZE = 2;
032    
033            /**
034             * Minimum code length in bits of white codes.
035             */
036            public static final int MIN_WHITE_CODE_SIZE = 4;
037    
038            /**
039             * The code words and their meanings for black codes.
040             * In ascending order, starting at MIN_BLACK_CODE_SIZE bits,
041             * each int[][] object contains all the code word / code value pairs
042             * for one bit length.
043             */
044            public static final int[][][] BLACK_CODES =
045            {
046                    { // 2 bits
047                            {2, 3},
048                            {3, 2},
049                    },
050                    { // 3 bits
051                            {2, 1},
052                            {3, 4},
053                    },
054                    { // 4 bits
055                            {2, 6},
056                            {3, 5},
057                    },
058                    { // 5 bits
059                            {3, 7},
060                    },
061                    { // 6 bits
062                            {4, 9},
063                            {5, 8},
064                    },
065                    { // 7 bits
066                            {4, 10},
067                            {5, 11},
068                            {7, 12},
069                    },
070                    { // 8 bits
071                            {4, 13},
072                            {7, 14},
073                    },
074                    { // 9 bits
075                            {24, 15},
076                    },
077                    { // 10 bits
078                            {23, 16},
079                            {24, 17},
080                            {55, 0},
081                            {8, 18},
082                            {15, 64},
083                    },
084                    { // 11 bits
085                            {23, 24},
086                            {24, 25},
087                            {40, 23},
088                            {55, 22},
089                            {103, 19},
090                            {104, 20},
091                            {108, 21},
092                            {8, 1792},
093                            {12, 1856},
094                            {13, 1920},
095                    },
096                    { // 12 bits
097                            {18, 1984},
098                            {19, 2048},
099                            {20, 2112},
100                            {21, 2176},
101                            {22, 2240},
102                            {23, 2304},
103                            {28, 2368},
104                            {29, 2432},
105                            {30, 2496},
106                            {31, 2560},
107                            {36, 52},
108                            {39, 55},
109                            {40, 56},
110                            {43, 59},
111                            {44, 60},
112                            {51, 320},
113                            {52, 384},
114                            {53, 448},
115                            {55, 53},
116                            {56, 54},
117                            {82, 50},
118                            {83, 51},
119                            {84, 44},
120                            {85, 45},
121                            {86, 46},
122                            {87, 47},
123                            {88, 57},
124                            {89, 58},
125                            {90, 61},
126                            {91, 256},
127                            {100, 48},
128                            {101, 49},
129                            {102, 62},
130                            {103, 63},
131                            {104, 30},
132                            {105, 31},
133                            {106, 32},
134                            {107, 33},
135                            {108, 40},
136                            {109, 41},
137                            {200, 128},
138                            {201, 192},
139                            {202, 26},
140                            {203, 27},
141                            {204, 28},
142                            {205, 29},
143                            {210, 34},
144                            {211, 35},
145                            {212, 36},
146                            {213, 37},
147                            {214, 38},
148                            {215, 39},
149                            {218, 42},
150                            {219, 43},
151                    },
152                    { // 13 bits
153                            {74, 640},
154                            {75, 704},
155                            {76, 768},
156                            {77, 832},
157                            {82, 1280},
158                            {83, 1344},
159                            {84, 1408},
160                            {85, 1472},
161                            {90, 1536},
162                            {91, 1600},
163                            {100, 1664},
164                            {101, 1728},
165                            {108, 512},
166                            {109, 576},
167                            {114, 896},
168                            {115, 960},
169                            {116, 1024},
170                            {117, 1088},
171                            {118, 1152},
172                            {119, 1216},
173                    }
174            };
175    
176            /**
177             * The code words and their meanings for white codes.
178             * In ascending order, starting at MIN_WHITE_CODE_SIZE bits,
179             * each int[][] object contains all the code word / code value pairs
180             * for one bit length.
181             */
182            public static final int[][][] WHITE_CODES =
183            {
184                    { // 4 bits
185                            {7, 2},
186                            {8, 3},
187                            {11, 4},
188                            {12, 5},
189                            {14, 6},
190                            {15, 7},
191                    },
192                    { // 5 bits
193                            {18, 128},
194                            {19, 8},
195                            {20, 9},
196                            {27, 64},
197                            {7, 10},
198                            {8, 11},
199                    },
200                    { // 6 bits
201                            {23, 192},
202                            {24, 1664},
203                            {42, 16},
204                            {43, 17},
205                            {3, 13},
206                            {52, 14},
207                            {53, 15},
208                            {7, 1},
209                            {8, 12},
210                    },
211                    { // 7 bits
212                            {19, 26},
213                            {23, 21},
214                            {24, 28},
215                            {36, 27},
216                            {39, 18},
217                            {40, 24},
218                            {43, 25},
219                            {3, 22},
220                            {55, 256},
221                            {4, 23},
222                            {8, 20},
223                            {12, 19},
224                    },
225                    { // 8 bits
226                            {18, 33},
227                            {19, 34},
228                            {20, 35},
229                            {21, 36},
230                            {22, 37},
231                            {23, 38},
232                            {26, 31},
233                            {27, 32},
234                            {2, 29},
235                            {36, 53},
236                            {37, 54},
237                            {40, 39},
238                            {41, 40},
239                            {42, 41},
240                            {43, 42},
241                            {44, 43},
242                            {45, 44},
243                            {3, 30},
244                            {50, 61},
245                            {51, 62},
246                            {52, 63},
247                            {53, 0},
248                            {54, 320},
249                            {55, 384},
250                            {4, 45},
251                            {74, 59},
252                            {75, 60},
253                            {5, 46},
254                            {82, 49},
255                            {83, 50},
256                            {84, 51},
257                            {85, 52},
258                            {88, 55},
259                            {89, 56},
260                            {90, 57},
261                            {91, 58},
262                            {100, 448},
263                            {101, 512},
264                            {103, 640},
265                            {104, 576},
266                            {10, 47},
267                            {11, 48},
268                    },
269                    { // 9 bits
270                            {152, 1472},
271                            {153, 1536},
272                            {154, 1600},
273                            {155, 1728},
274                            {204, 704},
275                            {205, 768},
276                            {210, 832},
277                            {211, 896},
278                            {212, 960},
279                            {213, 1024},
280                            {214, 1088},
281                            {215, 1152},
282                            {216, 1216},
283                            {217, 1280},
284                            {218, 1344},
285                            {219, 1408},
286                    },
287                    { // 10 bits
288                    },
289                    { // 11 bits
290                            {8, 1792},
291                            {12, 1856},
292                            {13, 1920},
293                    },
294                    { // 12 bits
295                            {18, 1984},
296                            {19, 2048},
297                            {20, 2112},
298                            {21, 2176},
299                            {22, 2240},
300                            {23, 2304},
301                            {28, 2368},
302                            {29, 2432},
303                            {30, 2496},
304                            {31, 2560},
305                    }
306            };
307    }
308