1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CCIDECOM_HXX 25 #define _CCIDECOM_HXX 26 27 #include <tools/stream.hxx> 28 29 30 #define CCI_OPTION_2D 1 // 2D-Komprimierung (statt 1D) 31 #define CCI_OPTION_EOL 2 // EOL-Codes am Ende jeder Zeile vorhanden 32 #define CCI_OPTION_BYTEALIGNEOL 4 // Fuellbits vor jedem EOL-Code, so dass 33 // Ende von EOL auf Bytes aligend 34 #define CCI_OPTION_BYTEALIGNROW 8 // Rows beginnen immer auf Byte-Grenze 35 #define CCI_OPTION_INVERSEBITORDER 16 36 37 // Eintrag in eine Huffman-Tabelle: 38 struct CCIHuffmanTableEntry { 39 sal_uInt16 nValue; // Der Daten-Wert. 40 sal_uInt16 nCode; // Der Code durch den der Daten-Wert repraesentiert wird. 41 sal_uInt16 nCodeBits; // Laenge des Codes in Bits. 42 }; 43 44 45 // Eintrag in eine Hash-Tabelle zur schnellen Dekodierung 46 struct CCILookUpTableEntry { 47 sal_uInt16 nValue; 48 sal_uInt16 nCodeBits; 49 }; 50 51 52 class CCIDecompressor { 53 54 public: 55 56 CCIDecompressor( sal_uLong nOptions, sal_uInt32 nImageWidth ); 57 ~CCIDecompressor(); 58 59 void StartDecompression( SvStream & rIStream ); 60 61 sal_Bool DecompressScanline(sal_uInt8 * pTarget, sal_uLong nTargetBits, bool bLastLine ); 62 63 private: 64 65 void MakeLookUp(const CCIHuffmanTableEntry * pHufTab, 66 const CCIHuffmanTableEntry * pHufTabSave, 67 CCILookUpTableEntry * pLookUp, 68 sal_uInt16 nHuffmanTableSize, 69 sal_uInt16 nMaxCodeBits); 70 71 sal_Bool ReadEOL( sal_uInt32 nMaxFillBits ); 72 73 sal_Bool Read2DTag(); 74 75 sal_uInt8 ReadBlackOrWhite(); 76 77 sal_uInt16 ReadCodeAndDecode(const CCILookUpTableEntry * pLookUp, 78 sal_uInt16 nMaxCodeBits); 79 80 void FillBits(sal_uInt8 * pTarget, sal_uInt16 nTargetBits, 81 sal_uInt16 nBitPos, sal_uInt16 nNumBits, 82 sal_uInt8 nBlackOrWhite); 83 84 sal_uInt16 CountBits(const sal_uInt8 * pData, sal_uInt16 nDataSizeBits, 85 sal_uInt16 nBitPos, sal_uInt8 nBlackOrWhite); 86 87 void Read1DScanlineData(sal_uInt8 * pTarget, sal_uInt16 nTargetBits); 88 89 void Read2DScanlineData(sal_uInt8 * pTarget, sal_uInt16 nTargetBits); 90 91 sal_Bool bTableBad; 92 93 sal_Bool bStatus; 94 95 sal_uInt8* pByteSwap; 96 97 SvStream * pIStream; 98 99 sal_uInt32 nEOLCount; 100 101 sal_uInt32 nWidth; 102 103 sal_uLong nOptions; 104 105 sal_Bool bFirstEOL; 106 107 CCILookUpTableEntry * pWhiteLookUp; 108 CCILookUpTableEntry * pBlackLookUp; 109 CCILookUpTableEntry * p2DModeLookUp; 110 CCILookUpTableEntry * pUncompLookUp; 111 112 sal_uLong nInputBitsBuf; 113 sal_uInt16 nInputBitsBufSize; 114 115 sal_uInt8 * pLastLine; 116 sal_uLong nLastLineSize; 117 }; 118 119 120 #endif 121 122