Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
98fb3dc
copy&paste error in cmake comment
pseyfert May 20, 2016
3b2f64a
rough draft for lzo
pseyfert May 20, 2016
404fad4
complete ifdef guards
pseyfert May 20, 2016
44876ec
lzo now might already work
pseyfert May 20, 2016
7406601
missing parenthesis in cmake file
pseyfert May 20, 2016
6ab47e2
first compilation round
pseyfert May 20, 2016
dfc4ed8
fix cmake file
pseyfert May 20, 2016
b665051
mixed up C and C++ compilation
pseyfert May 20, 2016
3ca2b7b
reorder typedefs and function declarations
pseyfert May 20, 2016
4a35f20
catching another typo
pseyfert May 20, 2016
d71df43
use root macro to extend cmake flags
pseyfert May 20, 2016
b6c8ad0
too stupidly copied and pasted
pseyfert May 20, 2016
32235d6
more copy&paste errors fixed
pseyfert May 20, 2016
744cace
attack compiler warnings
pseyfert May 21, 2016
cde6159
lz4 draft -- FindLZ4.cmake missing
pseyfert May 21, 2016
51be02b
fail on incompatible options
pseyfert May 21, 2016
2ef3aa8
syntax error
pseyfert May 21, 2016
ab06530
avoid type conversions and lzo types in lz4
pseyfert May 21, 2016
4218668
make compiler happy
pseyfert May 21, 2016
ea01847
specify failure reason and exclude checksum test
pseyfert May 21, 2016
089ac2c
reorganise cmake stuff
pseyfert May 21, 2016
49e45d4
accidentially ignored target size
pseyfert May 21, 2016
90f2f54
really dont use builtin lz4 if system one is requested
pseyfert May 21, 2016
c1893db
cmake corrections
pseyfert May 22, 2016
4eb7784
fiddle around with find lz4 module
pseyfert May 22, 2016
0aa6b74
zopfli draft
pseyfert May 22, 2016
3eed7df
make zopfli build
pseyfert May 22, 2016
13d5aa0
cut and paste zopfli down
pseyfert May 23, 2016
8f16cb5
excessive printout
pseyfert May 23, 2016
d61bd8a
draft brotli
pseyfert May 23, 2016
683eb90
catch first compiler errors with brotli
pseyfert May 23, 2016
057cb46
attacking more brotli errors
pseyfert May 23, 2016
6b43669
after compiler errors come linker errors
pseyfert May 23, 2016
340ca6b
some tests
pseyfert May 23, 2016
f6d3d6e
expose lzo configuration to -D flags in cmake
pseyfert May 26, 2016
c9790e4
add header comments
pseyfert May 26, 2016
28fda82
run astyle
pseyfert May 26, 2016
217c3c2
remove debugging output
pseyfert May 26, 2016
7755666
disable unused parameter warnings
pseyfert May 26, 2016
bd46e6d
Merge remote branch 'origin/master_compressions' into compression
pseyfert May 26, 2016
3abbe01
cleanup cmake
pseyfert May 26, 2016
890e38a
compiler warnings and dependency cleanup
pseyfert May 26, 2016
7d11843
compiler warnings
pseyfert May 26, 2016
31e80b7
remove lzo dependency from brotli by using adler32 from zlib
pseyfert May 26, 2016
4545179
add brotli documentation
pseyfert May 26, 2016
e0746d4
lz4 documentation
pseyfert May 26, 2016
7f7e53c
added acknowledgments since it is mainly copy and paste
pseyfert May 26, 2016
bc28b1b
copy and paste duplication
pseyfert May 26, 2016
c4b7152
super stupid copy&paste mistake
pseyfert May 30, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
zopfli draft
  • Loading branch information
pseyfert committed May 23, 2016
commit 0aa6b745511cfb8cde0159a757a1bdc72de63e42
59 changes: 59 additions & 0 deletions cmake/modules/FindZOPFLI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Find the ZOPFLI includes and library.
#
# This module defines
# ZOPFLI_INCLUDE_DIR, where to locate ZOPFLI header files
# ZOPFLI_LIBRARIES, the libraries to link against to use ZOPFLI
# ZOPFLI_FOUND. If false, you cannot build anything that requires ZOPFLI.

if(ZOPFLI_CONFIG_EXECUTABLE)
set(ZOPFLI_FIND_QUIETLY 1)
endif()
set(ZOPFLI_FOUND 0)

if(NOT ZOPFLI_DIR)
set(ZOPFLI_DIR $ENV{ZOPFLI_DIR})
endif()

find_path(ZOPFLI_INCLUDE_DIR zopfli.h PATHS
${ZOPFLI_DIR}/include
/usr/include
/usr/local/include
/opt/zopfli/include
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
DOC "Specify the directory containing zopfli.h"
)

