63 lines
2.3 KiB
C++
63 lines
2.3 KiB
C++
//======================================================================================================
|
|
// Copyright 2025, Rokoko Glove OptiTrack Integration
|
|
//======================================================================================================
|
|
/**
|
|
* LZ4Wrapper class provides LZ4 decompression functionality for Rokoko glove data.
|
|
* This wrapper handles safe decompression and validation of compressed data.
|
|
*/
|
|
|
|
#pragma once
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
// Unity LZ4 함수들 선언
|
|
extern "C" {
|
|
int Unity_LZ4_uncompressSize(const char* srcBuffer, int srcSize);
|
|
int Unity_LZ4_decompress(const char* src, int srcSize, char* dst, int dstCapacity);
|
|
}
|
|
|
|
namespace RokokoIntegration
|
|
{
|
|
class LZ4Wrapper
|
|
{
|
|
public:
|
|
/**
|
|
* Decompresses LZ4 compressed data
|
|
* @param compressedData Pointer to compressed data
|
|
* @param compressedSize Size of compressed data
|
|
* @return Decompressed data as vector, empty if decompression fails
|
|
*/
|
|
static std::vector<uint8_t> Decompress(const uint8_t* compressedData, int compressedSize);
|
|
|
|
/**
|
|
* Validates if the data appears to be valid LZ4 compressed data
|
|
* @param data Pointer to data to validate
|
|
* @param size Size of data
|
|
* @return true if data appears to be valid LZ4 data
|
|
*/
|
|
static bool IsValidLZ4Data(const uint8_t* data, int size);
|
|
|
|
/**
|
|
* Gets the decompressed size from LZ4 header
|
|
* @param compressedData Pointer to compressed data
|
|
* @param compressedSize Size of compressed data
|
|
* @return Decompressed size, -1 if invalid
|
|
*/
|
|
static int GetDecompressedSize(const uint8_t* compressedData, int compressedSize);
|
|
|
|
private:
|
|
/**
|
|
* Validates decompressed size is reasonable
|
|
* @param compressedSize Size of compressed data
|
|
* @param decompressedSize Size of decompressed data
|
|
* @return true if sizes are reasonable
|
|
*/
|
|
static bool ValidateDecompressedSize(int compressedSize, int decompressedSize);
|
|
|
|
/**
|
|
* Maximum reasonable decompressed size (10MB)
|
|
*/
|
|
static const int MAX_DECOMPRESSED_SIZE = 10 * 1024 * 1024;
|
|
};
|
|
}
|