1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ccidecom.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <tools/stream.hxx>
37 #define CCI_OPTION_2D 1 // 2D-Komprimierung (statt 1D)
38 #define CCI_OPTION_EOL 2 // EOL-Codes am Ende jeder Zeile vorhanden
39 #define CCI_OPTION_BYTEALIGNEOL 4 // Fuellbits vor jedem EOL-Code, so dass
40 // Ende von EOL auf Bytes aligend
41 #define CCI_OPTION_BYTEALIGNROW 8 // Rows beginnen immer auf Byte-Grenze
42 #define CCI_OPTION_INVERSEBITORDER 16
44 // Eintrag in eine Huffman-Tabelle:
45 struct CCIHuffmanTableEntry
{
46 USHORT nValue
; // Der Daten-Wert.
47 USHORT nCode
; // Der Code durch den der Daten-Wert repraesentiert wird.
48 USHORT nCodeBits
; // Laenge des Codes in Bits.
52 // Eintrag in eine Hash-Tabelle zur schnellen Dekodierung
53 struct CCILookUpTableEntry
{
59 class CCIDecompressor
{
63 CCIDecompressor( ULONG nOptions
, UINT32 nImageWidth
);
66 void StartDecompression( SvStream
& rIStream
);
68 BOOL
DecompressScanline(BYTE
* pTarget
, ULONG nTargetBits
);
72 void MakeLookUp(const CCIHuffmanTableEntry
* pHufTab
,
73 const CCIHuffmanTableEntry
* pHufTabSave
,
74 CCILookUpTableEntry
* pLookUp
,
75 USHORT nHuffmanTableSize
,
78 BOOL
ReadEOL( UINT32 nMaxFillBits
);
82 BYTE
ReadBlackOrWhite();
84 USHORT
ReadCodeAndDecode(const CCILookUpTableEntry
* pLookUp
,
87 void FillBits(BYTE
* pTarget
, USHORT nTargetBits
,
88 USHORT nBitPos
, USHORT nNumBits
,
91 USHORT
CountBits(const BYTE
* pData
, USHORT nDataSizeBits
,
92 USHORT nBitPos
, BYTE nBlackOrWhite
);
94 void Read1DScanlineData(BYTE
* pTarget
, USHORT nTargetBits
);
96 void Read2DScanlineData(BYTE
* pTarget
, USHORT nTargetBits
);
114 CCILookUpTableEntry
* pWhiteLookUp
;
115 CCILookUpTableEntry
* pBlackLookUp
;
116 CCILookUpTableEntry
* p2DModeLookUp
;
117 CCILookUpTableEntry
* pUncompLookUp
;
120 USHORT nInputBitsBufSize
;