LibreOffice Module vcl (master)  1
ccidecom.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include "ccidecom.hxx"
22 #include <tools/stream.hxx>
23 
24 //=============================== Huffman tables ========================
25 
26 //---------------------------- White-Run ------------------------------
27 
28 #define CCIWhiteTableSize 105
29 
31  { 0, 0x0035, 8 },
32  { 1, 0x0007, 6 },
33  { 2, 0x0007, 4 },
34  { 3, 0x0008, 4 },
35  { 4, 0x000b, 4 },
36  { 5, 0x000c, 4 },
37  { 6, 0x000e, 4 },
38  { 7, 0x000f, 4 },
39  { 8, 0x0013, 5 },
40  { 9, 0x0014, 5 },
41  { 10, 0x0007, 5 },
42  { 11, 0x0008, 5 },
43  { 12, 0x0008, 6 },
44  { 13, 0x0003, 6 },
45  { 14, 0x0034, 6 },
46  { 15, 0x0035, 6 },
47  { 16, 0x002a, 6 },
48  { 17, 0x002b, 6 },
49  { 18, 0x0027, 7 },
50  { 19, 0x000c, 7 },
51  { 20, 0x0008, 7 },
52  { 21, 0x0017, 7 },
53  { 22, 0x0003, 7 },
54  { 23, 0x0004, 7 },
55  { 24, 0x0028, 7 },
56  { 25, 0x002b, 7 },
57  { 26, 0x0013, 7 },
58  { 27, 0x0024, 7 },
59  { 28, 0x0018, 7 },
60  { 29, 0x0002, 8 },
61  { 30, 0x0003, 8 },
62  { 31, 0x001a, 8 },
63  { 32, 0x001b, 8 },
64  { 33, 0x0012, 8 },
65  { 34, 0x0013, 8 },
66  { 35, 0x0014, 8 },
67  { 36, 0x0015, 8 },
68  { 37, 0x0016, 8 },
69  { 38, 0x0017, 8 },
70  { 39, 0x0028, 8 },
71  { 40, 0x0029, 8 },
72  { 41, 0x002a, 8 },
73  { 42, 0x002b, 8 },
74  { 43, 0x002c, 8 },
75  { 44, 0x002d, 8 },
76  { 45, 0x0004, 8 },
77  { 46, 0x0005, 8 },
78  { 47, 0x000a, 8 },
79  { 48, 0x000b, 8 },
80  { 49, 0x0052, 8 },
81  { 50, 0x0053, 8 },
82  { 51, 0x0054, 8 },
83  { 52, 0x0055, 8 },
84  { 53, 0x0024, 8 },
85  { 54, 0x0025, 8 },
86  { 55, 0x0058, 8 },
87  { 56, 0x0059, 8 },
88  { 57, 0x005a, 8 },
89  { 58, 0x005b, 8 },
90  { 59, 0x004a, 8 },
91  { 60, 0x004b, 8 },
92  { 61, 0x0032, 8 },
93  { 62, 0x0033, 8 },
94  { 63, 0x0034, 8 },
95  { 64, 0x001b, 5 },
96  { 128, 0x0012, 5 },
97  { 192, 0x0017, 6 },
98  { 256, 0x0037, 7 },
99  { 320, 0x0036, 8 },
100  { 384, 0x0037, 8 },
101  { 448, 0x0064, 8 },
102  { 512, 0x0065, 8 },
103  { 576, 0x0068, 8 },
104  { 640, 0x0067, 8 },
105  { 704, 0x00cc, 9 },
106  { 768, 0x00cd, 9 },
107  { 832, 0x00d2, 9 },
108  { 896, 0x00d3, 9 },
109  { 960, 0x00d4, 9 },
110  { 1024, 0x00d5, 9 },
111  { 1088, 0x00d6, 9 },
112  { 1152, 0x00d7, 9 },
113  { 1216, 0x00d8, 9 },
114  { 1280, 0x00d9, 9 },
115  { 1344, 0x00da, 9 },
116  { 1408, 0x00db, 9 },
117  { 1472, 0x0098, 9 },
118  { 1536, 0x0099, 9 },
119  { 1600, 0x009a, 9 },
120  { 1664, 0x0018, 6 },
121  { 1728, 0x009b, 9 },
122  { 1792, 0x0008, 11 },
123  { 1856, 0x000c, 11 },
124  { 1920, 0x000d, 11 },
125  { 1984, 0x0012, 12 },
126  { 2048, 0x0013, 12 },
127  { 2112, 0x0014, 12 },
128  { 2176, 0x0015, 12 },
129  { 2240, 0x0016, 12 },
130  { 2304, 0x0017, 12 },
131  { 2368, 0x001c, 12 },
132  { 2432, 0x001d, 12 },
133  { 2496, 0x001e, 12 },
134  { 2560, 0x001f, 12 },
135  { 9999, 0x0001, 12 } // EOL
136 };
137 
138 //---------------------------- Black-Run ------------------------------
139 
140 #define CCIBlackTableSize 105
141 
143  { 0, 0x0037, 10 },
144  { 1, 0x0002, 3 },
145  { 2, 0x0003, 2 },
146  { 3, 0x0002, 2 },
147  { 4, 0x0003, 3 },
148  { 5, 0x0003, 4 },
149  { 6, 0x0002, 4 },
150  { 7, 0x0003, 5 },
151  { 8, 0x0005, 6 },
152  { 9, 0x0004, 6 },
153  { 10, 0x0004, 7 },
154  { 11, 0x0005, 7 },
155  { 12, 0x0007, 7 },
156  { 13, 0x0004, 8 },
157  { 14, 0x0007, 8 },
158  { 15, 0x0018, 9 },
159  { 16, 0x0017, 10 },
160  { 17, 0x0018, 10 },
161  { 18, 0x0008, 10 },
162  { 19, 0x0067, 11 },
163  { 20, 0x0068, 11 },
164  { 21, 0x006c, 11 },
165  { 22, 0x0037, 11 },
166  { 23, 0x0028, 11 },
167  { 24, 0x0017, 11 },
168  { 25, 0x0018, 11 },
169  { 26, 0x00ca, 12 },
170  { 27, 0x00cb, 12 },
171  { 28, 0x00cc, 12 },
172  { 29, 0x00cd, 12 },
173  { 30, 0x0068, 12 },
174  { 31, 0x0069, 12 },
175  { 32, 0x006a, 12 },
176  { 33, 0x006b, 12 },
177  { 34, 0x00d2, 12 },
178  { 35, 0x00d3, 12 },
179  { 36, 0x00d4, 12 },
180  { 37, 0x00d5, 12 },
181  { 38, 0x00d6, 12 },
182  { 39, 0x00d7, 12 },
183  { 40, 0x006c, 12 },
184  { 41, 0x006d, 12 },
185  { 42, 0x00da, 12 },
186  { 43, 0x00db, 12 },
187  { 44, 0x0054, 12 },
188  { 45, 0x0055, 12 },
189  { 46, 0x0056, 12 },
190  { 47, 0x0057, 12 },
191  { 48, 0x0064, 12 },
192  { 49, 0x0065, 12 },
193  { 50, 0x0052, 12 },
194  { 51, 0x0053, 12 },
195  { 52, 0x0024, 12 },
196  { 53, 0x0037, 12 },
197  { 54, 0x0038, 12 },
198  { 55, 0x0027, 12 },
199  { 56, 0x0028, 12 },
200  { 57, 0x0058, 12 },
201  { 58, 0x0059, 12 },
202  { 59, 0x002b, 12 },
203  { 60, 0x002c, 12 },
204  { 61, 0x005a, 12 },
205  { 62, 0x0066, 12 },
206  { 63, 0x0067, 12 },
207  { 64, 0x000f, 10 },
208  { 128, 0x00c8, 12 },
209  { 192, 0x00c9, 12 },
210  { 256, 0x005b, 12 },
211  { 320, 0x0033, 12 },
212  { 384, 0x0034, 12 },
213  { 448, 0x0035, 12 },
214  { 512, 0x006c, 13 },
215  { 576, 0x006d, 13 },
216  { 640, 0x004a, 13 },
217  { 704, 0x004b, 13 },
218  { 768, 0x004c, 13 },
219  { 832, 0x004d, 13 },
220  { 896, 0x0072, 13 },
221  { 960, 0x0073, 13 },
222  { 1024, 0x0074, 13 },
223  { 1088, 0x0075, 13 },
224  { 1152, 0x0076, 13 },
225  { 1216, 0x0077, 13 },
226  { 1280, 0x0052, 13 },
227  { 1344, 0x0053, 13 },
228  { 1408, 0x0054, 13 },
229  { 1472, 0x0055, 13 },
230  { 1536, 0x005a, 13 },
231  { 1600, 0x005b, 13 },
232  { 1664, 0x0064, 13 },
233  { 1728, 0x0065, 13 },
234  { 1792, 0x0008, 11 },
235  { 1856, 0x000c, 11 },
236  { 1920, 0x000d, 11 },
237  { 1984, 0x0012, 12 },
238  { 2048, 0x0013, 12 },
239  { 2112, 0x0014, 12 },
240  { 2176, 0x0015, 12 },
241  { 2240, 0x0016, 12 },
242  { 2304, 0x0017, 12 },
243  { 2368, 0x001c, 12 },
244  { 2432, 0x001d, 12 },
245  { 2496, 0x001e, 12 },
246  { 2560, 0x001f, 12 },
247  { 9999, 0x0001, 12 } // EOL
248 };
249 
250 
251 //---------------------------- 2D-Mode --------------------------------
252 
253 #define CCI2DMODE_UNCOMP 0
254 #define CCI2DMODE_PASS 1
255 #define CCI2DMODE_HORZ 2
256 #define CCI2DMODE_VERT_L3 3
257 #define CCI2DMODE_VERT_L2 4
258 #define CCI2DMODE_VERT_L1 5
259 #define CCI2DMODE_VERT_0 6
260 #define CCI2DMODE_VERT_R1 7
261 #define CCI2DMODE_VERT_R2 8
262 #define CCI2DMODE_VERT_R3 9
263 
264 #define CCI2DModeTableSize 10
265 
267  { CCI2DMODE_UNCOMP , 0x000f, 10 },
268  { CCI2DMODE_PASS , 0x0001, 4 },
269  { CCI2DMODE_HORZ , 0x0001, 3 },
270  { CCI2DMODE_VERT_L3, 0x0002, 7 },
271  { CCI2DMODE_VERT_L2, 0x0002, 6 },
272  { CCI2DMODE_VERT_L1, 0x0002, 3 },
273  { CCI2DMODE_VERT_0 , 0x0001, 1 },
274  { CCI2DMODE_VERT_R1, 0x0003, 3 },
275  { CCI2DMODE_VERT_R2, 0x0003, 6 },
276  { CCI2DMODE_VERT_R3, 0x0003, 7 }
277 };
278 
279 
280 //-------------------------- 2D-Uncompressed-Mode ----------------------
281 
282 #define CCIUNCOMP_0White_1Black 0
283 #define CCIUNCOMP_1White_1Black 1
284 #define CCIUNCOMP_2White_1Black 2
285 #define CCIUNCOMP_3White_1Black 3
286 #define CCIUNCOMP_4White_1Black 4
287 #define CCIUNCOMP_5White 5
288 #define CCIUNCOMP_0White_End 6
289 #define CCIUNCOMP_1White_End 7
290 #define CCIUNCOMP_2White_End 8
291 #define CCIUNCOMP_3White_End 9
292 #define CCIUNCOMP_4White_End 10
293 
294 #define CCIUncompTableSize 11
295 
297  { CCIUNCOMP_0White_1Black, 0x0001, 1 },
298  { CCIUNCOMP_1White_1Black, 0x0001, 2 },
299  { CCIUNCOMP_2White_1Black, 0x0001, 3 },
300  { CCIUNCOMP_3White_1Black, 0x0001, 4 },
301  { CCIUNCOMP_4White_1Black, 0x0001, 5 },
302  { CCIUNCOMP_5White , 0x0001, 6 },
303  { CCIUNCOMP_0White_End , 0x0001, 7 },
304  { CCIUNCOMP_1White_End , 0x0001, 8 },
305  { CCIUNCOMP_2White_End , 0x0001, 9 },
306  { CCIUNCOMP_3White_End , 0x0001, 10 },
307  { CCIUNCOMP_4White_End , 0x0001, 11 }
308 };
309 
310 
311 //================== backup of the Huffman tables ============================
312 // To make sure that the Huffman tables do not contain errors they were entered
313 // from two different sources (Phew) and compared.
314 // Since an error could creep into the source code while maintaining it
315 // (e.g. an accidental key press in the editor) the tables are listed twice
316 // and are compared during runtime. (If the comparison fails CCIDcompressor
317 // throws an error) The whole thing may appear insane, but an error within the
318 // tables would otherwise be really hard to discover and it's very unlikely that
319 // one or more sample files run through all codes.
320 
322  { 0, 0x0035, 8 },
323  { 1, 0x0007, 6 },
324  { 2, 0x0007, 4 },
325  { 3, 0x0008, 4 },
326  { 4, 0x000b, 4 },
327  { 5, 0x000c, 4 },
328  { 6, 0x000e, 4 },
329  { 7, 0x000f, 4 },
330  { 8, 0x0013, 5 },
331  { 9, 0x0014, 5 },
332  { 10, 0x0007, 5 },
333  { 11, 0x0008, 5 },
334  { 12, 0x0008, 6 },
335  { 13, 0x0003, 6 },
336  { 14, 0x0034, 6 },
337  { 15, 0x0035, 6 },
338  { 16, 0x002a, 6 },
339  { 17, 0x002b, 6 },
340  { 18, 0x0027, 7 },
341  { 19, 0x000c, 7 },
342  { 20, 0x0008, 7 },
343  { 21, 0x0017, 7 },
344  { 22, 0x0003, 7 },
345  { 23, 0x0004, 7 },
346  { 24, 0x0028, 7 },
347  { 25, 0x002b, 7 },
348  { 26, 0x0013, 7 },
349  { 27, 0x0024, 7 },
350  { 28, 0x0018, 7 },
351  { 29, 0x0002, 8 },
352  { 30, 0x0003, 8 },
353  { 31, 0x001a, 8 },
354  { 32, 0x001b, 8 },
355  { 33, 0x0012, 8 },
356  { 34, 0x0013, 8 },
357  { 35, 0x0014, 8 },
358  { 36, 0x0015, 8 },
359  { 37, 0x0016, 8 },
360  { 38, 0x0017, 8 },
361  { 39, 0x0028, 8 },
362  { 40, 0x0029, 8 },
363  { 41, 0x002a, 8 },
364  { 42, 0x002b, 8 },
365  { 43, 0x002c, 8 },
366  { 44, 0x002d, 8 },
367  { 45, 0x0004, 8 },
368  { 46, 0x0005, 8 },
369  { 47, 0x000a, 8 },
370  { 48, 0x000b, 8 },
371  { 49, 0x0052, 8 },
372  { 50, 0x0053, 8 },
373  { 51, 0x0054, 8 },
374  { 52, 0x0055, 8 },
375  { 53, 0x0024, 8 },
376  { 54, 0x0025, 8 },
377  { 55, 0x0058, 8 },
378  { 56, 0x0059, 8 },
379  { 57, 0x005a, 8 },
380  { 58, 0x005b, 8 },
381  { 59, 0x004a, 8 },
382  { 60, 0x004b, 8 },
383  { 61, 0x0032, 8 },
384  { 62, 0x0033, 8 },
385  { 63, 0x0034, 8 },
386  { 64, 0x001b, 5 },
387  { 128, 0x0012, 5 },
388  { 192, 0x0017, 6 },
389  { 256, 0x0037, 7 },
390  { 320, 0x0036, 8 },
391  { 384, 0x0037, 8 },
392  { 448, 0x0064, 8 },
393  { 512, 0x0065, 8 },
394  { 576, 0x0068, 8 },
395  { 640, 0x0067, 8 },
396  { 704, 0x00cc, 9 },
397  { 768, 0x00cd, 9 },
398  { 832, 0x00d2, 9 },
399  { 896, 0x00d3, 9 },
400  { 960, 0x00d4, 9 },
401  { 1024, 0x00d5, 9 },
402  { 1088, 0x00d6, 9 },
403  { 1152, 0x00d7, 9 },
404  { 1216, 0x00d8, 9 },
405  { 1280, 0x00d9, 9 },
406  { 1344, 0x00da, 9 },
407  { 1408, 0x00db, 9 },
408  { 1472, 0x0098, 9 },
409  { 1536, 0x0099, 9 },
410  { 1600, 0x009a, 9 },
411  { 1664, 0x0018, 6 },
412  { 1728, 0x009b, 9 },
413  { 1792, 0x0008, 11 },
414  { 1856, 0x000c, 11 },
415  { 1920, 0x000d, 11 },
416  { 1984, 0x0012, 12 },
417  { 2048, 0x0013, 12 },
418  { 2112, 0x0014, 12 },
419  { 2176, 0x0015, 12 },
420  { 2240, 0x0016, 12 },
421  { 2304, 0x0017, 12 },
422  { 2368, 0x001c, 12 },
423  { 2432, 0x001d, 12 },
424  { 2496, 0x001e, 12 },
425  { 2560, 0x001f, 12 },
426  { 9999, 0x0001, 12 } // EOL
427 };
428 
430  { 0, 0x0037, 10 },
431  { 1, 0x0002, 3 },
432  { 2, 0x0003, 2 },
433  { 3, 0x0002, 2 },
434  { 4, 0x0003, 3 },
435  { 5, 0x0003, 4 },
436  { 6, 0x0002, 4 },
437  { 7, 0x0003, 5 },
438  { 8, 0x0005, 6 },
439  { 9, 0x0004, 6 },
440  { 10, 0x0004, 7 },
441  { 11, 0x0005, 7 },
442  { 12, 0x0007, 7 },
443  { 13, 0x0004, 8 },
444  { 14, 0x0007, 8 },
445  { 15, 0x0018, 9 },
446  { 16, 0x0017, 10 },
447  { 17, 0x0018, 10 },
448  { 18, 0x0008, 10 },
449  { 19, 0x0067, 11 },
450  { 20, 0x0068, 11 },
451  { 21, 0x006c, 11 },
452  { 22, 0x0037, 11 },
453  { 23, 0x0028, 11 },
454  { 24, 0x0017, 11 },
455  { 25, 0x0018, 11 },
456  { 26, 0x00ca, 12 },
457  { 27, 0x00cb, 12 },
458  { 28, 0x00cc, 12 },
459  { 29, 0x00cd, 12 },
460  { 30, 0x0068, 12 },
461  { 31, 0x0069, 12 },
462  { 32, 0x006a, 12 },
463  { 33, 0x006b, 12 },
464  { 34, 0x00d2, 12 },
465  { 35, 0x00d3, 12 },
466  { 36, 0x00d4, 12 },
467  { 37, 0x00d5, 12 },
468  { 38, 0x00d6, 12 },
469  { 39, 0x00d7, 12 },
470  { 40, 0x006c, 12 },
471  { 41, 0x006d, 12 },
472  { 42, 0x00da, 12 },
473  { 43, 0x00db, 12 },
474  { 44, 0x0054, 12 },
475  { 45, 0x0055, 12 },
476  { 46, 0x0056, 12 },
477  { 47, 0x0057, 12 },
478  { 48, 0x0064, 12 },
479  { 49, 0x0065, 12 },
480  { 50, 0x0052, 12 },
481  { 51, 0x0053, 12 },
482  { 52, 0x0024, 12 },
483  { 53, 0x0037, 12 },
484  { 54, 0x0038, 12 },
485  { 55, 0x0027, 12 },
486  { 56, 0x0028, 12 },
487  { 57, 0x0058, 12 },
488  { 58, 0x0059, 12 },
489  { 59, 0x002b, 12 },
490  { 60, 0x002c, 12 },
491  { 61, 0x005a, 12 },
492  { 62, 0x0066, 12 },
493  { 63, 0x0067, 12 },
494  { 64, 0x000f, 10 },
495  { 128, 0x00c8, 12 },
496  { 192, 0x00c9, 12 },
497  { 256, 0x005b, 12 },
498  { 320, 0x0033, 12 },
499  { 384, 0x0034, 12 },
500  { 448, 0x0035, 12 },
501  { 512, 0x006c, 13 },
502  { 576, 0x006d, 13 },
503  { 640, 0x004a, 13 },
504  { 704, 0x004b, 13 },
505  { 768, 0x004c, 13 },
506  { 832, 0x004d, 13 },
507  { 896, 0x0072, 13 },
508  { 960, 0x0073, 13 },
509  { 1024, 0x0074, 13 },
510  { 1088, 0x0075, 13 },
511  { 1152, 0x0076, 13 },
512  { 1216, 0x0077, 13 },
513  { 1280, 0x0052, 13 },
514  { 1344, 0x0053, 13 },
515  { 1408, 0x0054, 13 },
516  { 1472, 0x0055, 13 },
517  { 1536, 0x005a, 13 },
518  { 1600, 0x005b, 13 },
519  { 1664, 0x0064, 13 },
520  { 1728, 0x0065, 13 },
521  { 1792, 0x0008, 11 },
522  { 1856, 0x000c, 11 },
523  { 1920, 0x000d, 11 },
524  { 1984, 0x0012, 12 },
525  { 2048, 0x0013, 12 },
526  { 2112, 0x0014, 12 },
527  { 2176, 0x0015, 12 },
528  { 2240, 0x0016, 12 },
529  { 2304, 0x0017, 12 },
530  { 2368, 0x001c, 12 },
531  { 2432, 0x001d, 12 },
532  { 2496, 0x001e, 12 },
533  { 2560, 0x001f, 12 },
534  { 9999, 0x0001, 12 } // EOL
535 };
536 
537 
539  { CCI2DMODE_UNCOMP , 0x000f, 10 },
540  { CCI2DMODE_PASS , 0x0001, 4 },
541  { CCI2DMODE_HORZ , 0x0001, 3 },
542  { CCI2DMODE_VERT_L3, 0x0002, 7 },
543  { CCI2DMODE_VERT_L2, 0x0002, 6 },
544  { CCI2DMODE_VERT_L1, 0x0002, 3 },
545  { CCI2DMODE_VERT_0 , 0x0001, 1 },
546  { CCI2DMODE_VERT_R1, 0x0003, 3 },
547  { CCI2DMODE_VERT_R2, 0x0003, 6 },
548  { CCI2DMODE_VERT_R3, 0x0003, 7 }
549 };
550 
551 
553  { CCIUNCOMP_0White_1Black, 0x0001, 1 },
554  { CCIUNCOMP_1White_1Black, 0x0001, 2 },
555  { CCIUNCOMP_2White_1Black, 0x0001, 3 },
556  { CCIUNCOMP_3White_1Black, 0x0001, 4 },
557  { CCIUNCOMP_4White_1Black, 0x0001, 5 },
558  { CCIUNCOMP_5White , 0x0001, 6 },
559  { CCIUNCOMP_0White_End , 0x0001, 7 },
560  { CCIUNCOMP_1White_End , 0x0001, 8 },
561  { CCIUNCOMP_2White_End , 0x0001, 9 },
562  { CCIUNCOMP_3White_End , 0x0001, 10 },
563  { CCIUNCOMP_4White_End , 0x0001, 11 }
564 };
565 
566 
567 CCIDecompressor::CCIDecompressor( sal_uInt32 nOpts, sal_uInt32 nImageWidth ) :
568  bTableBad ( false ),
569  bStatus ( false ),
570  pIStream ( nullptr ),
571  nEOLCount ( 0 ),
572  nWidth ( nImageWidth ),
573  nOptions ( nOpts ),
574  bFirstEOL ( false ),
575  nInputBitsBuf( 0 ),
576  nInputBitsBufSize( 0 ),
577  nLastLineSize( 0 )
578 {
579  if ( nOpts & CCI_OPTION_INVERSEBITORDER )
580  {
581  pByteSwap.reset( new sal_uInt8[ 256 ] );
582  for ( int i = 0; i < 256; i++ )
583  {
584  pByteSwap[ i ] = sal::static_int_cast< sal_uInt8 >(
585  ( i << 7 ) | ( ( i & 2 ) << 5 ) | ( ( i & 4 ) << 3 ) | ( ( i & 8 ) << 1 ) |
586  ( ( i & 16 ) >> 1 ) | ( ( i & 32 ) >> 3 ) | ( ( i & 64 ) >> 5 ) | ( ( i & 128 ) >> 7 ));
587  }
588  }
589 
590  MakeLookUp(CCIWhiteTable,CCIWhiteTableSave,pWhiteLookUp.data(),CCIWhiteTableSize,13);
591  MakeLookUp(CCIBlackTable,CCIBlackTableSave,pBlackLookUp.data(),CCIBlackTableSize,13);
592  MakeLookUp(CCI2DModeTable,CCI2DModeTableSave,p2DModeLookUp.data(),CCI2DModeTableSize,10);
593  MakeLookUp(CCIUncompTable,CCIUncompTableSave,pUncompLookUp.data(),CCIUncompTableSize,11);
594 }
595 
596 
598 {
599 }
600 
601 
603 {
604  pIStream = &rIStream;
605  nInputBitsBufSize = 0;
606  bFirstEOL = true;
607  bStatus = true;
608  nEOLCount = 0;
609 
610  if ( bTableBad )
611  return;
612 }
613 
614 DecompressStatus CCIDecompressor::DecompressScanline( sal_uInt8 * pTarget, sal_uInt64 nTargetBits, bool bLastLine )
615 {
616  //Read[1|2]DScanlineData take a sal_uInt16, so its either limit here or expand there
617  if (nTargetBits > SAL_MAX_UINT16)
618  return DecompressStatus(false, true);
619 
620  if ( nEOLCount >= 5 ) // RTC (Return To Controller)
621  return DecompressStatus(true, true);
622 
623  if ( !bStatus )
624  return DecompressStatus(false, true);
625 
626  // If EOL-Codes exist, the EOL-Code also appeared in front of the first line.
627  // (and I thought it means 'End of Line'...)
628  // Therefore we read the EOL-Code always at the beginning of each line first:
629  if ( nOptions & CCI_OPTION_EOL )
630  {
631  if ( bFirstEOL )
632  {
633  sal_uInt32 nCurPos = pIStream->Tell();
634  sal_uInt16 nOldInputBitsBufSize = nInputBitsBufSize;
635  sal_uInt32 nOldInputBitsBuf = nInputBitsBuf;
636  if ( !ReadEOL() )
637  {
638  nInputBitsBufSize = nOldInputBitsBufSize;
639  nInputBitsBuf = nOldInputBitsBuf;
640  pIStream->Seek( nCurPos );
641  nOptions &=~ CCI_OPTION_EOL; // CCITT Group 3 - Compression Type 2
642  }
643  bFirstEOL = false;
644  }
645  else
646  {
647  if ( !ReadEOL() )
648  {
649  return DecompressStatus(bStatus, true);
650  }
651  }
652  }
653 
654  if ( nEOLCount >= 5 ) // RTC (Return To Controller)
655  return DecompressStatus(true, true);
656 
657  // should the situation arise, generate a white previous line for 2D:
658  if ( nOptions & CCI_OPTION_2D )
659  {
660  if ( pLastLine == nullptr || nLastLineSize != ( ( nTargetBits + 7 ) >> 3 ) )
661  {
662  nLastLineSize = ( nTargetBits + 7 ) >> 3;
663  pLastLine.reset( new sal_uInt8[ nLastLineSize ] );
664  memset(pLastLine.get(), 0, nLastLineSize);
665  }
666  }
667  // conditionally align start of line to next byte:
669  nInputBitsBufSize &= 0xfff8;
670 
671  bool b2D;
672  // is it a 2D row?
673  if ( nOptions & CCI_OPTION_2D )
674  {
675  if ( nOptions & CCI_OPTION_EOL )
676  b2D = Read2DTag();
677  else
678  b2D = true;
679  }
680  else
681  b2D = false;
682 
683  bool bUnchanged;
684  // read scanline:
685  if ( b2D )
686  bUnchanged = Read2DScanlineData(pTarget, nTargetBits);
687  else
688  bUnchanged = Read1DScanlineData(pTarget, nTargetBits);
689 
690  // if we're in 2D mode we have to remember the line:
691  if ( nOptions & CCI_OPTION_2D && bStatus )
692  {
693  memcpy(pLastLine.get(), pTarget, nLastLineSize);
694  }
695 
696  // #i122984#
697  if( !bStatus && bLastLine )
698  {
699  bStatus = true;
700  }
701 
702  if ( pIStream->GetError() )
703  bStatus = false;
704 
705  return DecompressStatus(bStatus, bUnchanged);
706 }
707 
708 
710  const CCIHuffmanTableEntry * pHufTabSave,
711  CCILookUpTableEntry * pLookUp,
712  sal_uInt16 nHuffmanTableSize,
713  sal_uInt16 nMaxCodeBits)
714 {
715  sal_uInt16 nLookUpSize = 1 << nMaxCodeBits;
716  memset(pLookUp, 0, nLookUpSize * sizeof(CCILookUpTableEntry));
717 
718  if (bTableBad)
719  return;
720 
721  sal_uInt16 nMask = 0xffff >> (16-nMaxCodeBits);
722 
723  for (sal_uInt16 i = 0; i < nHuffmanTableSize; ++i)
724  {
725  if ( pHufTab[i].nValue!=pHufTabSave[i].nValue ||
726  pHufTab[i].nCode!=pHufTabSave[i].nCode ||
727  pHufTab[i].nCodeBits!=pHufTabSave[i].nCodeBits ||
728  pHufTab[i].nCodeBits==0 ||
729  pHufTab[i].nCodeBits>nMaxCodeBits )
730  {
731  bTableBad=true;
732  return;
733  }
734  sal_uInt16 nMinCode = nMask & (pHufTab[i].nCode << (nMaxCodeBits-pHufTab[i].nCodeBits));
735  sal_uInt16 nMaxCode = nMinCode | (nMask >> pHufTab[i].nCodeBits);
736  for (sal_uInt16 j=nMinCode; j<=nMaxCode; ++j)
737  {
738  if (pLookUp[j].nCodeBits!=0)
739  {
740  bTableBad=true;
741  return;
742  }
743  pLookUp[j].nValue=pHufTab[i].nValue;
744  pLookUp[j].nCodeBits=pHufTab[i].nCodeBits;
745  }
746  }
747 }
748 
749 
751 {
752  sal_uInt16 nCode;
753  sal_uInt8 nByte;
754 
755  // if (nOptions&CCI_OPTION_BYTEALIGNEOL) nMaxFillBits=7; else nMaxFillBits=0;
756  // D'oh: Either the option in itiff.cxx is not set correctly (-> error in documentation)
757  // or there exist some nasty export filter who always do align.
758  // In addition files were found in which more than the necessary maximum of 7 filling
759  // bits were found. Therefore we now generally accept up to 32 nonsense bits in front of the EOL-Code:
760  // And I found a file in which up to ??? nonsense bits are written. Furthermore the byte order is switched in it. (SJ)
761 
762  sal_uInt32 nMaxPos = pIStream->Tell();
763  nMaxPos += nWidth >> 3;
764 
765  for ( ;; )
766  {
767  while ( nInputBitsBufSize < 12 )
768  {
769  pIStream->ReadUChar( nByte );
770  if (!pIStream->good())
771  return false;
772  if ( pIStream->Tell() > nMaxPos )
773  return false;
774 
776  nByte = pByteSwap[ nByte ];
777  nInputBitsBuf=(nInputBitsBuf<<8) | static_cast<sal_uInt64>(nByte);
778  nInputBitsBufSize += 8;
779  }
780  nCode = static_cast<sal_uInt16>( ( nInputBitsBuf >> ( nInputBitsBufSize - 12 ) ) & 0x0fff );
781  if ( nCode == 0x0001 )
782  {
783  nEOLCount++;
784  nInputBitsBufSize -= 12;
785  break;
786  }
787  else
789  }
790  return true;
791 }
792 
793 
795 {
796  // read a bit and return sal_True if it's 0, otherwise return sal_False
797  if (nInputBitsBufSize==0) {
798  sal_uInt8 nByte;
799  pIStream->ReadUChar( nByte );
801  nByte = pByteSwap[ nByte ];
802  nInputBitsBuf = nByte;
804  }
806  return ((nInputBitsBuf>>nInputBitsBufSize)&0x0001) == 0;
807 }
808 
809 
811 {
812  // read a bit and deliver 0x00 if it's 0, otherwise 0xff
813  if (nInputBitsBufSize==0) {
814  sal_uInt8 nByte;
815  pIStream->ReadUChar( nByte );
817  nByte = pByteSwap[ nByte ];
818  nInputBitsBuf = nByte;
820  }
822  if ( (nInputBitsBuf>>nInputBitsBufSize) & 0x0001 ) return 0xff;
823  else return 0x00;
824 }
825 
826 
828  sal_uInt16 nMaxCodeBits)
829 {
830  // read a Huffman code and decode it:
831  while (nInputBitsBufSize<nMaxCodeBits)
832  {
833  sal_uInt8 nByte(0);
834  pIStream->ReadUChar( nByte );
836  nByte = pByteSwap[ nByte ];
837  nInputBitsBuf=(nInputBitsBuf<<8) | static_cast<sal_uInt64>(nByte);
839  }
840  sal_uInt16 nCode = static_cast<sal_uInt16>((nInputBitsBuf>>(nInputBitsBufSize-nMaxCodeBits))
841  &(0xffff>>(16-nMaxCodeBits)));
842  sal_uInt16 nCodeBits = pLookUp[nCode].nCodeBits;
843  if (nCodeBits==0) bStatus=false;
844  nInputBitsBufSize = nInputBitsBufSize - nCodeBits;
845  return pLookUp[nCode].nValue;
846 }
847 
848 
849 void CCIDecompressor::FillBits(sal_uInt8 * pTarget, sal_uInt16 nTargetBits,
850  sal_uInt16 nBitPos, sal_uInt16 nNumBits,
851  sal_uInt8 nBlackOrWhite)
852 {
853  if ( nBitPos >= nTargetBits )
854  return;
855  if ( nBitPos + nNumBits > nTargetBits )
856  nNumBits = nTargetBits - nBitPos;
857 
858  pTarget+=nBitPos>>3;
859  nBitPos&=7;
860 
861  if (nBlackOrWhite==0x00) *pTarget &= 0xff << (8-nBitPos);
862  else *pTarget |= 0xff >> nBitPos;
863  if (nNumBits>8-nBitPos) {
864  nNumBits-=8-nBitPos;
865  while (nNumBits>=8) {
866  *(++pTarget)=nBlackOrWhite;
867  nNumBits-=8;
868  }
869  if (nNumBits>0) *(++pTarget)=nBlackOrWhite;
870  }
871 }
872 
873 sal_uInt16 CCIDecompressor::CountBits(const sal_uInt8 * pData, sal_uInt16 nDataSizeBits,
874  sal_uInt16 nBitPos, sal_uInt8 nBlackOrWhite)
875 {
876  // here the number of bits belonging together is being counted
877  // which all have the color nBlackOrWhite (0xff or 0x00)
878  // from the position nBitPos on
879  sal_uInt32 nPos = nBitPos;
880  for (;;)
881  {
882  if (nPos>=nDataSizeBits)
883  {
884  nPos=nDataSizeBits;
885  break;
886  }
887  sal_uInt8 nData = pData[nPos>>3];
888  sal_uInt16 nLo = nPos & 7;
889  if (nLo==0 && nData==nBlackOrWhite)
890  {
891  nPos+=8;
892  }
893  else
894  {
895  if ( ((nData^nBlackOrWhite) & (0x80 >> nLo))!=0)
896  break;
897  ++nPos;
898  }
899  }
900  return nPos-nBitPos;
901 }
902 
903 bool CCIDecompressor::Read1DScanlineData(sal_uInt8 * pTarget, sal_uInt16 nBitsToRead)
904 {
905  sal_uInt16 nTargetBits = nBitsToRead;
906  sal_uInt16 nCode,nCodeBits,nDataBits,nTgtFreeByteBits;
907  sal_uInt8 nByte;
908  sal_uInt8 nBlackOrWhite; // is 0xff for black or 0x00 for white
909  bool bTerminatingCode;
910 
911  // the first code is always a "white-code":
912  nBlackOrWhite=0x00;
913 
914  // number of bits that aren't written in the byte *pTarget yet:
915  nTgtFreeByteBits=8;
916 
917  // loop through codes from the input stream:
918  do {
919 
920  // fetch next 13 bits into nCodem but don't remove them from
921  // the input buffer:
922  while (nInputBitsBufSize<13) {
923  pIStream->ReadUChar( nByte );
925  nByte = pByteSwap[ nByte ];
926  nInputBitsBuf=(nInputBitsBuf<<8) | static_cast<sal_uInt64>(nByte);
928  }
929  nCode=static_cast<sal_uInt16>((nInputBitsBuf>>(nInputBitsBufSize-13))&0x1fff);
930 
931  // determine the number of DataBits CodeBits:
932  if (nBlackOrWhite) {
933  nCodeBits=pBlackLookUp[nCode].nCodeBits;
934  nDataBits=pBlackLookUp[nCode].nValue;
935  }
936  else {
937  nCodeBits=pWhiteLookUp[nCode].nCodeBits;
938  nDataBits=pWhiteLookUp[nCode].nValue;
939  }
940  // is that an invalid code?
941  if ( nDataBits == 9999 )
942  {
943  return nTargetBits == nBitsToRead;
944  }
945  if ( nCodeBits == 0 )
946  {
947  return nTargetBits == nBitsToRead; // could be filling bits now
948  }
949  nEOLCount = 0;
950  // too much data?
951  if (nDataBits>nTargetBits) {
952  // Yes, could be a subsequent error cause by an invalid code
953  // Therefore continue anyhow:
954  nDataBits=nTargetBits;
955  }
956 
957  // is that a 'Terminating-Code'?
958  bTerminatingCode = nDataBits<64;
959 
960  // remove the read bits from the input buffer:
961  nInputBitsBufSize = nInputBitsBufSize - nCodeBits;
962 
963  // write the number of data bits into the scanline:
964  if (nDataBits>0) {
965  nTargetBits = nTargetBits - nDataBits;
966  if (nBlackOrWhite==0x00) *pTarget &= 0xff << nTgtFreeByteBits;
967  else *pTarget |= 0xff >> (8-nTgtFreeByteBits);
968  if (nDataBits<=nTgtFreeByteBits) {
969  if (nDataBits==nTgtFreeByteBits) {
970  pTarget++;
971  nTgtFreeByteBits=8;
972  }
973  else nTgtFreeByteBits = nTgtFreeByteBits - nDataBits;
974  }
975  else {
976  nDataBits = nDataBits - nTgtFreeByteBits;
977  pTarget++;
978  nTgtFreeByteBits=8;
979  if (nDataBits >= 8)
980  {
981  const sal_uInt16 nDataBytes = nDataBits / 8;
982  memset(pTarget, nBlackOrWhite, nDataBytes);
983  pTarget += nDataBytes;
984  nDataBits -= nDataBytes * 8;
985  }
986 
987  if (nDataBits>0) {
988  *pTarget=nBlackOrWhite;
989  nTgtFreeByteBits = nTgtFreeByteBits - nDataBits;
990  }
991  }
992  }
993 
994  // should the situation arise, switch Black <-> White:
995  if (bTerminatingCode) nBlackOrWhite = ~nBlackOrWhite;
996 
997  } while (nTargetBits>0 || !bTerminatingCode);
998 
999  return nTargetBits == nBitsToRead;
1000 }
1001 
1002 bool CCIDecompressor::Read2DScanlineData(sal_uInt8 * pTarget, sal_uInt16 nTargetBits)
1003 {
1004  sal_uInt16 n2DMode,nBitPos,nUncomp,nRun,nRun2,nt;
1005  sal_uInt8 nBlackOrWhite;
1006 
1007  nBlackOrWhite=0x00;
1008  nBitPos=0;
1009 
1010  while (nBitPos<nTargetBits && bStatus) {
1011 
1012  n2DMode=ReadCodeAndDecode(p2DModeLookUp.data(),10);
1013  if (!bStatus)
1014  return nBitPos == 0;
1015 
1016  if (n2DMode==CCI2DMODE_UNCOMP) {
1017  for (;;) {
1018  nUncomp=ReadCodeAndDecode(pUncompLookUp.data(),11);
1019  if (!bStatus)
1020  break;
1021  if ( nUncomp <= CCIUNCOMP_4White_1Black ) {
1022  nRun=nUncomp-CCIUNCOMP_0White_1Black;
1023  FillBits(pTarget,nTargetBits,nBitPos,nRun,0x00);
1024  nBitPos = nBitPos + nRun;
1025  FillBits(pTarget,nTargetBits,nBitPos,1,0xff);
1026  nBitPos++;
1027  }
1028  else if ( nUncomp == CCIUNCOMP_5White ) {
1029  FillBits(pTarget,nTargetBits,nBitPos,5,0x00);
1030  nBitPos = nBitPos + 5;
1031  }
1032  else {
1033  nRun=nUncomp-CCIUNCOMP_0White_End;
1034  FillBits(pTarget,nTargetBits,nBitPos,nRun,0x00);
1035  nBitPos = nBitPos + nRun;
1036  nBlackOrWhite=ReadBlackOrWhite();
1037  break;
1038  }
1039  }
1040  }
1041 
1042  else if (n2DMode==CCI2DMODE_PASS) {
1043  if (nBitPos==0 && nBlackOrWhite==0x00 && CountBits(pLastLine.get(), nTargetBits, 0, 0xff)!=0) nRun=0;
1044  else {
1045  nRun = CountBits(pLastLine.get(), nTargetBits, nBitPos, ~nBlackOrWhite);
1046  nRun = nRun + CountBits(pLastLine.get(), nTargetBits, nBitPos + nRun, nBlackOrWhite);
1047  }
1048  nRun = nRun + CountBits(pLastLine.get(), nTargetBits, nBitPos + nRun, ~nBlackOrWhite);
1049  FillBits(pTarget,nTargetBits,nBitPos,nRun,nBlackOrWhite);
1050  nBitPos = nBitPos + nRun;
1051  }
1052 
1053  else if (n2DMode==CCI2DMODE_HORZ) {
1054  if (nBlackOrWhite==0x00) {
1055  nRun=0;
1056  do {
1057  nt=ReadCodeAndDecode(pWhiteLookUp.data(),13);
1058  nRun = nRun + nt;
1059  } while (nt>=64);
1060  nRun2=0;
1061  do {
1062  nt=ReadCodeAndDecode(pBlackLookUp.data(),13);
1063  nRun2 = nRun2 + nt;
1064  } while (nt>=64);
1065  }
1066  else {
1067  nRun=0;
1068  do {
1069  nt=ReadCodeAndDecode(pBlackLookUp.data(),13);
1070  nRun = nRun + nt;
1071  } while (nt>=64);
1072  nRun2=0;
1073  do {
1074  nt=ReadCodeAndDecode(pWhiteLookUp.data(),13);
1075  nRun2 = nRun2 + nt;
1076  } while (nt>=64);
1077  }
1078  FillBits(pTarget,nTargetBits,nBitPos,nRun,nBlackOrWhite);
1079  nBitPos = nBitPos + nRun;
1080  FillBits(pTarget,nTargetBits,nBitPos,nRun2,~nBlackOrWhite);
1081  nBitPos = nBitPos + nRun2;
1082  }
1083 
1084  else { // it's one of the modes CCI2DMODE_VERT_...
1085  if (nBitPos==0 && nBlackOrWhite==0x00 && CountBits(pLastLine.get(), nTargetBits, 0, 0xff)!=0) nRun=0;
1086  else {
1087  nRun = CountBits(pLastLine.get(), nTargetBits, nBitPos, ~nBlackOrWhite);
1088  nRun = nRun + CountBits(pLastLine.get(), nTargetBits, nBitPos + nRun, nBlackOrWhite);
1089  }
1090  nRun+=n2DMode-CCI2DMODE_VERT_0;
1091  FillBits(pTarget,nTargetBits,nBitPos,nRun,nBlackOrWhite);
1092  nBitPos = nBitPos + nRun;
1093  nBlackOrWhite=~nBlackOrWhite;
1094  }
1095  }
1096 
1097  return nBitPos == 0;
1098 }
1099 
1100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const CCIHuffmanTableEntry CCIUncompTableSave[CCIUncompTableSize]
Definition: ccidecom.cxx:552
#define CCIUNCOMP_5White
Definition: ccidecom.cxx:287
#define CCIUncompTableSize
Definition: ccidecom.cxx:294
#define CCIUNCOMP_2White_End
Definition: ccidecom.cxx:290
const CCIHuffmanTableEntry CCI2DModeTableSave[CCI2DModeTableSize]
Definition: ccidecom.cxx:538
const CCIHuffmanTableEntry CCIUncompTable[CCIUncompTableSize]
Definition: ccidecom.cxx:296
#define CCI2DMODE_PASS
Definition: ccidecom.cxx:254
#define CCIUNCOMP_4White_1Black
Definition: ccidecom.cxx:286
CCIDecompressor(sal_uInt32 nOptions, sal_uInt32 nImageWidth)
Definition: ccidecom.cxx:567
#define CCIBlackTableSize
Definition: ccidecom.cxx:140
sal_uInt16 ReadCodeAndDecode(const CCILookUpTableEntry *pLookUp, sal_uInt16 nMaxCodeBits)
Definition: ccidecom.cxx:827
#define CCI2DMODE_VERT_R3
Definition: ccidecom.cxx:262
const CCIHuffmanTableEntry CCIBlackTable[CCIBlackTableSize]
Definition: ccidecom.cxx:142
sal_uInt16 nCode
Definition: ccidecom.hxx:37
const CCIHuffmanTableEntry CCIWhiteTableSave[CCIWhiteTableSize]
Definition: ccidecom.cxx:321
sal_uInt64 nLastLineSize
Definition: ccidecom.hxx:123
sal_uInt64 Seek(sal_uInt64 nPos)
#define CCI_OPTION_BYTEALIGNROW
Definition: ccidecom.hxx:31
#define CCI2DMODE_VERT_L3
Definition: ccidecom.cxx:256
std::unique_ptr< sal_uInt8[]> pByteSwap
Definition: ccidecom.hxx:102
const CCIHuffmanTableEntry CCI2DModeTable[CCI2DModeTableSize]
Definition: ccidecom.cxx:266
void StartDecompression(SvStream &rIStream)
Definition: ccidecom.cxx:602
std::array< CCILookUpTableEntry, 1<< 13 > pWhiteLookUp
Definition: ccidecom.hxx:114
#define CCI_OPTION_2D
Definition: ccidecom.hxx:27
sal_uInt8 ReadBlackOrWhite()
Definition: ccidecom.cxx:810
#define CCIWhiteTableSize
Definition: ccidecom.cxx:28
ErrCode GetError() const
#define SAL_MAX_UINT16
std::array< CCILookUpTableEntry, 1<< 11 > pUncompLookUp
Definition: ccidecom.hxx:117
const CCIHuffmanTableEntry CCIWhiteTable[CCIWhiteTableSize]
Definition: ccidecom.cxx:30
#define CCI2DMODE_VERT_R2
Definition: ccidecom.cxx:261
DecompressStatus DecompressScanline(sal_uInt8 *pTarget, sal_uInt64 nTargetBits, bool bLastLine)
Definition: ccidecom.cxx:614
#define CCI2DModeTableSize
Definition: ccidecom.cxx:264
sal_uInt16 nValue
Definition: ccidecom.hxx:43
#define CCIUNCOMP_3White_1Black
Definition: ccidecom.cxx:285
#define CCIUNCOMP_1White_1Black
Definition: ccidecom.cxx:283
sal_uInt16 nCode
#define CCI2DMODE_VERT_0
Definition: ccidecom.cxx:259
sal_uInt32 nWidth
Definition: ccidecom.hxx:108
#define CCIUNCOMP_3White_End
Definition: ccidecom.cxx:291
int i
sal_uInt32 nEOLCount
Definition: ccidecom.hxx:106
#define CCIUNCOMP_4White_End
Definition: ccidecom.cxx:292
#define CCI2DMODE_UNCOMP
Definition: ccidecom.cxx:253
SvStream & ReadUChar(unsigned char &rChar)
std::array< CCILookUpTableEntry, 1<< 13 > pBlackLookUp
Definition: ccidecom.hxx:115
void MakeLookUp(const CCIHuffmanTableEntry *pHufTab, const CCIHuffmanTableEntry *pHufTabSave, CCILookUpTableEntry *pLookUp, sal_uInt16 nHuffmanTableSize, sal_uInt16 nMaxCodeBits)
Definition: ccidecom.cxx:709
bool Read2DTag()
Definition: ccidecom.cxx:794
sal_uInt32 nOptions
Definition: ccidecom.hxx:110
#define CCI2DMODE_VERT_L1
Definition: ccidecom.cxx:258
#define CCI2DMODE_VERT_R1
Definition: ccidecom.cxx:260
sal_uInt32 nInputBitsBuf
Definition: ccidecom.hxx:119
sal_uInt16 nCodeBits
Definition: ccidecom.hxx:44
static void FillBits(sal_uInt8 *pTarget, sal_uInt16 nTargetBits, sal_uInt16 nBitPos, sal_uInt16 nNumBits, sal_uInt8 nBlackOrWhite)
Definition: ccidecom.cxx:849
unsigned char sal_uInt8
bool Read2DScanlineData(sal_uInt8 *pTarget, sal_uInt16 nTargetBits)
Definition: ccidecom.cxx:1002
#define CCIUNCOMP_2White_1Black
Definition: ccidecom.cxx:284
static sal_uInt16 CountBits(const sal_uInt8 *pData, sal_uInt16 nDataSizeBits, sal_uInt16 nBitPos, sal_uInt8 nBlackOrWhite)
Definition: ccidecom.cxx:873
#define CCI_OPTION_INVERSEBITORDER
Definition: ccidecom.hxx:32
sal_uInt64 Tell() const
#define CCI2DMODE_VERT_L2
Definition: ccidecom.cxx:257
#define CCI2DMODE_HORZ
Definition: ccidecom.cxx:255
const CCIHuffmanTableEntry CCIBlackTableSave[CCIBlackTableSize]
Definition: ccidecom.cxx:429
bool good() const
#define CCI_OPTION_EOL
Definition: ccidecom.hxx:28
#define CCIUNCOMP_0White_1Black
Definition: ccidecom.cxx:282
std::unique_ptr< sal_uInt8[]> pLastLine
Definition: ccidecom.hxx:122
sal_uInt16 nValue
Definition: ccidecom.hxx:36
sal_uInt16 nInputBitsBufSize
Definition: ccidecom.hxx:120
std::array< CCILookUpTableEntry, 1<< 10 > p2DModeLookUp
Definition: ccidecom.hxx:116
bool Read1DScanlineData(sal_uInt8 *pTarget, sal_uInt16 nTargetBits)
Definition: ccidecom.cxx:903
sal_uInt16 nCodeBits
Definition: ccidecom.hxx:38
#define CCIUNCOMP_0White_End
Definition: ccidecom.cxx:288
SvStream * pIStream
Definition: ccidecom.hxx:104
#define CCIUNCOMP_1White_End
Definition: ccidecom.cxx:289
sal_uInt16 nPos
sal_Int16 nValue