find_library(ZOPFLI_LIBRARY NAMES zopfli PATHS
${ZOPFLI_DIR}/lib
/usr/local/zopfli/lib
/usr/local/lib
/usr/lib/zopfli
/usr/local/lib/zopfli
/usr/zopfli/lib /usr/lib
/usr/zopfli /usr/local/zopfli
/opt/zopfli /opt/zopfli/lib
NO_DEFAULT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
DOC "Specify the zopfli library here."
)

if(ZOPFLI_INCLUDE_DIR)
message(STATUS "Found ZOPFLI includes at ${ZOPFLI_INCLUDE_DIR}")
else()
message(STATUS "ZOPFLI includes not found")
endif()

if(ZOPFLI_LIBRARY)
message(STATUS "Found ZOPFLI library at ${ZOPFLI_LIBRARY}")
else()
message(STATUS "ZOPFLI library not found")
endif()


if(ZOPFLI_INCLUDE_DIR AND ZOPFLI_LIBRARY)
set(ZOPFLI_FOUND 1)
endif()

set(ZOPFLI_LIBRARIES ${ZOPFLI_LIBRARY})
mark_as_advanced(ZOPFLI_FOUND ZOPFLI_LIBRARY ZOPFLI_INCLUDE_DIR)
1 change: 1 addition & 0 deletions cmake/modules/RootBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ ROOT_BUILD_OPTION(builtin_pcre OFF "Build included libpcre, or use system libpcr
ROOT_BUILD_OPTION(builtin_zlib OFF "Build included libz, or use system libz")
ROOT_BUILD_OPTION(builtin_lzma OFF "Build included liblzma, or use system liblzma")
ROOT_BUILD_OPTION(lzo OFF "LZO support, requires liblzo2")
ROOT_BUILD_OPTION(zopfli OFF "ZOPFLI support, requires libzopfli")
ROOT_BUILD_OPTION(lz4 OFF "LZ4 support, (either included lz4 or system lz4)")
ROOT_BUILD_OPTION(builtin_lz4 OFF "Build included lz4, or use system liblz4")
ROOT_BUILD_OPTION(builtin_davix OFF "Build the Davix library internally (downloading tarfile from the Web)")
Expand Down
5 changes: 5 additions & 0 deletions cmake/modules/RootConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ if(lzma)
else()
set(haslzmacompression undef)
endif()
if(zopfli)
set(haszopflicompression define)
else()
set(haszopflicompression undef)
endif()
if(lz4)
set(haslz4compression define)
else()
Expand Down
14 changes: 14 additions & 0 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,20 @@ if(lzo)
endif()
endif()

#---Check for ZOPFLI------------------------------------------------------------------
if(zopfli)
message(STATUS "Looking for ZOPFLI")
find_package(ZOPFLI)
if(NOT ZOPFLI_FOUND)
if(fail-on-missing)
message(FATAL_ERROR "zopfli not found but required (zopfli option enabled)")
else()
message(STATUS "zopfli not found. Switching off zopfli option")
set(zopfli OFF CACHE BOOL "" FORCE)
endif()
endif()
endif()

#---Check for OpenSSL------------------------------------------------------------------
if(ssl OR builtin_openssl)
if(builtin_openssl)
Expand Down
8 changes: 7 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ if(lzo)
set(lzo_objects $<TARGET_OBJECTS:Lzo>)
set(lzo_library ${LZO_LIBRARIES})
endif()
if(zopfli)
add_subdirectory(zopfli)
set(zopfli_objects $<TARGET_OBJECTS:Zopfli>)
set(zopfli_library ${ZOPFLI_LIBRARIES})
endif()
if(lz4)
add_subdirectory(lz4)
set(lz4_objects $<TARGET_OBJECTS:Lz4>)
Expand All @@ -57,6 +62,7 @@ set(objectlibs $<TARGET_OBJECTS:Base>
${macosx_objects}
${unix_objects}
${lzo_objects}
${zopfli_objects}
${lz4_objects}
${winnt_objects})

Expand Down Expand Up @@ -116,7 +122,7 @@ add_subdirectory(utils)
ROOT_LINKER_LIBRARY(Core
$<TARGET_OBJECTS:BaseTROOT>
${objectlibs}
LIBRARIES ${PCRE_LIBRARIES} ${lzo_library} ${lz4_library} ${LZMA_LIBRARIES} ${ZLIB_LIBRARY}
LIBRARIES ${PCRE_LIBRARIES} ${lzo_library} ${zopfli_library} ${lz4_library} ${LZMA_LIBRARIES} ${ZLIB_LIBRARY}
${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${corelinklibs} )

if(cling)
Expand Down
3 changes: 3 additions & 0 deletions core/zip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ else()
set(ZLIB_HEADERS ${ZipOldHeaders})
set(ZLIB_SRCS ${ZipOldSource} ${CMAKE_CURRENT_SOURCE_DIR}/src/Compression.cxx ${CMAKE_CURRENT_SOURCE_DIR}/src/RZip.cxx)
endif()
if(zopfli)
ROOT_ADD_CXX_FLAG(CMAKE_C_FLAGS -DZOPFLI)
endif()
if(lz4)
ROOT_ADD_CXX_FLAG(CMAKE_C_FLAGS -DLZ4)
endif()
Expand Down
2 changes: 1 addition & 1 deletion core/zip/src/Bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void R__zipLZ4(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, in
}
#endif
#ifdef ZOPFLI
#include "ZipZOPFLI.h"
extern void R__zipZOPFLI(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep) ;
#else
void R__zipZOPFLI(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep) {
R__error("ROOT built without ZOPFLI support");
Expand Down
11 changes: 11 additions & 0 deletions core/zopfli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
############################################################################
# CMakeLists.txt file for building ROOT core/zopfli package
############################################################################

#---Declare ZipZOPFLI sources as part of libCore-------------------------------
set(sources ${CMAKE_CURRENT_SOURCE_DIR}/src/ZipZOPFLI.c)

include_directories(${ZOPFLI_INCLUDE_DIR})

ROOT_OBJECT_LIBRARY(Zopfli ${sources})

100 changes: 100 additions & 0 deletions core/zopfli/src/ZipZOPFLI.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>

#include "zopfli/zopfli.h"

#ifndef NULL
#define NULL 0L
#endif

typedef char boolean;
typedef unsigned char uch; /* code assumes unsigned bytes; these type- */
typedef unsigned short ush; /* defs replace byte/UWORD/ULONG (which are */
typedef unsigned long ulg; /* predefined on some systems) & match zip */

extern void R__error(const char *msg);
#define HDRSIZE 9


int R__ZopfliCompress(ZopfliOptions* zpfopts, ZopfliFormat zpftype,
uch* src, size_t srcsize, char* target, size_t* dstsz)
{
uch* compression_target = 0;
size_t compression_size = 0;
unsigned long adler32;
lzo_uint obufs;
lzo_uint osz;
lzo_uintp obufsz;
uch* obufptr;

obufs = *dstsz;
obufsz = &obufs;
(target)[0] = 'Z';
(target)[1] = 'P';
if (ZOPFLI_FORMAT_ZLIB == zpftype) (target)[2] = 'Z';
if (ZOPFLI_FORMAT_GZIP == zpftype) (target)[2] = 'G';
if (ZOPFLI_FORMAT_DEFLATE == zpftype) (target)[2] = 'D';
ZopfliCompress(zpfopts, zpftype, src, srcsize, &compression_target, &compression_size);
if (compression_size > srcsize) {
free(compression_target);
if (*dstsz < srcsize + HDRSIZE + 4) {
R__error("could not leave uncompressed");
return -1;
}
memmove(target + HDRSIZE,src,srcsize);
target[2]=0;
compression_size = srcsize;
} else {
if (*dstsz < compression_size + HDRSIZE + 4) {
/* this is actually caught */
R__error("could not compress");
free(compression_target);
return -1;
}
memmove(target + HDRSIZE,compression_target,compression_size);
free(compression_target);
}

/* does all this make sense? */
*dstsz = compression_size + HDRSIZE + 4;
*obufsz = compression_size + HDRSIZE + 4;
osz = *obufsz - HDRSIZE;
(target)[3] = (char)(((osz) >> 0) & 0xff);
(target)[4] = (char)(((osz) >> 8) & 0xff);
(target)[5] = (char)(((osz) >>16) & 0xff);
(target)[6] = (char)(((srcsize) >> 0) & 0xff);
(target)[7] = (char)(((srcsize) >> 8) & 0xff);
(target)[8] = (char)(((srcsize) >>16) & 0xff);
/* calculate checksum */
adler32 = lzo_adler32(
lzo_adler32(0, NULL,0), (target) + HDRSIZE, osz - 4);
obufptr = target;
obufptr += *obufsz - 4;
obufptr[0] = (char) (adler32 & 0xff);
obufptr[1] = (char) ((adler32 >> 8) & 0xff);
obufptr[2] = (char) ((adler32 >> 16) & 0xff);
obufptr[3] = (char) ((adler32 >> 24) & 0xff);

return 0;

}

void R__zipZOPFLI(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
{
size_t dstsz = *tgtsize;
ZopfliFormat zpftype;
ZopfliOptions zpfopts;
ZopfliInitOptions(&zpfopts);
zpfopts.numiterations = cxlevel;
zpftype = ZOPFLI_FORMAT_ZLIB; /* also possible GZIP or DEFLATE */
if (R__ZopfliCompress( &zpfopts, zpftype, (uch*) src, *srcsize, tgt, &dstsz)) {
*irep = 0;
} else {
*irep = dstsz;
}
*tgtsize = dstsz;
}