source:
freewrt/tools/lzma/lzma-zlib.patch@
131a9d7
| Last change on this file since 131a9d7 was 131a9d7, checked in by , 19 years ago | |
|---|---|
|
|
| File size: 15.2 KB | |
-
C/7zip/Compress/LZMA/LZMADecoder.cpp
$FreeWRT$ diff -Nur lzma/C/7zip/Compress/LZMA/LZMADecoder.cpp lzma.patched/C/7zip/Compress/LZMA/LZMADecoder.cpp
old new 274 274 Byte remainder = (Byte)(properties[0] / 9); 275 275 int lp = remainder % 5; 276 276 int pb = remainder / 5; 277 if (pb > NLength::kNumPosStatesBitsMax)278 return E_INVALIDARG;279 _posStateMask = (1 << pb) - 1;280 277 UInt32 dictionarySize = 0; 281 278 for (int i = 0; i < 4; i++) 282 279 dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8); 280 return SetDecoderPropertiesRaw(lc, lp, pb, dictionarySize); 281 } 282 283 STDMETHODIMP CDecoder::SetDecoderPropertiesRaw(int lc, int lp, int pb, UInt32 dictionarySize) 284 { 285 if (pb > NLength::kNumPosStatesBitsMax) 286 return E_INVALIDARG; 287 _posStateMask = (1 << pb) - 1; 283 288 if (!_outWindowStream.Create(dictionarySize)) 284 289 return E_OUTOFMEMORY; 285 290 if (!_literalDecoder.Create(lp, lc)) -
C/7zip/Compress/LZMA/LZMADecoder.h
diff -Nur lzma/C/7zip/Compress/LZMA/LZMADecoder.h lzma.patched/C/7zip/Compress/LZMA/LZMADecoder.h
old new 228 228 ICompressProgressInfo *progress); 229 229 230 230 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); 231 STDMETHOD(SetDecoderPropertiesRaw)(int lc, int lp, int pb, UInt32 dictionarySize); 231 232 232 233 STDMETHOD(GetInStreamProcessedSize)(UInt64 *value); 233 234 -
C/7zip/Compress/LZMA_Lib/makefile
diff -Nur lzma/C/7zip/Compress/LZMA_Lib/makefile lzma.patched/C/7zip/Compress/LZMA_Lib/makefile
old new 1 PROG = liblzma.a 2 CXX = g++ -O3 -Wall 3 AR = ar 4 RM = rm -f 5 CFLAGSX = $(CFLAGS) -c -I ../../../ 6 7 OBJS = \ 8 ZLib.o \ 9 LZMADecoder.o \ 10 LZMAEncoder.o \ 11 LZInWindow.o \ 12 LZOutWindow.o \ 13 RangeCoderBit.o \ 14 InBuffer.o \ 15 OutBuffer.o \ 16 FileStreams.o \ 17 Alloc.o \ 18 C_FileIO.o \ 19 CommandLineParser.o \ 20 CRC.o \ 21 StreamUtils.o \ 22 String.o \ 23 StringConvert.o \ 24 StringToInt.o \ 25 Vector.o \ 26 27 28 all: $(PROG) 29 30 $(PROG): $(OBJS) 31 $(AR) r $(PROG) $(OBJS) 32 33 ZLib.o: ZLib.cpp 34 $(CXX) $(CFLAGSX) ZLib.cpp 35 36 LZMADecoder.o: ../LZMA/LZMADecoder.cpp 37 $(CXX) $(CFLAGSX) ../LZMA/LZMADecoder.cpp 38 39 LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp 40 $(CXX) $(CFLAGSX) ../LZMA/LZMAEncoder.cpp 41 42 LZInWindow.o: ../LZ/LZInWindow.cpp 43 $(CXX) $(CFLAGSX) ../LZ/LZInWindow.cpp 44 45 LZOutWindow.o: ../LZ/LZOutWindow.cpp 46 $(CXX) $(CFLAGSX) ../LZ/LZOutWindow.cpp 47 48 RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp 49 $(CXX) $(CFLAGSX) ../RangeCoder/RangeCoderBit.cpp 50 51 InBuffer.o: ../../Common/InBuffer.cpp 52 $(CXX) $(CFLAGSX) ../../Common/InBuffer.cpp 53 54 OutBuffer.o: ../../Common/OutBuffer.cpp 55 $(CXX) $(CFLAGSX) ../../Common/OutBuffer.cpp 56 57 StreamUtils.o: ../../Common/StreamUtils.cpp 58 $(CXX) $(CFLAGSX) ../../Common/StreamUtils.cpp 59 60 FileStreams.o: ../../Common/FileStreams.cpp 61 $(CXX) $(CFLAGSX) ../../Common/FileStreams.cpp 62 63 Alloc.o: ../../../Common/Alloc.cpp 64 $(CXX) $(CFLAGSX) ../../../Common/Alloc.cpp 65 66 C_FileIO.o: ../../../Common/C_FileIO.cpp 67 $(CXX) $(CFLAGSX) ../../../Common/C_FileIO.cpp 68 69 CommandLineParser.o: ../../../Common/CommandLineParser.cpp 70 $(CXX) $(CFLAGSX) ../../../Common/CommandLineParser.cpp 71 72 CRC.o: ../../../Common/CRC.cpp 73 $(CXX) $(CFLAGSX) ../../../Common/CRC.cpp 74 75 MyWindows.o: ../../../Common/MyWindows.cpp 76 $(CXX) $(CFLAGSX) ../../../Common/MyWindows.cpp 77 78 String.o: ../../../Common/String.cpp 79 $(CXX) $(CFLAGSX) ../../../Common/String.cpp 80 81 StringConvert.o: ../../../Common/StringConvert.cpp 82 $(CXX) $(CFLAGSX) ../../../Common/StringConvert.cpp 83 84 StringToInt.o: ../../../Common/StringToInt.cpp 85 $(CXX) $(CFLAGSX) ../../../Common/StringToInt.cpp 86 87 Vector.o: ../../../Common/Vector.cpp 88 $(CXX) $(CFLAGSX) ../../../Common/Vector.cpp 89 90 clean: 91 -$(RM) $(PROG) $(OBJS) 92 -
C/7zip/Compress/LZMA_Lib/ZLib.cpp
diff -Nur lzma/C/7zip/Compress/LZMA_Lib/ZLib.cpp lzma.patched/C/7zip/Compress/LZMA_Lib/ZLib.cpp
old new 1 /* 2 * lzma zlib simplified wrapper 3 * 4 * Copyright (c) 2005-2006 Oleg I. Vdovikin <oleg@cs.msu.su> 5 * 6 * This library is free software; you can redistribute 7 * it and/or modify it under the terms of the GNU Lesser 8 * General Public License as published by the Free Software 9 * Foundation; either version 2.1 of the License, or 10 * (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be 13 * useful, but WITHOUT ANY WARRANTY; without even the implied 14 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 15 * PURPOSE. See the GNU Lesser General Public License 16 * for more details. 17 * 18 * You should have received a copy of the GNU Lesser General 19 * Public License along with this library; if not, write to 20 * the Free Software Foundation, Inc., 59 Temple Place, 21 * Suite 330, Boston, MA 02111-1307 USA 22 */ 23 24 /* 25 * default values for encoder/decoder used by wrapper 26 */ 27 28 #include <zlib.h> 29 30 #define ZLIB_LC 3 31 #define ZLIB_LP 0 32 #define ZLIB_PB 2 33 34 #ifdef WIN32 35 #include <initguid.h> 36 #else 37 #define INITGUID 38 #endif 39 40 #include "../../../Common/MyWindows.h" 41 #include "../LZMA/LZMADecoder.h" 42 #include "../LZMA/LZMAEncoder.h" 43 44 #define STG_E_SEEKERROR ((HRESULT)0x80030019L) 45 #define STG_E_MEDIUMFULL ((HRESULT)0x80030070L) 46 47 class CInMemoryStream: 48 public IInStream, 49 public IStreamGetSize, 50 public CMyUnknownImp 51 { 52 public: 53 CInMemoryStream(const Bytef *data, UInt64 size) : 54 m_data(data), m_size(size), m_offset(0) {} 55 56 virtual ~CInMemoryStream() {} 57 58 MY_UNKNOWN_IMP2(IInStream, IStreamGetSize) 59 60 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) 61 { 62 if (size > m_size - m_offset) 63 size = m_size - m_offset; 64 65 if (size) { 66 memcpy(data, m_data + m_offset, size); 67 } 68 69 m_offset += size; 70 71 if (processedSize) 72 *processedSize = size; 73 74 return S_OK; 75 } 76 77 STDMETHOD(ReadPart)(void *data, UInt32 size, UInt32 *processedSize) 78 { 79 return Read(data, size, processedSize); 80 } 81 82 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 83 { 84 UInt64 _offset; 85 86 if (seekOrigin == STREAM_SEEK_SET) _offset = offset; 87 else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset; 88 else if (seekOrigin == STREAM_SEEK_END) _offset = m_size; 89 else return STG_E_INVALIDFUNCTION; 90 91 if (_offset < 0 || _offset > m_size) 92 return STG_E_SEEKERROR; 93 94 m_offset = _offset; 95 96 if (newPosition) 97 *newPosition = m_offset; 98 99 return S_OK; 100 } 101 102 STDMETHOD(GetSize)(UInt64 *size) 103 { 104 *size = m_size; 105 return S_OK; 106 } 107 protected: 108 const Bytef *m_data; 109 UInt64 m_size; 110 UInt64 m_offset; 111 }; 112 113 class COutMemoryStream: 114 public IOutStream, 115 public CMyUnknownImp 116 { 117 public: 118 COutMemoryStream(Bytef *data, UInt64 maxsize) : 119 m_data(data), m_size(0), m_maxsize(maxsize), m_offset(0) {} 120 virtual ~COutMemoryStream() {} 121 122 MY_UNKNOWN_IMP1(IOutStream) 123 124 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) 125 { 126 if (size > m_maxsize - m_offset) 127 size = m_maxsize - m_offset; 128 129 if (size) { 130 memcpy(m_data + m_offset, data, size); 131 } 132 133 m_offset += size; 134 135 if (m_offset > m_size) 136 m_size = m_offset; 137 138 if (processedSize) 139 *processedSize = size; 140 141 return S_OK; 142 } 143 144 STDMETHOD(WritePart)(const void *data, UInt32 size, UInt32 *processedSize) 145 { 146 return Write(data, size, processedSize); 147 } 148 149 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) 150 { 151 UInt64 _offset; 152 153 if (seekOrigin == STREAM_SEEK_SET) _offset = offset; 154 else if (seekOrigin == STREAM_SEEK_CUR) _offset = m_offset + offset; 155 else if (seekOrigin == STREAM_SEEK_END) _offset = m_size; 156 else return STG_E_INVALIDFUNCTION; 157 158 if (_offset < 0 || _offset > m_maxsize) 159 return STG_E_SEEKERROR; 160 161 m_offset = _offset; 162 163 if (newPosition) 164 *newPosition = m_offset; 165 166 return S_OK; 167 } 168 169 STDMETHOD(SetSize)(Int64 newSize) 170 { 171 if ((UInt64)newSize > m_maxsize) 172 return STG_E_MEDIUMFULL; 173 174 return S_OK; 175 } 176 protected: 177 Bytef *m_data; 178 UInt64 m_size; 179 UInt64 m_maxsize; 180 UInt64 m_offset; 181 }; 182 183 ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, 184 const Bytef *source, uLong sourceLen, 185 int level)) 186 { 187 CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen); 188 CMyComPtr<ISequentialInStream> inStream = inStreamSpec; 189 190 COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen); 191 CMyComPtr<ISequentialOutStream> outStream = outStreamSpec; 192 193 NCompress::NLZMA::CEncoder *encoderSpec = 194 new NCompress::NLZMA::CEncoder; 195 CMyComPtr<ICompressCoder> encoder = encoderSpec; 196 197 PROPID propIDs[] = 198 { 199 NCoderPropID::kDictionarySize, 200 NCoderPropID::kPosStateBits, 201 NCoderPropID::kLitContextBits, 202 NCoderPropID::kLitPosBits, 203 NCoderPropID::kAlgorithm, 204 NCoderPropID::kNumFastBytes, 205 NCoderPropID::kMatchFinder, 206 NCoderPropID::kEndMarker 207 }; 208 const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]); 209 210 PROPVARIANT properties[kNumProps]; 211 for (int p = 0; p < 6; p++) 212 properties[p].vt = VT_UI4; 213 properties[0].ulVal = UInt32(1 << (level + 14)); 214 properties[1].ulVal = UInt32(ZLIB_PB); 215 properties[2].ulVal = UInt32(ZLIB_LC); // for normal files 216 properties[3].ulVal = UInt32(ZLIB_LP); // for normal files 217 properties[4].ulVal = UInt32(2); 218 properties[5].ulVal = UInt32(128); 219 220 properties[6].vt = VT_BSTR; 221 properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4"; 222 223 properties[7].vt = VT_BOOL; 224 properties[7].boolVal = VARIANT_TRUE; 225 226 if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK) 227 return Z_MEM_ERROR; // should not happen 228 229 HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0); 230 if (result == E_OUTOFMEMORY) 231 { 232 return Z_MEM_ERROR; 233 } 234 else if (result != S_OK) 235 { 236 return Z_BUF_ERROR; // should not happen 237 } 238 239 UInt64 fileSize; 240 outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize); 241 *destLen = fileSize; 242 243 return Z_OK; 244 } 245 246 ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, 247 const Bytef *source, uLong sourceLen)) 248 { 249 CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen); 250 CMyComPtr<ISequentialInStream> inStream = inStreamSpec; 251 252 COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen); 253 CMyComPtr<ISequentialOutStream> outStream = outStreamSpec; 254 255 NCompress::NLZMA::CDecoder *decoderSpec = 256 new NCompress::NLZMA::CDecoder; 257 CMyComPtr<ICompressCoder> decoder = decoderSpec; 258 259 if (decoderSpec->SetDecoderPropertiesRaw(ZLIB_LC, 260 ZLIB_LP, ZLIB_PB, (1 << 23)) != S_OK) return Z_DATA_ERROR; 261 262 UInt64 fileSize = *destLen; 263 264 if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK) 265 { 266 return Z_DATA_ERROR; 267 } 268 269 outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize); 270 *destLen = fileSize; 271 272 return Z_OK; 273 } -
lzma/C/7zip/Compress/LZMA_Alone/makefile.gcc
old new 1 1 PROG = lzma 2 2 CXX = g++ -O2 -Wall 3 CXX_C = gcc-O2 -Wall3 CXX_C = $(CC) -O2 -Wall 4 4 LIB = -lm 5 5 RM = rm -f 6 CFLAGS =-c -I ../../../6 CFLAGSX = $(CFLAGS) -c -I ../../../ 7 7 8 8 OBJS = \ 9 9 LzmaAlone.o \ … … $(PROG): $(OBJS) 37 37 $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) 38 38 39 39 LzmaAlone.o: LzmaAlone.cpp 40 $(CXX) $(CFLAGS ) LzmaAlone.cpp40 $(CXX) $(CFLAGSX) LzmaAlone.cpp 41 41 42 42 LzmaBench.o: LzmaBench.cpp 43 $(CXX) $(CFLAGS ) LzmaBench.cpp43 $(CXX) $(CFLAGSX) LzmaBench.cpp 44 44 45 45 LzmaRam.o: LzmaRam.cpp 46 $(CXX) $(CFLAGS ) LzmaRam.cpp46 $(CXX) $(CFLAGSX) LzmaRam.cpp 47 47 48 48 LzmaRamDecode.o: LzmaRamDecode.c 49 $(CXX_C) $(CFLAGS ) LzmaRamDecode.c49 $(CXX_C) $(CFLAGSX) LzmaRamDecode.c 50 50 51 51 LzmaDecode.o: ../LZMA_C/LzmaDecode.c 52 $(CXX_C) $(CFLAGS ) ../LZMA_C/LzmaDecode.c52 $(CXX_C) $(CFLAGSX) ../LZMA_C/LzmaDecode.c 53 53 54 54 BranchX86.o: ../Branch/BranchX86.c 55 $(CXX_C) $(CFLAGS ) ../Branch/BranchX86.c55 $(CXX_C) $(CFLAGSX) ../Branch/BranchX86.c 56 56 57 57 LZMADecoder.o: ../LZMA/LZMADecoder.cpp 58 $(CXX) $(CFLAGS ) ../LZMA/LZMADecoder.cpp58 $(CXX) $(CFLAGSX) ../LZMA/LZMADecoder.cpp 59 59 60 60 LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp 61 $(CXX) $(CFLAGS ) ../LZMA/LZMAEncoder.cpp61 $(CXX) $(CFLAGSX) ../LZMA/LZMAEncoder.cpp 62 62 63 63 LZInWindow.o: ../LZ/LZInWindow.cpp 64 $(CXX) $(CFLAGS ) ../LZ/LZInWindow.cpp64 $(CXX) $(CFLAGSX) ../LZ/LZInWindow.cpp 65 65 66 66 LZOutWindow.o: ../LZ/LZOutWindow.cpp 67 $(CXX) $(CFLAGS ) ../LZ/LZOutWindow.cpp67 $(CXX) $(CFLAGSX) ../LZ/LZOutWindow.cpp 68 68 69 69 RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp 70 $(CXX) $(CFLAGS ) ../RangeCoder/RangeCoderBit.cpp70 $(CXX) $(CFLAGSX) ../RangeCoder/RangeCoderBit.cpp 71 71 72 72 InBuffer.o: ../../Common/InBuffer.cpp 73 $(CXX) $(CFLAGS ) ../../Common/InBuffer.cpp73 $(CXX) $(CFLAGSX) ../../Common/InBuffer.cpp 74 74 75 75 OutBuffer.o: ../../Common/OutBuffer.cpp 76 $(CXX) $(CFLAGS ) ../../Common/OutBuffer.cpp76 $(CXX) $(CFLAGSX) ../../Common/OutBuffer.cpp 77 77 78 78 FileStreams.o: ../../Common/FileStreams.cpp 79 $(CXX) $(CFLAGS ) ../../Common/FileStreams.cpp79 $(CXX) $(CFLAGSX) ../../Common/FileStreams.cpp 80 80 81 81 StreamUtils.o: ../../Common/StreamUtils.cpp 82 $(CXX) $(CFLAGS ) ../../Common/StreamUtils.cpp82 $(CXX) $(CFLAGSX) ../../Common/StreamUtils.cpp 83 83 84 84 Alloc.o: ../../../Common/Alloc.cpp 85 $(CXX) $(CFLAGS ) ../../../Common/Alloc.cpp85 $(CXX) $(CFLAGSX) ../../../Common/Alloc.cpp 86 86 87 87 C_FileIO.o: ../../../Common/C_FileIO.cpp 88 $(CXX) $(CFLAGS ) ../../../Common/C_FileIO.cpp88 $(CXX) $(CFLAGSX) ../../../Common/C_FileIO.cpp 89 89 90 90 CommandLineParser.o: ../../../Common/CommandLineParser.cpp 91 $(CXX) $(CFLAGS ) ../../../Common/CommandLineParser.cpp91 $(CXX) $(CFLAGSX) ../../../Common/CommandLineParser.cpp 92 92 93 93 CRC.o: ../../../Common/CRC.cpp 94 $(CXX) $(CFLAGS ) ../../../Common/CRC.cpp94 $(CXX) $(CFLAGSX) ../../../Common/CRC.cpp 95 95 96 96 MyWindows.o: ../../../Common/MyWindows.cpp 97 $(CXX) $(CFLAGS ) ../../../Common/MyWindows.cpp97 $(CXX) $(CFLAGSX) ../../../Common/MyWindows.cpp 98 98 99 99 String.o: ../../../Common/String.cpp 100 $(CXX) $(CFLAGS ) ../../../Common/String.cpp100 $(CXX) $(CFLAGSX) ../../../Common/String.cpp 101 101 102 102 StringConvert.o: ../../../Common/StringConvert.cpp 103 $(CXX) $(CFLAGS ) ../../../Common/StringConvert.cpp103 $(CXX) $(CFLAGSX) ../../../Common/StringConvert.cpp 104 104 105 105 StringToInt.o: ../../../Common/StringToInt.cpp 106 $(CXX) $(CFLAGS ) ../../../Common/StringToInt.cpp106 $(CXX) $(CFLAGSX) ../../../Common/StringToInt.cpp 107 107 108 108 Vector.o: ../../../Common/Vector.cpp 109 $(CXX) $(CFLAGS ) ../../../Common/Vector.cpp109 $(CXX) $(CFLAGSX) ../../../Common/Vector.cpp 110 110 111 111 clean: 112 112 -$(RM) $(PROG) $(OBJS)
Note:
See TracBrowser
for help on using the repository browser.
