重构项目,现支持多线程操作

This commit is contained in:
2026-06-20 18:03:34 +08:00
parent db3be495d7
commit 0e0bf9b357
266 changed files with 2919 additions and 5783 deletions

2
.gitignore vendored
View File

@ -5,6 +5,8 @@ cmake-build-*/
# build # build
build/ build/
compile_commands.json
# vs # vs
.vs/ .vs/
.vscode/ .vscode/

View File

@ -2,9 +2,31 @@ cmake_minimum_required(VERSION 3.31)
project(expkg) project(expkg)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(expkg) # 默认 Release 构建Debug 模式下 GIF/PNG 编码慢 3-5 倍)
add_subdirectory(testApp) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
# 第三方依赖
add_subdirectory(vendor/lz4/build/cmake)
# 源文件CONFIGURE_DEPENDS: 文件增删时自动重新配置)
file(GLOB_RECURSE SRC_SOURCE CONFIGURE_DEPENDS src/*.cpp)
file(GLOB STB_SOURCE CONFIGURE_DEPENDS vendor/stb/*.cpp)
# 可执行文件
add_executable(${PROJECT_NAME} ${SRC_SOURCE} ${STB_SOURCE})
# MSVC 默认编码设为 UTF-8
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /utf-8)
endif()
# 依赖与头文件路径
target_link_libraries(${PROJECT_NAME} PRIVATE lz4)
target_include_directories(${PROJECT_NAME}
PRIVATE vendor/stb vendor/gif-h src
)

View File

@ -1,35 +1,12 @@
# exPKG # exPKG
## useage ## useage
> ```c++ > ```bash
> #include "EXPKG/EXPKG.h" > expkg /path/to/file.pkg|file.mpkg [output/path]
>
> int main(int argc, char** argv) {
> CommandArgs args{ argc, argv};
>
> PKG::EXPKG decompress(args);
> PKG::EXPKG decompress("path/to/file");
> PKG::EXPKG decompress("path/to/file", "path/to/output/directory");
>
> return 0;
> }
>``` >```
## Cmake build
> ```bash
> use as subdirectory
>
> ```cmake
> add_subdirectory(path/to/expkg)
>
>add_executable(${TARGET} ${SRC_SOURCE})
>target_link_libraries(${TARGET} expkg-static)
>
> # or use dll by
> # target_link_libraries(${TARGET} expkg-shared)
>```
> then
> ```bash
> cmake -B build > cmake -B build
> cmake --build build --config Release -j8 > cmake --build build --config Release -j8
>``` >```

View File

@ -1,46 +0,0 @@
set(TARGET expkg)
project(${TARGET})
add_subdirectory(vendor/lz4/build/cmake)
file(GLOB_RECURSE SRC_SOURCE src/**.cpp vendor/gif-h/gif.h)
file(GLOB STB_SOURCE vendor/stb/*.cpp)
if(MSVC)
add_compile_options(/utf-8)
endif()
# static
add_library(expkg-static STATIC
${SRC_SOURCE}
${STB_SOURCE}
)
target_link_libraries(expkg-static PRIVATE lz4)
target_include_directories(expkg-static PRIVATE vendor/stb vendor/gif-h)
target_include_directories(expkg-static PUBLIC src)
# shared
add_library(expkg-shared SHARED
${SRC_SOURCE}
${STB_SOURCE}
)
set_target_properties(expkg-shared PROPERTIES
OUTPUT_NAME "expkg"
PREFIX ""
)
target_link_libraries(expkg-shared PRIVATE lz4)
target_compile_definitions(expkg-shared PRIVATE -DPKG_SHARED -DPKG_BUILD_DLL)
target_include_directories(expkg-shared PRIVATE vendor/stb vendor/gif-h)
target_include_directories(expkg-shared PUBLIC src)

View File

@ -1,105 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#include "BinaryReader.h"
#include <filesystem>
#include <iostream>
namespace PKG
{
BinaryReader::BinaryReader(const std::filesystem::path& fileName)
{
m_FilePath = fileName.string();
m_File.open(m_FilePath, std::ios::in | std::ios::binary);
if (!m_File.is_open())
{
std::cerr << "Failed to open file " << m_FilePath << std::endl;
system("pause");
exit(0);
}
}
BinaryReader::~BinaryReader()
{
if (m_File.is_open())
m_File.close();
}
int32_t BinaryReader::ReadInt32()
{
int32_t result = 0;
m_File.read(reinterpret_cast<char*>(&result), sizeof(int32_t));
return result;
}
uint32_t BinaryReader::ReadUInt32()
{
uint32_t result = 0;
m_File.read(reinterpret_cast<char*>(&result), sizeof(uint32_t));
return result;
}
float BinaryReader::ReadSingle()
{
float result = 0;
m_File.read(reinterpret_cast<char*>(&result), sizeof(float));
return result;
}
char BinaryReader::ReadChar()
{
char result;
m_File.read(&result, sizeof(char));
return result;
}
void BinaryReader::ReadData(std::string& data, const uint32_t length)
{
data.resize(length);
m_File.read(data.data(), length);
}
void BinaryReader::ReadData(std::vector<uint8_t>& data, uint32_t length)
{
data.resize(length);
m_File.read(reinterpret_cast<char*>(data.data()), length);
}
std::string BinaryReader::ReadString(const uint32_t length)
{
std::vector<uint8_t> result;
result.resize(length);
m_File.read(reinterpret_cast<char*>(result.data()), length);
return std::filesystem::u8path(std::string(reinterpret_cast<const char*>(result.data()), length)).string();
}
std::string BinaryReader::ReadStringFileData(const uint32_t length)
{
std::vector<uint8_t> result;
result.resize(length);
m_File.read(reinterpret_cast<char*>(result.data()), length);
return std::string(reinterpret_cast<const char*>(result.data()), length);
}
std::string BinaryReader::ReadNString(const int32_t maxLength)
{
std::vector<uint8_t> result;
result.resize(0);
int count = maxLength <= 0 ? 16 : maxLength;
char chr = ReadChar();
while (chr != '\0' && (maxLength == -1 || count <= maxLength))
{
result.push_back(chr);
chr = ReadChar();
}
return std::string(reinterpret_cast<const char*>(result.data()), result.size());
}
}

View File

@ -1,50 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#ifndef BINARYREADER_H
#define BINARYREADER_H
#include <filesystem>
#include <fstream>
#include <vector>
#include "Core.h"
namespace PKG
{
using pos_type = long long;
class PKG_API BinaryReader
{
public:
BinaryReader() = delete;
explicit BinaryReader(const std::filesystem::path& fileName);
~BinaryReader();
int32_t ReadInt32();
uint32_t ReadUInt32();
float ReadSingle();
char ReadChar();
std::string ReadString(uint32_t length);
std::string ReadNString(int32_t maxLength = -1);
std::string ReadStringFileData(uint32_t length);
void ReadData(std::string& data, uint32_t length);
void ReadData(std::vector<uint8_t>& data, uint32_t length);
void seekg(const pos_type pos) { m_File.seekg(pos); }
pos_type tellg() { return m_File.tellg(); }
std::string GetFilePath() const { return m_FilePath; }
std::string GetFileName() const { return m_FilePath.substr(m_FilePath.find_last_of("\\/") + 1); }
private:
std::ifstream m_File;
std::string m_FilePath;
};
}
#endif //BINARYREADER_H

View File

@ -1,47 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#include "BinaryWriter.h"
#include <filesystem>
#include <iostream>
namespace PKG
{
BinaryWriter::BinaryWriter(const std::filesystem::path& fileName, const std::ios_base::openmode optMode)
{
m_FilePath = fileName.string();
const std::filesystem::path path(fileName.parent_path());
m_File.open(m_FilePath, optMode);
if (!m_File.is_open() && !std::filesystem::exists(path))
{
std::filesystem::create_directories(path);
m_File.open(m_FilePath, optMode);
if (!m_File.is_open())
std::cerr << "cound not create file: " << m_FilePath << std::endl;
}
}
BinaryWriter::~BinaryWriter()
{
close();
}
void BinaryWriter::WriteBytes(const char* data, const uint32_t size)
{
m_File.write(data, size);
}
void BinaryWriter::WriteString(const std::string& str)
{
m_File.write(str.c_str(), str.size());
}
void BinaryWriter::close()
{
if (!m_File.is_open())
m_File.close();
}
}

View File

@ -1,38 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#ifndef BINARYWRITER_H
#define BINARYWRITER_H
#include <filesystem>
#include <fstream>
#include "Core.h"
namespace PKG
{
class PKG_API BinaryWriter
{
public:
BinaryWriter() = delete;
explicit BinaryWriter(const std::filesystem::path& fileName, std::ios_base::openmode optMode = std::ios::out);
~BinaryWriter();
void WriteBytes(const char* data, uint32_t size);
void WriteString(const std::string& str);
std::string GetFilePath() const { return m_FilePath; }
std::string GetFileName() const { return m_FilePath.substr(m_FilePath.find_last_of("\\/") + 1); }
void close();
private:
std::ofstream m_File;
std::string m_FilePath;
};
}
#endif //BINARYWRITER_H

View File

@ -1,265 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#include "ImageReader.h"
#include <iostream>
#include "lz4.h"
namespace PKG
{
#include <vector>
std::vector<unsigned char> Lz4Decompress(const unsigned char* compressedData,
size_t compressedSize,
size_t decompressedSize)
{
// 准备输出缓冲区
std::vector<unsigned char> output(decompressedSize);
// 执行解压缩
int result = LZ4_decompress_safe(
reinterpret_cast<const char*>(compressedData),
reinterpret_cast<char*>(output.data()),
static_cast<int>(compressedSize),
static_cast<int>(decompressedSize)
);
// 检查解压结果
if (result < 0 || static_cast<size_t>(result) != decompressedSize) {
throw std::runtime_error("LZ4 decompression failed");
}
return output;
}
TexImage ImageReader::ReadFrom(BinaryReader& reader, const TexImageContainer& container, const TexFormat format)
{
int mipMapCount = reader.ReadInt32();
auto aFormat = GetFormatFromTex(container.ImageFormat, format);
TexImage image{};
for (int i = 0; i < mipMapCount; i++)
{
TexMipMap mipmap;
switch (container.imageContainerVersion)
{
case ImageContainerVersion::VERSION1:
mipmap = ReadMipMapV1(reader); break;
case ImageContainerVersion::VERSION2:
case ImageContainerVersion::VERSION3:
mipmap = ReadMipMapV2AndV3(reader); break;
case ImageContainerVersion::VERSION4:
mipmap = ReadMipMapV4(reader); break;
}
mipmap.Format = aFormat;
if (mipmap.IsZ4Compressed)
{
mipmap.Data = Lz4Decompress(mipmap.Data.data(), mipmap.Data.size(), mipmap.DecompressedDataCount);
mipmap.IsZ4Compressed = false;
}
image.Mipmaps.push_back(mipmap);
}
return image;
}
TexImageContainer ImageReader::ImageContainerReaderReadFrom(BinaryReader& reader, TexFormat texFormat)
{
TexImageContainer container;
container.Magic = reader.ReadNString();
int imageCount = reader.ReadInt32();
if (container.Magic == "TEXB0001")
{
}
else if (container.Magic == "TEXB0002")
{
}
else if (container.Magic == "TEXB0003")
{
container.ImageFormat = (FreeImageFormat)reader.ReadInt32();
}
else if (container.Magic == "TEXB0004")
{
auto format = (FreeImageFormat)reader.ReadInt32();
bool isVideoMp4 = reader.ReadInt32();
if (format == FreeImageFormat::FIF_UNKNOWN)
{
if (isVideoMp4)
format = FreeImageFormat::FIF_MP4;
}
container.ImageFormat = format;
}
else
{
std::cerr << "bad image format" << std::endl;
}
int version = std::stoi(container.Magic.substr(4, 4));
container.imageContainerVersion = (ImageContainerVersion)version;
if (container.imageContainerVersion == ImageContainerVersion::VERSION4 && container.ImageFormat != FreeImageFormat::FIF_MP4)
{
container.imageContainerVersion = ImageContainerVersion::VERSION3;
}
for (int i = 0; i < imageCount; i++)
{
container.Images.push_back(ReadFrom(reader, container, texFormat));
}
return container;
}
TexMipMap ImageReader::ReadMipMapV1(BinaryReader& reader)
{
TexMipMap mipmap{};
mipmap.Width = reader.ReadInt32();
mipmap.Height = reader.ReadInt32();
mipmap.Data = ReadBytes(reader);
return mipmap;
}
TexMipMap ImageReader::ReadMipMapV2AndV3(BinaryReader& reader)
{
TexMipMap mipmap{};
mipmap.Width = reader.ReadInt32();
mipmap.Height = reader.ReadInt32();
mipmap.IsZ4Compressed = reader.ReadInt32() == 1;
mipmap.DecompressedDataCount = reader.ReadInt32();
mipmap.Data = ReadBytes(reader);
return mipmap;
}
TexMipMap ImageReader::ReadMipMapV4(BinaryReader& reader)
{
int param1 = reader.ReadInt32();
if (param1 != 1)
{
std::cerr << "ReadMipmapV4 unknow param1: " << param1 << std::endl;
}
int param2 = reader.ReadInt32();
if (param2 != 2)
{
std::cerr << "ReadMipmapV4 unknow param2: " << param1 << std::endl;
}
std::string condition = reader.ReadNString();
int param3 = reader.ReadInt32();
if (param3 != 1)
{
std::cerr << "ReadMipmapV4 unknow param3: " << param1 << std::endl;
}
TexMipMap mipmap{};
mipmap.Width = reader.ReadInt32();
mipmap.Height = reader.ReadInt32();
mipmap.IsZ4Compressed = reader.ReadInt32() == 1;
mipmap.DecompressedDataCount = reader.ReadInt32();
mipmap.Data = ReadBytes(reader);
return mipmap;
}
std::vector<uint8_t> ImageReader::ReadBytes(BinaryReader& reader)
{
int count = reader.ReadInt32();
std::vector<uint8_t> bytes;
reader.ReadData(bytes, count);
return bytes;
}
MipmapFormat ImageReader::GetFormatFromTex(FreeImageFormat imageFormat, TexFormat format)
{
if (imageFormat != FreeImageFormat::FIF_UNKNOWN)
{
return FreeImageFormatToMipmapFormat(imageFormat);
}
switch (format)
{
case TexFormat::RGBA8888: return MipmapFormat::RGBA8888;
case TexFormat::DXT5: return MipmapFormat::CompressedDXT5;
case TexFormat::DXT3: return MipmapFormat::CompressedDXT3;
case TexFormat::DXT1: return MipmapFormat::CompressedDXT1;
case TexFormat::RG88: return MipmapFormat::RG88;
case TexFormat::R8: return MipmapFormat::R8;
}
std::cerr << "unknow format" << std::endl;
return MipmapFormat::Invalid;
}
MipmapFormat ImageReader::FreeImageFormatToMipmapFormat(FreeImageFormat imageFormat)
{
switch (imageFormat)
{
case FreeImageFormat::FIF_BMP: return MipmapFormat::ImageBMP;
case FreeImageFormat::FIF_ICO: return MipmapFormat::ImageICO;
case FreeImageFormat::FIF_JPEG: return MipmapFormat::ImageJPEG;
case FreeImageFormat::FIF_JNG: return MipmapFormat::ImageJNG;
case FreeImageFormat::FIF_KOALA: return MipmapFormat::ImageKOALA;
case FreeImageFormat::FIF_LBM: return MipmapFormat::ImageLBM;
case FreeImageFormat::FIF_MNG: return MipmapFormat::ImageMNG;
case FreeImageFormat::FIF_PBM: return MipmapFormat::ImagePBM;
case FreeImageFormat::FIF_PBMRAW: return MipmapFormat::ImagePBMRAW;
case FreeImageFormat::FIF_PCD: return MipmapFormat::ImagePCD;
case FreeImageFormat::FIF_PCX: return MipmapFormat::ImagePCX;
case FreeImageFormat::FIF_PGM: return MipmapFormat::ImagePGM;
case FreeImageFormat::FIF_PGMRAW: return MipmapFormat::ImagePGMRAW;
case FreeImageFormat::FIF_PNG: return MipmapFormat::ImagePNG;
case FreeImageFormat::FIF_PPM: return MipmapFormat::ImagePPM;
case FreeImageFormat::FIF_PPMRAW: return MipmapFormat::ImagePPMRAW;
case FreeImageFormat::FIF_RAS: return MipmapFormat::ImageRAS;
case FreeImageFormat::FIF_TARGA: return MipmapFormat::ImageTARGA;
case FreeImageFormat::FIF_TIFF: return MipmapFormat::ImageTIFF;
case FreeImageFormat::FIF_WBMP: return MipmapFormat::ImageWBMP;
case FreeImageFormat::FIF_PSD: return MipmapFormat::ImagePSD;
case FreeImageFormat::FIF_CUT: return MipmapFormat::ImageCUT;
case FreeImageFormat::FIF_XBM: return MipmapFormat::ImageXBM;
case FreeImageFormat::FIF_XPM: return MipmapFormat::ImageXPM;
case FreeImageFormat::FIF_DDS: return MipmapFormat::ImageDDS;
case FreeImageFormat::FIF_GIF: return MipmapFormat::ImageGIF;
case FreeImageFormat::FIF_HDR: return MipmapFormat::ImageHDR;
case FreeImageFormat::FIF_FAXG3: return MipmapFormat::ImageFAXG3;
case FreeImageFormat::FIF_SGI: return MipmapFormat::ImageSGI;
case FreeImageFormat::FIF_EXR: return MipmapFormat::ImageEXR;
case FreeImageFormat::FIF_J2K: return MipmapFormat::ImageJ2K;
case FreeImageFormat::FIF_JP2: return MipmapFormat::ImageJP2;
case FreeImageFormat::FIF_PFM: return MipmapFormat::ImagePFM;
case FreeImageFormat::FIF_PICT: return MipmapFormat::ImagePICT;
case FreeImageFormat::FIF_RAW: return MipmapFormat::ImageRAW;
case FreeImageFormat::FIF_MP4: return MipmapFormat::VideoMp4;
}
std::cerr << "unknown format" << std::endl;
return MipmapFormat::Invalid;
}
}

View File

@ -1,32 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#ifndef IMAGEREADER_H
#define IMAGEREADER_H
#include "BinaryOPT/BinaryReader.h"
#include "Tex/TexImageContainer.h"
namespace PKG
{
class PKG_API ImageReader
{
public:
static TexImage ReadFrom(BinaryReader& reader, const TexImageContainer& container, TexFormat format);
static TexImageContainer ImageContainerReaderReadFrom(BinaryReader& reader, TexFormat texFormat);
private:
static TexMipMap ReadMipMapV1(BinaryReader& reader);
static TexMipMap ReadMipMapV2AndV3(BinaryReader& reader);
static TexMipMap ReadMipMapV4(BinaryReader& reader);
static std::vector<uint8_t> ReadBytes(BinaryReader& reader);
static MipmapFormat GetFormatFromTex(FreeImageFormat imageFormat, TexFormat format);
static MipmapFormat FreeImageFormatToMipmapFormat(FreeImageFormat imageFormat);
};
}
#endif //IMAGEREADER_H

View File

@ -1,5 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#include "Core.h"

View File

@ -1,23 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#ifndef CORE_H
#define CORE_H
#ifdef PKG_SHARED
#ifdef __WIN32__
#ifdef PKG_BUILD_DLL
#define PKG_API __declspec(dllexport)
#else
#define PKG_API __declspec(dllimport)
#endif
#else
#define PKG_API
#endif
#else
#define PKG_API
#endif
#endif //CORE_H

View File

@ -1,230 +0,0 @@
//
// Created by sfd on 25-9-21.
//
#include "DXT.h"
namespace PKG
{
void DXT::DecompressImage(int width, int height, std::vector<uint8_t>& data, const DXTFlags flags)
{
std::vector<uint8_t> rgba(width * height * 4);
// uint8_t rgba[width * height * 4];
// init the block pos
int sourceBlockPos = 0;
int bytesPerBlock = flags == DXTFlags::DXT1 ? 8 : 16;
std::vector<uint8_t> targetRGBA(4 * 16);
// loop over blocks
for (int y = 0; y < height; y += 4)
{
for (int x = 0; x < width; x += 4)
{
// decompress the block
uint8_t targetRGBA_pos = 0;
if (data.size() == sourceBlockPos)
continue;
Decompress(targetRGBA, data, sourceBlockPos, flags);
// Write the decompressed pixels to the correct image locations
for (int py = 0; py < 4; py++)
{
for (int px = 0; px < 4; px++)
{
const int sx = x + px;
const int sy = y + py;
if (sx < width && sy < height)
{
const int targetPixel = 4 * (width * sy + sx);
rgba[targetPixel + 0] = targetRGBA[targetRGBA_pos + 0];
rgba[targetPixel + 1] = targetRGBA[targetRGBA_pos + 1];
rgba[targetPixel + 2] = targetRGBA[targetRGBA_pos + 2];
rgba[targetPixel + 3] = targetRGBA[targetRGBA_pos + 3];
targetRGBA_pos += 4;
}
else
{
// Ignore that pixel
targetRGBA_pos += 4;
}
}
}
sourceBlockPos += bytesPerBlock;
}
}
data = rgba;
}
void DXT::Decompress(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, const int blockIndex, const DXTFlags flags)
{
// get block locations
int colorBlockIndex = blockIndex;
if (flags == DXTFlags::DXT3 | flags == DXTFlags::DXT5)
colorBlockIndex += 8;
DecompressColor(rgba, block, colorBlockIndex, flags == DXTFlags::DXT1);
// decompress alpha separately is necessary
if (flags == DXTFlags::DXT3)
DecompressAlphaDxt3(rgba, block, blockIndex);
else if (flags == DXTFlags::DXT5)
DecompressAlphaDxt5(rgba, block, blockIndex);
}
void DXT::DecompressColor(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, const int blockIndex, const bool isDxt1)
{
// unpack end points
std::vector<uint8_t> codes(16);
const int a = UnPack565(block, blockIndex, 0, codes, 0);
const int b = UnPack565(block, blockIndex, 2, codes, 4);
// generate Midpoints
for (int i = 0; i < 3; i++)
{
const int c = codes[i];
const int d = codes[4 + i];
if (isDxt1 && a <= b)
{
codes[8 + i] = (uint8_t)((c + d) / 2);
codes[12 + i] = 0;
}
else
{
codes[8 + i] = (uint8_t)((2 * c + d) / 3);
codes[12 + i] = (uint8_t)((c + 2 * d) / 3);
}
}
// Fill in alpha for intermediate values
codes[8 + 3] = 255;
codes[12 + 3] = (isDxt1 && a <= b) ? (uint8_t)0 : (uint8_t)255;
// unpack the indices
std::vector<uint8_t> indices(16);
for (int i = 0; i < 4; i++)
{
const int packed = block[blockIndex + 4 + i];
indices[0 + i * 4] = (uint8_t)(packed & 0x3);
indices[1 + i * 4] = (uint8_t)((packed >> 2) & 0x3);
indices[2 + i * 4] = (uint8_t)((packed >> 4) & 0x3);
indices[3 + i * 4] = (uint8_t)((packed >> 6) & 0x3);
}
// store out the colours
for (int i = 0; i < 16; i++)
{
const int offset = 4 * indices[i];
rgba[4 * i + 0] = codes[offset + 0];
rgba[4 * i + 1] = codes[offset + 1];
rgba[4 * i + 2] = codes[offset + 2];
rgba[4 * i + 3] = codes[offset + 3];
}
}
void DXT::DecompressAlphaDxt3(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, const int blockIndex)
{
// Unpack the alpha values pairwise
for (int i = 0; i < 8; i++)
{
// Quantise down to 4 bits
int quant = block[blockIndex + i];
const uint8_t lo = (uint8_t)(quant & 0x0F);
const uint8_t hi = (uint8_t)(quant & 0xF0);
// Convert back up to bytes
rgba[8 * i + 3] = (uint8_t)(lo | (lo << 4));
rgba[8 * i + 7] = (uint8_t)(hi | (hi >> 4));
}
}
void DXT::DecompressAlphaDxt5(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, const int blockIndex)
{
// Get the two alpha values
uint8_t alpha0 = block[blockIndex + 0];
uint8_t alpha1 = block[blockIndex + 1];
// compare the values to build the codebook
std::vector<uint8_t> codes(8);
codes[0] = alpha0;
codes[1] = alpha1;
if (alpha0 <= alpha1)
{
// Use 5-Alpha Codebook
for (int i = 1; i < 5; i++)
codes[1 + i] = (uint8_t)(((5 - i) * alpha0 + i * alpha1) / 5);
codes[6] = 0;
codes[7] = 255;
}
else
{
// Use 7-Alpha Codebook
for (int i = 1; i < 7; i++)
{
codes[i + 1] = (uint8_t)(((7 - i) * alpha0 + i * alpha1) / 7);
}
}
// decode indices
std::vector<uint8_t> indices(16);
uint8_t blockSrc_pos = 2;
uint8_t indices_pos = 0;
for (int i = 0; i < 2; i++)
{
// grab 3 bytes
int value = 0;
for (int j = 0; j < 3; j++)
{
int _byte = block[blockIndex + blockSrc_pos++];
value |= (_byte << 8 * j);
}
// unpack 8 3-bit values from it
for (int j = 0; j < 8; j++)
{
int index = (value >> 3 * j) & 0x07;
indices[indices_pos++] = (uint8_t)index;
}
}
// write out the indexed codebook values
for (int i = 0; i < 16; i++)
{
rgba[4 * i + 3] = codes[indices[i]];
}
}
int DXT::UnPack565(std::vector<uint8_t>& block, const int blockIndex, const int packedOffset, std::vector<uint8_t>& color, const int colorOffset)
{
// build packed value
const int value = block[blockIndex + packedOffset] | (block[blockIndex + packedOffset + 1] << 8);
// get components in the stored range
const uint16_t red = ((value >> 11) & 0x1F);
const uint16_t green = ((value >> 5) & 0x3F);
const uint16_t blue = (value & 0x1F);
// Scale up to 8 Bit
color[0 + colorOffset] = (uint8_t)((red << 3) | (red >> 2));
color[1 + colorOffset] = (uint8_t)((green << 2) | (green >> 4));
color[2 + colorOffset] = (uint8_t)((blue << 3) | (blue >> 2));
color[3 + colorOffset] = 255;
return value;
}
}

View File

@ -1,38 +0,0 @@
//
// Created by sfd on 25-9-21.
//
#ifndef DXT_H
#define DXT_H
#include <cstdint>
#include <vector>
namespace PKG
{
enum class DXTFlags
{
DXT1 = 1,
DXT3 = 1 << 1,
DXT5 = 1 << 2,
};
class DXT
{
public:
// public static byte[] DecompressImage(int width, int height, byte[] data, DXTFlags flags)
static void DecompressImage(int width, int height, std::vector<uint8_t>& data, DXTFlags flags);
private:
static void Decompress(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex, DXTFlags flags);
static int UnPack565(std::vector<uint8_t>& block, int blockIndex, int packedOffset, std::vector<uint8_t>& color, int colorOffset);
static void DecompressColor(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex, bool isDxt1);
static void DecompressAlphaDxt3(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex);
static void DecompressAlphaDxt5(std::vector<uint8_t>& rgba, std::vector<uint8_t>& block, int blockIndex);
};
}
#endif //DXT_H

View File

@ -1,544 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#include "EXPKG.h"
#include <iostream>
#include "gif.h"
#include "BinaryOPT/BinaryWriter.h"
#include "BinaryOPT/ImageReader.h"
#include "DXT/DXT.h"
#include "Tex/Tex.h"
extern "C" unsigned char* stbi_write_png_to_mem(const unsigned char* pixels, int stride_bytes, int x, int y, int n,
int* out_len);
namespace PKG
{
const char* help = R"(
usage:
expkg path/to/file.pkg [path/to/output](optional)
example:
expkg demo.pkg
expkg demo.pkg outdir
)";
enum class FILE_EXTENSION
{
TEX,
PKG,
UNKNOWN
};
EXPKG::EXPKG(const CommandArgs& commandArgs)
{
if (commandArgs.argc < 2)
{
std::cout << help << std::endl;
system("pause");
exit(0);
}
m_Reader = std::make_shared<BinaryReader>(commandArgs.argv[1]);
if (commandArgs.argc == 3)
{
m_OutDir = commandArgs.argv[2];
m_OutDir = m_OutDir.make_preferred();
}
else
{
m_OutDir = "out";
}
Run();
}
EXPKG::EXPKG(const std::string& filePath, const std::string& outDir)
{
m_Reader = std::make_shared<BinaryReader>(std::filesystem::u8path(filePath));
m_OutDir = std::filesystem::u8path(outDir);
m_OutDir = m_OutDir.make_preferred();
if (m_Reader)
Run();
}
FILE_EXTENSION EXPKG::checkExtension(const std::filesystem::path& filePath)
{
if (filePath.extension() == ".pkg")
return FILE_EXTENSION::PKG;
if (filePath.extension() == ".mpkg")
return FILE_EXTENSION::PKG;
if (filePath.extension() == ".tex")
return FILE_EXTENSION::TEX;
std::cerr << "not a pkg file or mpkg file or tex file" << std::endl;
return FILE_EXTENSION::UNKNOWN;
}
void EXPKG::Run()
{
switch (checkExtension(m_Reader->GetFilePath()))
{
case FILE_EXTENSION::TEX:
ExtractTex();
break;
case FILE_EXTENSION::PKG:
ExtractPkg();
break;
case FILE_EXTENSION::UNKNOWN:
break;
}
}
void EXPKG::ExtractPkg()
{
// Read Binary resource
const int head = m_Reader->ReadInt32();
const std::string magicHeader = m_Reader->ReadString(head);
if (magicHeader.substr(0,3) != "PKG")
{
std::cerr << "unknown header: " << m_Reader->GetFilePath() << std::endl;
std::cerr << "not a pkg file " << std::endl;
exit(0);
}
const int count = m_Reader->ReadInt32();
if (count > 0)
{
for (int i = 0; i < count; i++)
{
Entry entry;
const int size = m_Reader->ReadInt32();
entry.FullPath = m_Reader->ReadString(size);
entry.FullPath = entry.FullPath.make_preferred(); // conflict with system "\\" or "/", use it to solve
entry.Offset = m_Reader->ReadInt32();
entry.Length = m_Reader->ReadInt32();
entry.Type = entry.FullPath.extension().string();
m_Entries.push_back(entry);
}
}
else
{
std::cerr << "could not get resource: " << m_Reader->GetFilePath() << std::endl;
exit(0);
}
// try Extract
uint32_t offsetPosition = m_Reader->tellg();
for (const auto& entry : m_Entries)
{
std::cout << "convert file: " << m_OutDir / entry.FullPath << std::endl;
m_Reader->seekg(entry.Offset + offsetPosition);
if (entry.Type == ".tex")
{
std::filesystem::path texPath = m_OutDir / entry.FullPath;
{
BinaryWriter writer(texPath, std::ios::binary);
std::string texdata;
m_Reader->ReadData(texdata, entry.Length);
writer.WriteBytes(texdata.data(), texdata.size());
writer.close();
}
ExtractTex(texPath);
}
else if (entry.Type == ".gif" ||
entry.Type == ".jpg" ||
entry.Type == ".png" ||
entry.Type == ".jpeg" ||
entry.Type == ".webp")
{
BinaryWriter writer(m_OutDir / entry.FullPath, std::ios::binary);
std::string texdata;
m_Reader->ReadData(texdata, entry.Length);
writer.WriteBytes(texdata.data(), texdata.size());
writer.close();
}
else
{
BinaryWriter writer(m_OutDir / entry.FullPath);
writer.WriteString(m_Reader->ReadStringFileData(entry.Length));
}
}
}
void EXPKG::ExtractTex(const std::filesystem::path& path) const
{
std::shared_ptr<BinaryReader> reader = m_Reader;
if (path != "")
{
reader = std::make_shared<BinaryReader>(path);
}
// Tex ReadHeader
Tex tex{};
tex.Magic1 = reader->ReadNString(16);
if (tex.Magic1 != "TEXV0005")
{
std::cerr << "bad magic" << std::endl;
return;
}
tex.Magic2 = reader->ReadNString(16);
if (tex.Magic2 != "TEXI0001")
{
std::cerr << "bad magic" << std::endl;
return;
}
tex.Header.Format = (TexFormat)reader->ReadInt32();
tex.Header.Flags = (TexType)reader->ReadInt32();
tex.Header.TextureWidth = reader->ReadInt32();
tex.Header.TextureHeight = reader->ReadInt32();
tex.Header.ImageWidth = reader->ReadInt32();
tex.Header.ImageHeight = reader->ReadInt32();
tex.Header.UnkInt0 = reader->ReadInt32();
if ((int)tex.Header.Flags & (int)TexType::IsGif) tex.IsGif = true;
if ((int)tex.Header.Flags & (int)TexType::IsVideoTexture) tex.IsVideoTexture = true;
tex.ImageContainer = ImageReader::ImageContainerReaderReadFrom(*reader, tex.Header.Format);
// ReadHeader end
if (!tex.ImageContainer.Images.empty())
{
// GetConvertFormat
MipmapFormat format;
if (tex.IsVideoTexture)
format = MipmapFormat::VideoMp4;
else
format = tex.ImageContainer.Images[0].Mipmaps[0].Format;
auto tmpfotmat = format;
for(auto& Image : tex.ImageContainer.Images)
{
auto& mipmap = Image.Mipmaps[0];
switch (tmpfotmat)
{
case MipmapFormat::CompressedDXT5:
DXT::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT5);
mipmap.Format = MipmapFormat::RGBA8888; format = MipmapFormat::RGBA8888;
break;
case MipmapFormat::CompressedDXT3:
DXT::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT3);
mipmap.Format = MipmapFormat::RGBA8888; format = MipmapFormat::RGBA8888;
break;
case MipmapFormat::CompressedDXT1:
DXT::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT1);
mipmap.Format = MipmapFormat::RGBA8888; format = MipmapFormat::RGBA8888;
break;
default:
break;
}
}
if ((int)format >= 1 && (int)format <= 3)
{
format = MipmapFormat::ImagePNG;
}
// GetConvertFormat end
// Convert source
if (tex.IsGif)
{
// convert gif
// tex.GifContainer
auto& container = tex.FrameInfoContainer;
container.Magic = reader->ReadNString(16);
int frameCount = reader->ReadInt32();
/*
switch (container.Magic)
{
case "TEXS0001":
case "TEXS0002":
break;
case "TEXS0003":
container.GifWidth = reader->ReadInt32();
container.GifHeight = reader->ReadInt32();
break;
default:
std::cerr << "bad magic" << std::endl;
}
*/
{
if (container.Magic == "TEXS0001" || container.Magic == "TEXS0002")
{
}else if (container.Magic == "TEXS0003")
{
container.GifWidth = reader->ReadInt32();
container.GifHeight = reader->ReadInt32();
}else
{
std::cerr << "bad magic" << std::endl;
}
}
/*
switch (container.Magic)
{
case "TEXS0001":
for (int i = 0; i < frameCount; i++)
{
TexFrameInfo frameInfo = {};
frameInfo.ImageId = reader->ReadInt32();
frameInfo.Frametime = reader->ReadSingle();
frameInfo.X = reader->ReadInt32();
frameInfo.Y = reader->ReadInt32();
frameInfo.Width = reader->ReadInt32();
frameInfo.WidthY = reader->ReadInt32();
frameInfo.HeightX = reader->ReadInt32();
frameInfo.Height = reader->ReadInt32();
container.Frames.push_back(frameInfo);
}
case "TEXS0002":
case "TEXS0003":
for (int i = 0; i < frameCount; i++)
{
TexFrameInfo frameInfo = {};
frameInfo.ImageId = reader->ReadInt32();
frameInfo.Frametime = reader->ReadSingle();
frameInfo.X = reader->ReadSingle();
frameInfo.Y = reader->ReadSingle();
frameInfo.Width = reader->ReadSingle();
frameInfo.WidthY = reader->ReadSingle();
frameInfo.HeightX = reader->ReadSingle();
frameInfo.Height = reader->ReadSingle();
container.Frames.push_back(frameInfo);
}
default:
std::cerr << "bad magic" << std::endl;
}
*/
{
if (container.Magic == "TEXS0001")
{
for (int i = 0; i < frameCount; i++)
{
TexFrameInfo frameInfo = {};
frameInfo.ImageId = reader->ReadInt32();
frameInfo.Frametime = reader->ReadSingle();
frameInfo.PosX = reader->ReadInt32();
frameInfo.PosY = reader->ReadInt32();
frameInfo.Width = reader->ReadInt32();
frameInfo.WidthY = reader->ReadInt32();
frameInfo.HeightX = reader->ReadInt32();
frameInfo.Height = reader->ReadInt32();
container.Frames.push_back(frameInfo);
}
}else if (container.Magic == "TEXS0002" || container.Magic == "TEXS0003")
{
for (int i = 0; i < frameCount; i++)
{
TexFrameInfo frameInfo = {};
frameInfo.ImageId = reader->ReadInt32();
frameInfo.Frametime = reader->ReadSingle();
frameInfo.PosX = reader->ReadSingle();
frameInfo.PosY = reader->ReadSingle();
frameInfo.Width = reader->ReadSingle();
frameInfo.WidthY = reader->ReadSingle();
frameInfo.HeightX = reader->ReadSingle();
frameInfo.Height = reader->ReadSingle();
container.Frames.push_back(frameInfo);
}
}else
{
std::cerr << "bad magic" << std::endl;
}
}
if (container.GifWidth == 0 || container.GifHeight == 0)
{
container.GifWidth = (int) container.Frames[0].Width;
container.GifHeight = (int) container.Frames[0].Height;
}
std::filesystem::path outPath = reader->GetFilePath();
outPath.replace_extension("gif");
std::cout << "convert file: " << outPath << std::endl;
GifWriter writer;
uint32_t delay = (int)(tex.FrameInfoContainer.Frames[0].Frametime * 100);
GifBegin(&writer,
outPath.string().c_str(),
(uint32_t)tex.FrameInfoContainer.Frames[0].Width,
(uint32_t)tex.FrameInfoContainer.Frames[0].Height,
delay);
int frameIndex = 0;
int imageIndex = 1;
for (const auto& [Mipmap] : tex.ImageContainer.Images)
{
const auto& Image = Mipmap[0];
int SingleImageFrameCount = (Image.Width / container.GifWidth) * (Image.Height / container.GifHeight);
for (; frameIndex < SingleImageFrameCount * imageIndex; frameIndex++)
{
const auto& frameInfo = container.Frames[frameIndex];
std::vector<uint8_t> frameImage;
for (int heightIndex = 0; heightIndex < container.GifHeight; heightIndex++)
{
auto lineDataStart = Image.Data.begin() + Image.Width * 4 * ((int)frameInfo.PosY + heightIndex)+ (int)frameInfo.PosX * 4;
auto lineData = std::vector<uint8_t>(lineDataStart, lineDataStart + (int)frameInfo.Width * 4);
frameImage.insert(frameImage.end(), lineData.begin(), lineData.end());
}
// output by gif
{
GifWriteFrame(&writer, frameImage.data(), (uint32_t)frameInfo.Width, (uint32_t)frameInfo.Height, delay);
}
// output one by one
/*
{
int len = 0;
static int index = 0;
auto* data = stbi_write_png_to_mem(frameImage.data(),
(int)frameInfo.Width * 4,
(int)frameInfo.Width,
(int)frameInfo.Height,
4,
&len);
std::filesystem::path outputfile = outPath;
std::string name = outputfile.filename().string();
outputfile = outputfile.parent_path();
std::string filename = std::to_string(index++) + "_" + name;
outputfile /= "out";
outputfile /= filename;
std::cout << "convert file: " << outputfile << std::endl;
BinaryWriter imageWriter(outputfile, std::ios::binary);
imageWriter.WriteBytes(reinterpret_cast<const char*>(data), len);
imageWriter.close();
free(data);
data = nullptr;
}
*/
}
imageIndex ++;
}
GifEnd(&writer);
}else
{
auto& sourceMipmap = tex.ImageContainer.Images[0].Mipmaps[0];
if (tex.IsVideoTexture)
{
if (sourceMipmap.Data.size() < 12)
{
std::cerr << "expect mp4 magic header" << std::endl;
}
std::string mp4Magic = std::string(reinterpret_cast<const char*>(&sourceMipmap.Data[4]), 8);
if (mp4Magic != "ftypisom" && mp4Magic != "ftypmsnv" && mp4Magic != "ftypmp42")
{
std::cerr << "bad mp4 magic header" << std::endl;
}
}
else
{
auto imgformat = sourceMipmap.Format;
if ((int)imgformat >= 1 && (int)imgformat <= 3)
{
int len = 0;
auto& imgData = tex.ImageContainer.Images[0].Mipmaps[0].Data;
uint8_t* data = nullptr;
int channel = 4;
switch (imgformat)
{
case MipmapFormat::R8: channel = 1; break;
case MipmapFormat::RG88: channel = 2; break;
case MipmapFormat::RGBA8888: channel = 4; break;
default: break;
}
data = stbi_write_png_to_mem(sourceMipmap.Data.data(),
sourceMipmap.Width * channel,
sourceMipmap.Width,
sourceMipmap.Height,
channel,
&len);
if (data)
{
imgData.assign(data, data + len);
free(data);
}
}
}
// return ImageResult
// data format
std::filesystem::path outPath = reader->GetFilePath();
outPath.replace_extension(GetFileExtension(format));
std::cout << "convert file: " << outPath << std::endl;
BinaryWriter imageWriter(outPath, std::ios::binary);
imageWriter.WriteBytes(reinterpret_cast<const char*>(sourceMipmap.Data.data()), sourceMipmap.Data.size());
imageWriter.close();
// Convert source end
}
}
}
}

View File

@ -1,48 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#ifndef EXPKG_H
#define EXPKG_H
#include <vector>
#include "Entry.h"
typedef struct CommandArgs
{
int argc;
char** argv;
} CommandArgs;
namespace PKG
{
class BinaryReader;
enum class FILE_EXTENSION;
class PKG_API EXPKG
{
public:
EXPKG(const CommandArgs& commandArgs);
EXPKG(const std::string& filePath, const std::string& outDir = "out");
private:
static FILE_EXTENSION checkExtension(const std::filesystem::path& filePath);
void ExtractTex(const std::filesystem::path& path = "") const;
void ExtractPkg();
void Run();
private:
std::shared_ptr<BinaryReader> m_Reader;
std::filesystem::path m_OutDir;
std::vector<Entry> m_Entries;
};
}
#endif //EXPKG_H

View File

@ -1,5 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#include "Entry.h"

View File

@ -1,427 +0,0 @@
//
// Created by sfd on 25-8-4.
//
#ifndef ENTRY_H
#define ENTRY_H
#include <filesystem>
#include <string>
#include "Core.h"
namespace PKG
{
enum class TexFormat
{
RGBA8888 = 0,
DXT5 = 4,
DXT3 = 6,
DXT1 = 7,
RG88 = 8,
R8 = 9
};
enum class TexType
{
None = 0,
NoInterpolation = 1,
ClampUVs = 2,
IsGif = 4,
// Placeholders
Unk3 = 8,
Unk4 = 16,
IsVideoTexture = 32,
Unk6 = 64,
Unk7 = 128,
};
enum class MipmapFormat
{
Invalid = 0,
/// Raw pixels (4 bytes per pixel) (RGBA8888)
RGBA8888 = 1,
/// Raw pixels (1 byte per pixel) (R8)
R8 = 2,
/// Raw pixels (2 bytes per pixel) (RG88)
RG88 = 3,
/// Raw pixels compressed using DXT5
CompressedDXT5,
/// Raw pixels compressed using DXT3
CompressedDXT3,
/// Raw pixels compressed using DXT1
CompressedDXT1,
/// MP4 Video
VideoMp4,
/// Windows or OS/2 Bitmap File (*.BMP)
/// Keep '= 1000' because MipmapFormatExtensions.IsImage uses this to check if format is an image format
ImageBMP = 1000,
/// Windows Icon (*.ICO)
ImageICO,
/// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE)
ImageJPEG,
/// JPEG Network Graphics (*.JNG)
ImageJNG,
/// Commodore 64 Koala format (*.KOA)
ImageKOALA,
/// Amiga IFF (*.IFF, *.LBM)
ImageLBM,
/// Amiga IFF (*.IFF, *.LBM)
ImageIFF,
/// Multiple Network Graphics (*.MNG)
ImageMNG,
/// Portable Bitmap (ASCII) (*.PBM)
ImagePBM,
/// Portable Bitmap (BINARY) (*.PBM)
ImagePBMRAW,
/// Kodak PhotoCD (*.PCD)
ImagePCD,
/// Zsoft Paintbrush PCX bitmap format (*.PCX)
ImagePCX,
/// Portable Graymap (ASCII) (*.PGM)
ImagePGM,
/// Portable Graymap (BINARY) (*.PGM)
ImagePGMRAW,
/// Portable Network Graphics (*.PNG)
ImagePNG,
/// Portable Pixelmap (ASCII) (*.PPM)
ImagePPM,
/// Portable Pixelmap (BINARY) (*.PPM)
ImagePPMRAW,
/// Sun Rasterfile (*.RAS)
ImageRAS,
/// truevision Targa files (*.TGA, *.TARGA)
ImageTARGA,
/// Tagged Image File Format (*.TIF, *.TIFF)
ImageTIFF,
/// Wireless Bitmap (*.WBMP)
ImageWBMP,
/// Adobe Photoshop (*.PSD)
ImagePSD,
/// Dr. Halo (*.CUT)
ImageCUT,
/// X11 Bitmap Format (*.XBM)
ImageXBM,
/// X11 Pixmap Format (*.XPM)
ImageXPM,
/// DirectDraw Surface (*.DDS)
ImageDDS,
/// Graphics Interchange Format (*.GIF)
ImageGIF,
/// High Dynamic Range (*.HDR)
ImageHDR,
/// Raw Fax format CCITT G3 (*.G3)
ImageFAXG3,
/// Silicon Graphics SGI image format (*.SGI)
ImageSGI,
/// OpenEXR format (*.EXR)
ImageEXR,
/// JPEG-2000 format (*.J2K, *.J2C)
ImageJ2K,
/// JPEG-2000 format (*.JP2)
ImageJP2,
/// Portable FloatMap (*.PFM)
ImagePFM,
/// Macintosh PICT (*.PICT)
ImagePICT,
/// RAW camera image (*.*)
ImageRAW,
};
enum class FreeImageFormat {
/// <summary>
/// Unknown format (returned value only, never use it as input value)
/// </summary>
FIF_UNKNOWN = -1,
/// <summary>
/// Windows or OS/2 Bitmap File (*.BMP)
/// </summary>
FIF_BMP = 0,
/// <summary>
/// Windows Icon (*.ICO)
/// </summary>
FIF_ICO = 1,
/// <summary>
/// Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE)
/// </summary>
FIF_JPEG = 2,
/// <summary>
/// JPEG Network Graphics (*.JNG)
/// </summary>
FIF_JNG = 3,
/// <summary>
/// Commodore 64 Koala format (*.KOA)
/// </summary>
FIF_KOALA = 4,
/// <summary>
/// Amiga IFF (*.IFF, *.LBM)
/// </summary>
FIF_LBM = 5,
/// <summary>
/// Amiga IFF (*.IFF, *.LBM)
/// </summary>
FIF_IFF = 5,
/// <summary>
/// Multiple Network Graphics (*.MNG)
/// </summary>
FIF_MNG = 6,
/// <summary>
/// Portable Bitmap (ASCII) (*.PBM)
/// </summary>
FIF_PBM = 7,
/// <summary>
/// Portable Bitmap (BINARY) (*.PBM)
/// </summary>
FIF_PBMRAW = 8,
/// <summary>
/// Kodak PhotoCD (*.PCD)
/// </summary>
FIF_PCD = 9,
/// <summary>
/// Zsoft Paintbrush PCX bitmap format (*.PCX)
/// </summary>
FIF_PCX = 10,
/// <summary>
/// Portable Graymap (ASCII) (*.PGM)
/// </summary>
FIF_PGM = 11,
/// <summary>
/// Portable Graymap (BINARY) (*.PGM)
/// </summary>
FIF_PGMRAW = 12,
/// <summary>
/// Portable Network Graphics (*.PNG)
/// </summary>
FIF_PNG = 13,
/// <summary>
/// Portable Pixelmap (ASCII) (*.PPM)
/// </summary>
FIF_PPM = 14,
/// <summary>
/// Portable Pixelmap (BINARY) (*.PPM)
/// </summary>
FIF_PPMRAW = 15,
/// <summary>
/// Sun Rasterfile (*.RAS)
/// </summary>
FIF_RAS = 16,
/// <summary>
/// truevision Targa files (*.TGA, *.TARGA)
/// </summary>
FIF_TARGA = 17,
/// <summary>
/// Tagged Image File Format (*.TIF, *.TIFF)
/// </summary>
FIF_TIFF = 18,
/// <summary>
/// Wireless Bitmap (*.WBMP)
/// </summary>
FIF_WBMP = 19,
/// <summary>
/// Adobe Photoshop (*.PSD)
/// </summary>
FIF_PSD = 20,
/// <summary>
/// Dr. Halo (*.CUT)
/// </summary>
FIF_CUT = 21,
/// <summary>
/// X11 Bitmap Format (*.XBM)
/// </summary>
FIF_XBM = 22,
/// <summary>
/// X11 Pixmap Format (*.XPM)
/// </summary>
FIF_XPM = 23,
/// <summary>
/// DirectDraw Surface (*.DDS)
/// </summary>
FIF_DDS = 24,
/// <summary>
/// Graphics Interchange Format (*.GIF)
/// </summary>
FIF_GIF = 25,
/// <summary>
/// High Dynamic Range (*.HDR)
/// </summary>
FIF_HDR = 26,
/// <summary>
/// Raw Fax format CCITT G3 (*.G3)
/// </summary>
FIF_FAXG3 = 27,
/// <summary>
/// Silicon Graphics SGI image format (*.SGI)
/// </summary>
FIF_SGI = 28,
/// <summary>
/// OpenEXR format (*.EXR)
/// </summary>
FIF_EXR = 29,
/// <summary>
/// JPEG-2000 format (*.J2K, *.J2C)
/// </summary>
FIF_J2K = 30,
/// <summary>
/// JPEG-2000 format (*.JP2)
/// </summary>
FIF_JP2 = 31,
/// <summary>
/// Portable FloatMap (*.PFM)
/// </summary>
FIF_PFM = 32,
/// <summary>
/// Macintosh PICT (*.PICT)
/// </summary>
FIF_PICT = 33,
/// <summary>
/// RAW camera image (*.*)
/// </summary>
FIF_RAW = 34,
/// <summary>
/// RAW camera MP4 (*.mp4)
/// </summary>
FIF_MP4 = 35,
};
struct PKG_API Entry
{
std::filesystem::path FullPath;
int32_t Offset{};
int32_t Length{};
std::string Type;
};
struct PKG_API TexHeader
{
TexFormat Format;
TexType Flags;
int32_t TextureWidth;
int32_t TextureHeight;
int32_t ImageWidth;
int32_t ImageHeight;
uint32_t UnkInt0;
};
}
#endif //ENTRY_H

View File

@ -1,5 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#include "Tex.h"

View File

@ -1,30 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#ifndef TEX_H
#define TEX_H
#include "TexFrameInfoContainer.h"
#include "TexImageContainer.h"
namespace PKG
{
class Tex
{
public:
std::string Magic1;
std::string Magic2;
TexHeader Header = {};
TexImageContainer ImageContainer = {};
bool IsGif = false;
bool IsVideoTexture = false;
TexFrameInfoContainer FrameInfoContainer = {};
};
}
#endif //TEX_H

View File

@ -1,5 +0,0 @@
//
// Created by sfd on 25-9-21.
//
#include "TexFrameInfoContainer.h"

View File

@ -1,39 +0,0 @@
//
// Created by sfd on 25-9-21.
//
#ifndef TEXFRAMEINFOCONTAINER_H
#define TEXFRAMEINFOCONTAINER_H
#include <string>
#include <vector>
namespace PKG
{
struct TexFrameInfo
{
int ImageId;
float Frametime;
float PosX;
float PosY;
float Width;
float WidthY;
float HeightX;
float Height;
};
class TexFrameInfoContainer
{
public:
std::string Magic;
std::vector<TexFrameInfo> Frames;
int GifWidth;
int GifHeight;
};
}
#endif //TEXFRAMEINFOCONTAINER_H

View File

@ -1,88 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#include "TexImage.h"
#include <iostream>
std::string PKG::GetFileExtension(const MipmapFormat format)
{
switch (format)
{
case MipmapFormat::ImageBMP:
return "bmp";
case MipmapFormat::ImageICO:
return "ico";
case MipmapFormat::ImageJPEG:
return "jpg";
case MipmapFormat::ImageJNG:
return "jng";
case MipmapFormat::ImageKOALA:
return "koa";
case MipmapFormat::ImageLBM:
return "lbm";
case MipmapFormat::ImageIFF:
return "iff";
case MipmapFormat::ImageMNG:
return "mng";
case MipmapFormat::ImagePBM:
case MipmapFormat::ImagePBMRAW:
return "pbm";
case MipmapFormat::ImagePCD:
return "pcd";
case MipmapFormat::ImagePCX:
return "pcx";
case MipmapFormat::ImagePGM:
case MipmapFormat::ImagePGMRAW:
return "pgm";
case MipmapFormat::ImagePNG:
return "png";
case MipmapFormat::ImagePPM:
case MipmapFormat::ImagePPMRAW:
return "ppm";
case MipmapFormat::ImageRAS:
return "ras";
case MipmapFormat::ImageTARGA:
return "tga";
case MipmapFormat::ImageTIFF:
return "tif";
case MipmapFormat::ImageWBMP:
return "wbmp";
case MipmapFormat::ImagePSD:
return "psd";
case MipmapFormat::ImageCUT:
return "cut";
case MipmapFormat::ImageXBM:
return "xbm";
case MipmapFormat::ImageXPM:
return "xpm";
case MipmapFormat::ImageDDS:
return "dds";
case MipmapFormat::ImageGIF:
return "gif";
case MipmapFormat::ImageHDR:
return "hdr";
case MipmapFormat::ImageFAXG3:
return "g3";
case MipmapFormat::ImageSGI:
return "sgi";
case MipmapFormat::ImageEXR:
return "exr";
case MipmapFormat::ImageJ2K:
return "j2k";
case MipmapFormat::ImageJP2:
return "jp2";
case MipmapFormat::ImagePFM:
return "pfm";
case MipmapFormat::ImagePICT:
return "pict";
case MipmapFormat::ImageRAW:
return "raw";
case MipmapFormat::VideoMp4:
return "mp4";
}
std::cerr << "unknown file type" << std::endl;
return ".unknown";
}

View File

@ -1,37 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#ifndef TEXIMAGE_H
#define TEXIMAGE_H
#include <vector>
#include "Entry.h"
namespace PKG
{
std::string GetFileExtension(MipmapFormat format);
class TexMipMap
{
public:
int Width;
int Height;
int DecompressedDataCount;
bool IsZ4Compressed = false;
MipmapFormat Format;
std::vector<uint8_t> Data;
};
class TexImage
{
public:
std::vector<TexMipMap> Mipmaps;
};
}
#endif //TEXIMAGE_H

View File

@ -1,6 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#include "TexImageContainer.h"

View File

@ -1,32 +0,0 @@
//
// Created by sfd on 25-8-5.
//
#ifndef TEXIMAGECONTAINER_H
#define TEXIMAGECONTAINER_H
#include "TexImage.h"
namespace PKG
{
enum class ImageContainerVersion
{
VERSION1 = 1,
VERSION2 = 2,
VERSION3 = 3,
VERSION4 = 4,
};
class TexImageContainer
{
public:
std::string Magic;
FreeImageFormat ImageFormat{};
// name conflict
ImageContainerVersion imageContainerVersion;
std::vector<TexImage> Images;
};
}
#endif //TEXIMAGECONTAINER_H

View File

@ -1,14 +0,0 @@
#ifndef EXPKG_H
#define EXPKG_H
#include "Entry.h"
#include "BinaryOPT/BinaryReader.h"
#include "BinaryOPT/BinaryWriter.h"
#include "BinaryOPT/ImageReader.h"
#include "EXPKG/EXPKG.h"
#include "Tex/Tex.h"
#include "Tex/TexImage.h"
#include "Tex/TexImageContainer.h"
#endif // EXPKG_H

View File

@ -1,18 +0,0 @@
# Visual C++
.vs/
*Copy
*.db
*.opensdf
*.sdf
*.suo
*.user
ver*/
VS2010/bin/
VS2017/bin/
VS*/bin/
ipch
# Fixup for lz4 project directories
!VS2010/lz4
!VS2017/lz4
!VS*/lz4

View File

@ -1,44 +0,0 @@
Projects for various integrated development environments (IDE)
==============================================================
#### Included projects
The following projects are included with the lz4 distribution:
- `cmake` - CMake project
- `meson` - Meson project
- `visual` - scripts to generate Visual Studio solutions from `cmake` script
- `VS2022` - Visual Studio 2022 solution - will soon be deprecated, prefer `visual` generators
#### Projects available within VS2022\lz4.sln
The Visual Studio solution file `lz4.sln` contains many projects that will be compiled to the
`build\VS2010\bin\$(Platform)_$(Configuration)` directory. For example `lz4` set to `x64` and
`Release` will be compiled to `build\VS2010\bin\x64_Release\lz4.exe`. The solution file contains the
following projects:
- `lz4` : Command Line Utility, supporting gzip-like arguments
- `datagen` : Synthetic and parametrable data generator, for tests
- `frametest` : Test tool that checks lz4frame integrity on target platform
- `fullbench` : Precisely measure speed for each lz4 inner functions
- `fuzzer` : Test tool, to check lz4 integrity on target platform
- `liblz4` : A static LZ4 library compiled to `liblz4_static.lib`
- `liblz4-dll` : A dynamic LZ4 library (DLL) compiled to `liblz4.dll` with the import library `liblz4.lib`
- `fullbench-dll` : The fullbench program compiled with the import library; the executable requires LZ4 DLL
#### Using LZ4 DLL with Microsoft Visual C++ project
The header files `lib\lz4.h`, `lib\lz4hc.h`, `lib\lz4frame.h` and the import library
`build\VS2010\bin\$(Platform)_$(Configuration)\liblz4.lib` are required to
compile a project using Visual C++.
1. The path to header files should be added to `Additional Include Directories` that can
be found in Project Properties of Visual Studio IDE in the `C/C++` Property Pages on the `General` page.
2. The import library has to be added to `Additional Dependencies` that can
be found in Project Properties in the `Linker` Property Pages on the `Input` page.
If one will provide only the name `liblz4.lib` without a full path to the library
then the directory has to be added to `Linker\General\Additional Library Directories`.
The compiled executable will require LZ4 DLL which is available at
`build\VS2010\bin\$(Platform)_$(Configuration)\liblz4.dll`.

View File

@ -1,39 +0,0 @@
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
rem https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
set "sln=lz4.sln"
@rem set "Configuration=Debug"
@rem set "Platform=Win32"
set "BIN=.\bin\!Platform!_!Configuration!"
rmdir /S /Q "!BIN!" 2>nul
echo msbuild "%sln%" /p:Configuration=!Configuration! /p:Platform=!Platform!
msbuild "%sln%" ^
/nologo ^
/v:minimal ^
/m ^
/p:Configuration=!Configuration! ^
/p:Platform=!Platform! ^
/t:Clean,Build ^
|| goto :ERROR
if not exist "!BIN!\datagen.exe" ( echo FAIL: "!BIN!\datagen.exe" && goto :ERROR )
if not exist "!BIN!\frametest.exe" ( echo FAIL: "!BIN!\frametest.exe" && goto :ERROR )
if not exist "!BIN!\fullbench-dll.exe" ( echo FAIL: "!BIN!\fullbench-dll.exe" && goto :ERROR )
if not exist "!BIN!\fullbench.exe" ( echo FAIL: "!BIN!\fullbench.exe" && goto :ERROR )
if not exist "!BIN!\fuzzer.exe" ( echo FAIL: "!BIN!\fuzzer.exe" && goto :ERROR )
if not exist "!BIN!\liblz4.dll" ( echo FAIL: "!BIN!\liblz4.dll" && goto :ERROR )
if not exist "!BIN!\liblz4.lib" ( echo FAIL: "!BIN!\liblz4.lib" && goto :ERROR )
if not exist "!BIN!\liblz4_static.lib" ( echo FAIL: "!BIN!\liblz4_static.lib" && goto :ERROR )
if not exist "!BIN!\lz4.exe" ( echo FAIL: "!BIN!\lz4.exe" && goto :ERROR )
set /a errorno=0
goto :END
:ERROR
:END
exit /B %errorno%

View File

@ -1,35 +0,0 @@
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
rem https://github.com/Microsoft/vswhere
rem https://github.com/microsoft/vswhere/wiki/Find-VC#batch
set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%vswhere%" (
echo Failed to find "vswhere.exe". Please install the latest version of Visual Studio.
goto :ERROR
)
set "InstallDir="
for /f "usebackq tokens=*" %%i in (
`"%vswhere%" -latest ^
-products * ^
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^
-property installationPath`
) do (
set "InstallDir=%%i"
)
if "%InstallDir%" == "" (
echo Failed to find Visual C++. Please install the latest version of Visual C++.
goto :ERROR
)
call "%InstallDir%\VC\Auxiliary\Build\vcvars64.bat" || goto :ERROR
set /a errorno=0
goto :END
:ERROR
:END
exit /B %errorno%

View File

@ -1,38 +0,0 @@
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
@rem set "Configuration=Debug"
@rem set "Platform=Win32"
set "BIN=.\bin\!Platform!_!Configuration!"
set "TEST_FILES=..\..\tests\COPYING"
echo !BIN!\lz4 -h
!BIN!\lz4 -h || goto :ERROR
echo !BIN!\lz4 -i1b
!BIN!\lz4 -i1b || goto :ERROR
echo !BIN!\lz4 -i1b5
!BIN!\lz4 -i1b5 || goto :ERROR
echo !BIN!\lz4 -i1b10
!BIN!\lz4 -i1b10 || goto :ERROR
echo !BIN!\lz4 -i1b15
!BIN!\lz4 -i1b15 || goto :ERROR
echo fullbench
!BIN!\fullbench.exe --no-prompt -i1 %TEST_FILES% || goto :ERROR
echo fuzzer
!BIN!\fuzzer.exe -v -T30s || goto :ERROR
set /a errorno=0
goto :END
:ERROR
:END
exit /B %errorno%

View File

