Integrated lzokay
This commit is contained in:
parent
02e4e47fb2
commit
12ff0d1f73
|
@ -19,3 +19,6 @@
|
||||||
[submodule "externals/lzo"]
|
[submodule "externals/lzo"]
|
||||||
path = externals/lzo
|
path = externals/lzo
|
||||||
url = https://github.com/nemequ/lzo
|
url = https://github.com/nemequ/lzo
|
||||||
|
[submodule "externals/lzokay"]
|
||||||
|
path = externals/lzokay
|
||||||
|
url = https://github.com/jackoalan/lzokay
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit f7da328248f3fea1a5e05d3f39598850383b1867
|
|
@ -1,4 +1,5 @@
|
||||||
# CONFIG += PUBLIC_RELEASE
|
# CONFIG += PUBLIC_RELEASE
|
||||||
|
DEFINES += USE_LZOKAY
|
||||||
|
|
||||||
win32: {
|
win32: {
|
||||||
QMAKE_CXXFLAGS += /WX \ # Treat warnings as errors
|
QMAKE_CXXFLAGS += /WX \ # Treat warnings as errors
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
#include "CompressionUtil.h"
|
#include "CompressionUtil.h"
|
||||||
#include <Common/Common.h>
|
#include <Common/Common.h>
|
||||||
|
|
||||||
|
#if USE_LZOKAY
|
||||||
|
#include <lzokay.hpp>
|
||||||
|
#else
|
||||||
#include <lzo/lzo1x.h>
|
#include <lzo/lzo1x.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
namespace CompressionUtil
|
namespace CompressionUtil
|
||||||
|
@ -23,6 +28,21 @@ namespace CompressionUtil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_LZOKAY
|
||||||
|
const char* ErrorText_LZO(lzokay::EResult Result)
|
||||||
|
{
|
||||||
|
switch (Result)
|
||||||
|
{
|
||||||
|
case lzokay::EResult::LookbehindOverrun: return "LookbehindOverrun";
|
||||||
|
case lzokay::EResult::OutputOverrun: return "OutputOverrun";
|
||||||
|
case lzokay::EResult::InputOverrun: return "InputOverrun";
|
||||||
|
case lzokay::EResult::Error: return "Error";
|
||||||
|
case lzokay::EResult::Success: return "Success";
|
||||||
|
case lzokay::EResult::InputNotConsumed: return "InputNotConsumed";
|
||||||
|
default: return "UNKNOWN LZO ERROR";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
const char* ErrorText_LZO(int32 Error)
|
const char* ErrorText_LZO(int32 Error)
|
||||||
{
|
{
|
||||||
switch (Error)
|
switch (Error)
|
||||||
|
@ -44,6 +64,7 @@ namespace CompressionUtil
|
||||||
default: return "UNKNOWN LZO ERROR";
|
default: return "UNKNOWN LZO ERROR";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ************ DECOMPRESS ************
|
// ************ DECOMPRESS ************
|
||||||
bool DecompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
|
bool DecompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
|
||||||
|
@ -83,6 +104,17 @@ namespace CompressionUtil
|
||||||
|
|
||||||
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut)
|
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut)
|
||||||
{
|
{
|
||||||
|
#if USE_LZOKAY
|
||||||
|
lzokay::EResult Result = lzokay::decompress(pSrc, (size_t) SrcLen, pDst, (size_t&) rTotalOut);
|
||||||
|
|
||||||
|
if (Result < lzokay::EResult::Success)
|
||||||
|
{
|
||||||
|
errorf("LZO error: %s", ErrorText_LZO(Result));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
lzo_init();
|
lzo_init();
|
||||||
lzo_uint TotalOut;
|
lzo_uint TotalOut;
|
||||||
int32 Error = lzo1x_decompress(pSrc, SrcLen, pDst, &TotalOut, LZO1X_MEM_DECOMPRESS);
|
int32 Error = lzo1x_decompress(pSrc, SrcLen, pDst, &TotalOut, LZO1X_MEM_DECOMPRESS);
|
||||||
|
@ -95,6 +127,7 @@ namespace CompressionUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen)
|
bool DecompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen)
|
||||||
|
@ -182,8 +215,20 @@ namespace CompressionUtil
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut)
|
bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
|
||||||
{
|
{
|
||||||
|
#if USE_LZOKAY
|
||||||
|
rTotalOut = DstLen;
|
||||||
|
lzokay::EResult Result = lzokay::compress(pSrc, (size_t) SrcLen, pDst, (size_t&) rTotalOut);
|
||||||
|
|
||||||
|
if (Result < lzokay::EResult::Success)
|
||||||
|
{
|
||||||
|
errorf("LZO error: %s", ErrorText_LZO(Result));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
lzo_init();
|
lzo_init();
|
||||||
|
|
||||||
uint8 *pWorkMem = new uint8[LZO1X_999_MEM_COMPRESS];
|
uint8 *pWorkMem = new uint8[LZO1X_999_MEM_COMPRESS];
|
||||||
|
@ -197,6 +242,7 @@ namespace CompressionUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments)
|
bool CompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments)
|
||||||
|
@ -219,7 +265,7 @@ namespace CompressionUtil
|
||||||
if (IsZlib)
|
if (IsZlib)
|
||||||
CompressZlib(pSrc, Size, Compressed.data(), Compressed.size(), TotalOut);
|
CompressZlib(pSrc, Size, Compressed.data(), Compressed.size(), TotalOut);
|
||||||
else
|
else
|
||||||
CompressLZO(pSrc, Size, Compressed.data(), TotalOut);
|
CompressLZO(pSrc, Size, Compressed.data(), Compressed.size(), TotalOut);
|
||||||
|
|
||||||
// Verify that the compressed data is actually smaller.
|
// Verify that the compressed data is actually smaller.
|
||||||
if (AllowUncompressedSegments && TotalOut >= Size)
|
if (AllowUncompressedSegments && TotalOut >= Size)
|
||||||
|
|
|
@ -67,7 +67,6 @@ INCLUDEPATH += $$PWE_MAIN_INCLUDE \
|
||||||
$$EXTERNALS_DIR/CodeGen/include \
|
$$EXTERNALS_DIR/CodeGen/include \
|
||||||
$$EXTERNALS_DIR/glew-2.1.0/include \
|
$$EXTERNALS_DIR/glew-2.1.0/include \
|
||||||
$$EXTERNALS_DIR/LibCommon/Source \
|
$$EXTERNALS_DIR/LibCommon/Source \
|
||||||
$$EXTERNALS_DIR/lzo/include \
|
|
||||||
$$EXTERNALS_DIR/nod/include \
|
$$EXTERNALS_DIR/nod/include \
|
||||||
$$EXTERNALS_DIR/nod/logvisor/include \
|
$$EXTERNALS_DIR/nod/logvisor/include \
|
||||||
$$EXTERNALS_DIR/tinyxml2 \
|
$$EXTERNALS_DIR/tinyxml2 \
|
||||||
|
@ -366,7 +365,14 @@ CODEGEN_OUT_PATH = $$BUILD_DIR/Core/codegen_build/auto_codegen.cpp
|
||||||
CODEGEN_SRC_PATH = $$PWD
|
CODEGEN_SRC_PATH = $$PWD
|
||||||
include($$EXTERNALS_DIR/CodeGen/codegen.pri)
|
include($$EXTERNALS_DIR/CodeGen/codegen.pri)
|
||||||
|
|
||||||
# Library Sources
|
# LZO
|
||||||
|
contains(DEFINES, USE_LZOKAY) {
|
||||||
|
INCLUDEPATH += $$EXTERNALS_DIR/lzokay
|
||||||
|
SOURCES += $$EXTERNALS_DIR/lzokay/lzokay.cpp
|
||||||
|
} else {
|
||||||
|
INCLUDEPATH += $$EXTERNALS_DIR/lzo/include
|
||||||
|
|
||||||
SOURCES += $$EXTERNALS_DIR/lzo/src/lzo_init.c \
|
SOURCES += $$EXTERNALS_DIR/lzo/src/lzo_init.c \
|
||||||
$$EXTERNALS_DIR/lzo/src/lzo1x_9x.c \
|
$$EXTERNALS_DIR/lzo/src/lzo1x_9x.c \
|
||||||
$$EXTERNALS_DIR/lzo/src/lzo1x_d1.c
|
$$EXTERNALS_DIR/lzo/src/lzo1x_d1.c
|
||||||
|
}
|
||||||
|
|
|
@ -79,7 +79,6 @@ INCLUDEPATH += $$PWE_MAIN_INCLUDE \
|
||||||
$$EXTERNALS_DIR/CodeGen/include \
|
$$EXTERNALS_DIR/CodeGen/include \
|
||||||
$$EXTERNALS_DIR/glew-2.1.0/include \
|
$$EXTERNALS_DIR/glew-2.1.0/include \
|
||||||
$$EXTERNALS_DIR/LibCommon/Source \
|
$$EXTERNALS_DIR/LibCommon/Source \
|
||||||
$$EXTERNALS_DIR/lzo/include \
|
|
||||||
$$EXTERNALS_DIR/nod/include \
|
$$EXTERNALS_DIR/nod/include \
|
||||||
$$EXTERNALS_DIR/nod/logvisor/include \
|
$$EXTERNALS_DIR/nod/logvisor/include \
|
||||||
$$EXTERNALS_DIR/tinyxml2 \
|
$$EXTERNALS_DIR/tinyxml2 \
|
||||||
|
@ -308,3 +307,10 @@ CODEGEN_DIR = $$EXTERNALS_DIR/CodeGen
|
||||||
CODEGEN_OUT_PATH = $$BUILD_DIR/Editor/codegen_build/auto_codegen.cpp
|
CODEGEN_OUT_PATH = $$BUILD_DIR/Editor/codegen_build/auto_codegen.cpp
|
||||||
CODEGEN_SRC_PATH = $$PWD
|
CODEGEN_SRC_PATH = $$PWD
|
||||||
include($$EXTERNALS_DIR/CodeGen/codegen.pri)
|
include($$EXTERNALS_DIR/CodeGen/codegen.pri)
|
||||||
|
|
||||||
|
# LZO
|
||||||
|
contains(DEFINES, USE_LZOKAY) {
|
||||||
|
INCLUDEPATH += $$EXTERNALS_DIR/lzokay
|
||||||
|
} else {
|
||||||
|
INCLUDEPATH += $$EXTERNALS_DIR/lzo/include
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue