Files
UnrealEngineUWP/Engine/Source/Runtime/TraceLog/Private/Trace/Codec.cpp
Martin Ridgers efee2a9978 Allow LZ4 to be provided externally.
#rb none
#rnx
#preflight 61680e471ae4f30001ad7f0b

[CL 17814766 by Martin Ridgers in ue5-main branch]
2021-10-14 07:50:32 -04:00

56 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "CoreTypes.h"
THIRD_PARTY_INCLUDES_START
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 6239)
#endif
#if !defined(TRACE_PRIVATE_EXTERNAL_LZ4)
# define LZ4_NAMESPACE Trace
# include "LZ4/lz4.c.inl"
# undef LZ4_NAMESPACE
# define TRACE_PRIVATE_LZ4_NAMESPACE ::Trace::
#else
# define TRACE_PRIVATE_LZ4_NAMESPACE
#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
THIRD_PARTY_INCLUDES_END
namespace UE {
namespace Trace {
namespace Private {
////////////////////////////////////////////////////////////////////////////////
int32 Encode(const void* Src, int32 SrcSize, void* Dest, int32 DestSize)
{
return TRACE_PRIVATE_LZ4_NAMESPACE LZ4_compress_fast(
(const char*)Src,
(char*)Dest,
SrcSize,
DestSize,
1 // increase by 1 for small speed increase
);
}
////////////////////////////////////////////////////////////////////////////////
uint32 GetEncodeMaxSize(uint32 InputSize)
{
return LZ4_COMPRESSBOUND(InputSize);
}
////////////////////////////////////////////////////////////////////////////////
TRACELOG_API int32 Decode(const void* Src, int32 SrcSize, void* Dest, int32 DestSize)
{
return TRACE_PRIVATE_LZ4_NAMESPACE LZ4_decompress_safe((const char*)Src, (char*)Dest, SrcSize, DestSize);
}
} // namespace Private
} // namespace Trace
} // namespace UE