@ -1,26 +0,0 @@
@setlocal enabledelayedexpansion
@echo off
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
call _setup.bat || goto :ERROR
set "Configuration=Debug"
set "Platform=Win32"
call _build.bat || goto :ERROR
call _test.bat || goto :ERROR
echo Build Status -%esc%[92m SUCCEEDED %esc%[0m
set /a errorno=0
goto :END
:ERROR
echo Abort by error.
echo Build Status -%esc%[91m ERROR %esc%[0m
:END
exit /B %errorno%

View File

@ -1,26 +0,0 @@
@setlocal enabledelayedexpansion
@echo off
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
call _setup.bat || goto :ERROR
set "Configuration=Release"
set "Platform=Win32"
call _build.bat || goto :ERROR
call _test.bat || goto :ERROR
echo Build Status -%esc%[92m SUCCEEDED %esc%[0m
set /a errorno=0
goto :END
:ERROR
echo Abort by error.
echo Build Status -%esc%[91m ERROR %esc%[0m
:END
exit /B %errorno%

View File

@ -1,26 +0,0 @@
@setlocal enabledelayedexpansion
@echo off
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
call _setup.bat || goto :ERROR
set "Configuration=Debug"
set "Platform=x64"
call _build.bat || goto :ERROR
call _test.bat || goto :ERROR
echo Build Status -%esc%[92m SUCCEEDED %esc%[0m
set /a errorno=0
goto :END
:ERROR
echo Abort by error.
echo Build Status -%esc%[91m ERROR %esc%[0m
:END
exit /B %errorno%

View File

@ -1,26 +0,0 @@
@setlocal enabledelayedexpansion
@echo off
set /a errorno=1
for /F "delims=#" %%E in ('"prompt #$E# & for %%E in (1) do rem"') do set "esc=%%E"
call _setup.bat || goto :ERROR
set "Configuration=Release"
set "Platform=x64"
call _build.bat || goto :ERROR
call _test.bat || goto :ERROR
echo Build Status -%esc%[92m SUCCEEDED %esc%[0m
set /a errorno=0
goto :END
:ERROR
echo Abort by error.
echo Build Status -%esc%[91m ERROR %esc%[0m
:END
exit /B %errorno%

View File

@ -1,177 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D745AE2F-596A-403A-9B91-81A8C6779243}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>datagen</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\programs;$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\programs\lorem.c" />
<ClCompile Include="..\..\..\tests\datagen.c" />
<ClCompile Include="..\..\..\tests\datagencli.c" />
<ClCompile Include="..\..\..\tests\loremOut.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\programs\lorem.h" />
<ClInclude Include="..\..\..\tests\datagen.h" />
<ClInclude Include="..\..\..\tests\loremOut.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,180 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>frametest</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\lz4.c" />
<ClCompile Include="..\..\..\lib\lz4frame.c" />
<ClCompile Include="..\..\..\lib\lz4hc.c" />
<ClCompile Include="..\..\..\lib\xxhash.c" />
<ClCompile Include="..\..\..\tests\frametest.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4frame.h" />
<ClInclude Include="..\..\..\lib\lz4frame_static.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,184 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{13992FD2-077E-4954-B065-A428198201A9}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>fullbench-dll</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;LZ4_DLL_IMPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\xxhash.c" />
<ClCompile Include="..\..\..\tests\fullbench.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4frame.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,180 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>fullbench</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\lz4.c" />
<ClCompile Include="..\..\..\lib\lz4frame.c" />
<ClCompile Include="..\..\..\lib\lz4hc.c" />
<ClCompile Include="..\..\..\lib\xxhash.c" />
<ClCompile Include="..\..\..\tests\fullbench.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4frame.h" />
<ClInclude Include="..\..\..\lib\lz4frame_static.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,177 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{18B9F1A7-9C66-4352-898B-30804DADE0FD}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>fuzzer</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\lz4.c" />
<ClCompile Include="..\..\..\lib\lz4hc.c" />
<ClCompile Include="..\..\..\lib\xxhash.c" />
<ClCompile Include="..\..\..\tests\fuzzer.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,51 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "lz4.h" /* LZ4_VERSION_STRING */
#define APSTUDIO_READONLY_SYMBOLS
#include "verrsrc.h"
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION LZ4_VERSION_MAJOR,LZ4_VERSION_MINOR,LZ4_VERSION_RELEASE,0
PRODUCTVERSION LZ4_VERSION_MAJOR,LZ4_VERSION_MINOR,LZ4_VERSION_RELEASE,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "Yann Collet"
VALUE "FileDescription", "Extremely fast compression"
VALUE "FileVersion", LZ4_VERSION_STRING
VALUE "InternalName", "lz4.dll"
VALUE "LegalCopyright", "Copyright (C) 2013-2020, Yann Collet"
VALUE "OriginalFilename", "lz4.dll"
VALUE "ProductName", "LZ4"
VALUE "ProductVersion", LZ4_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END
#endif

View File

@ -1,183 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9800039D-4AAA-43A4-BB78-FEF6F4836927}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>liblz4-dll</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
<ProjectName>liblz4-dll</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>liblz4</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>liblz4</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>liblz4</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>liblz4</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4frame.h" />
<ClInclude Include="..\..\..\lib\lz4frame_static.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\lz4.c" />
<ClCompile Include="..\..\..\lib\lz4frame.c" />
<ClCompile Include="..\..\..\lib\lz4hc.c" />
<ClCompile Include="..\..\..\lib\xxhash.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="liblz4-dll.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,179 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>liblz4</RootNamespace>
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization Condition="'$(EnableWholeProgramOptimization)'=='true'">true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>liblz4_static</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetName>liblz4_static</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>liblz4_static</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetName>liblz4_static</TargetName>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>false</EnablePREfast>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;LZ4_DLL_EXPORT=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>false</TreatWarningAsError>
<EnablePREfast>true</EnablePREfast>
<AdditionalOptions>/analyze:stacksize295252 %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(UseStaticCRT)'=='true'">MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4frame.h" />
<ClInclude Include="..\..\..\lib\lz4frame_static.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\lz4.c" />
<ClCompile Include="..\..\..\lib\lz4frame.c" />
<ClCompile Include="..\..\..\lib\lz4hc.c" />
<ClCompile Include="..\..\..\lib\xxhash.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,106 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33712.159
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4-dll", "liblz4-dll\liblz4-dll.vcxproj", "{9800039D-4AAA-43A4-BB78-FEF6F4836927}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4", "liblz4\liblz4.vcxproj", "{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fuzzer", "fuzzer\fuzzer.vcxproj", "{18B9F1A7-9C66-4352-898B-30804DADE0FD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench", "fullbench\fullbench.vcxproj", "{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "frametest", "frametest\frametest.vcxproj", "{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datagen", "datagen\datagen.vcxproj", "{D745AE2F-596A-403A-9B91-81A8C6779243}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fullbench-dll", "fullbench-dll\fullbench-dll.vcxproj", "{13992FD2-077E-4954-B065-A428198201A9}"
ProjectSection(ProjectDependencies) = postProject
{9800039D-4AAA-43A4-BB78-FEF6F4836927} = {9800039D-4AAA-43A4-BB78-FEF6F4836927}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lz4", "lz4\lz4.vcxproj", "{60A3115E-B988-41EE-8815-F4D4F253D866}"
ProjectSection(ProjectDependencies) = postProject
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476} = {9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Debug|Win32.ActiveCfg = Debug|Win32
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Debug|Win32.Build.0 = Debug|Win32
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Debug|x64.ActiveCfg = Debug|x64
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Debug|x64.Build.0 = Debug|x64
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Release|Win32.ActiveCfg = Release|Win32
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Release|Win32.Build.0 = Release|Win32
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Release|x64.ActiveCfg = Release|x64
{9800039D-4AAA-43A4-BB78-FEF6F4836927}.Release|x64.Build.0 = Release|x64
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Debug|Win32.ActiveCfg = Debug|Win32
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Debug|Win32.Build.0 = Debug|Win32
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Debug|x64.ActiveCfg = Debug|x64
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Debug|x64.Build.0 = Debug|x64
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Release|Win32.ActiveCfg = Release|Win32
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Release|Win32.Build.0 = Release|Win32
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Release|x64.ActiveCfg = Release|x64
{9092C5CC-3E71-41B3-BF68-4A7BDD8A5476}.Release|x64.Build.0 = Release|x64
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Debug|Win32.ActiveCfg = Debug|Win32
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Debug|Win32.Build.0 = Debug|Win32
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Debug|x64.ActiveCfg = Debug|x64
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Debug|x64.Build.0 = Debug|x64
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Release|Win32.ActiveCfg = Release|Win32
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Release|Win32.Build.0 = Release|Win32
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Release|x64.ActiveCfg = Release|x64
{18B9F1A7-9C66-4352-898B-30804DADE0FD}.Release|x64.Build.0 = Release|x64
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Debug|Win32.ActiveCfg = Debug|Win32
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Debug|Win32.Build.0 = Debug|Win32
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Debug|x64.ActiveCfg = Debug|x64
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Debug|x64.Build.0 = Debug|x64
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Release|Win32.ActiveCfg = Release|Win32
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Release|Win32.Build.0 = Release|Win32
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Release|x64.ActiveCfg = Release|x64
{6A4DF4EF-C77F-43C6-8901-DDCD20879E4E}.Release|x64.Build.0 = Release|x64
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Debug|Win32.ActiveCfg = Debug|Win32
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Debug|Win32.Build.0 = Debug|Win32
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Debug|x64.ActiveCfg = Debug|x64
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Debug|x64.Build.0 = Debug|x64
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Release|Win32.ActiveCfg = Release|Win32
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Release|Win32.Build.0 = Release|Win32
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Release|x64.ActiveCfg = Release|x64
{39AD6ECC-8BAD-4368-95E4-A1AA2F077BB7}.Release|x64.Build.0 = Release|x64
{D745AE2F-596A-403A-9B91-81A8C6779243}.Debug|Win32.ActiveCfg = Debug|Win32
{D745AE2F-596A-403A-9B91-81A8C6779243}.Debug|Win32.Build.0 = Debug|Win32
{D745AE2F-596A-403A-9B91-81A8C6779243}.Debug|x64.ActiveCfg = Debug|x64
{D745AE2F-596A-403A-9B91-81A8C6779243}.Debug|x64.Build.0 = Debug|x64
{D745AE2F-596A-403A-9B91-81A8C6779243}.Release|Win32.ActiveCfg = Release|Win32
{D745AE2F-596A-403A-9B91-81A8C6779243}.Release|Win32.Build.0 = Release|Win32
{D745AE2F-596A-403A-9B91-81A8C6779243}.Release|x64.ActiveCfg = Release|x64
{D745AE2F-596A-403A-9B91-81A8C6779243}.Release|x64.Build.0 = Release|x64
{13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.ActiveCfg = Debug|Win32
{13992FD2-077E-4954-B065-A428198201A9}.Debug|Win32.Build.0 = Debug|Win32
{13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.ActiveCfg = Debug|x64
{13992FD2-077E-4954-B065-A428198201A9}.Debug|x64.Build.0 = Debug|x64
{13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.ActiveCfg = Release|Win32
{13992FD2-077E-4954-B065-A428198201A9}.Release|Win32.Build.0 = Release|Win32
{13992FD2-077E-4954-B065-A428198201A9}.Release|x64.ActiveCfg = Release|x64
{13992FD2-077E-4954-B065-A428198201A9}.Release|x64.Build.0 = Release|x64
{60A3115E-B988-41EE-8815-F4D4F253D866}.Debug|Win32.ActiveCfg = Debug|Win32
{60A3115E-B988-41EE-8815-F4D4F253D866}.Debug|Win32.Build.0 = Debug|Win32
{60A3115E-B988-41EE-8815-F4D4F253D866}.Debug|x64.ActiveCfg = Debug|x64
{60A3115E-B988-41EE-8815-F4D4F253D866}.Debug|x64.Build.0 = Debug|x64
{60A3115E-B988-41EE-8815-F4D4F253D866}.Release|Win32.ActiveCfg = Release|Win32
{60A3115E-B988-41EE-8815-F4D4F253D866}.Release|Win32.Build.0 = Release|Win32
{60A3115E-B988-41EE-8815-F4D4F253D866}.Release|x64.ActiveCfg = Release|x64
{60A3115E-B988-41EE-8815-F4D4F253D866}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BBC259B2-BABF-47CD-8A6A-7B8318A803AC}
EndGlobalSection
EndGlobal

View File

@ -1,51 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "lz4.h" /* LZ4_VERSION_STRING */
#define APSTUDIO_READONLY_SYMBOLS
#include "verrsrc.h"
#undef APSTUDIO_READONLY_SYMBOLS
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION LZ4_VERSION_MAJOR,LZ4_VERSION_MINOR,LZ4_VERSION_RELEASE,0
PRODUCTVERSION LZ4_VERSION_MAJOR,LZ4_VERSION_MINOR,LZ4_VERSION_RELEASE,0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "Yann Collet"
VALUE "FileDescription", "Extremely fast compression"
VALUE "FileVersion", LZ4_VERSION_STRING
VALUE "InternalName", "lz4.exe"
VALUE "LegalCopyright", "Copyright (C) 2013-2020, Yann Collet"
VALUE "OriginalFilename", "lz4.exe"
VALUE "ProductName", "LZ4"
VALUE "ProductVersion", LZ4_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END
#endif

View File

@ -1,189 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{60A3115E-B988-41EE-8815-F4D4F253D866}</ProjectGuid>
<RootNamespace>lz4</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)_$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)bin\obj\$(RootNamespace)_$(Platform)_$(Configuration)\</IntDir>
<IncludePath>$(IncludePath);$(UniversalCRT_IncludePath);$(SolutionDir)..\..\lib;$(SolutionDir)..\..\programs;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);</IncludePath>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<TreatWarningAsError>true</TreatWarningAsError>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>false</OptimizeReferences>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
<AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)..\bin\$(Platform)_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>liblz4_static.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\lib\lz4.c" />
<ClCompile Include="..\..\..\lib\lz4frame.c" />
<ClCompile Include="..\..\..\lib\lz4hc.c" />
<ClCompile Include="..\..\..\lib\xxhash.c" />
<ClCompile Include="..\..\..\programs\bench.c" />
<ClCompile Include="..\..\..\programs\lorem.c" />
<ClCompile Include="..\..\..\programs\lz4cli.c" />
<ClCompile Include="..\..\..\programs\lz4io.c" />
<ClCompile Include="..\..\..\programs\threadpool.c" />
<ClCompile Include="..\..\..\programs\timefn.c" />
<ClCompile Include="..\..\..\programs\util.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\lib\lz4.h" />
<ClInclude Include="..\..\..\lib\lz4frame.h" />
<ClInclude Include="..\..\..\lib\lz4frame_static.h" />
<ClInclude Include="..\..\..\lib\lz4hc.h" />
<ClInclude Include="..\..\..\lib\xxhash.h" />
<ClInclude Include="..\..\..\programs\bench.h" />
<ClInclude Include="..\..\..\programs\lorem.h" />
<ClInclude Include="..\..\..\programs\lz4io.h" />
<ClInclude Include="..\..\..\programs\util.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="lz4.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,10 +0,0 @@
# cmake build artefact
CMakeCache.txt
CMakeFiles
*.cmake
Makefile
liblz4.pc
lz4c
install_manifest.txt
build

View File

@ -1,362 +0,0 @@
# CMake support for LZ4
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to
# the public domain worldwide. This software is distributed without
# any warranty.
#
# For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# Use range version specification for policy control while maintaining
# compatibility with older CMake versions
cmake_minimum_required(VERSION 3.5...4.0.2)
set(LZ4_TOP_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
#-----------------------------------------------------------------------------
# VERSION EXTRACTION - Parse version information from header file
#-----------------------------------------------------------------------------
function(parse_lz4_version VERSION_TYPE)
file(STRINGS "${LZ4_TOP_SOURCE_DIR}/lib/lz4.h" version_line REGEX "^#define LZ4_VERSION_${VERSION_TYPE} +([0-9]+).*$")
string(REGEX REPLACE "^#define LZ4_VERSION_${VERSION_TYPE} +([0-9]+).*$" "\\1" version_number "${version_line}")
set(LZ4_VERSION_${VERSION_TYPE} ${version_number} PARENT_SCOPE)
endfunction()
foreach(version_type IN ITEMS MAJOR MINOR RELEASE)
parse_lz4_version(${version_type})
endforeach()
set(LZ4_VERSION_STRING "${LZ4_VERSION_MAJOR}.${LZ4_VERSION_MINOR}.${LZ4_VERSION_RELEASE}")
mark_as_advanced(LZ4_VERSION_STRING LZ4_VERSION_MAJOR LZ4_VERSION_MINOR LZ4_VERSION_RELEASE)
message(STATUS "Creating build script for LZ4 version: ${LZ4_VERSION_STRING}")
project(LZ4 VERSION ${LZ4_VERSION_STRING} LANGUAGES C)
#-----------------------------------------------------------------------------
# DEFAULT BUILD TYPE - Set Release as default when no build type is specified
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#-----------------------------------------------------------------------------
# BUILD OPTIONS - Configure build targets and features
#-----------------------------------------------------------------------------
option(LZ4_BUILD_CLI "Build lz4 program" ON)
option(LZ4_BUILD_LEGACY_LZ4C "Build lz4c program with legacy argument support" OFF)
# Determine if LZ4 is being built as part of another project.
# If LZ4 is bundled in another project, we don't want to install anything.
# Default behavior can be overridden by setting the LZ4_BUNDLED_MODE variable.
if(NOT DEFINED LZ4_BUNDLED_MODE)
get_directory_property(LZ4_IS_SUBPROJECT PARENT_DIRECTORY)
if(LZ4_IS_SUBPROJECT)
set(LZ4_BUNDLED_MODE ON)
else()
set(LZ4_BUNDLED_MODE OFF)
endif()
endif()
mark_as_advanced(LZ4_BUNDLED_MODE)
#-----------------------------------------------------------------------------
# PACKAGING - CPack configuration
#-----------------------------------------------------------------------------
if(NOT LZ4_BUNDLED_MODE AND NOT CPack_CMake_INCLUDED)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${LZ4_TOP_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${LZ4_TOP_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR ${LZ4_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${LZ4_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${LZ4_VERSION_RELEASE})
include(CPack)
endif(NOT LZ4_BUNDLED_MODE AND NOT CPack_CMake_INCLUDED)
#-----------------------------------------------------------------------------
# LIBRARY TYPE CONFIGURATION - Static vs Shared libraries
#-----------------------------------------------------------------------------
# Allow people to choose whether to build shared or static libraries
# via the BUILD_SHARED_LIBS option unless we are in bundled mode, in
# which case we always use static libraries.
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON "NOT LZ4_BUNDLED_MODE" OFF)
CMAKE_DEPENDENT_OPTION(BUILD_STATIC_LIBS "Build static libraries" OFF "BUILD_SHARED_LIBS" ON)
if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
message(FATAL_ERROR "Both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS have been disabled")
endif(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
#-----------------------------------------------------------------------------
# SOURCE FILES & DIRECTORIES - Path setup and source file collection
#-----------------------------------------------------------------------------
set(LZ4_LIB_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/lib")
set(LZ4_PROG_SOURCE_DIR "${LZ4_TOP_SOURCE_DIR}/programs")
include_directories("${LZ4_LIB_SOURCE_DIR}")
# CLI sources
file(GLOB LZ4_SOURCES
"${LZ4_LIB_SOURCE_DIR}/*.c")
file(GLOB LZ4_CLI_SOURCES
"${LZ4_PROG_SOURCE_DIR}/*.c")
list(APPEND LZ4_CLI_SOURCES ${LZ4_SOURCES}) # LZ4_CLI always use liblz4 sources directly.
#-----------------------------------------------------------------------------
# POSITION INDEPENDENT CODE - PIC settings for static libraries
#-----------------------------------------------------------------------------
# Whether to use position independent code for the static library. If
# we're building a shared library this is ignored and PIC is always
# used.
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE OR CMAKE_POSITION_INDEPENDENT_CODE)
set(LZ4_POSITION_INDEPENDENT_LIB_DEFAULT ON)
else()
set(LZ4_POSITION_INDEPENDENT_LIB_DEFAULT OFF)
endif(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE OR CMAKE_POSITION_INDEPENDENT_CODE)
option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ${LZ4_POSITION_INDEPENDENT_LIB_DEFAULT})
#-----------------------------------------------------------------------------
# TARGETS - Library and executable targets
#-----------------------------------------------------------------------------
# liblz4
include(GNUInstallDirs)
set(LZ4_LIBRARIES_BUILT)
if(BUILD_SHARED_LIBS)
add_library(lz4_shared SHARED ${LZ4_SOURCES})
target_include_directories(lz4_shared
PUBLIC $<BUILD_INTERFACE:${LZ4_LIB_SOURCE_DIR}>
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(lz4_shared PROPERTIES
OUTPUT_NAME lz4
SOVERSION "${LZ4_VERSION_MAJOR}"
VERSION "${LZ4_VERSION_STRING}")
if(MSVC)
target_compile_definitions(lz4_shared PRIVATE
LZ4_DLL_EXPORT=1)
endif(MSVC)
list(APPEND LZ4_LIBRARIES_BUILT lz4_shared)
endif()
if(BUILD_STATIC_LIBS)
set(STATIC_LIB_NAME lz4)
if(MSVC AND BUILD_SHARED_LIBS)
set(STATIC_LIB_NAME lz4_static)
endif(MSVC AND BUILD_SHARED_LIBS)
add_library(lz4_static STATIC ${LZ4_SOURCES})
target_include_directories(lz4_static
PUBLIC $<BUILD_INTERFACE:${LZ4_LIB_SOURCE_DIR}>
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
set_target_properties(lz4_static PROPERTIES
OUTPUT_NAME ${STATIC_LIB_NAME}
POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB})
list(APPEND LZ4_LIBRARIES_BUILT lz4_static)
endif()
# Add unified target.
add_library(lz4 INTERFACE)
list(APPEND LZ4_LIBRARIES_BUILT lz4)
if(BUILD_SHARED_LIBS)
target_link_libraries(lz4 INTERFACE lz4_shared)
else()
target_link_libraries(lz4 INTERFACE lz4_static)
endif(BUILD_SHARED_LIBS)
#-----------------------------------------------------------------------------
# DEBUG CONFIGURATION - Configurable LZ4_DEBUG level
#-----------------------------------------------------------------------------
# LZ4_DEBUG levels:
# 0 - Disable everything (default for Release)
# 1 - Enable assert() statements
# 2-8 - Enable debug traces with increasing verbosity
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LZ4_DEBUG_LEVEL_DEFAULT 1)
else()
set(LZ4_DEBUG_LEVEL_DEFAULT 0)
endif()
set(LZ4_DEBUG_LEVEL ${LZ4_DEBUG_LEVEL_DEFAULT} CACHE STRING
"LZ4 debug level: 0=disabled, 1=assert(), 2-8=debug traces with increasing verbosity")
set_property(CACHE LZ4_DEBUG_LEVEL PROPERTY STRINGS "0" "1" "2" "3" "4" "5" "6" "7" "8")
# Apply LZ4_DEBUG configuration if level > 0
if(LZ4_DEBUG_LEVEL GREATER 0)
if(MSVC)
add_definitions(/DLZ4_DEBUG=${LZ4_DEBUG_LEVEL})
else()
add_definitions(-DLZ4_DEBUG=${LZ4_DEBUG_LEVEL})
endif()
endif()
#-----------------------------------------------------------------------------
# NAMESPACE CONFIGURATION - xxHash namespace settings
#-----------------------------------------------------------------------------
# xxhash namespace
if(BUILD_SHARED_LIBS)
target_compile_definitions(lz4_shared PRIVATE
XXH_NAMESPACE=LZ4_)
endif(BUILD_SHARED_LIBS)
if(BUILD_STATIC_LIBS)
target_compile_definitions(lz4_static PRIVATE
XXH_NAMESPACE=LZ4_)
endif(BUILD_STATIC_LIBS)
#-----------------------------------------------------------------------------
# CLI EXECUTABLES - Configuring command-line programs
#-----------------------------------------------------------------------------
# lz4
if(LZ4_BUILD_CLI)
set(LZ4_PROGRAMS_BUILT lz4cli)
add_executable(lz4cli ${LZ4_CLI_SOURCES})
set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4)
endif(LZ4_BUILD_CLI)
# lz4c
if(LZ4_BUILD_LEGACY_LZ4C)
list(APPEND LZ4_PROGRAMS_BUILT lz4c)
add_executable(lz4c ${LZ4_CLI_SOURCES})
set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS")
endif(LZ4_BUILD_LEGACY_LZ4C)
#-----------------------------------------------------------------------------
# COMPILER FLAGS - Configure warning flags and compiler-specific options
#-----------------------------------------------------------------------------
# Extra warning flags
if(MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /W4")
else()
include(CheckCCompilerFlag)
foreach(flag
# GCC-style
-pedantic-errors
-Wall
-Wextra
-Wundef
-Wcast-qual
-Wcast-align
-Wshadow
-Wswitch-enum
-Wdeclaration-after-statement
-Wstrict-prototypes
-Wpointer-arith)
# Because https://gcc.gnu.org/wiki/FAQ#wnowarning
string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" test_name "CFLAG_${flag_to_test}")
check_c_compiler_flag("${ADD_COMPILER_FLAGS_PREPEND} ${flag_to_test}" ${test_name})
if(${test_name})
set(CMAKE_C_FLAGS_DEBUG "${flag} ${CMAKE_C_FLAGS_DEBUG}")
endif()
unset(test_name)
unset(flag_to_test)
endforeach(flag)
endif(MSVC)
#-----------------------------------------------------------------------------
# INSTALLATION - Install targets, headers, and documentation
#-----------------------------------------------------------------------------
if(NOT LZ4_BUNDLED_MODE)
install(TARGETS ${LZ4_PROGRAMS_BUILT}
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS ${LZ4_LIBRARIES_BUILT}
EXPORT lz4Targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES
"${LZ4_LIB_SOURCE_DIR}/lz4.h"
"${LZ4_LIB_SOURCE_DIR}/lz4hc.h"
"${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
"${LZ4_LIB_SOURCE_DIR}/lz4file.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES "${LZ4_PROG_SOURCE_DIR}/lz4.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblz4.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
#-----------------------------------------------------------------------------
# CMAKE PACKAGE CONFIG - Configure CMake package for find_package support
#-----------------------------------------------------------------------------
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake"
VERSION ${LZ4_VERSION_STRING}
COMPATIBILITY SameMajorVersion)
set(LZ4_PKG_INSTALLDIR "${CMAKE_INSTALL_LIBDIR}/cmake/lz4")
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/lz4Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/lz4Config.cmake"
INSTALL_DESTINATION ${LZ4_PKG_INSTALLDIR})
export(EXPORT lz4Targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/lz4Targets.cmake
NAMESPACE LZ4::)
install(EXPORT lz4Targets
FILE lz4Targets.cmake
NAMESPACE LZ4::
DESTINATION ${LZ4_PKG_INSTALLDIR})
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/lz4Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/lz4ConfigVersion.cmake
DESTINATION ${LZ4_PKG_INSTALLDIR})
#-----------------------------------------------------------------------------
# SYMLINKS - Create and install Unix symlinks and manpage aliases
#-----------------------------------------------------------------------------
# Install lz4cat and unlz4 symlinks on Unix systems
if(UNIX AND LZ4_BUILD_CLI)
foreach(cli_tool IN ITEMS lz4cat unlz4)
# Create a custom target for the symlink creation
add_custom_target("create_${cli_tool}_symlink" ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink
$<TARGET_FILE_NAME:lz4cli> ${cli_tool}
DEPENDS lz4cli
COMMENT "Creating symlink for ${cli_tool}"
VERBATIM)
# Install the symlink into the binary installation directory
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${cli_tool}"
DESTINATION ${CMAKE_INSTALL_BINDIR}
RENAME ${cli_tool})
endforeach()
# create manpage aliases
foreach(f lz4cat unlz4)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${f}.1" ".so man1/lz4.1\n")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${f}.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
endforeach()
endif(UNIX AND LZ4_BUILD_CLI)
endif(NOT LZ4_BUNDLED_MODE)
#-----------------------------------------------------------------------------
# PKG-CONFIG - Generate and install pkg-config file
#-----------------------------------------------------------------------------
# pkg-config
set(PREFIX "${CMAKE_INSTALL_PREFIX}")
if("${CMAKE_INSTALL_FULL_LIBDIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
else()
set(LIBDIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif("${CMAKE_INSTALL_FULL_LIBDIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
if("${CMAKE_INSTALL_FULL_INCLUDEDIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
endif("${CMAKE_INSTALL_FULL_INCLUDEDIR}" STREQUAL "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
# for liblz4.pc substitution
set(VERSION ${LZ4_VERSION_STRING})
configure_file(${LZ4_LIB_SOURCE_DIR}/liblz4.pc.in liblz4.pc @ONLY)

View File

@ -1,10 +0,0 @@
@PACKAGE_INIT@
include( "${CMAKE_CURRENT_LIST_DIR}/lz4Targets.cmake" )
if(NOT TARGET lz4::lz4)
add_library(lz4::lz4 INTERFACE IMPORTED)
if("@BUILD_SHARED_LIBS@")
set_target_properties(lz4::lz4 PROPERTIES INTERFACE_LINK_LIBRARIES LZ4::lz4_shared)
else()
set_target_properties(lz4::lz4 PROPERTIES INTERFACE_LINK_LIBRARIES LZ4::lz4_static)
endif()
endif()

View File

@ -1,69 +0,0 @@
# multiconf.make
**multiconf.make** is a self-contained Makefile include that lets you build the **same targets under many different flag sets**—debug vs release, ASan vs UBSan, GCC vs Clang, etc.—without the usual “object-file soup.”
It hashes every combination of `CC/CXX`, `CFLAGS/CXXFLAGS`, `CPPFLAGS`, `LDFLAGS` and `LDLIBS` into a **dedicated cache directory**, so objects compiled with one configuration are never reused by another. Swap flags, rebuild, swap back—previous objects are still there and never collide.
---
## Key Benefits
| Why it matters | What multiconf.make does |
| --- | --- |
| **Isolated configs** | Stores objects into `cachedObjs/<hash>/`, one directory per unique flag set. |
| **Fast switching** | Reusing an old config is instant—link only, no recompilation. |
| **Header deps** | Edits to headers trigger only needed rebuilds. |
| **One-liner targets** | Macros (`c_program`, `cxx_program`, …) hide all rule boilerplate. |
| **Parallel-ready** | Safe with `make -j`, no duplicate compiles of shared sources. |
---
## Quick Start
### 1 · List your sources
```make
C_SRCDIRS := src src/cdeps # all .c are in these directories
CXX_SRCDIRS := src src/cxxdeps # all .cpp are in these directories
```
### 2 · Add and include
```make
# root/Makefile
include multiconf.make
```
### 3 · Declare targets
```make
app:
$(eval $(call c_program,app,app.o obj1.o obj2.o))
test:
$(eval $(call cxx_program,test, test.o objcxx1.o objcxx2.o))
```
### 4 · Build any config you like
```sh
# Release with GCC
make CFLAGS="-O3"
# Debug with Clang + AddressSanitizer (new cache dir)
make CC=clang CFLAGS="-g -O0 -fsanitize=address"
# Switch back to GCC release (objects still valid, relink only)
make CFLAGS="-O3"
```
Objects for each command live in different sub-folders; nothing overlaps.
---
## Additional capabilities
| Command | Description |
| --- | --- |
| `make clean_cache` | Wipe **all** cached objects & deps (full rebuild next time) |
| `V=1` | Show full compile/link commands |
---

View File

@ -1,115 +0,0 @@
# ################################################################
# LZ4 - Makefile common definitions
# Copyright (C) Yann Collet 2020
# All rights reserved.
#
# BSD license
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# You can contact the author at :
# - LZ4 source repository : https://github.com/lz4/lz4
# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
# ################################################################
UNAME ?= uname
TARGET_OS ?= $(shell $(UNAME))
ifeq ($(TARGET_OS),)
TARGET_OS ?= $(OS)
endif
ifneq (,$(filter Windows%,$(TARGET_OS)))
LIBLZ4_NAME = liblz4-$(LIBVER_MAJOR)
LIBLZ4_EXP = liblz4.lib
WINBASED = yes
else
LIBLZ4_EXP = liblz4.dll.a
ifneq (,$(filter MINGW%,$(TARGET_OS)))
LIBLZ4_NAME = liblz4
WINBASED = yes
else
ifneq (,$(filter MSYS%,$(TARGET_OS)))
LIBLZ4_NAME = msys-lz4-$(LIBVER_MAJOR)
WINBASED = yes
else
ifneq (,$(filter CYGWIN%,$(TARGET_OS)))
LIBLZ4_NAME = cyglz4-$(LIBVER_MAJOR)
WINBASED = yes
else
LIBLZ4_NAME = liblz4
WINBASED = no
EXT =
endif
endif
endif
endif
ifeq ($(WINBASED),yes)
EXT = .exe
WINDRES ?= windres
LDFLAGS += -Wl,--force-exe-suffix
endif
LIBLZ4 = $(LIBLZ4_NAME).$(SHARED_EXT_VER)
#determine if dev/nul based on host environment
ifneq (,$(filter MINGW% MSYS% CYGWIN%,$(shell $(UNAME))))
VOID := /dev/null
else
ifneq (,$(filter Windows%,$(OS)))
VOID := nul
else
VOID := /dev/null
endif
endif
ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW% CYGWIN% MSYS% AIX,$(shell $(UNAME))))
POSIX_ENV = Yes
else
POSIX_ENV = No
endif
# Avoid symlinks when targeting Windows or building on a Windows host
ifeq ($(WINBASED),yes)
LN_SF = cp -p
else
ifneq (,$(filter MINGW% MSYS% CYGWIN%,$(shell $(UNAME))))
LN_SF = cp -p
else
ifneq (,$(filter Windows%,$(OS)))
LN_SF = cp -p
else
LN_SF = ln -sf
endif
endif
endif
ifneq (,$(filter $(shell $(UNAME)),SunOS))
INSTALL ?= ginstall
else
INSTALL ?= install
endif
INSTALL_PROGRAM ?= $(INSTALL) -m 755
INSTALL_DATA ?= $(INSTALL) -m 644
MAKE_DIR ?= $(INSTALL) -d -m 755

View File

@ -1,258 +0,0 @@
# ##########################################################################
# multiconf.make
# Copyright (C) Yann Collet
#
# GPL v2 License
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# ##########################################################################
# Provides c_program(_shared_o) and cxx_program(_shared_o) target generation macros
# Provides static_library and c_dynamic_library target generation macros
# Support recompilation of only impacted units when an associated *.h is updated.
# Provides V=1 / VERBOSE=1 support. V=2 is used for debugging purposes.
# Complement target clean: delete objects and binaries created by this script
# Requires:
# - C_SRCDIRS, CXX_SRCDIRS, ASM_SRCDIRS defined
# OR
# C_SRCS, CXX_SRCS and ASM_SRCS variables defined
# *and* vpath set to find all source files
# OR
# C_OBJS, CXX_OBJS and ASM_OBJS variables defined
# *and* vpath set to find all source files
# - directory `cachedObjs/` available to cache object files.
# alternatively: set CACHE_ROOT to some different value.
# Optional:
# - HASH can be set to a different custom hash program.
# *_program*: generates a recipe for a target that will be built in a cache directory.
# The cache directory is automatically derived from CACHE_ROOT and list of flags and compilers.
# *_shared_o* variants are optional optimization variants, that share the same objects across multiple targets.
# However, as a consequence, all these objects must have exactly the same list of flags,
# which in practice means that there must be no target-level modification (like: target: CFLAGS += someFlag).
# If unsure, only use the standard variants, c_program and cxx_program.
# All *_program* macro functions take up to 4 argument:
# - The name of the target
# - The list of object files to build in the cache directory
# - An optional list of dependencies for linking, that will not be built
# - An optional complementary recipe code, that will run after compilation and link
# Silent mode is default; use V = 1 or VERBOSE = 1 to see compilation lines
VERBOSE ?= $(V)
$(VERBOSE).SILENT:
# Directory where object files will be built
CACHE_ROOT ?= cachedObjs
# --------------------------------------------------------------------------------------------
# Dependency management
DEPFLAGS = -MT $@ -MMD -MP -MF
# Include dependency files
include $(wildcard $(CACHE_ROOT)/**/*.d)
include $(wildcard $(CACHE_ROOT)/generic/*/*.d)
# --------------------------------------------------------------------------------------------
# Automatic determination of build artifacts cache directory, keyed on build
# flags, so that we can do incremental, parallel builds of different binaries
# with different build flags without collisions.
UNAME ?= $(shell uname)
ifeq ($(UNAME), Darwin)
HASH ?= md5
else ifeq ($(UNAME), FreeBSD)
HASH ?= gmd5sum
else ifeq ($(UNAME), OpenBSD)
HASH ?= md5
endif
HASH ?= md5sum
HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
ifeq ($(HAVE_HASH),0)
$(info warning : could not find HASH ($(HASH)), required to differentiate builds using different flags)
HASH_FUNC = generic/$(1)
else
HASH_FUNC = $(firstword $(shell echo $(2) | $(HASH) ))
endif
MKDIR ?= mkdir
LN ?= ln
# --------------------------------------------------------------------------------------------
# The following macros are used to create object files in the cache directory.
# The object files are named after the source file, but with a different path.
# Create build directories on-demand.
#
# For some reason, make treats the directory as an intermediate file and tries
# to delete it. So we work around that by marking it "precious". Solution found
# here:
# http://ismail.badawi.io/blog/2017/03/28/automatic-directory-creation-in-make/
.PRECIOUS: $(CACHE_ROOT)/%/.
$(CACHE_ROOT)/%/. :
$(MKDIR) -p $@
define addTargetAsmObject # targetName, addlDeps
$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2))))
.PRECIOUS: $$(CACHE_ROOT)/%/$(1)
$$(CACHE_ROOT)/%/$(1) : $(1:.o=.S) $(2) | $$(CACHE_ROOT)/%/.
@echo AS $$@
$$(CC) $$(CPPFLAGS) $$(CXXFLAGS) $$(DEPFLAGS) $$(CACHE_ROOT)/$$*/$(1:.o=.d) -c $$< -o $$@
endef # addTargetAsmObject
define addTargetCObject # targetName, addlDeps
$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2)))) #debug print
.PRECIOUS: $$(CACHE_ROOT)/%/$(1)
$$(CACHE_ROOT)/%/$(1) : $(1:.o=.c) $(2) | $$(CACHE_ROOT)/%/.
@echo CC $$@
$$(CC) $$(CPPFLAGS) $$(CFLAGS) $$(DEPFLAGS) $$(CACHE_ROOT)/$$*/$(1:.o=.d) -c $$< -o $$@
endef # addTargetCObject
define addTargetCxxObject # targetName, suffix, addlDeps
$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3))))
.PRECIOUS: $$(CACHE_ROOT)/%/$(1)
$$(CACHE_ROOT)/%/$(1) : $(1:.o=.$(2)) $(3) | $$(CACHE_ROOT)/%/.
@echo CXX $$@
$$(CXX) $$(CPPFLAGS) $$(CXXFLAGS) $$(DEPFLAGS) $$(CACHE_ROOT)/$$*/$(1:.o=.d) -c $$< -o $$@
endef # addTargetCxxObject
# Create targets for individual object files
C_SRCDIRS += .
vpath %.c $(C_SRCDIRS)
CXX_SRCDIRS += .
vpath %.cpp $(CXX_SRCDIRS)
vpath %.cc $(CXX_SRCDIRS)
ASM_SRCDIRS += .
vpath %.S $(ASM_SRCDIRS)
# If C_SRCDIRS, CXX_SRCDIRS and ASM_SRCDIRS are not defined, use C_SRCS, CXX_SRCS and ASM_SRCS
C_SRCS ?= $(notdir $(foreach dir,$(C_SRCDIRS),$(wildcard $(dir)/*.c)))
CPP_SRCS ?= $(notdir $(foreach dir,$(CXX_SRCDIRS),$(wildcard $(dir)/*.cpp)))
CC_SRCS ?= $(notdir $(foreach dir,$(CXX_SRCDIRS),$(wildcard $(dir)/*.cc)))
CXX_SRCS ?= $(CPP_SRCS) $(CC_SRCS)
ASM_SRCS ?= $(notdir $(foreach dir,$(ASM_SRCDIRS),$(wildcard $(dir)/*.S)))
# If C_SRCS, CXX_SRCS and ASM_SRCS are not defined, use C_OBJS, CXX_OBJS and ASM_OBJS
C_OBJS ?= $(patsubst %.c,%.o,$(C_SRCS))
CPP_OBJS ?= $(patsubst %.cpp,%.o,$(CPP_SRCS))
CC_OBJS ?= $(patsubst %.cc,%.o,$(CC_SRCS))
CXX_OBJS ?= $(CPP_OBJS) $(CC_OBJS) # Note: not used
ASM_OBJS ?= $(patsubst %.S,%.o,$(ASM_SRCS))
$(foreach OBJ,$(C_OBJS),$(eval $(call addTargetCObject,$(OBJ))))
$(foreach OBJ,$(CPP_OBJS),$(eval $(call addTargetCxxObject,$(OBJ),cpp)))
$(foreach OBJ,$(CC_OBJS),$(eval $(call addTargetCxxObject,$(OBJ),cc)))
$(foreach OBJ,$(ASM_OBJS),$(eval $(call addTargetAsmObject,$(OBJ))))
# --------------------------------------------------------------------------------------------
# The following macros are used to create targets in the user Makefile.
# Binaries are built in the cache directory, and then symlinked to the current directory.
# The cache directory is automatically derived from CACHE_ROOT and list of flags and compilers.
define static_library # targetName, targetDeps, addlDeps, addRecipe, hashComplement
$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3),$(4),$(5))))
MCM_ALL_BINS += $(1)
$$(CACHE_ROOT)/%/$(1) : $$(addprefix $$(CACHE_ROOT)/%/,$(2)) $(3)
@echo AR $$@
$$(AR) $$(ARFLAGS) $$@ $$^
$(4)
.PHONY: $(1)
$(1) : ARFLAGS = rcs
$(1) : $$(CACHE_ROOT)/$$(call HASH_FUNC,$(1),$(2) $$(CPPFLAGS) $$(CC) $$(CFLAGS) $$(CXX) $$(CXXFLAGS) $$(AR) $$(ARFLAGS) $(5))/$(1)
$$(LN) -sf $$< $$@
endef # static_library
define c_dynamic_library # targetName, targetDeps, addlDeps, addRecipe, hashComplement
$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3),$(4),$(5))))
MCM_ALL_BINS += $(1)
$$(CACHE_ROOT)/%/$(1) : $$(addprefix $$(CACHE_ROOT)/%/,$(2)) $(3)
@echo LD $$@
$$(CC) $$(CPPFLAGS) $$(CFLAGS) $$(LDFLAGS) -shared -o $$@ $$^ $$(LDLIBS)
$(4)
.PHONY: $(1)
$(1) : CFLAGS += -fPIC
$(1) : $$(CACHE_ROOT)/$$(call HASH_FUNC,$(1),$(2) $$(CPPFLAGS) $$(CC) $$(CFLAGS) $$(LDFLAGS) $$(LDLIBS) $(5))/$(1)
$$(LN) -sf $$< $$@
endef # c_dynamic_library
define program_base # targetName, targetDeps, addlDeps, addRecipe, hashComplement, compiler, flags
$$(if $$(filter 2,$$(V)),$$(info $$(call $(0),$(1),$(2),$(3),$(4),$(5),$(6),$(7))))
MCM_ALL_BINS += $(1)
$$(CACHE_ROOT)/%/$(1) : $$(addprefix $$(CACHE_ROOT)/%/,$(2)) $(3)
@echo LD $$@
$$($(6)) $$(CPPFLAGS) $$($(7)) $$^ -o $$@ $$(LDFLAGS) $$(LDLIBS)
$(4)
.PHONY: $(1)
$(1) : $$(CACHE_ROOT)/$$(call HASH_FUNC,$(1),$$($(6)) $$(CPPFLAGS) $$($(7)) $$(LDFLAGS) $$(LDLIBS) $(5))/$(1)
$$(LN) -sf $$< $$@$(EXT)
endef # program_base
# Note: $(EXT) must be set to .exe for Windows
define c_program # targetName, targetDeps, addlDeps, addRecipe
$$(eval $$(call program_base,$(1),$(2),$(3),$(4),$(1)$(2),CC,CFLAGS))
endef # c_program
define c_program_shared_o # targetName, targetDeps, addlDeps, addRecipe
$$(eval $$(call program_base,$(1),$(2),$(3),$(4),,CC,CFLAGS))
endef # c_program_shared_o
define cxx_program # targetName, targetDeps, addlDeps, addRecipe
$$(eval $$(call program_base,$(1),$(2),$(3),$(4),$(1)$(2),CXX,CXXFLAGS))
endef # cxx_program
define cxx_program_shared_o # targetName, targetDeps, addlDeps, addRecipe
$$(eval $$(call program_base,$(1),$(2),$(3),$(4),,CXX,CXXFLAGS))
endef # cxx_program_shared_o
# --------------------------------------------------------------------------------------------
# Cleaning: delete all objects and binaries created with this script
.PHONY: clean_cache
clean_cache:
$(RM) -rf $(CACHE_ROOT)
$(RM) $(MCM_ALL_BINS)
# automatically attach to standard clean target
.PHONY: clean
clean: clean_cache

View File

@ -1,39 +0,0 @@
#!/usr/bin/env python3
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
import re
def find_version_tuple(filepath):
version_file_data = None
with open(filepath) as fd:
version_file_data = fd.read()
patterns = r"""\s*#\s*define\s+LZ4_VERSION_MAJOR\s+([0-9]+).*$
\s*#\s*define\s+LZ4_VERSION_MINOR\s+([0-9]+).*$
\s*#\s*define\s+LZ4_VERSION_RELEASE\s+([0-9]+).*$
"""
regex = re.compile(patterns, re.MULTILINE)
version_match = regex.search(version_file_data)
if version_match:
return version_match.groups()
raise Exception("Unable to find version string.")
def main():
import argparse
parser = argparse.ArgumentParser(description='Print lz4 version from lib/lz4.h')
parser.add_argument('file', help='path to lib/lz4.h')
args = parser.parse_args()
version_tuple = find_version_tuple(args.file)
print('.'.join(version_tuple))
if __name__ == '__main__':
main()

View File

@ -1,34 +0,0 @@
Meson build system for lz4
==========================
Meson is a build system designed to optimize programmer productivity.
It aims to do this by providing simple, out-of-the-box support for
modern software development tools and practices, such as unit tests,
coverage reports, Valgrind, CCache and the like.
This Meson build system is provided with no guarantee.
## How to build
`cd` to this meson directory (`build/meson`)
```sh
meson setup --buildtype=release -Ddefault_library=shared -Dprograms=true builddir
cd builddir
ninja # to build
ninja install # to install
```
You might want to install it in staging directory:
```sh
DESTDIR=./staging ninja install
```
To configure build options, use:
```sh
meson configure
```
See [man meson(1)](https://manpages.debian.org/testing/meson/meson.1.en.html).

View File

@ -1,30 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
# This is a dummy meson file.
# The intention is that it can be easily moved to the root of the project
# (together with meson_options.txt) and packaged for wrapdb.
project(
'lz4',
'c',
license: 'BSD-2-Clause-Patent AND GPL-2.0-or-later',
default_options: [
'buildtype=release',
'warning_level=3'
],
version: run_command(
find_program('GetLz4LibraryVersion.py'),
'../../lib/lz4.h',
check: true
).stdout().strip(),
meson_version: '>=0.58.0'
)
subdir('meson')

View File

@ -1,42 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../../..'
add_languages('cpp', native: true)
sources = files(
lz4_source_root / 'contrib/gen_manual/gen_manual.cpp'
)
gen_manual = executable(
'gen_manual',
sources,
native: true,
install: false
)
manual_pages = ['lz4', 'lz4frame']
foreach mp : manual_pages
custom_target(
'@0@_manual.html'.format(mp),
build_by_default: true,
input: lz4_source_root / 'lib/@0@.h'.format(mp),
output: '@0@_manual.html'.format(mp),
command: [
gen_manual,
meson.project_version(),
'@INPUT@',
'@OUTPUT@',
],
install: false
)
endforeach

View File

@ -1,11 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
subdir('gen_manual')

View File

@ -1,32 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
examples = {
'print_version': 'print_version.c',
'blockStreaming_doubleBuffer': 'blockStreaming_doubleBuffer.c',
'dictionaryRandomAccess': 'dictionaryRandomAccess.c',
'blockStreaming_ringBuffer': 'blockStreaming_ringBuffer.c',
'streamingHC_ringBuffer': 'streamingHC_ringBuffer.c',
'blockStreaming_lineByLine': 'blockStreaming_lineByLine.c',
'frameCompress': 'frameCompress.c',
'bench_functions': 'bench_functions.c',
'simple_buffer': 'simple_buffer.c',
}
foreach e, src : examples
executable(
e,
lz4_source_root / 'examples' / src,
dependencies: [liblz4_internal_dep],
install: false
)
endforeach

View File

@ -1,87 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
sources = files(
lz4_source_root / 'lib/lz4.c',
lz4_source_root / 'lib/lz4frame.c',
lz4_source_root / 'lib/lz4hc.c',
lz4_source_root / 'lib/xxhash.c'
)
if get_option('unstable')
sources += files(lz4_source_root / 'lib/lz4file.c')
endif
c_args = []
if host_machine.system() == 'windows' and get_option('default_library') != 'static'
c_args += '-DLZ4_DLL_EXPORT=1'
endif
liblz4 = library(
'lz4',
sources,
c_args: c_args,
install: true,
version: meson.project_version(),
gnu_symbol_visibility: 'hidden'
)
liblz4_dep = declare_dependency(
link_with: liblz4,
compile_args: compile_args,
include_directories: include_directories(lz4_source_root / 'lib')
)
meson.override_dependency('liblz4', liblz4_dep)
if get_option('tests') or get_option('programs') or get_option('examples') or get_option('ossfuzz')
if get_option('default_library') == 'shared'
liblz4_internal = static_library(
'lz4-internal',
objects: liblz4.extract_all_objects(recursive: true),
gnu_symbol_visibility: 'hidden'
)
elif get_option('default_library') == 'static'
liblz4_internal = liblz4
elif get_option('default_library') == 'both'
liblz4_internal = liblz4.get_static_lib()
endif
liblz4_internal_dep = declare_dependency(
link_with: liblz4_internal,
compile_args: compile_args,
include_directories: include_directories(lz4_source_root / 'lib')
)
endif
pkgconfig.generate(
liblz4,
name: 'lz4',
filebase: 'liblz4',
description: 'extremely fast lossless compression algorithm library',
version: meson.project_version(),
url: 'http://www.lz4.org/'
)
install_headers(
lz4_source_root / 'lib/lz4.h',
lz4_source_root / 'lib/lz4hc.h',
lz4_source_root / 'lib/lz4frame.h'
)
if get_option('default_library') != 'shared'
install_headers(lz4_source_root / 'lib/lz4frame_static.h')
if get_option('unstable')
install_headers(lz4_source_root / 'lib/lz4file.h')
endif
endif

View File

@ -1,135 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
cc = meson.get_compiler('c')
fs = import('fs')
pkgconfig = import('pkgconfig')
lz4_source_root = '../../..'
add_project_arguments('-DXXH_NAMESPACE=LZ4_', language: 'c')
if get_option('debug')
add_project_arguments(cc.get_supported_arguments(
'-Wcast-qual',
'-Wcast-align',
'-Wshadow',
'-Wswitch-enum',
'-Wdeclaration-after-statement',
'-Wstrict-prototypes',
'-Wundef',
'-Wpointer-arith',
'-Wstrict-aliasing=1',
'-DLZ4_DEBUG=@0@'.format(get_option('debug-level'))
),
language: 'c'
)
endif
compile_args = []
if not get_option('align-test')
add_project_arguments('-DLZ4_ALIGN_TEST=0', language: 'c')
endif
if get_option('disable-memory-allocation')
if get_option('default_library') != 'static'
error('Memory allocation can only be disabled in static builds')
endif
add_project_arguments('-DLZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION')
compile_args += '-DLZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION'
endif
add_project_arguments(
'-DLZ4_DISTANCE_MAX=@0@'.format(get_option('distance-max')),
language: 'c'
)
compile_args += '-DLZ4_DISTANCE_MAX=@0@'.format(get_option('distance-max'))
if not get_option('fast-dec-loop').auto()
add_project_arguments(
'-DLZ4_FAST_DEC_LOOP=@0@'.format(
get_option('fast-dec-loop').enabled() ? 1 : 0
),
language: 'c'
)
endif
if get_option('force-sw-bitcount')
add_project_arguments('-DLZ4_FORCE_SW_BITCOUNT', language: 'c')
endif
if get_option('freestanding')
add_project_arguments('-DLZ4_FREESTANDING=1', language: 'c')
compile_args += '-DLZ4_FREESTANDING=1'
endif
if get_option('memory-usage') > 0
add_project_arguments(
'-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage')),
language: 'c'
)
compile_args += '-DLZ4_MEMORY_USAGE=@0@'.format(get_option('memory-usage'))
endif
if get_option('endianness-independent-output')
if get_option('default_library') != 'static'
error('Endianness-independent output can only be enabled in static builds')
endif
add_project_arguments('-DLZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT')
compile_args += '-DLZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT'
endif
if get_option('unstable')
add_project_arguments('-DLZ4_STATIC_LINKING_ONLY', language: 'c')
compile_args += '-DLZ4_STATIC_LINKING_ONLY'
if get_option('default_library') != 'static'
add_project_arguments('-DLZ4_PUBLISH_STATIC_FUNCTIONS', language: 'c')
compile_args += '-DLZ4_PUBLISH_STATIC_FUNCTIONS'
add_project_arguments('-DLZ4F_PUBLISH_STATIC_FUNCTIONS', language: 'c')
compile_args += '-DLZ4F_PUBLISH_STATIC_FUNCTIONS'
endif
endif
if get_option('user-memory-functions')
add_project_arguments('-DLZ4_USER_MEMORY_FUNCTIONS', language: 'c')
endif
run_env = environment()
subdir('lib')
if get_option('programs')
subdir('programs')
else
lz4 = disabler()
lz4cat = disabler()
unlz4 = disabler()
endif
if get_option('tests')
subdir('tests')
endif
if get_option('contrib')
subdir('contrib')
endif
if get_option('examples')
subdir('examples')
endif
if get_option('ossfuzz')
subdir('ossfuzz')
endif

View File

@ -1,37 +0,0 @@
lz4_source_root = '../../../..'
fuzzers = [
'compress_frame_fuzzer',
'compress_fuzzer',
'compress_hc_fuzzer',
'decompress_frame_fuzzer',
'decompress_fuzzer',
'round_trip_frame_uncompressed_fuzzer',
'round_trip_fuzzer',
'round_trip_hc_fuzzer',
'round_trip_stream_fuzzer'
]
c_args = cc.get_supported_arguments(
'-Wno-unused-function',
'-Wno-sign-compare',
'-Wno-declaration-after-statement'
)
foreach f : fuzzers
lib = static_library(
f,
lz4_source_root / 'ossfuzz/@0@.c'.format(f),
lz4_source_root / 'ossfuzz/lz4_helpers.c',
lz4_source_root / 'ossfuzz/fuzz_data_producer.c',
c_args: c_args,
dependencies: [liblz4_internal_dep]
)
executable(
f,
lz4_source_root / 'ossfuzz/standaloneengine.c',
link_with: lib,
dependencies: [liblz4_internal_dep]
)
endforeach

View File

@ -1,91 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
# note:
# it would be preferable to use some kind of glob or wildcard expansion here...
sources = files(
lz4_source_root / 'programs/bench.c',
lz4_source_root / 'programs/lorem.c',
lz4_source_root / 'programs/lz4cli.c',
lz4_source_root / 'programs/lz4io.c',
lz4_source_root / 'programs/util.c',
lz4_source_root / 'programs/threadpool.c',
lz4_source_root / 'programs/timefn.c',
)
# Initialize an empty list for extra dependencies
extra_deps = []
if get_option('enable_multithread')
pthread_dep = dependency('threads', required : true)
extra_deps += [pthread_dep]
multithread_args = ['-DLZ4IO_MULTITHREAD']
else
multithread_args = []
endif
lz4 = executable(
'lz4',
sources,
include_directories: include_directories(lz4_source_root / 'programs'),
dependencies: [liblz4_internal_dep] + extra_deps,
c_args: multithread_args,
export_dynamic: get_option('debug') and host_machine.system() == 'windows',
install: true
)
lz4cat = custom_target(
'lz4cat',
input: lz4,
output: 'lz4cat',
command: [
'ln',
'-s',
'-f',
fs.name(lz4.full_path()),
'@OUTPUT@'
]
)
unlz4 = custom_target(
'unlz4',
input: lz4,
output: 'unlz4',
command: [
'ln',
'-s',
'-f',
fs.name(lz4.full_path()),
'@OUTPUT@'
]
)
meson.override_find_program('lz4', lz4)
run_env.prepend('PATH', meson.current_build_dir())
install_man(lz4_source_root / 'programs/lz4.1')
if meson.version().version_compare('>=0.61.0')
foreach alias : ['lz4c', 'lz4cat', 'unlz4']
install_symlink(
alias,
install_dir: get_option('bindir'),
pointing_to: 'lz4'
)
install_symlink(
'@0@.1'.format(alias),
install_dir: get_option('mandir') / 'man1',
pointing_to: 'lz4.1'
)
endforeach
endif

View File

@ -1,162 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
lz4_source_root = '../../../..'
fuzzer_time = 90
test_exes = {
'abiTest': {
'sources': files(lz4_source_root / 'tests/abiTest.c'),
'test': false,
},
'checkFrame': {
'sources': files(lz4_source_root / 'tests/checkFrame.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'checkTag': {
'sources': files(lz4_source_root / 'tests/checkTag.c'),
'test': false,
},
'datagen': {
'sources': files(
lz4_source_root / 'programs/lorem.c',
lz4_source_root / 'tests/datagencli.c',
lz4_source_root / 'tests/datagen.c',
lz4_source_root / 'tests/loremOut.c',
),
'include_directories': include_directories(lz4_source_root / 'programs'),
},
'decompress-partial-usingDict.c': {
'sources': files(lz4_source_root / 'tests/decompress-partial-usingDict.c'),
},
'decompress-partial.c': {
'sources': files(lz4_source_root / 'tests/decompress-partial.c'),
},
'frametest': {
'sources': files(lz4_source_root / 'tests/frametest.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
'args': ['-v', '-T@0@s'.format(fuzzer_time)],
'test': false,
},
'freestanding': {
'sources': files(lz4_source_root / 'tests/freestanding.c'),
'c_args': ['-ffreestanding', '-fno-stack-protector', '-Wno-unused-parameter', '-Wno-declaration-after-statement', '-DLZ4_DEBUG=0'],
'link_args': ['-nostdlib'],
'build': cc.get_id() in ['gcc', 'clang'] and
host_machine.system() == 'linux' and host_machine.cpu_family() == 'x86_64',
'override_options': ['optimization=1'],
},
'fullbench': {
'sources': files(lz4_source_root / 'tests/fullbench.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
'args': ['--no-prompt', '-i1', files(lz4_source_root / 'tests/COPYING')],
'test': false,
},
'fuzzer': {
'sources': files(lz4_source_root / 'tests/fuzzer.c'),
'include_directories': include_directories(lz4_source_root / 'programs'),
'args': ['-T@0@s'.format(fuzzer_time)],
'test': false,
},
'roundTripTest': {
'sources': files(lz4_source_root / 'tests/roundTripTest.c'),
'test': false,
},
}
targets = {}
foreach e, attrs : test_exes
if not attrs.get('build', true)
targets += {e: disabler()}
continue
endif
t = executable(
e,
attrs.get('sources'),
c_args: attrs.get('c_args', []),
link_args: attrs.get('link_args', []),
objects: attrs.get('objects', []),
dependencies: [liblz4_internal_dep],
include_directories: attrs.get('include_directories', []),
install: false,
override_options: attrs.get('override_options', [])
)
targets += {e: t}
if not attrs.get('test', true)
continue
endif
test(
e,
t,
args: attrs.get('params', []),
timeout: 120
)
endforeach
fs = import('fs')
run_env.prepend('PATH', meson.current_build_dir())
test_scripts = {
'lz4-basic': {
'depends': [lz4, lz4cat, unlz4, targets['datagen']],
},
'lz4-dict': {
'depends': [lz4, targets['datagen']],
},
'lz4-contentSize': {
'depends': [lz4, targets['datagen']],
},
'lz4-fast-hugefile': {
'depends': [lz4, targets['datagen']],
},
'lz4-frame-concatenation': {
'depends': [lz4, targets['datagen']],
},
'lz4-multiple': {
'depends': [lz4, targets['datagen']],
},
'lz4-multiple-legacy': {
'depends': [lz4, targets['datagen']],
},
'lz4-opt-parser': {
'depends': [lz4, targets['datagen']],
},
'lz4-skippable': {
'depends': [lz4],
},
'lz4-sparse': {
'depends': [lz4, targets['datagen']],
},
'lz4-testmode': {
'depends': [lz4, targets['datagen']],
},
'lz4hc-hugefile': {
'depends': [lz4, targets['datagen']],
},
}
foreach s, attrs : test_scripts
script = find_program(lz4_source_root / 'tests/test-@0@.sh'.format(s))
test(
'@0@'.format(s),
script,
depends: attrs.get('depends', []),
workdir: fs.parent(script.full_path()),
env: run_env,
timeout: 360
)
endforeach

View File

@ -1,44 +0,0 @@
# #############################################################################
# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
# Copyright (c) 2022-present Tristan Partin <tristan(at)partin.io>
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# #############################################################################
option('enable_multithread', type: 'boolean', value: true,
description: 'Enable multi-threading support')
option('align-test', type: 'boolean', value: true,
description: 'See LZ4_ALIGN_TEST')
option('contrib', type: 'boolean', value: false,
description: 'Enable contrib')
option('debug-level', type: 'integer', min: 0, max: 7, value: 1,
description: 'Enable run-time debug. See lib/lz4hc.c')
option('disable-memory-allocation', type: 'boolean', value: false,
description: 'See LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION. Static builds only')
option('distance-max', type: 'integer', min: 0, max: 65535, value: 65535,
description: 'See LZ4_DISTANCE_MAX')
option('endianness-independent-output', type: 'boolean', value: false,
description: 'See LZ4_STATIC_LINKING_ONLY_ENDIANNESS_INDEPENDENT_OUTPUT. Static builds only')
option('examples', type: 'boolean', value: false,
description: 'Enable examples')
option('fast-dec-loop', type: 'feature', value: 'auto',
description: 'See LZ4_FAST_DEC_LOOP')
option('force-sw-bitcount', type: 'boolean', value: false,
description: 'See LZ4_FORCE_SW_BITCOUNT')
option('freestanding', type: 'boolean', value: false,
description: 'See LZ4_FREESTANDING')
option('memory-usage', type: 'integer', min: 0, max: 20, value: 0,
description: 'See LZ4_MEMORY_USAGE. 0 means use the LZ4 default')
option('ossfuzz', type: 'boolean', value: true,
description: 'Enable ossfuzz')
option('programs', type: 'boolean', value: false,
description: 'Enable programs')
option('tests', type: 'boolean', value: false,
description: 'Enable tests')
option('unstable', type: 'boolean', value: false,
description: 'Expose unstable interfaces')
option('user-memory-functions', type: 'boolean', value: false,
description: 'See LZ4_USER_MEMORY_FUNCTIONS')

View File

@ -1,5 +0,0 @@
These scripts will generate Visual Studio Solutions for a selected set of supported versions of MS Visual.
For these scripts to work, both `cmake` and the relevant Visual Studio version must be locally installed on the system where the script is run.
If `cmake` is installed into a non-standard directory, or user wants to test a specific version of `cmake`, the target `cmake` directory can be provided via the environment variable `CMAKE_PATH`.

View File

@ -1,55 +0,0 @@
:: Requires 1 parameter == GENERATOR
@echo off
setlocal
:: Set path
set "BUILD_BASE_DIR=%~dp0" :: Use the directory where the script is located
set "CMAKELIST_DIR=..\..\cmake"
if "%~1"=="" (
echo No generator specified as first parameter
exit /b 1
)
set "GENERATOR=%~1"
:: Check if a user-defined CMAKE_PATH is set and prioritize it
if defined CMAKE_PATH (
set "CMAKE_EXECUTABLE=%CMAKE_PATH%\cmake.exe"
echo Using user-defined cmake at %CMAKE_PATH%
) else (
:: Attempt to find cmake in the system PATH
where cmake >nul 2>&1
if %ERRORLEVEL% neq 0 (
:: Use the default standard cmake installation directory if not found in PATH
set "CMAKE_PATH=C:\Program Files\CMake\bin"
echo CMake not in system PATH => using default CMAKE_PATH=%CMAKE_PATH%
set "CMAKE_EXECUTABLE=%CMAKE_PATH%\cmake.exe"
) else (
set "CMAKE_EXECUTABLE=cmake"
echo CMake found in system PATH.
)
)
:: Set the build directory to a subdirectory named after the generator
set "BUILD_DIR=%BUILD_BASE_DIR%\%GENERATOR%"
:: Create the build directory if it doesn't exist
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
:: Run CMake to configure the project and generate the solution
pushd "%BUILD_DIR%"
"%CMAKE_EXECUTABLE%" -G "%GENERATOR%" "%CMAKELIST_DIR%"
if %ERRORLEVEL% neq 0 goto :error
:: If successful, end script
echo Build configuration successful for %GENERATOR%.
goto :end
:error
echo Failed to configure build for %GENERATOR%.
exit /b 1
:end
popd
endlocal
@echo on

View File

@ -1,3 +0,0 @@
@echo off
:: Call the central script with the specific generator for VS2015
call generate_solution.cmd "Visual Studio 14 2015"

View File

@ -1,3 +0,0 @@
@echo off
:: Call the central script with the specific generator for VS2017
call generate_solution.cmd "Visual Studio 15 2017"

View File

@ -1,3 +0,0 @@
@echo off
:: Call the central script with the specific generator for VS2019
call generate_solution.cmd "Visual Studio 16 2019"

View File

@ -1,3 +0,0 @@
@echo off
:: Call the central script with the specific generator for VS2022
call generate_solution.cmd "Visual Studio 17 2022"

15
src/Core/Config.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef PKG_CONFIG_H
#define PKG_CONFIG_H
#include <cstdint>
namespace PKG {
// 提取配置
struct ExtractConfig {
uint32_t threadCount = 0; // 工作线程数0 = 自动hardware_concurrency
};
} // namespace PKG
#endif // PKG_CONFIG_H

51
src/Core/ExtractStats.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef PKG_EXTRACT_STATS_H
#define PKG_EXTRACT_STATS_H
#include <atomic>
#include <chrono>
#include <cstddef>
#include <map>
#include <mutex>
#include <string>
namespace PKG {
// 提取统计信息(线程安全,可在多线程环境中累加)
// 由 ExtractPipeline::Run 填充,调用方可读取展示
struct ExtractStats {
std::atomic<size_t> totalEntries{0}; // 总条目数
std::atomic<size_t> succeeded{0}; // 成功数
std::atomic<size_t> failed{0}; // 失败数
std::atomic<uint64_t> totalOutputBytes{0}; // 输出总字节数
// 各输出格式数量(按扩展名统计,如 "png" -> 23
// 注意map 操作非原子,内部用 mutex 保护
std::map<std::string, size_t> formatCounts;
std::mutex formatMutex;
std::chrono::steady_clock::time_point startTime; // 由 Run 设置
std::chrono::steady_clock::time_point endTime;
uint64_t inputFileSize = 0; // 输入文件大小(字节)
// 记录一个成功输出的文件(线程安全)
void AddOutput(const std::string &ext, uint64_t bytes) {
succeeded.fetch_add(1, std::memory_order_relaxed);
totalOutputBytes.fetch_add(bytes, std::memory_order_relaxed);
std::lock_guard<std::mutex> lock(formatMutex);
formatCounts[ext]++;
}
// 记录一个失败(线程安全)
void AddFailure() {
failed.fetch_add(1, std::memory_order_relaxed);
}
// 耗时(秒)
double ElapsedSeconds() const {
return std::chrono::duration<double>(endTime - startTime).count();
}
};
} // namespace PKG
#endif // PKG_EXTRACT_STATS_H

33
src/Core/Logger.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "Logger.h"
#include "ProgressBar.h"
#include <iostream>
namespace PKG {
Logger& Logger::Instance() {
static Logger instance;
return instance;
}
void Logger::SetProgressBar(ProgressBar* pb) {
std::lock_guard<std::mutex> lock(m_Mutex);
m_ProgressBar = pb;
}
void Logger::Info(const std::string& msg) {
std::lock_guard<std::mutex> lock(m_Mutex);
if (m_ProgressBar)
m_ProgressBar->PrintLog(msg);
else
std::cout << msg << std::endl;
}
void Logger::Error(const std::string& msg) {
std::lock_guard<std::mutex> lock(m_Mutex);
if (m_ProgressBar)
m_ProgressBar->PrintLog("[ERROR] " + msg);
else
std::cerr << "[ERROR] " << msg << std::endl;
}
} // namespace PKG

32
src/Core/Logger.h Normal file
View File

@ -0,0 +1,32 @@
#ifndef PKG_LOGGER_H
#define PKG_LOGGER_H
#include <mutex>
#include <string>
namespace PKG {
class ProgressBar; // 前向声明
// 线程安全的日志输出(单例)
// 关联 ProgressBar 后日志会通过进度条协调打印pacman 风格:
// 日志在进度条上方滚动,进度条始终固定在底部)
class Logger {
public:
static Logger& Instance();
void Info(const std::string& msg);
void Error(const std::string& msg);
// 关联/取消关联进度条(线程安全)
void SetProgressBar(ProgressBar* pb);
private:
Logger() = default;
std::mutex m_Mutex;
ProgressBar* m_ProgressBar = nullptr;
};
} // namespace PKG
#endif // PKG_LOGGER_H

59
src/Core/ProcessInfo.cpp Normal file
View File

@ -0,0 +1,59 @@
#include "ProcessInfo.h"
#include <iomanip>
#include <sstream>
// ─── 字节格式化(跨平台通用)──────────────────────────────────────
namespace PKG {
std::string FormatBytes(uint64_t bytes) {
static const char* units[] = {"B", "KB", "MB", "GB"};
int u = 0;
double size = static_cast<double>(bytes);
while (size >= 1024 && u < 3) { size /= 1024; ++u; }
std::ostringstream oss;
oss << std::fixed << std::setprecision(u == 0 ? 0 : 1) << size << " " << units[u];
return oss.str();
}
} // namespace PKG
// ─── POSIX (Linux/macOS) ──────────────────────────────────────────
#if defined(__unix__) || defined(__APPLE__)
#include <sys/resource.h>
#include <unistd.h>
namespace PKG {
size_t GetPeakRssBytes() {
struct rusage usage {};
if (getrusage(RUSAGE_SELF, &usage) != 0)
return 0;
#if defined(__APPLE__)
return static_cast<size_t>(usage.ru_maxrss); // macOS: 字节
#else
return static_cast<size_t>(usage.ru_maxrss) * 1024; // Linux: KB → 字节
#endif
}
} // namespace PKG
// ─── Windows ──────────────────────────────────────────────────────
#elif defined(_WIN32)
#include <windows.h>
#include <psapi.h>
namespace PKG {
size_t GetPeakRssBytes() {
PROCESS_MEMORY_COUNTERS pmc;
if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
return 0;
return static_cast<size_t>(pmc.PeakWorkingSetSize);
}
} // namespace PKG
#else
#warning "Unsupported platform: GetPeakRssBytes returns 0"
namespace PKG {
size_t GetPeakRssBytes() { return 0; }
} // namespace PKG
#endif

23
src/Core/ProcessInfo.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef PKG_PROCESS_INFO_H
#define PKG_PROCESS_INFO_H
// 跨平台进程内存占用查询与字节格式化工具
// POSIX: getrusage(RUSAGE_SELF)
// Windows: GetProcessMemoryInfo
#include <cstddef>
#include <cstdint>
#include <string>
namespace PKG {
// 返回当前进程峰值物理内存占用,单位字节;失败返回 0
size_t GetPeakRssBytes();
// 将字节数格式化为人类可读字符串(如 "1.2 MB"
// 单位自动选择B / KB / MB / GB
std::string FormatBytes(uint64_t bytes);
} // namespace PKG
#endif // PKG_PROCESS_INFO_H

262
src/Core/ProgressBar.cpp Normal file
View File

@ -0,0 +1,262 @@
#include "ProgressBar.h"
#include <cstdio>
#include <string>
// Windows: 启用 VT100 转义序列 + 终端宽度检测
#if defined(_WIN32)
#include <windows.h>
static void EnableVt100() {
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
if (h == INVALID_HANDLE_VALUE)
return;
DWORD mode = 0;
if (!GetConsoleMode(h, &mode))
return;
SetConsoleMode(h, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
}
#else
#include <sys/ioctl.h>
#include <unistd.h>
static void EnableVt100() {}
#endif
namespace PKG {
// braille 盲文点 spinner 字符序列
static const char *kSpinnerFrames[] = {
"\xe2\xa0\x8b", // ⠋
"\xe2\xa0\x99", // ⠙
"\xe2\xa0\xb9", // ⠹
"\xe2\xa0\xb8", // ⠸
"\xe2\xa0\xbc", // ⠼
"\xe2\xa0\xb4", // ⠴
"\xe2\xa0\xa6", // ⠦
"\xe2\xa0\xa7", // ⠧
"\xe2\xa0\x87", // ⠇
"\xe2\xa0\x8f", // ⠏
};
static const size_t kSpinnerCount = sizeof(kSpinnerFrames) / sizeof(kSpinnerFrames[0]);
// ─── ProgressStyle 预设 ───────────────────────────────────────────
ProgressStyle ProgressStyle::Modern() {
ProgressStyle s;
s.filledChar = "\xe2\x94\x81"; // ━
s.emptyChar = "\xe2\x94\x80"; // ─
s.suffixFormat = " {percent}% ({done}/{total}) {elapsed}s {spinner}";
s.filledColor = "\033[36m"; // cyan
s.emptyColor = "\033[90m"; // gray
s.suffixColor = "\033[2m"; // dim
s.showSpinner = true;
return s;
}
ProgressStyle ProgressStyle::Classic() {
ProgressStyle s;
s.filledChar = "\xe2\x96\x88"; // █
s.emptyChar = "\xe2\x96\x91"; // ░
s.leftBracket = "[";
s.rightBracket = "]";
s.suffixFormat = " {percent}% ({done}/{total}) {elapsed}s";
s.filledColor.clear();
s.emptyColor.clear();
s.suffixColor.clear();
s.showSpinner = false;
return s;
}
ProgressStyle ProgressStyle::Minimal() {
ProgressStyle s;
s.filledChar = "\xe2\x96\x88"; // █
s.emptyChar = " ";
s.suffixFormat = " {percent}% {done}/{total}";
s.filledColor = "\033[32m"; // green
s.showSpinner = false;
return s;
}
ProgressStyle ProgressStyle::Blocks() {
ProgressStyle s;
s.filledChar = "\xe2\x96\x93"; // ▓
s.emptyChar = "\xe2\x96\x91"; // ░
s.suffixFormat = " {percent}% ({done}/{total}) {elapsed}s {spinner}";
s.filledColor = "\033[35m"; // magenta
s.emptyColor = "\033[90m"; // gray
s.suffixColor = "\033[2m"; // dim
s.showSpinner = true;
return s;
}
// ─── ProgressBar ──────────────────────────────────────────────────
ProgressBar::ProgressBar(size_t total, ProgressStyle style)
: m_Total(total), m_Style(std::move(style)), m_Start(std::chrono::steady_clock::now()) {
EnableVt100();
if (m_Total == 0) {
m_Running = false;
return;
}
m_Thread = std::thread(&ProgressBar::RefreshLoop, this);
}
ProgressBar::~ProgressBar() {
if (!m_Running.exchange(false))
return;
if (m_Thread.joinable())
m_Thread.join();
std::lock_guard<std::mutex> lock(m_DrawMutex);
DrawLocked();
std::fputc('\n', stdout);
std::fflush(stdout);
}
void ProgressBar::PrintLog(const std::string &msg) {
std::lock_guard<std::mutex> lock(m_DrawMutex);
// 清除当前进度条行:\r 回到行首,\033[K 清除到行尾
std::fputs("\r\033[K", stdout);
std::fputs(msg.c_str(), stdout);
std::fputc('\n', stdout);
DrawLocked();
std::fflush(stdout);
}
void ProgressBar::RefreshLoop() {
while (m_Running.load(std::memory_order_relaxed)) {
{
std::lock_guard<std::mutex> lock(m_DrawMutex);
DrawLocked();
}
if (m_Done.load(std::memory_order_relaxed) >= m_Total)
break;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
int ProgressBar::GetTerminalWidth() {
#if defined(_WIN32)
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (GetConsoleScreenBufferInfo(h, &csbi))
return csbi.srWindow.Right - csbi.srWindow.Left + 1;
return 80;
#else
struct winsize w;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == 0 && w.ws_col > 0)
return w.ws_col;
return 80;
#endif
}
// 占位符替换:{percent} {done} {total} {elapsed} {spinner}
std::string ProgressBar::FormatSuffix(size_t done, size_t total, size_t percent, double secs) {
std::string out;
out.reserve(m_Style.suffixFormat.size() + 32);
const std::string &fmt = m_Style.suffixFormat;
for (size_t i = 0; i < fmt.size();) {
if (fmt[i] == '{') {
size_t end = fmt.find('}', i);
if (end == std::string::npos) {
out += fmt[i++];
continue;
}
std::string key = fmt.substr(i + 1, end - i - 1);
if (key == "percent")
out += std::to_string(percent);
else if (key == "done")
out += std::to_string(done);
else if (key == "total")
out += std::to_string(total);
else if (key == "elapsed")
out += std::to_string(secs);
else if (key == "spinner") {
if (m_Style.showSpinner)
out += kSpinnerFrames[m_SpinnerIndex % kSpinnerCount];
} else {
out += fmt.substr(i, end - i + 1);
}
i = end + 1;
} else {
out += fmt[i++];
}
}
return out;
}
void ProgressBar::DrawLocked() {
size_t done = m_Done.load(std::memory_order_relaxed);
size_t total = m_Total;
if (total == 0)
return;
size_t percent = (done * 100) / total;
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - m_Start)
.count();
double secs = elapsed / 1000.0;
// 推进 spinner
m_SpinnerIndex = (m_SpinnerIndex + 1) % kSpinnerCount;
// 格式化后缀(含颜色)
std::string suffix = FormatSuffix(done, total, percent, secs);
if (!m_Style.suffixColor.empty())
suffix = m_Style.suffixColor + suffix + m_Style.resetColor;
// 计算后缀可见宽度(排除 ANSI 转义序列)
size_t suffixVisible = 0;
bool inEscape = false;
for (char c : suffix) {
if (c == '\033') {
inEscape = true;
continue;
}
if (inEscape) {
if (c == 'm')
inEscape = false;
continue;
}
++suffixVisible;
}
int termWidth = GetTerminalWidth();
int fixedWidth = static_cast<int>(m_Style.leftBracket.size()) + static_cast<int>(m_Style.rightBracket.size()) + static_cast<int>(suffixVisible);
int barWidth = termWidth - fixedWidth;
if (barWidth < 1)
barWidth = 1;
size_t filled = (done * static_cast<size_t>(barWidth)) / total;
// 构建进度条
std::string bar;
bar.reserve(static_cast<size_t>(barWidth) * 6); // 含颜色预留
if (!m_Style.leftBracket.empty())
bar += m_Style.leftBracket;
if (!m_Style.filledColor.empty())
bar += m_Style.filledColor;
for (int i = 0; i < barWidth; ++i) {
if (static_cast<size_t>(i) < filled) {
bar += m_Style.filledChar;
} else {
// 切换到 empty 颜色(仅首次遇到空白时)
if (i > 0 && !m_Style.emptyColor.empty())
bar += m_Style.resetColor + m_Style.emptyColor;
bar += m_Style.emptyChar;
}
}
if (!m_Style.filledColor.empty() || !m_Style.emptyColor.empty())
bar += m_Style.resetColor;
if (!m_Style.rightBracket.empty())
bar += m_Style.rightBracket;
bar += suffix;
std::fprintf(stdout, "\r%s", bar.c_str());
std::fflush(stdout);
}
} // namespace PKG

73
src/Core/ProgressBar.h Normal file
View File

@ -0,0 +1,73 @@
#ifndef PKG_PROGRESS_BAR_H
#define PKG_PROGRESS_BAR_H
#include <atomic>
#include <chrono>
#include <cstddef>
#include <mutex>
#include <string>
#include <thread>
namespace PKG {
// 进度条样式(可定制)
// 后缀格式支持占位符:{percent} {done} {total} {elapsed} {spinner}
struct ProgressStyle {
std::string filledChar = "\xe2\x94\x81"; // ━ U+2501 heavy horizontal
std::string emptyChar = "\xe2\x94\x80"; // ─ U+2500 light horizontal
std::string leftBracket;
std::string rightBracket;
std::string suffixFormat = " {percent}% ({done}/{total}) {elapsed}s {spinner}";
// ANSI 颜色(空字符串表示不着色)
std::string filledColor = "\033[36m"; // cyan
std::string emptyColor = "\033[90m"; // bright black (gray)
std::string suffixColor = "\033[2m"; // dim
std::string resetColor = "\033[0m";
bool showSpinner = true;
// 预设样式
static ProgressStyle Modern(); // 横线 + 青色 + braille spinner默认
static ProgressStyle Classic(); // 方块 █░ + 无色 + 括号
static ProgressStyle Minimal(); // 极简:百分比 + 计数
static ProgressStyle Blocks(); // 彩色方块 ▓░ + spinner
};
// 线程安全终端进度条
// - 全宽度自适应终端宽度
// - 日志在进度条上方滚动打印(通过 PrintLog 协调pacman 风格)
// - 样式可通过构造函数定制
class ProgressBar {
public:
explicit ProgressBar(size_t total, ProgressStyle style = ProgressStyle::Modern());
~ProgressBar();
ProgressBar(const ProgressBar&) = delete;
ProgressBar& operator=(const ProgressBar&) = delete;
// 原子递增已完成数(线程安全)
void Increment() { m_Done.fetch_add(1, std::memory_order_relaxed); }
// 打印日志:清除进度条行 → 打印日志 → 重绘进度条
void PrintLog(const std::string& msg);
private:
void RefreshLoop();
void DrawLocked();
int GetTerminalWidth();
std::string FormatSuffix(size_t done, size_t total, size_t percent, double secs);
std::atomic<size_t> m_Done{0};
size_t m_Total;
ProgressStyle m_Style;
std::atomic<bool> m_Running{true};
std::thread m_Thread;
std::chrono::steady_clock::time_point m_Start;
std::mutex m_DrawMutex;
size_t m_SpinnerIndex{0};
};
} // namespace PKG
#endif // PKG_PROGRESS_BAR_H

77
src/Core/Result.h Normal file
View File

@ -0,0 +1,77 @@
#ifndef PKG_RESULT_H
#define PKG_RESULT_H
#include <string>
#include <utility>
namespace PKG {
// ===== 错误码 =====
enum class ErrorCode {
None,
FileOpen, // 文件打开失败
FileCreate, // 文件创建失败
BadMagic, // 魔数校验失败(格式不符)
ReadFailed, // 读取失败
WriteFailed, // 写入失败
DecompressFailed, // 解压失败LZ4/DXT
EncodeFailed, // 编码失败PNG/GIF
UnsupportedFormat, // 不支持的格式
InvalidArgument, // 无效参数
};
// ===== 错误信息 =====
struct Error {
ErrorCode code = ErrorCode::None;
std::string message;
bool IsOk() const { return code == ErrorCode::None; }
explicit operator bool() const { return IsOk(); }
};
// ===== Result<T>: 携带值与错误的返回类型 =====
template <typename T>
struct Result {
T value;
Error error;
bool IsOk() const { return error.IsOk(); }
explicit operator bool() const { return IsOk(); }
T &operator*() { return value; }
const T &operator*() const { return value; }
T *operator->() { return &value; }
const T *operator->() const { return &value; }
};
// ===== Result<void> 特化:仅含错误 =====
template <>
struct Result<void> {
Error error;
bool IsOk() const { return error.IsOk(); }
explicit operator bool() const { return IsOk(); }
};
// ===== 工厂函数 =====
template <typename T>
inline Result<T> Ok(T value) {
return Result<T>{std::move(value), Error{}};
}
inline Result<void> Ok() {
return Result<void>{Error{}};
}
template <typename T>
inline Result<T> Fail(ErrorCode code, std::string message = "") {
return Result<T>{T{}, Error{code, std::move(message)}};
}
inline Result<void> Fail(ErrorCode code, std::string message = "") {
return Result<void>{Error{code, std::move(message)}};
}
} // namespace PKG
#endif // PKG_RESULT_H

223
src/Core/Types.h Normal file
View File

@ -0,0 +1,223 @@
#ifndef PKG_TYPES_H
#define PKG_TYPES_H
#include <cstdint>
#include <filesystem>
#include <string>
#include <vector>
namespace PKG {
// ===== 纹理原始格式TEX 文件头中声明)=====
enum class TexFormat {
RGBA8888 = 0, // 未压缩 RGBA
DXT5 = 4, // DXT5 压缩(含 alpha
DXT3 = 6, // DXT3 压缩(显式 alpha
DXT1 = 7, // DXT1 压缩(无 alpha
RG88 = 8, // 双通道
R8 = 9, // 单通道
};
// ===== 纹理标志位(可按位组合)=====
enum class TexType {
None = 0,
NoInterpolation = 1, // 禁用纹理过滤
ClampUVs = 2, // UV 钳制(非重复)
IsGif = 4, // GIF 动画纹理
Unk3 = 8,
Unk4 = 16,
IsVideoTexture = 32, // 视频纹理MP4
Unk6 = 64,
Unk7 = 128,
};
// ===== Mipmap 数据格式 =====
enum class MipmapFormat {
Invalid = 0,
// 原始像素格式1-3
RGBA8888 = 1,
R8 = 2,
RG88 = 3,
// DXT 块压缩格式
CompressedDXT5,
CompressedDXT3,
CompressedDXT1,
// 视频
VideoMp4,
// 已编码图像格式(>= 1000对应 FreeImage 格式)
ImageBMP = 1000,
ImageICO,
ImageJPEG,
ImageJNG,
ImageKOALA,
ImageLBM,
ImageIFF,
ImageMNG,
ImagePBM,
ImagePBMRAW,
ImagePCD,
ImagePCX,
ImagePGM,
ImagePGMRAW,
ImagePNG,
ImagePPM,
ImagePPMRAW,
ImageRAS,
ImageTARGA,
ImageTIFF,
ImageWBMP,
ImagePSD,
ImageCUT,
ImageXBM,
ImageXPM,
ImageDDS,
ImageGIF,
ImageHDR,
ImageFAXG3,
ImageSGI,
ImageEXR,
ImageJ2K,
ImageJP2,
ImagePFM,
ImagePICT,
ImageRAW,
};
// ===== FreeImage 格式标识(对应原项目 FreeImageFormat 枚举)=====
enum class FreeImageFormat {
FIF_UNKNOWN = -1,
FIF_BMP = 0,
FIF_ICO,
FIF_JPEG,
FIF_JNG,
FIF_KOALA,
FIF_LBM,
FIF_IFF = 5,
FIF_MNG,
FIF_PBM,
FIF_PBMRAW,
FIF_PCD,
FIF_PCX,
FIF_PGM,
FIF_PGMRAW,
FIF_PNG,
FIF_PPM,
FIF_PPMRAW,
FIF_RAS,
FIF_TARGA,
FIF_TIFF,
FIF_WBMP,
FIF_PSD,
FIF_CUT,
FIF_XBM,
FIF_XPM,
FIF_DDS,
FIF_GIF,
FIF_HDR,
FIF_FAXG3,
FIF_SGI,
FIF_EXR,
FIF_J2K,
FIF_JP2,
FIF_PFM,
FIF_PICT,
FIF_RAW,
FIF_MP4 = 35,
};
// ===== 图像容器版本(对应 TEXB0001~0004=====
enum class ImageContainerVersion {
VERSION1 = 1,
VERSION2 = 2,
VERSION3 = 3,
VERSION4 = 4,
};
// ===== DXT 解压标志 =====
enum class DXTFlags {
DXT1 = 1,
DXT3 = 1 << 1,
DXT5 = 1 << 2,
};
// ===== 数据结构 =====
// PKG 索引条目:描述一个文件在 PKG 中的位置与类型
struct Entry {
std::filesystem::path FullPath; // 文件相对路径
int32_t Offset{}; // 相对数据区起始的偏移
int32_t Length{}; // 数据长度(字节)
std::string Type; // 扩展名(含点,如 ".tex"
};
// TEX 文件头
struct TexHeader {
TexFormat Format = TexFormat::RGBA8888;
TexType Flags = TexType::None;
int32_t TextureWidth = 0; // 纹理尺寸(可能含 padding
int32_t TextureHeight = 0;
int32_t ImageWidth = 0; // 实际图像尺寸
int32_t ImageHeight = 0;
uint32_t UnkInt0 = 0; // 未知字段
};
// 单个 mipmap 层级
struct TexMipMap {
int Width = 0;
int Height = 0;
int DecompressedDataCount = 0; // LZ4 解压后大小
bool IsZ4Compressed = false;
MipmapFormat Format = MipmapFormat::Invalid;
std::vector<uint8_t> Data; // 像素或压缩数据
};
// 一张图像(可含多个 mipmap 层级)
struct TexImage {
std::vector<TexMipMap> Mipmaps;
};
// 图像容器TEXB 块)
struct TexImageContainer {
std::string Magic; // "TEXB0001"~"TEXB0004"
FreeImageFormat ImageFormat = FreeImageFormat::FIF_UNKNOWN;
ImageContainerVersion imageContainerVersion = ImageContainerVersion::VERSION1;
std::vector<TexImage> Images;
};
// GIF 单帧信息(位置、尺寸、帧时长)
struct TexFrameInfo {
int ImageId = 0;
float Frametime = 0.0f; // 秒
float PosX = 0.0f, PosY = 0.0f;
float Width = 0.0f, WidthY = 0.0f, HeightX = 0.0f, Height = 0.0f;
};
// GIF 帧信息容器TEXS 块)
struct TexFrameInfoContainer {
std::string Magic; // "TEXS0001" 或 "TEXS0003"
std::vector<TexFrameInfo> Frames;
int GifWidth = 0; // GIF 画布尺寸
int GifHeight = 0;
};
// 完整 TEX 文件结构
struct Tex {
std::string Magic1; // "TEXV0005"
std::string Magic2; // "TEXI0001"
TexHeader Header;
TexImageContainer ImageContainer;
bool IsGif = false; // 是否为 GIF 动画
bool IsVideoTexture = false; // 是否为视频纹理
TexFrameInfoContainer FrameInfoContainer;
};
// 根据 MipmapFormat 获取对应文件扩展名(不含点,如 "png"
std::string GetFileExtension(MipmapFormat format);
} // namespace PKG
#endif // PKG_TYPES_H

142
src/Decoder/DxtDecoder.cpp Normal file
View File

@ -0,0 +1,142 @@
#include "DxtDecoder.h"
namespace PKG {
// DXT 解压:每 4x4 像素为一个块
// - DXT1: 8 字节/块仅颜色1-bit alpha
// - DXT3: 16 字节/块(显式 alpha + 颜色)
// - DXT5: 16 字节/块(插值 alpha + 颜色)
void DxtDecoder::DecompressImage(int width, int height, std::vector<uint8_t>& data, DXTFlags flags) {
std::vector<uint8_t> rgba(width * height * 4);
int sourceBlockPos = 0;
int bytesPerBlock = (flags == DXTFlags::DXT1) ? 8 : 16;
// 循环外分配,避免每块重复分配
std::vector<uint8_t> targetRGBA(4 * 16); // 当前块 4x4 像素的 RGBA
std::vector<uint8_t> codes(16); // 4 个颜色调色板RGBA
std::vector<uint8_t> indices(16); // 每像素的调色板索引2-bit
std::vector<uint8_t> alphaCodes(8); // DXT5: 8 个 alpha 值
std::vector<uint8_t> alphaIndices(16); // DXT5: 每像素的 alpha 索引3-bit
for (int y = 0; y < height; y += 4) {
for (int x = 0; x < width; x += 4) {
if (static_cast<size_t>(sourceBlockPos) >= data.size())
continue;
// 颜色块位置DXT3/DXT5 前 8 字节是 alpha
int colorBlockIndex = sourceBlockPos;
if (flags == DXTFlags::DXT3 || flags == DXTFlags::DXT5)
colorBlockIndex += 8;
// 解码 2 个 16-bit RGB565 基色,插值出 4 个颜色
int a = data[colorBlockIndex] | (data[colorBlockIndex + 1] << 8);
int b = data[colorBlockIndex + 2] | (data[colorBlockIndex + 3] << 8);
codes[0] = (a >> 11) & 0x1F;
codes[1] = (a >> 5) & 0x3F;
codes[2] = a & 0x1F;
codes[3] = 255;
codes[4] = (b >> 11) & 0x1F;
codes[5] = (b >> 5) & 0x3F;
codes[6] = b & 0x1F;
codes[7] = 255;
for (int i = 0; i < 3; i++) {
int c = codes[i];
int d = codes[4 + i];
if (flags == DXTFlags::DXT1 && a <= b) {
codes[8 + i] = static_cast<uint8_t>((c + d) / 2);
codes[12 + i] = 0;
} else {
codes[8 + i] = static_cast<uint8_t>((2 * c + d) / 3);
codes[12 + i] = static_cast<uint8_t>((c + 2 * d) / 3);
}
}
codes[8 + 3] = 255;
codes[12 + 3] = (flags == DXTFlags::DXT1 && a <= b) ? 0 : 255;
// 解码 4x4 像素的 2-bit 颜色索引
for (int i = 0; i < 4; i++) {
int packed = data[colorBlockIndex + 4 + i];
indices[0 + i * 4] = packed & 0x3;
indices[1 + i * 4] = (packed >> 2) & 0x3;
indices[2 + i * 4] = (packed >> 4) & 0x3;
indices[3 + i * 4] = (packed >> 6) & 0x3;
}
// 根据索引查表得到 RGBA
for (int i = 0; i < 16; i++) {
int offset = 4 * indices[i];
targetRGBA[4 * i + 0] = (codes[offset] << 3) | (codes[offset] >> 2);
targetRGBA[4 * i + 1] = (codes[offset + 1] << 2) | (codes[offset + 1] >> 4);
targetRGBA[4 * i + 2] = (codes[offset + 2] << 3) | (codes[offset + 2] >> 2);
targetRGBA[4 * i + 3] = codes[offset + 3];
}
// 解码 alpha
if (flags == DXTFlags::DXT3) {
// DXT3: 显式 4-bit alpha
for (int i = 0; i < 8; i++) {
int quant = data[sourceBlockPos + i];
uint8_t lo = quant & 0x0F;
uint8_t hi = (quant >> 4) & 0x0F;
targetRGBA[8 * i + 3] = lo | (lo << 4);
targetRGBA[8 * i + 7] = hi | (hi << 4);
}
} else if (flags == DXTFlags::DXT5) {
// DXT5: 2 个 alpha 基值 + 3-bit 索引插值
uint8_t alpha0 = data[sourceBlockPos + 0];
uint8_t alpha1 = data[sourceBlockPos + 1];
alphaCodes[0] = alpha0;
alphaCodes[1] = alpha1;
if (alpha0 <= alpha1) {
for (int i = 1; i < 5; i++)
alphaCodes[1 + i] = static_cast<uint8_t>(((5 - i) * alpha0 + i * alpha1) / 5);
alphaCodes[6] = 0;
alphaCodes[7] = 255;
} else {
for (int i = 1; i < 7; i++)
alphaCodes[i + 1] = static_cast<uint8_t>(((7 - i) * alpha0 + i * alpha1) / 7);
}
// 解码 16 个 3-bit alpha 索引(共 6 字节)
int blockSrcPos = 2;
int indicesPos = 0;
for (int i = 0; i < 2; i++) {
int value = 0;
for (int j = 0; j < 3; j++)
value |= (data[sourceBlockPos + blockSrcPos++] << (8 * j));
for (int j = 0; j < 8; j++)
alphaIndices[indicesPos++] = (value >> (3 * j)) & 0x07;
}
for (int i = 0; i < 16; i++)
targetRGBA[4 * i + 3] = alphaCodes[alphaIndices[i]];
}
// 将 4x4 块写入目标图像
uint8_t targetRGBA_pos = 0;
for (int py = 0; py < 4; py++) {
for (int px = 0; px < 4; px++) {
int sx = x + px;
int sy = y + py;
if (sx < width && sy < height) {
int targetPixel = 4 * (width * sy + sx);
rgba[targetPixel + 0] = targetRGBA[targetRGBA_pos + 0];
rgba[targetPixel + 1] = targetRGBA[targetRGBA_pos + 1];
rgba[targetPixel + 2] = targetRGBA[targetRGBA_pos + 2];
rgba[targetPixel + 3] = targetRGBA[targetRGBA_pos + 3];
}
targetRGBA_pos += 4;
}
}
sourceBlockPos += bytesPerBlock;
}
}
data = std::move(rgba);
}
} // namespace PKG

18
src/Decoder/DxtDecoder.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef PKG_DXT_DECODER_H
#define PKG_DXT_DECODER_H
#include "Core/Types.h"
namespace PKG {
// DXT 块压缩纹理解码器
// 将 DXT1/DXT3/DXT5 压缩数据解压为 RGBA8888
class DxtDecoder {
public:
// 就地解压data 既输入压缩数据,也输出 RGBA8888 数据
static void DecompressImage(int width, int height, std::vector<uint8_t>& data, DXTFlags flags);
};
} // namespace PKG
#endif // PKG_DXT_DECODER_H

264
src/Decoder/ImageReader.cpp Normal file
View File

@ -0,0 +1,264 @@
#include "ImageReader.h"
#include "lz4.h"
namespace PKG {
// LZ4 解压
static std::vector<uint8_t> Lz4Decompress(const unsigned char* compressedData, size_t compressedSize, size_t decompressedSize) {
std::vector<uint8_t> output(decompressedSize);
int result = LZ4_decompress_safe(
reinterpret_cast<const char*>(compressedData),
reinterpret_cast<char*>(output.data()),
static_cast<int>(compressedSize),
static_cast<int>(decompressedSize));
if (result < 0 || static_cast<size_t>(result) != decompressedSize)
throw std::runtime_error("LZ4 decompression failed");
return output;
}
// ─── Mipmap 读取(按容器版本区分)──────────────────────────────────
// V1: [width][height][count][data:count]
static Result<TexMipMap> ReadMipMapV1(StreamReader& reader) {
auto widthRes = reader.ReadInt32();
if (!widthRes) return Fail<TexMipMap>(widthRes.error.code, widthRes.error.message);
auto heightRes = reader.ReadInt32();
if (!heightRes) return Fail<TexMipMap>(heightRes.error.code, heightRes.error.message);
auto countRes = reader.ReadInt32();
if (!countRes) return Fail<TexMipMap>(countRes.error.code, countRes.error.message);
std::vector<uint8_t> bytes;
auto dataRes = reader.ReadData(bytes, *countRes);
if (!dataRes) return Fail<TexMipMap>(dataRes.error.code, dataRes.error.message);
return Ok(TexMipMap{ *widthRes, *heightRes, 0, false, MipmapFormat::Invalid, std::move(bytes) });
}
// V2/V3: [width][height][compressed][decompressed][count][data:count]
static Result<TexMipMap> ReadMipMapV2AndV3(StreamReader& reader) {
auto widthRes = reader.ReadInt32();
if (!widthRes) return Fail<TexMipMap>(widthRes.error.code, widthRes.error.message);
auto heightRes = reader.ReadInt32();
if (!heightRes) return Fail<TexMipMap>(heightRes.error.code, heightRes.error.message);
auto compressedRes = reader.ReadInt32();
if (!compressedRes) return Fail<TexMipMap>(compressedRes.error.code, compressedRes.error.message);
auto decompressedRes = reader.ReadInt32();
if (!decompressedRes) return Fail<TexMipMap>(decompressedRes.error.code, decompressedRes.error.message);
auto countRes = reader.ReadInt32();
if (!countRes) return Fail<TexMipMap>(countRes.error.code, countRes.error.message);
std::vector<uint8_t> bytes;
auto dataRes = reader.ReadData(bytes, *countRes);
if (!dataRes) return Fail<TexMipMap>(dataRes.error.code, dataRes.error.message);
return Ok(TexMipMap{ *widthRes, *heightRes, *decompressedRes,
(*compressedRes) == 1, MipmapFormat::Invalid, std::move(bytes) });
}
// V4: [param1][param2][condition:NString][param3] + V2/V3 数据
static Result<TexMipMap> ReadMipMapV4(StreamReader& reader) {
auto param1Res = reader.ReadInt32();
if (!param1Res) return Fail<TexMipMap>(param1Res.error.code, param1Res.error.message);
auto param2Res = reader.ReadInt32();
if (!param2Res) return Fail<TexMipMap>(param2Res.error.code, param2Res.error.message);
auto conditionRes = reader.ReadNString();
if (!conditionRes) return Fail<TexMipMap>(conditionRes.error.code, conditionRes.error.message);
auto param3Res = reader.ReadInt32();
if (!param3Res) return Fail<TexMipMap>(param3Res.error.code, param3Res.error.message);
return ReadMipMapV2AndV3(reader);
}
// ─── 格式映射 ─────────────────────────────────────────────────────
// FreeImage 格式 → MipmapFormat已编码图像
static MipmapFormat FreeImageToMipmap(FreeImageFormat fmt) {
switch (fmt) {
case FreeImageFormat::FIF_BMP: return MipmapFormat::ImageBMP;
case FreeImageFormat::FIF_ICO: return MipmapFormat::ImageICO;
case FreeImageFormat::FIF_JPEG: return MipmapFormat::ImageJPEG;
case FreeImageFormat::FIF_JNG: return MipmapFormat::ImageJNG;
case FreeImageFormat::FIF_KOALA: return MipmapFormat::ImageKOALA;
case FreeImageFormat::FIF_LBM: return MipmapFormat::ImageLBM;
// FIF_IFF 与 FIF_LBM 同值(均为 5共用一个 case
case FreeImageFormat::FIF_MNG: return MipmapFormat::ImageMNG;
case FreeImageFormat::FIF_PBM: return MipmapFormat::ImagePBM;
case FreeImageFormat::FIF_PBMRAW: return MipmapFormat::ImagePBMRAW;
case FreeImageFormat::FIF_PCD: return MipmapFormat::ImagePCD;
case FreeImageFormat::FIF_PCX: return MipmapFormat::ImagePCX;
case FreeImageFormat::FIF_PGM: return MipmapFormat::ImagePGM;
case FreeImageFormat::FIF_PGMRAW: return MipmapFormat::ImagePGMRAW;
case FreeImageFormat::FIF_PNG: return MipmapFormat::ImagePNG;
case FreeImageFormat::FIF_PPM: return MipmapFormat::ImagePPM;
case FreeImageFormat::FIF_PPMRAW: return MipmapFormat::ImagePPMRAW;
case FreeImageFormat::FIF_RAS: return MipmapFormat::ImageRAS;
case FreeImageFormat::FIF_TARGA: return MipmapFormat::ImageTARGA;
case FreeImageFormat::FIF_TIFF: return MipmapFormat::ImageTIFF;
case FreeImageFormat::FIF_WBMP: return MipmapFormat::ImageWBMP;
case FreeImageFormat::FIF_PSD: return MipmapFormat::ImagePSD;
case FreeImageFormat::FIF_CUT: return MipmapFormat::ImageCUT;
case FreeImageFormat::FIF_XBM: return MipmapFormat::ImageXBM;
case FreeImageFormat::FIF_XPM: return MipmapFormat::ImageXPM;
case FreeImageFormat::FIF_DDS: return MipmapFormat::ImageDDS;
case FreeImageFormat::FIF_GIF: return MipmapFormat::ImageGIF;
case FreeImageFormat::FIF_HDR: return MipmapFormat::ImageHDR;
case FreeImageFormat::FIF_FAXG3: return MipmapFormat::ImageFAXG3;
case FreeImageFormat::FIF_SGI: return MipmapFormat::ImageSGI;
case FreeImageFormat::FIF_EXR: return MipmapFormat::ImageEXR;
case FreeImageFormat::FIF_J2K: return MipmapFormat::ImageJ2K;
case FreeImageFormat::FIF_JP2: return MipmapFormat::ImageJP2;
case FreeImageFormat::FIF_PFM: return MipmapFormat::ImagePFM;
case FreeImageFormat::FIF_PICT: return MipmapFormat::ImagePICT;
case FreeImageFormat::FIF_RAW: return MipmapFormat::ImageRAW;
case FreeImageFormat::FIF_MP4: return MipmapFormat::VideoMp4;
default: return MipmapFormat::Invalid;
}
}
// TexFormat → MipmapFormat原始像素或 DXT 压缩)
static MipmapFormat TexToMipmap(TexFormat fmt) {
switch (fmt) {
case TexFormat::RGBA8888: return MipmapFormat::RGBA8888;
case TexFormat::DXT5: return MipmapFormat::CompressedDXT5;
case TexFormat::DXT3: return MipmapFormat::CompressedDXT3;
case TexFormat::DXT1: return MipmapFormat::CompressedDXT1;
case TexFormat::RG88: return MipmapFormat::RG88;
case TexFormat::R8: return MipmapFormat::R8;
default: return MipmapFormat::Invalid;
}
}
// 综合格式判定:优先使用 FreeImage 格式,否则用 TexFormat
static MipmapFormat GetFormatFromTex(FreeImageFormat imageFormat, TexFormat format) {
if (imageFormat != FreeImageFormat::FIF_UNKNOWN)
return FreeImageToMipmap(imageFormat);
return TexToMipmap(format);
}
// ─── 公开接口 ─────────────────────────────────────────────────────
Result<TexImage> ImageReader::ReadFrom(StreamReader& reader, const TexImageContainer& container, TexFormat format) {
auto mipMapCountRes = reader.ReadInt32();
if (!mipMapCountRes)
return Fail<TexImage>(mipMapCountRes.error.code, mipMapCountRes.error.message);
MipmapFormat aFormat = GetFormatFromTex(container.ImageFormat, format);
TexImage image{};
for (int i = 0; i < *mipMapCountRes; i++) {
TexMipMap mipmap{};
switch (container.imageContainerVersion) {
case ImageContainerVersion::VERSION1:
{
auto res = ReadMipMapV1(reader);
if (!res) return Fail<TexImage>(res.error.code, res.error.message);
mipmap = *res;
break;
}
case ImageContainerVersion::VERSION2:
case ImageContainerVersion::VERSION3:
{
auto res = ReadMipMapV2AndV3(reader);
if (!res) return Fail<TexImage>(res.error.code, res.error.message);
mipmap = *res;
break;
}
case ImageContainerVersion::VERSION4:
{
auto res = ReadMipMapV4(reader);
if (!res) return Fail<TexImage>(res.error.code, res.error.message);
mipmap = *res;
break;
}
}
mipmap.Format = aFormat;
// LZ4 解压
if (mipmap.IsZ4Compressed) {
try {
mipmap.Data = Lz4Decompress(mipmap.Data.data(), mipmap.Data.size(), mipmap.DecompressedDataCount);
mipmap.IsZ4Compressed = false;
} catch (const std::exception& e) {
return Fail<TexImage>(ErrorCode::DecompressFailed, e.what());
}
}
image.Mipmaps.push_back(mipmap);
}
return Ok(std::move(image));
}
// TEXB 容器结构:
// [magic:NString] "TEXB0001"~"TEXB0004"
// [imageCount:int32]
// V3: [imageFormat:int32]
// V4: [imageFormat:int32][isVideo:int32] (FIF_UNKNOWN + isVideo=1 → MP4)
// repeat imageCount: <TexImage>
Result<TexImageContainer> ImageReader::ReadContainer(StreamReader& reader, TexFormat texFormat) {
TexImageContainer container{};
auto magicRes = reader.ReadNString();
if (!magicRes)
return Fail<TexImageContainer>(magicRes.error.code, magicRes.error.message);
container.Magic = *magicRes;
auto imageCountRes = reader.ReadInt32();
if (!imageCountRes)
return Fail<TexImageContainer>(imageCountRes.error.code, imageCountRes.error.message);
// 按版本读取附加字段
if (container.Magic == "TEXB0003") {
auto formatRes = reader.ReadInt32();
if (!formatRes) return Fail<TexImageContainer>(formatRes.error.code, formatRes.error.message);
container.ImageFormat = static_cast<FreeImageFormat>(*formatRes);
} else if (container.Magic == "TEXB0004") {
auto formatRes = reader.ReadInt32();
if (!formatRes) return Fail<TexImageContainer>(formatRes.error.code, formatRes.error.message);
auto format = static_cast<FreeImageFormat>(*formatRes);
auto isVideoRes = reader.ReadInt32();
if (!isVideoRes) return Fail<TexImageContainer>(isVideoRes.error.code, isVideoRes.error.message);
// 视频纹理FIF_UNKNOWN + isVideo=1 → MP4
if (format == FreeImageFormat::FIF_UNKNOWN && (*isVideoRes) == 1)
format = FreeImageFormat::FIF_MP4;
container.ImageFormat = format;
} else if (container.Magic != "TEXB0001" && container.Magic != "TEXB0002") {
return Fail<TexImageContainer>(ErrorCode::BadMagic, "Invalid TEXB magic: " + container.Magic);
}
// 从魔数提取版本号("TEXB0003" → 3
int version = std::stoi(container.Magic.substr(4, 4));
container.imageContainerVersion = static_cast<ImageContainerVersion>(version);
// V4 仅对 MP4 有效,其余降级为 V3
if (container.imageContainerVersion == ImageContainerVersion::VERSION4
&& container.ImageFormat != FreeImageFormat::FIF_MP4)
container.imageContainerVersion = ImageContainerVersion::VERSION3;
for (int i = 0; i < *imageCountRes; i++) {
auto imageRes = ReadFrom(reader, container, texFormat);
if (!imageRes)
return Fail<TexImageContainer>(imageRes.error.code, imageRes.error.message);
container.Images.push_back(*imageRes);
}
return Ok(std::move(container));
}
} // namespace PKG

22
src/Decoder/ImageReader.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef PKG_IMAGE_READER_H
#define PKG_IMAGE_READER_H
#include "Core/Types.h"
#include "Core/Result.h"
#include "IO/StreamReader.h"
namespace PKG {
// TEX 图像容器与 mipmap 读取器
class ImageReader {
public:
// 读取单张图像(含多个 mipmap 层级)
static Result<TexImage> ReadFrom(StreamReader& reader, const TexImageContainer& container, TexFormat format);
// 读取图像容器TEXB 块)
static Result<TexImageContainer> ReadContainer(StreamReader& reader, TexFormat texFormat);
};
} // namespace PKG
#endif // PKG_IMAGE_READER_H

View File

@ -0,0 +1,67 @@
#include "PkgExtractor.h"
namespace PKG {
// PKG 文件结构:
// [magicLen:int32][magic:string(magicLen)] // "PKG..."
// [count:int32]
// repeat count:
// [pathLen:int32][path:string(pathLen)]
// [offset:int32][length:int32]
// <数据区offset 相对此处>
Result<std::vector<Entry>> PkgExtractor::ParseIndex(StreamReader& reader) {
// 读取魔数
auto headRes = reader.ReadInt32();
if (!headRes)
return Fail<std::vector<Entry>>(headRes.error.code, headRes.error.message);
auto magicHeaderRes = reader.ReadString(*headRes);
if (!magicHeaderRes)
return Fail<std::vector<Entry>>(magicHeaderRes.error.code, magicHeaderRes.error.message);
if (magicHeaderRes->substr(0, 3) != "PKG")
return Fail<std::vector<Entry>>(ErrorCode::BadMagic, "Invalid PKG header: " + *magicHeaderRes);
// 读取条目数
auto countRes = reader.ReadInt32();
if (!countRes)
return Fail<std::vector<Entry>>(countRes.error.code, countRes.error.message);
if (*countRes <= 0)
return Fail<std::vector<Entry>>(ErrorCode::InvalidArgument, "No entries found");
// 逐条解析索引
std::vector<Entry> entries;
entries.reserve(*countRes);
for (int i = 0; i < *countRes; i++) {
Entry entry{};
auto sizeRes = reader.ReadInt32();
if (!sizeRes)
return Fail<std::vector<Entry>>(sizeRes.error.code, sizeRes.error.message);
auto pathRes = reader.ReadString(*sizeRes);
if (!pathRes)
return Fail<std::vector<Entry>>(pathRes.error.code, pathRes.error.message);
entry.FullPath = std::filesystem::path(*pathRes).make_preferred();
auto offsetRes = reader.ReadInt32();
if (!offsetRes)
return Fail<std::vector<Entry>>(offsetRes.error.code, offsetRes.error.message);
entry.Offset = *offsetRes;
auto lengthRes = reader.ReadInt32();
if (!lengthRes)
return Fail<std::vector<Entry>>(lengthRes.error.code, lengthRes.error.message);
entry.Length = *lengthRes;
entry.Type = entry.FullPath.extension().string();
entries.push_back(entry);
}
return Ok(std::move(entries));
}
} // namespace PKG

View File

@ -0,0 +1,19 @@
#ifndef PKG_PKG_EXTRACTOR_H
#define PKG_PKG_EXTRACTOR_H
#include "Core/Types.h"
#include "Core/Result.h"
#include "IO/StreamReader.h"
namespace PKG {
// PKG/MPKG 包索引解析器
// 解析包头部与文件索引表,返回所有条目的元信息
class PkgExtractor {
public:
Result<std::vector<Entry>> ParseIndex(StreamReader& reader);
};
} // namespace PKG
#endif // PKG_PKG_EXTRACTOR_H

View File

@ -0,0 +1,75 @@
#include "TexDecoder.h"
#include "ImageReader.h"
namespace PKG {
// TEX 文件结构:
// [magic1:NString(16)] "TEXV0005"
// [magic2:NString(16)] "TEXI0001"
// [format:int32] TexFormat
// [flags:int32] TexType 标志位
// [texW:int32][texH:int32] 纹理尺寸
// [imgW:int32][imgH:int32] 图像尺寸
// [unk:uint32]
// <TexImageContainer> 图像数据TEXB 块)
Result<Tex> TexDecoder::Decode(StreamReader& reader) {
Tex tex{};
// 校验魔数
auto magic1Res = reader.ReadNString(16);
if (!magic1Res)
return Fail<Tex>(magic1Res.error.code, magic1Res.error.message);
tex.Magic1 = *magic1Res;
if (tex.Magic1 != "TEXV0005")
return Fail<Tex>(ErrorCode::BadMagic, "Invalid TEX magic1: " + tex.Magic1);
auto magic2Res = reader.ReadNString(16);
if (!magic2Res)
return Fail<Tex>(magic2Res.error.code, magic2Res.error.message);
tex.Magic2 = *magic2Res;
if (tex.Magic2 != "TEXI0001")
return Fail<Tex>(ErrorCode::BadMagic, "Invalid TEX magic2: " + tex.Magic2);
// 读取头部字段
auto formatRes = reader.ReadInt32();
if (!formatRes) return Fail<Tex>(formatRes.error.code, formatRes.error.message);
tex.Header.Format = static_cast<TexFormat>(*formatRes);
auto flagsRes = reader.ReadInt32();
if (!flagsRes) return Fail<Tex>(flagsRes.error.code, flagsRes.error.message);
tex.Header.Flags = static_cast<TexType>(*flagsRes);
auto texWidthRes = reader.ReadInt32();
if (!texWidthRes) return Fail<Tex>(texWidthRes.error.code, texWidthRes.error.message);
tex.Header.TextureWidth = *texWidthRes;
auto texHeightRes = reader.ReadInt32();
if (!texHeightRes) return Fail<Tex>(texHeightRes.error.code, texHeightRes.error.message);
tex.Header.TextureHeight = *texHeightRes;
auto imgWidthRes = reader.ReadInt32();
if (!imgWidthRes) return Fail<Tex>(imgWidthRes.error.code, imgWidthRes.error.message);
tex.Header.ImageWidth = *imgWidthRes;
auto imgHeightRes = reader.ReadInt32();
if (!imgHeightRes) return Fail<Tex>(imgHeightRes.error.code, imgHeightRes.error.message);
tex.Header.ImageHeight = *imgHeightRes;
auto unkRes = reader.ReadUInt32();
if (!unkRes) return Fail<Tex>(unkRes.error.code, unkRes.error.message);
tex.Header.UnkInt0 = *unkRes;
// 解析标志位
tex.IsGif = (static_cast<int>(tex.Header.Flags) & static_cast<int>(TexType::IsGif)) != 0;
tex.IsVideoTexture = (static_cast<int>(tex.Header.Flags) & static_cast<int>(TexType::IsVideoTexture)) != 0;
// 读取图像容器
auto containerRes = ImageReader::ReadContainer(reader, tex.Header.Format);
if (!containerRes)
return Fail<Tex>(containerRes.error.code, containerRes.error.message);
tex.ImageContainer = *containerRes;
return Ok(std::move(tex));
}
} // namespace PKG

20
src/Decoder/TexDecoder.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef PKG_TEX_DECODER_H
#define PKG_TEX_DECODER_H
#include "Core/Types.h"
#include "Core/Result.h"
#include "IO/StreamReader.h"
namespace PKG {
// TEX 纹理文件解码器
// 解析 TEXV0005/TEXI0001 头部与图像容器TEXB 块)
// GIF 帧信息TEXS 块)由 ExtractPipeline::ReadGifFrameInfo 单独读取
class TexDecoder {
public:
Result<Tex> Decode(StreamReader& reader);
};
} // namespace PKG
#endif // PKG_TEX_DECODER_H

View File

@ -0,0 +1,223 @@
#include "ImageEncoder.h"
#include "IO/StreamWriter.h"
#include "Decoder/DxtDecoder.h"
#include "gif.h"
#include <memory>
#include <unordered_map>
extern "C" unsigned char* stbi_write_png_to_mem(const unsigned char* pixels, int stride_bytes,
int x, int y, int n, int* out_len);
namespace PKG
{
// ─── RAII 工具 ───────────────────────────────────────────────────
// 管理 stbi_write_png_to_mem 返回的 C 缓冲,确保任何退出路径都释放
struct StbiPngBufferDeleter {
void operator()(uint8_t* p) const { free(p); }
};
using StbiPngBuffer = std::unique_ptr<uint8_t, StbiPngBufferDeleter>;
// GifWriter 的 RAII 守卫:构造时调用 GifBegin析构时调用 GifEnd
// 保证即使编码过程中抛异常或提前 return文件句柄和 oldImage 都被释放
class GifWriterGuard {
public:
GifWriterGuard() = default;
// 调用 GifBegin 初始化;成功返回 true失败返回 false
bool Begin(const char* filename, uint32_t width, uint32_t height, uint32_t delay)
{
return GifBegin(&m_Writer, filename, width, height, delay);
}
GifWriter* Get() { return &m_Writer; }
~GifWriterGuard()
{
if (m_Writer.f) // f 非空表示 GifBegin 成功,需要清理
GifEnd(&m_Writer);
}
GifWriterGuard(const GifWriterGuard&) = delete;
GifWriterGuard& operator=(const GifWriterGuard&) = delete;
private:
GifWriter m_Writer{};
};
// ─── 格式 → 扩展名映射表 ─────────────────────────────────────────
// 使用静态 map 替代冗长的 switch-case便于维护和扩展
static const std::unordered_map<MipmapFormat, std::string>& FormatExtensionMap()
{
static const std::unordered_map<MipmapFormat, std::string> map = {
{MipmapFormat::ImageBMP, "bmp"},
{MipmapFormat::ImageICO, "ico"},
{MipmapFormat::ImageJPEG, "jpg"},
{MipmapFormat::ImageJNG, "jng"},
{MipmapFormat::ImageKOALA, "koa"},
{MipmapFormat::ImageLBM, "lbm"},
{MipmapFormat::ImageIFF, "iff"},
{MipmapFormat::ImageMNG, "mng"},
{MipmapFormat::ImagePBM, "pbm"},
{MipmapFormat::ImagePBMRAW, "pbm"},
{MipmapFormat::ImagePCD, "pcd"},
{MipmapFormat::ImagePCX, "pcx"},
{MipmapFormat::ImagePGM, "pgm"},
{MipmapFormat::ImagePGMRAW, "pgm"},
{MipmapFormat::ImagePNG, "png"},
{MipmapFormat::ImagePPM, "ppm"},
{MipmapFormat::ImagePPMRAW, "ppm"},
{MipmapFormat::ImageRAS, "ras"},
{MipmapFormat::ImageTARGA, "tga"},
{MipmapFormat::ImageTIFF, "tif"},
{MipmapFormat::ImageWBMP, "wbmp"},
{MipmapFormat::ImagePSD, "psd"},
{MipmapFormat::ImageCUT, "cut"},
{MipmapFormat::ImageXBM, "xbm"},
{MipmapFormat::ImageXPM, "xpm"},
{MipmapFormat::ImageDDS, "dds"},
{MipmapFormat::ImageGIF, "gif"},
{MipmapFormat::ImageHDR, "hdr"},
{MipmapFormat::ImageFAXG3, "g3"},
{MipmapFormat::ImageSGI, "sgi"},
{MipmapFormat::ImageEXR, "exr"},
{MipmapFormat::ImageJ2K, "j2k"},
{MipmapFormat::ImageJP2, "jp2"},
{MipmapFormat::ImagePFM, "pfm"},
{MipmapFormat::ImagePICT, "pict"},
{MipmapFormat::ImageRAW, "raw"},
{MipmapFormat::VideoMp4, "mp4"},
};
return map;
}
std::string GetFileExtension(MipmapFormat format)
{
const auto& map = FormatExtensionMap();
auto it = map.find(format);
return it != map.end() ? it->second : "unknown";
}
// ─── PNG 编码 ────────────────────────────────────────────────────
// 将原始像素数据R8/RG88/RGBA8888编码为 PNG 文件
// 使用 stb_image_write 的内存编码接口,再一次性写入磁盘
Result<void> ImageEncoder::EncodePng(const TexMipMap& mipmap, const std::filesystem::path& outPath)
{
// 根据像素格式确定通道数
int channel = 4;
switch (mipmap.Format)
{
case MipmapFormat::R8: channel = 1; break;
case MipmapFormat::RG88: channel = 2; break;
case MipmapFormat::RGBA8888: channel = 4; break;
default:
return Fail(ErrorCode::UnsupportedFormat, "Unsupported format for PNG encoding");
}
// 编码到内存缓冲StbiPngBuffer 的 RAII 析构会自动 free无需手动释放
int len = 0;
StbiPngBuffer data(stbi_write_png_to_mem(mipmap.Data.data(), mipmap.Width * channel,
mipmap.Width, mipmap.Height, channel, &len));
if (!data)
return Fail(ErrorCode::EncodeFailed, "Failed to encode PNG");
// 写入磁盘
StreamWriter writer(outPath, std::ios::binary);
return writer.WriteBytes(reinterpret_cast<const char*>(data.get()), len);
}
// ─── GIF 编码 ────────────────────────────────────────────────────
// 逐帧处理策略(降低峰值内存):
// 1. 遍历每张源图像(图集),仅对当前图像执行 DXT 解压
// 2. 从解压后的图集中按帧信息裁剪出每一帧
// 3. 写入 GIF 后立即释放该图集的像素数据
// 这样任意时刻内存中最多只保留一张图集的 RGBA 数据
Result<void> ImageEncoder::EncodeGif(Tex& tex, const std::filesystem::path& outPath)
{
// GifWriterGuard 在析构时自动调用 GifEnd保证异常/提前返回时也释放资源
GifWriterGuard writer;
// GIF 帧延时单位1/100 秒
uint32_t delay = static_cast<uint32_t>(tex.FrameInfoContainer.Frames[0].Frametime * 100);
if (!writer.Begin(outPath.string().c_str(),
static_cast<uint32_t>(tex.FrameInfoContainer.Frames[0].Width),
static_cast<uint32_t>(tex.FrameInfoContainer.Frames[0].Height), delay))
return Fail(ErrorCode::EncodeFailed, "Failed to create GIF file");
int frameIndex = 0; // 已写入的全局帧序号
int imageIndex = 1; // 当前图集序号(用于计算帧边界)
for (auto& image : tex.ImageContainer.Images)
{
if (image.Mipmaps.empty())
continue;
auto& mipmap = image.Mipmaps[0];
// 就地 DXT 解压(仅当前帧所在的图集),避免一次性解压所有图集
switch (mipmap.Format)
{
case MipmapFormat::CompressedDXT5:
DxtDecoder::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT5);
mipmap.Format = MipmapFormat::RGBA8888;
break;
case MipmapFormat::CompressedDXT3:
DxtDecoder::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT3);
mipmap.Format = MipmapFormat::RGBA8888;
break;
case MipmapFormat::CompressedDXT1:
DxtDecoder::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT1);
mipmap.Format = MipmapFormat::RGBA8888;
break;
default:
break;
}
// 当前图集可切分出的帧数(图集尺寸 / 单帧尺寸)
int singleImageFrameCount = (mipmap.Width / tex.FrameInfoContainer.GifWidth)
* (mipmap.Height / tex.FrameInfoContainer.GifHeight);
// 从图集中逐帧裁剪并写入 GIF
for (; frameIndex < singleImageFrameCount * imageIndex
&& frameIndex < static_cast<int>(tex.FrameInfoContainer.Frames.size());
frameIndex++)
{
const auto& frameInfo = tex.FrameInfoContainer.Frames[frameIndex];
std::vector<uint8_t> frameImage;
frameImage.reserve(static_cast<size_t>(frameInfo.Width) * frameInfo.Height * 4);
// 按行裁剪:从图集的 (PosX, PosY) 处取 Width×Height 的像素块
for (int row = 0; row < tex.FrameInfoContainer.GifHeight; row++)
{
auto lineStart = mipmap.Data.begin()
+ mipmap.Width * 4 * (static_cast<int>(frameInfo.PosY) + row)
+ static_cast<int>(frameInfo.PosX) * 4;
auto lineEnd = lineStart + static_cast<int>(frameInfo.Width) * 4;
frameImage.insert(frameImage.end(), lineStart, lineEnd);
}
GifWriteFrame(writer.Get(), frameImage.data(),
static_cast<uint32_t>(frameInfo.Width),
static_cast<uint32_t>(frameInfo.Height), delay);
}
imageIndex++;
// 释放已编码图集的像素数据,降低峰值内存
std::vector<uint8_t>().swap(mipmap.Data);
}
// writer 析构时自动调用 GifEnd
return Ok();
}
// ─── 原始数据写出 ────────────────────────────────────────────────
// 直接将 mipmap 数据写入文件,不做任何转码
// 用于 MP4 视频纹理或已编码图像PNG/JPEG 等)
Result<void> ImageEncoder::EncodeRaw(const TexMipMap& mipmap, const std::filesystem::path& outPath)
{
StreamWriter writer(outPath, std::ios::binary);
return writer.WriteBytes(reinterpret_cast<const char*>(mipmap.Data.data()),
static_cast<uint32_t>(mipmap.Data.size()));
}
}

View File

@ -0,0 +1,24 @@
#ifndef PKG_IMAGE_ENCODER_H
#define PKG_IMAGE_ENCODER_H
#include "Core/Types.h"
#include "Core/Result.h"
namespace PKG
{
// 图像编码器:将 TEX mipmap 数据编码为 PNG/GIF 或直接写出原始数据
class ImageEncoder
{
public:
// PNG 编码:支持 R8/RG88/RGBA8888 像素格式
Result<void> EncodePng(const TexMipMap& mipmap, const std::filesystem::path& outPath);
// GIF 编码:逐帧 DXT 解压 + 裁剪,降低峰值内存
Result<void> EncodeGif(Tex& tex, const std::filesystem::path& outPath);
// 原始数据写出:用于 MP4 视频纹理或已编码图像
Result<void> EncodeRaw(const TexMipMap& mipmap, const std::filesystem::path& outPath);
};
}
#endif // PKG_IMAGE_ENCODER_H

125
src/IO/StreamReader.cpp Normal file
View File

@ -0,0 +1,125 @@
#include "StreamReader.h"
namespace PKG {
StreamReader::StreamReader(const std::filesystem::path& fileName)
: m_FilePath(fileName.string()) {
m_File.open(m_FilePath, std::ios::in | std::ios::binary);
if (m_File.is_open())
m_Stream = &m_File;
}
StreamReader::StreamReader(std::string data)
: m_MemoryStream(std::move(data), std::ios::in | std::ios::binary)
, m_Stream(&m_MemoryStream)
, m_FilePath("<memory>") {
}
StreamReader::~StreamReader() {
if (m_File.is_open())
m_File.close();
}
Result<int32_t> StreamReader::ReadInt32() {
int32_t result = 0;
m_Stream->read(reinterpret_cast<char*>(&result), sizeof(int32_t));
if (m_Stream->fail())
return Fail<int32_t>(ErrorCode::ReadFailed, "Failed to read int32");
return Ok(result);
}
Result<uint32_t> StreamReader::ReadUInt32() {
uint32_t result = 0;
m_Stream->read(reinterpret_cast<char*>(&result), sizeof(uint32_t));
if (m_Stream->fail())
return Fail<uint32_t>(ErrorCode::ReadFailed, "Failed to read uint32");
return Ok(result);
}
Result<float> StreamReader::ReadSingle() {
float result = 0;
m_Stream->read(reinterpret_cast<char*>(&result), sizeof(float));
if (m_Stream->fail())
return Fail<float>(ErrorCode::ReadFailed, "Failed to read float");
return Ok(result);
}
Result<char> StreamReader::ReadChar() {
char result = 0;
m_Stream->read(&result, sizeof(char));
if (m_Stream->fail())
return Fail<char>(ErrorCode::ReadFailed, "Failed to read char");
return Ok(result);
}
Result<std::string> StreamReader::ReadString(uint32_t length) {
std::vector<uint8_t> result(length);
m_Stream->read(reinterpret_cast<char*>(result.data()), length);
if (m_Stream->fail())
return Fail<std::string>(ErrorCode::ReadFailed, "Failed to read string");
// 按 UTF-8 路径解码(处理多字节字符文件名)
return Ok(std::filesystem::u8path(
std::string(reinterpret_cast<const char*>(result.data()), length)).string());
}
Result<std::string> StreamReader::ReadNString(int32_t maxLength) {
std::vector<uint8_t> result;
int count = 0;
while (maxLength == -1 || count < maxLength) {
auto readRes = ReadChar();
if (!readRes)
return Fail<std::string>(readRes.error.code, readRes.error.message);
char chr = *readRes;
if (chr == '\0')
break;
result.push_back(chr);
count++;
}
return Ok(std::string(reinterpret_cast<const char*>(result.data()), result.size()));
}
Result<std::string> StreamReader::ReadStringFileData(uint32_t length) {
std::vector<uint8_t> result(length);
m_Stream->read(reinterpret_cast<char*>(result.data()), length);
if (m_Stream->fail())
return Fail<std::string>(ErrorCode::ReadFailed, "Failed to read file data");
return Ok(std::string(reinterpret_cast<const char*>(result.data()), length));
}
Result<void> StreamReader::ReadData(std::string& data, uint32_t length) {
data.resize(length);
m_Stream->read(data.data(), length);
if (m_Stream->fail())
return Fail(ErrorCode::ReadFailed, "Failed to read data to string");
return Ok();
}
Result<void> StreamReader::ReadData(std::vector<uint8_t>& data, uint32_t length) {
data.resize(length);
m_Stream->read(reinterpret_cast<char*>(data.data()), length);
if (m_Stream->fail())
return Fail(ErrorCode::ReadFailed, "Failed to read data to vector");
return Ok();
}
void StreamReader::seekg(pos_type pos) {
m_Stream->seekg(pos);
}
pos_type StreamReader::tellg() {
return m_Stream->tellg();
}
std::string StreamReader::GetFilePath() const {
return m_FilePath;
}
std::string StreamReader::GetFileName() const {
return m_FilePath.substr(m_FilePath.find_last_of("\\/") + 1);
}
} // namespace PKG

57
src/IO/StreamReader.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef PKG_STREAM_READER_H
#define PKG_STREAM_READER_H
#include <filesystem>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "Core/Result.h"
namespace PKG {
using pos_type = long long;
// 流式读取器:支持文件模式与内存模式
// - 文件模式:从磁盘文件读取
// - 内存模式:从 std::string 缓冲区读取(避免中间文件 I/O
// 两种模式通过 m_Stream 指针统一操作
class StreamReader {
public:
explicit StreamReader(const std::filesystem::path& fileName); // 文件模式
explicit StreamReader(std::string data); // 内存模式move 语义,零拷贝)
~StreamReader();
// 基本类型读取(小端序)
Result<int32_t> ReadInt32();
Result<uint32_t> ReadUInt32();
Result<float> ReadSingle();
Result<char> ReadChar();
// 字符串读取
Result<std::string> ReadString(uint32_t length); // 读取 length 字节并按 UTF-8 路径解码
Result<std::string> ReadNString(int32_t maxLength = -1); // 读取 NUL 结尾字符串
Result<std::string> ReadStringFileData(uint32_t length); // 读取 length 字节为原始字符串
// 数据块读取
Result<void> ReadData(std::string& data, uint32_t length);
Result<void> ReadData(std::vector<uint8_t>& data, uint32_t length);
void seekg(pos_type pos);
pos_type tellg();
bool IsOpen() const { return m_Stream != nullptr; }
std::string GetFilePath() const;
std::string GetFileName() const;
private:
std::ifstream m_File; // 文件模式底层流
std::istringstream m_MemoryStream; // 内存模式底层流
std::istream* m_Stream = nullptr; // 统一操作指针(指向 m_File 或 m_MemoryStream
std::string m_FilePath;
};
} // namespace PKG
#endif // PKG_STREAM_READER_H

46
src/IO/StreamWriter.cpp Normal file
View File

@ -0,0 +1,46 @@
#include "StreamWriter.h"
namespace PKG {
StreamWriter::StreamWriter(const std::filesystem::path& fileName, std::ios_base::openmode optMode)
: m_FilePath(fileName.string()) {
// 自动创建父目录多线程安全create_directories 对已存在目录是 no-op
const std::filesystem::path parent = fileName.parent_path();
if (!parent.empty() && !std::filesystem::exists(parent))
std::filesystem::create_directories(parent);
m_File.open(m_FilePath, optMode);
}
StreamWriter::~StreamWriter() {
close();
}
Result<void> StreamWriter::WriteBytes(const char* data, uint32_t size) {
m_File.write(data, size);
if (m_File.fail())
return Fail(ErrorCode::WriteFailed, "Failed to write bytes");
return Ok();
}
Result<void> StreamWriter::WriteString(const std::string& str) {
m_File.write(str.c_str(), str.size());
if (m_File.fail())
return Fail(ErrorCode::WriteFailed, "Failed to write string");
return Ok();
}
void StreamWriter::close() {
if (m_File.is_open())
m_File.close();
}
std::string StreamWriter::GetFilePath() const {
return m_FilePath;
}
std::string StreamWriter::GetFileName() const {
return m_FilePath.substr(m_FilePath.find_last_of("\\/") + 1);
}
} // namespace PKG

34
src/IO/StreamWriter.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef PKG_STREAM_WRITER_H
#define PKG_STREAM_WRITER_H
#include <filesystem>
#include <fstream>
#include <string>
#include "Core/Result.h"
namespace PKG {
// 文件写入器:构造时自动创建父目录
class StreamWriter {
public:
StreamWriter() = delete;
explicit StreamWriter(const std::filesystem::path& fileName,
std::ios_base::openmode optMode = std::ios::out);
~StreamWriter();
Result<void> WriteBytes(const char* data, uint32_t size);
Result<void> WriteString(const std::string& str);
void close();
std::string GetFilePath() const;
std::string GetFileName() const;
private:
std::ofstream m_File;
std::string m_FilePath;
};
} // namespace PKG
#endif // PKG_STREAM_WRITER_H

View File

@ -0,0 +1,528 @@
#include "Core/Logger.h"
#include "Core/ProgressBar.h"
#include "Decoder/DxtDecoder.h"
#include "Decoder/PkgExtractor.h"
#include "Decoder/TexDecoder.h"
#include "Encoder/ImageEncoder.h"
#include "ExtractPipeline.h"
#include "IO/StreamReader.h"
#include "IO/StreamWriter.h"
#include "TaskScheduler.h"
#include <algorithm>
#include <chrono>
namespace PKG {
// ─── RAII 计时器 ─────────────────────────────────────────────────
// 构造时记录起始时间,析构时打印耗时(自动选择 ms/s 单位)
class ScopedTimer {
public:
ScopedTimer() : m_Start(std::chrono::steady_clock::now()) {}
~ScopedTimer() {
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now() - m_Start)
.count();
if (ms < 1000)
Logger::Instance().Info("Time: " + std::to_string(ms) + " ms");
else
Logger::Instance().Info("Time: " + std::to_string(ms / 1000.0) + " s");
}
private:
std::chrono::steady_clock::time_point m_Start;
};
// ─── 辅助函数 ─────────────────────────────────────────────────────
// 就地 DXT 解压并将格式标记为 RGBA8888
// 返回是否实际执行了解压
static bool DecompressDxtInPlace(TexMipMap &mipmap) {
switch (mipmap.Format) {
case MipmapFormat::CompressedDXT5:
DxtDecoder::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT5);
mipmap.Format = MipmapFormat::RGBA8888;
return true;
case MipmapFormat::CompressedDXT3:
DxtDecoder::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT3);
mipmap.Format = MipmapFormat::RGBA8888;
return true;
case MipmapFormat::CompressedDXT1:
DxtDecoder::DecompressImage(mipmap.Width, mipmap.Height, mipmap.Data, DXTFlags::DXT1);
mipmap.Format = MipmapFormat::RGBA8888;
return true;
default:
return false;
}
}
// 通过文件头魔数检测图像格式,返回对应扩展名(不含点)
// 用于修正未识别格式的输出扩展名,避免产生 .unknown 文件
static std::string DetectExtensionByMagic(const std::vector<uint8_t> &data) {
if (data.size() >= 8 && data[0] == 0x89 && data[1] == 0x50 && data[2] == 0x4E && data[3] == 0x47)
return "png"; // \x89PNG
if (data.size() >= 3 && data[0] == 0xFF && data[1] == 0xD8 && data[2] == 0xFF)
return "jpg"; // \xFF\xD8\xFF
if (data.size() >= 6 && data[0] == 0x47 && data[1] == 0x49 && data[2] == 0x46)
return "gif"; // GIF8
if (data.size() >= 2 && data[0] == 0x42 && data[1] == 0x4D)
return "bmp"; // BM
if (data.size() >= 12 && data[0] == 0x52 && data[1] == 0x49 && data[2] == 0x46 && data[3] == 0x46 && data[8] == 0x57 && data[9] == 0x45 && data[10] == 0x42 && data[11] == 0x50)
return "webp"; // RIFF....WEBP
return {};
}
// 判断是否为已编码图像扩展名(直接拷贝无需转码)
static bool IsRawImageFile(const std::string &ext) {
return ext == ".gif" || ext == ".jpg" || ext == ".png" || ext == ".jpeg" || ext == ".webp";
}
// ─── ExtractPipeline 公开接口 ─────────────────────────────────────
ExtractPipeline::ExtractPipeline() = default;
ExtractPipeline::ExtractPipeline(const ExtractConfig &config)
: m_Config(config) {}
Result<void> ExtractPipeline::Run(const std::filesystem::path &inputPath,
const std::filesystem::path &outDir,
bool showProgress,
ExtractStats *stats) {
ScopedTimer timer;
// 记录起始时间和输入文件大小
if (stats) {
stats->startTime = std::chrono::steady_clock::now();
std::error_code ec;
uint64_t sz = std::filesystem::file_size(inputPath, ec);
stats->inputFileSize = ec ? 0 : sz; // 文件不存在时置 0避免垃圾值
}
// 输出路径outDir/<输入文件名(去扩展名)>/
// 这样多次提取不同 pkg 时,输出按文件名分目录存放,互不混淆
std::filesystem::path subDir = outDir / inputPath.stem();
std::string ext = inputPath.extension().string();
Result<void> res;
if (ext == ".pkg" || ext == ".mpkg")
res = RunPkg(inputPath, subDir, showProgress, stats);
else if (ext == ".tex")
res = RunTex(inputPath, subDir, stats);
else
res = Fail(ErrorCode::UnsupportedFormat, "Unsupported file extension: " + ext);
// 统一设置结束时间,确保早期失败时 stats 时间也有效
if (stats)
stats->endTime = std::chrono::steady_clock::now();
return res;
}
// ─── PKG/MPKG 包提取 ──────────────────────────────────────────────
Result<void> ExtractPipeline::RunPkg(const std::filesystem::path &inputPath,
const std::filesystem::path &outDir,
bool showProgress,
ExtractStats *stats) {
StreamReader reader(inputPath);
if (!reader.IsOpen())
return Fail(ErrorCode::FileOpen, "Failed to open file: " + inputPath.string());
// 解析包索引
PkgExtractor extractor;
auto entriesRes = extractor.ParseIndex(reader);
if (!entriesRes)
return Fail(entriesRes.error.code, entriesRes.error.message);
uint32_t offsetPosition = static_cast<uint32_t>(reader.tellg());
// 预创建所有目录,避免多线程并发创建冲突
for (const auto &entry : *entriesRes) {
auto parentDir = (outDir / entry.FullPath).parent_path();
if (!parentDir.empty() && !std::filesystem::exists(parentDir))
std::filesystem::create_directories(parentDir);
}
// 线程数上限:不超过条目数,避免创建无用线程
uint32_t threadCount = m_Config.threadCount;
if (threadCount == 0)
threadCount = std::thread::hardware_concurrency();
threadCount = std::min(threadCount, static_cast<uint32_t>(entriesRes->size()));
if (threadCount == 0)
threadCount = 1;
TaskScheduler scheduler(threadCount);
Logger::Instance().Info("Using " + std::to_string(scheduler.ThreadCount()) + " threads");
// 限制并发 .tex 处理数:.tex 解码 + DXT 解压 + PNG 编码内存开销大,
// 全部线程同时处理大纹理会导致峰值内存过高
Semaphore texSem(4);
// 进度条在解析索引后创建(此时已知总条目数)
// 注册到 Logger日志会通过进度条协调打印
ProgressBar progress(showProgress ? entriesRes->size() : 0);
if (showProgress)
Logger::Instance().SetProgressBar(&progress);
if (stats)
stats->totalEntries.store(entriesRes->size(), std::memory_order_relaxed);
// 提交所有任务到线程池
std::vector<std::future<Result<void>>> futures;
futures.reserve(entriesRes->size());
for (const auto &entry : *entriesRes) {
auto future = scheduler.Submit(
[this, entry, pkgPath = inputPath, offsetPosition, outDir, &texSem, &progress, stats]() -> Result<void> {
auto res = ProcessEntry(entry, pkgPath, offsetPosition, outDir, texSem, stats);
progress.Increment();
if (!res && stats)
stats->AddFailure();
return res;
});
futures.push_back(std::move(future));
}
scheduler.WaitAll();
Logger::Instance().SetProgressBar(nullptr);
if (stats)
stats->endTime = std::chrono::steady_clock::now();
// 收集错误信息
std::vector<std::string> errors;
for (size_t i = 0; i < futures.size(); i++) {
auto res = futures[i].get();
if (!res)
errors.push_back((*entriesRes)[i].FullPath.string() + ": " + res.error.message);
}
if (!errors.empty()) {
std::string msg = "Completed with " + std::to_string(errors.size()) + " errors:\n";
for (const auto &e : errors)
msg += " " + e + "\n";
return Fail(ErrorCode::ReadFailed, msg);
}
return Ok();
}
// ─── 单个 TEX 文件提取 ────────────────────────────────────────────
Result<void> ExtractPipeline::RunTex(const std::filesystem::path &inputPath,
const std::filesystem::path &outDir,
ExtractStats *stats) {
StreamReader reader(inputPath);
if (!reader.IsOpen())
return Fail(ErrorCode::FileOpen, "Failed to open file: " + inputPath.string());
TexDecoder texDecoder;
auto texRes = texDecoder.Decode(reader);
if (!texRes)
return Fail(texRes.error.code, texRes.error.message);
auto &tex = *texRes;
// GIF 需要额外读取帧信息表(位于 TEX 数据末尾)
if (tex.IsGif) {
auto frameRes = ReadGifFrameInfo(tex, reader);
if (!frameRes)
return frameRes;
}
if (stats)
stats->totalEntries.store(1, std::memory_order_relaxed);
// 输出路径outDir/<输入文件名(去扩展名)>/<输入文件名(去扩展名)>.<新扩展名>
// 确保输出目录存在
std::error_code ec;
std::filesystem::create_directories(outDir, ec);
std::filesystem::path outPath = outDir / inputPath.stem();
auto res = EncodeTex(tex, outPath, stats);
if (stats)
stats->endTime = std::chrono::steady_clock::now();
if (!res && stats)
stats->AddFailure();
return res;
}
// ─── GIF 帧信息读取 ───────────────────────────────────────────────
// TEXS 块位于 TEX 文件末尾,包含 GIF 动画的每一帧位置与时长
// 支持 TEXS0001整数坐标和 TEXS0003浮点坐标 + 画布尺寸)两个版本
Result<void> ExtractPipeline::ReadGifFrameInfo(Tex &tex, StreamReader &reader) {
auto magicRes = reader.ReadNString(16);
if (!magicRes)
return Fail(magicRes.error.code, magicRes.error.message);
tex.FrameInfoContainer.Magic = *magicRes;
auto frameCountRes = reader.ReadInt32();
if (!frameCountRes)
return Fail(frameCountRes.error.code, frameCountRes.error.message);
// TEXS0003 额外包含 GIF 画布尺寸
if (tex.FrameInfoContainer.Magic == "TEXS0003") {
auto widthRes = reader.ReadInt32();
if (!widthRes)
return Fail(widthRes.error.code, widthRes.error.message);
tex.FrameInfoContainer.GifWidth = *widthRes;
auto heightRes = reader.ReadInt32();
if (!heightRes)
return Fail(heightRes.error.code, heightRes.error.message);
tex.FrameInfoContainer.GifHeight = *heightRes;
}
// 逐帧读取
for (int i = 0; i < *frameCountRes; i++) {
TexFrameInfo frameInfo{};
auto imageIdRes = reader.ReadInt32();
if (!imageIdRes)
return Fail(imageIdRes.error.code, imageIdRes.error.message);
frameInfo.ImageId = *imageIdRes;
auto frametimeRes = reader.ReadSingle();
if (!frametimeRes)
return Fail(frametimeRes.error.code, frametimeRes.error.message);
frameInfo.Frametime = *frametimeRes;
// TEXS0001: 坐标为整数TEXS0003: 坐标为浮点
if (tex.FrameInfoContainer.Magic == "TEXS0001") {
auto posXRes = reader.ReadInt32();
if (!posXRes)
return Fail(posXRes.error.code, posXRes.error.message);
frameInfo.PosX = static_cast<float>(*posXRes);
auto posYRes = reader.ReadInt32();
if (!posYRes)
return Fail(posYRes.error.code, posYRes.error.message);
frameInfo.PosY = static_cast<float>(*posYRes);
auto widthRes = reader.ReadInt32();
if (!widthRes)
return Fail(widthRes.error.code, widthRes.error.message);
frameInfo.Width = static_cast<float>(*widthRes);
auto widthYRes = reader.ReadInt32();
if (!widthYRes)
return Fail(widthYRes.error.code, widthYRes.error.message);
frameInfo.WidthY = static_cast<float>(*widthYRes);
auto heightXRes = reader.ReadInt32();
if (!heightXRes)
return Fail(heightXRes.error.code, heightXRes.error.message);
frameInfo.HeightX = static_cast<float>(*heightXRes);
auto heightRes = reader.ReadInt32();
if (!heightRes)
return Fail(heightRes.error.code, heightRes.error.message);
frameInfo.Height = static_cast<float>(*heightRes);
} else {
auto posXRes = reader.ReadSingle();
if (!posXRes)
return Fail(posXRes.error.code, posXRes.error.message);
frameInfo.PosX = *posXRes;
auto posYRes = reader.ReadSingle();
if (!posYRes)
return Fail(posYRes.error.code, posYRes.error.message);
frameInfo.PosY = *posYRes;
auto widthRes = reader.ReadSingle();
if (!widthRes)
return Fail(widthRes.error.code, widthRes.error.message);
frameInfo.Width = *widthRes;
auto widthYRes = reader.ReadSingle();
if (!widthYRes)
return Fail(widthYRes.error.code, widthYRes.error.message);
frameInfo.WidthY = *widthYRes;
auto heightXRes = reader.ReadSingle();
if (!heightXRes)
return Fail(heightXRes.error.code, heightXRes.error.message);
frameInfo.HeightX = *heightXRes;
auto heightRes = reader.ReadSingle();
if (!heightRes)
return Fail(heightRes.error.code, heightRes.error.message);
frameInfo.Height = *heightRes;
}
tex.FrameInfoContainer.Frames.push_back(frameInfo);
}
// 兜底:若画布尺寸未设置,取首帧尺寸
if (tex.FrameInfoContainer.GifWidth == 0 || tex.FrameInfoContainer.GifHeight == 0) {
tex.FrameInfoContainer.GifWidth = static_cast<int>(tex.FrameInfoContainer.Frames[0].Width);
tex.FrameInfoContainer.GifHeight = static_cast<int>(tex.FrameInfoContainer.Frames[0].Height);
}
return Ok();
}
// ─── TEX 编码输出 ────────────────────────────────────────────────
// 根据纹理类型选择编码方式:
// - GIF 动画 → EncodeGif逐帧处理
// - 视频纹理 → 原始数据写出MP4
// - DXT 压缩 → 解压后 PNG 编码
// - 已编码图像 → 魔数检测修正扩展名后直接写出
Result<void> ExtractPipeline::EncodeTex(Tex &tex, const std::filesystem::path &outPath, ExtractStats *stats) {
if (tex.ImageContainer.Images.empty())
return Ok();
// GIF 动画:交给 EncodeGif 逐帧处理
if (tex.IsGif) {
std::filesystem::path gifOutPath = outPath;
gifOutPath.replace_extension("gif");
Logger::Instance().Info("Convert: " + gifOutPath.string());
ImageEncoder encoder;
auto res = encoder.EncodeGif(tex, gifOutPath);
if (res && stats)
stats->AddOutput("gif", std::filesystem::file_size(gifOutPath));
return res;
}
auto &sourceMipmap = tex.ImageContainer.Images[0].Mipmaps[0];
MipmapFormat format = tex.IsVideoTexture ? MipmapFormat::VideoMp4 : sourceMipmap.Format;
// 视频纹理:校验 MP4 头并直接写出
if (tex.IsVideoTexture) {
if (sourceMipmap.Data.size() >= 12) {
std::string mp4Magic = std::string(reinterpret_cast<const char *>(&sourceMipmap.Data[4]), 8);
if (mp4Magic != "ftypisom" && mp4Magic != "ftypmsnv" && mp4Magic != "ftypmp42")
Logger::Instance().Error("Warning: Bad MP4 magic header");
} else {
Logger::Instance().Error("Warning: MP4 data too short");
}
std::filesystem::path imgOutPath = outPath;
imgOutPath.replace_extension(GetFileExtension(format));
Logger::Instance().Info("Convert: " + imgOutPath.string());
ImageEncoder encoder;
auto res = encoder.EncodeRaw(sourceMipmap, imgOutPath);
if (res && stats)
stats->AddOutput(imgOutPath.extension().string().substr(1),
std::filesystem::file_size(imgOutPath));
return res;
}
// 非 GIF、非视频尝试 DXT 解压
DecompressDxtInPlace(sourceMipmap);
// DXT 解压后为原始像素R8/RG88/RGBA8888编码为 PNG
if (static_cast<int>(sourceMipmap.Format) >= 1 && static_cast<int>(sourceMipmap.Format) <= 3) {
std::filesystem::path imgOutPath = outPath;
imgOutPath.replace_extension("png");
Logger::Instance().Info("Convert: " + imgOutPath.string());
ImageEncoder encoder;
auto res = encoder.EncodePng(sourceMipmap, imgOutPath);
if (res && stats)
stats->AddOutput("png", std::filesystem::file_size(imgOutPath));
return res;
}
// 原始数据可能是已编码图像PNG/JPEG/GIF/BMP/WEBP
// 通过魔数检测修正扩展名,避免输出 .unknown
std::filesystem::path imgOutPath = outPath;
std::string detectedExt = DetectExtensionByMagic(sourceMipmap.Data);
if (!detectedExt.empty())
imgOutPath.replace_extension(detectedExt);
else
imgOutPath.replace_extension(GetFileExtension(format));
Logger::Instance().Info("Convert: " + imgOutPath.string());
StreamWriter writer(imgOutPath, std::ios::binary);
auto res = writer.WriteBytes(reinterpret_cast<const char *>(sourceMipmap.Data.data()),
static_cast<uint32_t>(sourceMipmap.Data.size()));
if (res && stats)
stats->AddOutput(imgOutPath.extension().string().substr(1),
std::filesystem::file_size(imgOutPath));
return res;
}
// ─── 单条目处理(线程池任务)──────────────────────────────────────
// 每个任务独立打开 PKG 文件并 seek 到条目偏移,避免共享 StreamReader
Result<void> ExtractPipeline::ProcessEntry(const Entry &entry,
const std::filesystem::path &pkgPath,
uint32_t offsetPosition,
const std::filesystem::path &outDir,
Semaphore &texSem,
ExtractStats *stats) {
std::filesystem::path outPath = outDir / entry.FullPath;
StreamReader reader(pkgPath);
if (!reader.IsOpen())
return Fail(ErrorCode::FileOpen, "Failed to open pkg: " + pkgPath.string());
reader.seekg(entry.Offset + offsetPosition);
// .tex 文件:解码 + 编码(内存开销大,需信号量限流)
if (entry.Type == ".tex") {
SemaphoreGuard guard(texSem);
// 读取条目数据到内存,再用内存模式 reader 解码(零拷贝)
std::string texData;
auto readRes = reader.ReadData(texData, entry.Length);
if (!readRes)
return readRes;
StreamReader texReader(std::move(texData));
TexDecoder texDecoder;
auto texRes = texDecoder.Decode(texReader);
if (!texRes)
return Fail(texRes.error.code, texRes.error.message);
auto &tex = *texRes;
if (tex.IsGif) {
auto frameRes = ReadGifFrameInfo(tex, texReader);
if (!frameRes)
return frameRes;
}
return EncodeTex(tex, outPath, stats);
}
// 已编码图像文件:直接拷贝
if (IsRawImageFile(entry.Type)) {
Logger::Instance().Info("Extract: " + outPath.string());
std::string data;
auto readRes = reader.ReadData(data, entry.Length);
if (!readRes)
return readRes;
StreamWriter writer(outPath, std::ios::binary);
auto res = writer.WriteBytes(data.data(), static_cast<uint32_t>(data.size()));
if (res && stats)
stats->AddOutput(outPath.extension().string().substr(1),
std::filesystem::file_size(outPath));
return res;
}
// 其他文本文件(.json/.frag/.vert/.mdl 等)
Logger::Instance().Info("Extract: " + outPath.string());
auto dataRes = reader.ReadStringFileData(entry.Length);
if (!dataRes)
return Fail(dataRes.error.code, dataRes.error.message);
StreamWriter writer(outPath);
auto res = writer.WriteString(*dataRes);
if (res && stats) {
std::string ext = outPath.extension().string();
stats->AddOutput(ext.empty() ? "bin" : ext.substr(1),
std::filesystem::file_size(outPath));
}
return res;
}
} // namespace PKG

View File

@ -0,0 +1,64 @@
#ifndef PKG_EXTRACT_PIPELINE_H
#define PKG_EXTRACT_PIPELINE_H
#include "Core/Types.h"
#include "Core/Result.h"
#include "Core/Config.h"
#include "Core/ExtractStats.h"
#include "IO/StreamReader.h"
namespace PKG
{
class Semaphore; // 前向声明,定义在 TaskScheduler.h
// 提取流水线PKG/MPKG/TEX 文件解码与编码的协调器
// - PKG/MPKG: 多线程并行提取所有条目
// - TEX: 单文件解码后编码输出
class ExtractPipeline
{
public:
ExtractPipeline();
explicit ExtractPipeline(const ExtractConfig& config);
// 执行提取
// inputPath 输入文件路径(.pkg/.mpkg/.tex
// outDir 输出目录
// showProgress 为 true 时显示终端进度条
// stats 可选,传入则填充统计信息
Result<void> Run(const std::filesystem::path& inputPath,
const std::filesystem::path& outDir,
bool showProgress = false,
ExtractStats* stats = nullptr);
private:
// PKG/MPKG 包提取:解析索引 + 多线程处理所有条目
Result<void> RunPkg(const std::filesystem::path& inputPath,
const std::filesystem::path& outDir,
bool showProgress,
ExtractStats* stats);
// 单个 TEX 文件提取:解码 + 编码输出
Result<void> RunTex(const std::filesystem::path& inputPath,
const std::filesystem::path& outDir,
ExtractStats* stats);
// 处理单个条目(线程池任务,可并行执行)
// texSem 用于限制并发 .tex 处理数,降低峰值内存
Result<void> ProcessEntry(const Entry& entry,
const std::filesystem::path& pkgPath,
uint32_t offsetPosition,
const std::filesystem::path& outDir,
Semaphore& texSem,
ExtractStats* stats);
// 读取 GIF 帧信息TEXS 块,位于 TEX 数据末尾)
Result<void> ReadGifFrameInfo(Tex& tex, StreamReader& reader);
// TEX 编码输出:根据类型选择 GIF/PNG/MP4/原始数据
Result<void> EncodeTex(Tex& tex, const std::filesystem::path& outPath, ExtractStats* stats);
ExtractConfig m_Config;
};
}
#endif // PKG_EXTRACT_PIPELINE_H

View File

@ -0,0 +1,109 @@
#include "TaskScheduler.h"
namespace PKG
{
// ─── 线程池构造 ─────────────────────────────────────────────────
// 创建 threadCount 个工作线程,每个线程循环从任务队列取任务执行
TaskScheduler::TaskScheduler(uint32_t threadCount)
{
if (threadCount == 0)
threadCount = std::thread::hardware_concurrency();
if (threadCount == 0)
threadCount = 4; // hardware_concurrency 失败时的兜底值
for (uint32_t i = 0; i < threadCount; i++)
{
m_Workers.emplace_back([this]
{
while (true)
{
std::function<void()> task;
{
// 等待:有任务可取 或 收到停止信号
std::unique_lock<std::mutex> lock(m_QueueMutex);
m_Condition.wait(lock, [this] { return m_Stop || !m_Tasks.empty(); });
// 停止且队列空 → 退出线程
if (m_Stop && m_Tasks.empty())
return;
task = std::move(m_Tasks.front());
m_Tasks.pop();
}
task(); // 执行任务(已捕获异常,不会抛出)
// 任务完成:递减活跃计数,可能唤醒 WaitAll
{
std::lock_guard<std::mutex> lock(m_ActiveMutex);
if (m_ActiveTasks > 0)
m_ActiveTasks--;
if (m_ActiveTasks == 0)
m_ActiveCondition.notify_all();
}
}
});
}
}
TaskScheduler::~TaskScheduler()
{
{
std::lock_guard<std::mutex> lock(m_QueueMutex);
m_Stop = true;
}
m_Condition.notify_all(); // 唤醒所有等待的工作线程
for (auto& worker : m_Workers)
{
if (worker.joinable())
worker.join();
}
}
// ─── 提交任务 ───────────────────────────────────────────────────
// 将任务包装为 promise/future 模式,捕获所有异常转为错误结果
std::future<Result<void>> TaskScheduler::Submit(std::function<Result<void>()> task)
{
auto promise = std::make_shared<std::promise<Result<void>>>();
auto future = promise->get_future();
// 活跃任务数 +1必须在入队前完成防止 WaitAll 提前返回)
{
std::lock_guard<std::mutex> lock(m_ActiveMutex);
m_ActiveTasks++;
}
// 包装任务:执行并设置结果,捕获所有异常
std::function<void()> wrapped = [promise, task = std::move(task)]()
{
try
{
promise->set_value(task());
}
catch (const std::exception& e)
{
promise->set_value(Fail(ErrorCode::ReadFailed, std::string("Exception: ") + e.what()));
}
catch (...)
{
promise->set_value(Fail(ErrorCode::ReadFailed, "Unknown exception"));
}
};
{
std::lock_guard<std::mutex> lock(m_QueueMutex);
m_Tasks.emplace(std::move(wrapped));
}
m_Condition.notify_one(); // 唤醒一个等待的工作线程
return future;
}
// ─── 等待所有任务完成 ───────────────────────────────────────────
void TaskScheduler::WaitAll()
{
std::unique_lock<std::mutex> lock(m_ActiveMutex);
m_ActiveCondition.wait(lock, [this] { return m_ActiveTasks == 0; });
}
}

View File

@ -0,0 +1,94 @@
#ifndef PKG_TASK_SCHEDULER_H
#define PKG_TASK_SCHEDULER_H
#include <cstdint>
#include <functional>
#include <future>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <thread>
#include <vector>
#include "Core/Result.h"
namespace PKG
{
// ─── 计数信号量 ─────────────────────────────────────────────────
// 用于限制并发重操作(如 .tex 解码)的数量,降低峰值内存
class Semaphore
{
public:
explicit Semaphore(int count) : m_Count(count) {}
// 获取一个许可(计数为 0 时阻塞等待)
void Acquire()
{
std::unique_lock<std::mutex> lock(m_Mutex);
m_Cond.wait(lock, [this] { return m_Count > 0; });
m_Count--;
}
// 释放一个许可(唤醒一个等待者)
void Release()
{
std::lock_guard<std::mutex> lock(m_Mutex);
m_Count++;
m_Cond.notify_one();
}
private:
std::mutex m_Mutex;
std::condition_variable m_Cond;
int m_Count;
};
// ─── RAII 信号量守卫 ────────────────────────────────────────────
// 构造时获取信号量,析构时自动释放(异常安全)
class SemaphoreGuard
{
public:
explicit SemaphoreGuard(Semaphore& sem) : m_Sem(sem) { m_Sem.Acquire(); }
~SemaphoreGuard() { m_Sem.Release(); }
SemaphoreGuard(const SemaphoreGuard&) = delete;
SemaphoreGuard& operator=(const SemaphoreGuard&) = delete;
private:
Semaphore& m_Sem;
};
// ─── 线程池 ─────────────────────────────────────────────────────
// 固定大小的线程池,提交任务返回 future 用于获取结果
// 支持 WaitAll() 等待所有已提交任务完成
class TaskScheduler
{
public:
// threadCount = 0 时自动使用 hardware_concurrency
explicit TaskScheduler(uint32_t threadCount = 0);
~TaskScheduler();
TaskScheduler(const TaskScheduler&) = delete;
TaskScheduler& operator=(const TaskScheduler&) = delete;
// 提交任务,返回 future 以获取结果或等待完成
std::future<Result<void>> Submit(std::function<Result<void>()> task);
// 阻塞等待所有已提交任务完成
void WaitAll();
uint32_t ThreadCount() const { return static_cast<uint32_t>(m_Workers.size()); }
private:
std::vector<std::thread> m_Workers; // 工作线程
std::queue<std::function<void()>> m_Tasks; // 待执行任务队列
std::mutex m_QueueMutex; // 保护 m_Tasks
std::condition_variable m_Condition; // 唤醒等待任务的工作线程
bool m_Stop = false; // 析构标志
uint32_t m_ActiveTasks = 0; // 正在执行的任务数
std::mutex m_ActiveMutex; // 保护 m_ActiveTasks
std::condition_variable m_ActiveCondition; // WaitAll 等待条件
};
}
#endif // PKG_TASK_SCHEDULER_H

20
src/expkg.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef PKG_EXPKG_H
#define PKG_EXPKG_H
#include "Core/Types.h"
#include "Core/Result.h"
#include "Core/Config.h"
#include "Core/Logger.h"
#include "Core/ProcessInfo.h"
#include "Core/ExtractStats.h"
#include "IO/StreamReader.h"
#include "IO/StreamWriter.h"
#include "Decoder/PkgExtractor.h"
#include "Decoder/TexDecoder.h"
#include "Decoder/DxtDecoder.h"
#include "Decoder/ImageReader.h"
#include "Encoder/ImageEncoder.h"
#include "Pipeline/TaskScheduler.h"
#include "Pipeline/ExtractPipeline.h"
#endif // PKG_EXPKG_H

Some files were not shown because too many files have changed in this diff Show More