options WITH_LZO and WITH_LZMA for cmake and scons (default to true) pointcache.c...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 25 Sep 2009 02:40:10 +0000 (02:40 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 25 Sep 2009 02:40:10 +0000 (02:40 +0000)
CMakeLists.txt
extern/CMakeLists.txt
extern/Makefile
extern/SConscript
source/blender/SConscript
source/blender/blenkernel/CMakeLists.txt
source/blender/blenkernel/SConscript
source/blender/blenkernel/intern/Makefile
source/blender/blenkernel/intern/pointcache.c
tools/btools.py

index 92c670f572c8274f66cdf970165844e20abe3146..d8c5a132995dbf03d927e2944873580078ce1890 100644 (file)
@@ -75,6 +75,8 @@ OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
 OPTION(WITH_FFTW3         "Enable FFTW3 support" OFF)
 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
 OPTION(WITH_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
+OPTION(WITH_LZO           "Enable fast LZO compression, used for pointcache" ON)
+OPTION(WITH_LZMA          "Enable best LZMA compression, used for pointcache" ON)
 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation" OFF)
 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
index 44e47aaf88d4fa3c415b5b916fabf5fde86dfa3f..35271d24a2d4945bdc1f20fd73e4fbf155c75ed7 100644 (file)
@@ -38,5 +38,10 @@ IF(WITH_OPENJPEG)
        ADD_SUBDIRECTORY(libopenjpeg)
 ENDIF(WITH_OPENJPEG)
 
-ADD_SUBDIRECTORY(lzo)
-ADD_SUBDIRECTORY(lzma)
+IF(WITH_LZO)
+       ADD_SUBDIRECTORY(lzo)
+ENDIF(WITH_LZO)
+
+IF(WITH_LZMA)
+       ADD_SUBDIRECTORY(lzma)
+ENDIF(WITH_LZMA)
index b81fbd2b91ab4d40165a3c9899b9e691e26795fc..a30cd1d7ca3ccacc3a5f7ac55ca93c1b10aa874d 100644 (file)
@@ -33,9 +33,9 @@ DIR = $(OCGDIR)/extern
 DIRS = glew/src
 
 # Cloth requires it
-#ifneq ($(NAN_NO_KETSJI), true)
-DIRS += bullet2
-#endif
+ifeq ($(NAN_USE_BULLET), true)
+       DIRS += bullet2
+endif
 
 ifeq ($(WITH_BINRELOC), true)
     DIRS += binreloc
index 20604d87e45f76ba995405fbf1da80c856439dc8..af057a739276b9be0a4491bb362dfba86d0d4261 100644 (file)
@@ -22,5 +22,8 @@ if env['WITH_BF_REDCODE'] and env['BF_REDCODE_LIB'] == '':
 if env['OURPLATFORM'] == 'linux2':
     SConscript(['binreloc/SConscript']);
 
-SConscript(['lzo/SConscript'])
-SConscript(['lzma/SConscript'])
+if env['WITH_BF_LZO']:
+       SConscript(['lzo/SConscript'])
+
+if env['WITH_BF_LZMA']:
+       SConscript(['lzma/SConscript'])
index af2c81a3b45bacb22c50f8109955a4893dece2ac..3625678f6102603782d91d632e37fc2fc18d190f 100644 (file)
@@ -18,7 +18,7 @@ SConscript(['avi/SConscript',
             'nodes/SConscript',
             'ikplugin/SConscript',
             'windowmanager/SConscript',
-           'blenfont/SConscript'])
+            'blenfont/SConscript'])
 
 
 
index 3473950ab3a90b138e271cb764eaff0ee03f689c..f60cade61ed1b9970191213d892a09c17d861f53 100644 (file)
@@ -34,8 +34,6 @@ SET(INC
        ../nodes ../../../extern/glew/include ../gpu ../makesrna ../../../intern/smoke/extern
        ../../../intern/bsp/extern ../blenfont
        ../../../intern/audaspace/intern
-       ../../../extern/lzo/minilzo
-       ../../../extern/lzma
        ${ZLIB_INC}
 )
 
@@ -76,6 +74,16 @@ IF(NOT WITH_ELBEEM)
        ADD_DEFINITIONS(-DDISABLE_ELBEEM)
 ENDIF(NOT WITH_ELBEEM)
 
+IF(WITH_LZO)
+       SET(INC ${INC} ../../../extern/lzo/minilzo)
+       ADD_DEFINITIONS(-DWITH_LZO)
+ENDIF(WITH_LZO)
+
+IF(WITH_LZMA)
+       SET(INC ${INC} ../../../extern/lzma)
+       ADD_DEFINITIONS(-DWITH_LZMA)
+ENDIF(WITH_LZMA)
+
 IF(WIN32)
        SET(INC ${INC} ${PTHREADS_INC})
 ENDIF(WIN32)
index 944667e296389ccb78cb0dde3e3b0c2445098a4e..63631ddc40fc35194367135234991e6832ba4ee6 100644 (file)
@@ -11,8 +11,6 @@ incs += ' #/extern/bullet2/src'
 incs += ' #/intern/opennl/extern #/intern/bsp/extern'
 incs += ' ../gpu #/extern/glew/include'
 incs += ' #/intern/smoke/extern'
-incs += ' #/extern/lzo/minilzo'
-incs += ' #/extern/lzma'
 incs += ' #/intern/audaspace/intern'
 
 incs += ' ' + env['BF_OPENGL_INC']
