All pastes #83356 Raw Edit

db90h

public text v1 · immutable
·published 2006-07-09 17:47 UTC
rendered paste body
diff -BurN ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/lzmaext.h ./lzma/SRC/7zip/Compress/LZMA_Lib/lzmaext.h
--- ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/lzmaext.h	1969-12-31 19:00:00.000000000 -0500
+++ ./lzma/SRC/7zip/Compress/LZMA_Lib/lzmaext.h	2006-07-07 13:04:44.000000000 -0400
@@ -0,0 +1,27 @@
+/*
+ * lzmaext.h
+ *
+ * LZMA Parameter extensions
+ * these minor additions by Jeremy Collake <jeremy@bitsum.com>
+ *
+ * This library is free software; you can redistribute 
+ * it and/or modify it under the terms of the GNU Lesser 
+ * General Public License as published by the Free Software 
+ * Foundation; either version 2.1 of the License, or 
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be 
+ * useful, but WITHOUT ANY WARRANTY; without even the implied 
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE. See the GNU Lesser General Public License 
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General 
+ * Public License along with this library; if not, write to 
+ * the Free Software Foundation, Inc., 59 Temple Place, 
+ * Suite 330, Boston, MA 02111-1307 USA 
+ */
+http://nonmips.sourceforge.net
+int compress2_lzma (Bytef *dest, uLongf *destLen,
+                    const Bytef *source, uLong sourceLen,				
+                    int level, int fb,	int lc,	int lp,	int pb);
diff -BurN ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/makefile ./lzma/SRC/7zip/Compress/LZMA_Lib/makefile
--- ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/makefile	2006-07-07 12:17:30.000000000 -0400
+++ ./lzma/SRC/7zip/Compress/LZMA_Lib/makefile	2006-07-06 10:23:46.000000000 -0400
@@ -84,5 +84,4 @@
 	$(CXX) $(CFLAGS) ../../../Common/Vector.cpp
 
 clean:
-	-$(RM) $(PROG) $(OBJS)
-
+	-$(RM) $(PROG) $(OBJS)
diff -BurN ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp ./lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp
--- ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp	2006-07-07 12:17:30.000000000 -0400
+++ ./lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.cpp	2006-07-07 11:08:59.000000000 -0400
@@ -20,6 +20,19 @@
  * the Free Software Foundation, Inc., 59 Temple Place, 
  * Suite 330, Boston, MA 02111-1307 USA 
  */
+ 
+#ifdef WIN32
+#include <initguid.h>
+#else
+#define INITGUID
+#endif
+
+/* jc: undef to kill compress2_lzma */
+#define _LZMA_PARAMS 
+
+#include "../../../Common/MyWindows.h"
+#include "../LZMA/LZMADecoder.h"
+#include "../LZMA/LZMAEncoder.h"
 
 /*
  * default values for encoder/decoder used by wrapper
@@ -27,19 +40,14 @@
 
 #include <zlib.h>
 
+#ifdef _LZMA_PARAMS
+//#include "lzmaext.h"
+#endif
+
 #define ZLIB_LC 3
 #define ZLIB_LP 0
 #define ZLIB_PB 2
-
-#ifdef WIN32
-#include <initguid.h>
-#else
-#define INITGUID
-#endif
-
-#include "../../../Common/MyWindows.h"
-#include "../LZMA/LZMADecoder.h"
-#include "../LZMA/LZMAEncoder.h"
+#define ZLIB_FB 128 /* jc: add fast bytes param */
 
 #define STG_E_SEEKERROR                  ((HRESULT)0x80030019L)
 #define STG_E_MEDIUMFULL                 ((HRESULT)0x80030070L)
@@ -180,6 +188,8 @@
 	UInt64 m_offset;
 };
 
+
+
 ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
                                   const Bytef *source, uLong sourceLen,
                                   int level))
@@ -214,8 +224,8 @@
 	properties[1].ulVal = UInt32(ZLIB_PB);
 	properties[2].ulVal = UInt32(ZLIB_LC); // for normal files
 	properties[3].ulVal = UInt32(ZLIB_LP); // for normal files
-	properties[4].ulVal = UInt32(2);
-	properties[5].ulVal = UInt32(128);
+	properties[4].ulVal = UInt32(2);       // todo
+	properties[5].ulVal = UInt32(ZLIB_FB); 
 	
 	properties[6].vt = VT_BSTR;
 	properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
@@ -243,6 +253,76 @@
 	return Z_OK;
 }
 