@@ -61,7 +59,15 @@ if env['BF_NO_ELBEEM']:
 
 if env['WITH_BF_LCMS']:
        defs.append('WITH_LCMS')
-       
+
+if env['WITH_BF_LZO']:
+       incs += ' #/extern/lzo/minilzo'
+       defs.append('WITH_LZO')
+
+if env['WITH_BF_LZMA']:
+       incs += ' #/extern/lzma'
+       defs.append('WITH_LZMA')
+
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
     incs += ' ' + env['BF_PTHREADS_INC']
 
index f16b57c846958b71dec1cc03c5d8fa26f7b1ec69..26b9b9ef0dd398712cc9d1f33c1c61973709ee98 100644 (file)
@@ -86,14 +86,24 @@ CPPFLAGS += -I../../gpu
 # path to our own external headerfiles
 CPPFLAGS += -I..
 
-# path to bullet2, for cloth
-CPPFLAGS += -I$(NAN_BULLET2)/include
 CPPFLAGS += -I$(NAN_FREETYPE)/include
 CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
 
+# path to bullet2, for cloth
+ifeq ($(NAN_USE_BULLET), true)
+       CPPFLAGS += -I$(NAN_BULLET2)/include
+endif
+
 # lzo and lzma, for pointcache
-CPPFLAGS += -I$(NAN_LZO)/minilzo
-CPPFLAGS += -I$(NAN_LZMA)
+ifeq ($(WITH_LZO),true)
+       CPPFLAGS += -I$(NAN_LZO)/minilzo
+       CPPFLAGS += -DWITH_LZO
+endif
+
+ifeq ($(WITH_LZO),true)
+       CPPFLAGS += -I$(NAN_LZMA)
+       CPPFLAGS += -DWITH_LZMA
+endif
 
 ifeq ($(WITH_FFMPEG),true)
     CPPFLAGS += -DWITH_FFMPEG
index e5f89727ab810f14751bc23a248e511641f12eee..3915a6901a0edf926f83ef13a3e22ca7c3ec103b 100644 (file)
 
 /* both in intern */
 #include "smoke_API.h"
+
+#ifdef WITH_LZO
 #include "minilzo.h"
+#else
+/* used for non-lzo cases */
+#define LZO_OUT_LEN(size)     ((size) + (size) / 16 + 64 + 3)
+#endif
 
+#ifdef WITH_LZMA
 #include "LzmaLib.h"
-
+#endif
 
 /* needed for directory lookup */
 /* untitled blend's need getpid for a unique name */
@@ -625,20 +632,25 @@ static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size);
 static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode)
 {
        int r = 0;
-       unsigned char compressed;
-       LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
-       unsigned int out_len = LZO_OUT_LEN(in_len);
+       unsigned char compressed = 0;
+       unsigned int out_len= 0;
        unsigned char *props = MEM_callocN(16*sizeof(char), "tmp");
        size_t sizeOfIt = 5;
 
+#ifdef WITH_LZO
+       out_len= LZO_OUT_LEN(in_len);
        if(mode == 1) {
+               LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS);
+               
                r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem);  
                if (!(r == LZO_E_OK) || (out_len >= in_len))
                        compressed = 0;
                else
                        compressed = 1;
        }
-       else if(mode == 2) {
+#endif
+#ifdef WITH_LZMA
+       if(mode == 2) {
                
                r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1....
                                                props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2);
@@ -648,7 +660,8 @@ static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned i
                else
                        compressed = 2;
        }
-
+#endif
+       
        ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char));
        if(compressed) {
                ptcache_file_write(pf, &out_len, 1, sizeof(unsigned int));
@@ -762,16 +775,19 @@ static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigne
                in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer");
                ptcache_file_read(pf, in, in_len, sizeof(unsigned char));
 
+#ifdef WITH_LZO
                if(compressed == 1)
                                r = lzo1x_decompress(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL);
-               else if(compressed == 2)
+#endif
+#ifdef WITH_LZMA
+               if(compressed == 2)
                {
                        size_t leni = in_len, leno = out_len;
                        ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int));
                        ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char));
                        r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt);
                }
-
+#endif
                MEM_freeN(in);
        }
        else {
index e3f3827ff4539f77654ceca6b91d39a8f0c539e6..b1584ae8784ba5a83dd118b8fed3957fd244dc86 100755 (executable)
@@ -56,6 +56,7 @@ def validate_arguments(args, bc):
                        'WITH_BF_PLAYER',
                        'WITH_BF_NOBLENDER',
                        'WITH_BF_BINRELOC',
+                       'WITH_BF_LZO', 'WITH_BF_LZMA',
                        'LCGDIR',
                        'BF_CXX', 'WITH_BF_STATICCXX', 'BF_CXX_LIB_STATIC',
                        'BF_TWEAK_MODE', 'BF_SPLIT_SRC',
@@ -379,6 +380,9 @@ def read_opts(cfg, args):
                (BoolVariable('BF_QUIET', 'Enable silent output if true', True)),
                (BoolVariable('WITH_BF_BINRELOC', 'Enable relocatable binary (linux only)', False)),
                
+               (BoolVariable('WITH_BF_LZO', 'Enable fast LZO pointcache compression', True)),
+               (BoolVariable('WITH_BF_LZMA', 'Enable best LZMA pointcache compression', True)),
+               
                (BoolVariable('WITH_BF_LCMS', 'Enable color correction with lcms', False)),
                ('BF_LCMS_LIB', 'LCMSlibrary', 'lcms'),