+#ifdef _LZMA_PARAMS
+/* jc: new compress2 proxy that allows lzma param specification */
+extern "C" int compress2_lzma (Bytef *dest,   uLongf *destLen,
+                                  	const Bytef *source, uLong sourceLen,
+                                  	int level, int fb, int lc, int lp, int pb)
+{	
+	CInMemoryStream *inStreamSpec = new CInMemoryStream(source, sourceLen);
+	CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
+	
+	COutMemoryStream *outStreamSpec = new COutMemoryStream(dest, *destLen);
+	CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
+	
+	NCompress::NLZMA::CEncoder *encoderSpec = 
+		new NCompress::NLZMA::CEncoder;
+	CMyComPtr<ICompressCoder> encoder = encoderSpec;
+	
+	PROPID propIDs[] = 
+	{
+		NCoderPropID::kDictionarySize,
+		NCoderPropID::kPosStateBits,
+		NCoderPropID::kLitContextBits,
+		NCoderPropID::kLitPosBits,
+		NCoderPropID::kAlgorithm,
+		NCoderPropID::kNumFastBytes,
+		NCoderPropID::kMatchFinder,
+		NCoderPropID::kEndMarker
+	};
+	const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
+	
+	if(pb<0) pb=ZLIB_PB;
+	if(lc<0) lc=ZLIB_LC;
+	if(lp<0) lp=ZLIB_LP;
+	if(fb<0) fb=ZLIB_FB;
+	PROPVARIANT properties[kNumProps];
+	for (int p = 0; p < 6; p++)
+		properties[p].vt = VT_UI4;
+	properties[0].ulVal = UInt32(1 << (level + 14));
+	properties[1].ulVal = UInt32(pb);
+	properties[2].ulVal = UInt32(lc); // for normal files
+	properties[3].ulVal = UInt32(lp); // for normal files
+	properties[4].ulVal = UInt32(2);       // todo
+	properties[5].ulVal = UInt32(fb); 
+	
+	properties[6].vt = VT_BSTR;
+	properties[6].bstrVal = (BSTR)(const wchar_t *)L"BT4";
+	
+	properties[7].vt = VT_BOOL;
+	properties[7].boolVal = VARIANT_TRUE;
+	
+	if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
+		return Z_MEM_ERROR; // should not happen
+	
+	HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
+	if (result == E_OUTOFMEMORY)
+	{
+		return Z_MEM_ERROR;
+	}   
+	else if (result != S_OK)
+	{
+		return Z_BUF_ERROR;	// should not happen
+	}   
+	
+	UInt64 fileSize;
+	outStreamSpec->Seek(0, STREAM_SEEK_END, &fileSize);
+	*destLen = fileSize;
+	
+	return Z_OK;
+}
+#endif
+
 ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
                                    const Bytef *source, uLong sourceLen))
 {
Binary files ../build_old/lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.o and ./lzma/SRC/7zip/Compress/LZMA_Lib/ZLib.o differ
diff -BurN ../build_old/squashfs2.1-r2/squashfs-tools/Makefile ./squashfs2.1-r2/squashfs-tools/Makefile
--- ../build_old/squashfs2.1-r2/squashfs-tools/Makefile	2006-07-07 12:19:20.000000000 -0400
+++ ./squashfs2.1-r2/squashfs-tools/Makefile	2006-07-07 12:11:44.000000000 -0400
@@ -1,7 +1,7 @@
 INCLUDEDIR = .
-#LZMAPATH = ../lzma/SRC/7zip/Compress/LZMA_Lib
+#LZMAPATH = ../../lzma/SRC/7zip/Compress/LZMA_Lib
 
-CFLAGS := -I$(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -O2
+CFLAGS := -v -I$(INCLUDEDIR) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -O2 -D_LZMA_PARAMS
 
 mksquashfs: mksquashfs.o read_fs.o sort.o
 	$(CC) mksquashfs.o read_fs.o sort.o -lz -o $@
diff -BurN ../build_old/squashfs2.1-r2/squashfs-tools/mksquashfs.c ./squashfs2.1-r2/squashfs-tools/mksquashfs.c
--- ../build_old/squashfs2.1-r2/squashfs-tools/mksquashfs.c	2004-12-12 20:51:20.000000000 -0500
+++ ./squashfs2.1-r2/squashfs-tools/mksquashfs.c	2006-07-07 13:20:58.000000000 -0400
@@ -17,8 +17,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  *
+ *
  * mksquashfs.c
  */
+ 
+/* jc: define to add lzma params, specify during compile */
+// #define _LZMA_PARAMS 
 
 #define TRUE 1
 #include <pwd.h>
@@ -57,6 +61,15 @@
 					fprintf(stderr, "FATAL ERROR:" s, ##args);\
 					EXIT_MKSQUASHFS();\
 					} while(0)
+					
+#ifdef _LZMA_PARAMS
+#include "../../lzma/SRC/7zip/Compress/LZMA_Lib/lzmaext.h"					
+/* jc: be lame and use some globals.. this app is signle threaded*/					
+int g_fb=-1;
+int g_lc=-1;
+int g_lp=-1;
+int g_pb=-1;				
+#endif
 
 int total_compressed = 0, total_uncompressed = 0;
 int fd;
@@ -265,7 +278,11 @@
 	unsigned long c_byte = block_size << 1;
 	unsigned int res;
 
+#ifdef _LZMA_PARAMS
+	if(!uncompressed && (res = compress2_lzma(d, &c_byte, s, size, 9, g_fb, g_lc, g_lp, g_pb)) != Z_OK) {
+#else
 	if(!uncompressed && (res = compress2(d, &c_byte, s, size, 9)) != Z_OK) {
+#endif		
 		if(res == Z_MEM_ERROR)
 			BAD_ERROR("zlib::compress failed, not enough memory\n");
 		else if(res == Z_BUF_ERROR)
@@ -1624,7 +1641,66 @@
 				ERROR("%s: -b block size not power of two or not between 512 and 64K\n", argv[0]);
 				exit(1);
 			}
-		} else if(strcmp(argv[i], "-ef") == 0) {
+		} 
+#ifdef _LZMA_PARAMS		
+		else if(strcmp(argv[i], "-lc") == 0)
+		{
+			if(++i == argc) 
+			{
+			    ERROR("%s: -lc missing or invalid value\n", argv[0]);
+			    exit(1);
+			}
+			g_lc = strtol(argv[i], &g_lc, 10);
+			if(g_lc<0 || g_lc>8)
+			{
+				ERROR("lc is out of bounds.");
+				exit(1);
+			}
+		}
+		else if(strcmp(argv[i], "-lp") == 0)
+		{
+			if(++i == argc) 
+			{
+			    ERROR("%s: -lp missing or invalid value\n", argv[0]);
+			    exit(1);
+			}
+			g_lp = strtol(argv[i], &g_lp, 10);
+			if(g_lp<0 || g_lp>4)
+			{
+				ERROR("lp is out of bounds.");
+				exit(1);				
+			}			
+		}
+		else if(strcmp(argv[i], "-pb") == 0)
+		{
+			if(++i == argc) 
+			{
+			    ERROR("%s: -pb missing or invalid value\n", argv[0]);
+			    exit(1);
+			}
+			g_pb = strtol(argv[i], &g_pb, 10);
+			if(g_pb<0 || g_pb>4)
+			{
+				ERROR("pb is out of bounds.");
+				exit(1);
+			}			
+		}		
+		else if(strcmp(argv[i], "-fb") == 0)
+		{
+			if(++i == argc) 
+			{
+			    ERROR("%s: -fb missing or invalid value\n", argv[0]);
+			    exit(1);
+			}
+			g_fb = strtol(argv[i], &g_fb, 10);
+			if(g_fb<5 || g_fb>272)
+			{
+				ERROR("fb is out of bounds.");
+				exit(1);
+			}
+		}
+#endif		
+		else if(strcmp(argv[i], "-ef") == 0) {
 			if(++i == argc) {
 				ERROR("%s: -ef missing filename\n", argv[0]);
 				exit(1);
@@ -1770,6 +1846,12 @@
 			ERROR("\t\t\tfile or dir with priority per line.  Priority -32768 to\n");
 			ERROR("\t\t\t32767, default priority 0\n");
 			ERROR("-ef <exclude_file>\tlist of exclude dirs/files.  One per line\n");
+			#ifdef _LZMA_PARAMS
+			ERROR("-fb x\t\t\tset lzma fast bytes to x\n");			
+			ERROR("-lc x\t\t\tset lzma literal context bits to x\n");
+			ERROR("-lp x\t\t\tset lzma literal pos bits to x\n");
+			ERROR("-pb x\t\t\tset lzma pos bits to x\n");
+			#endif
 			exit(1);
 		}
 	}