UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
lz4.h
Go to the documentation of this file.
1/*
2 * LZ4 - Fast LZ compression algorithm
3 * Header File
4 * Copyright (C) 2011-present, Yann Collet.
5
6 BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above
15 copyright notice, this list of conditions and the following disclaimer
16 in the documentation and/or other materials provided with the
17 distribution.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 You can contact the author at :
32 - LZ4 homepage : http://www.lz4.org
33 - LZ4 source repository : https://github.com/lz4/lz4
34*/
35
36#pragma once // EPIC MOD: Placate IncludeTool warning
37
38#if defined (__cplusplus)
39extern "C" {
40#endif
41
42// BEGIN EPIC MOD : Wrap library in an optional namespace
43#if defined(LZ4_NAMESPACE) && defined(__cplusplus)
44# define LZ4_BEGIN_NAMESPACE extern "C++" { namespace LZ4_NAMESPACE {
45# define LZ4_END_NAMESPACE } /* extern */ } /* namespace */
46#else
47# define LZ4_BEGIN_NAMESPACE
48# define LZ4_END_NAMESPACE
49#endif // LZ4_NAMESPACE
50// END EPIC MOD
51
52#ifndef LZ4_H_2983827168210
53#define LZ4_H_2983827168210
54
55/* --- Dependency --- */
56#include <stddef.h> /* size_t */
57
58
89/*^***************************************************************
90* Export parameters
91*****************************************************************/
92/*
93* LZ4_DLL_EXPORT :
94* Enable exporting of functions when building a Windows DLL
95* LZ4LIB_VISIBILITY :
96* Control library symbols visibility.
97*/
98#ifndef LZ4LIB_VISIBILITY
99# if defined(__GNUC__) && (__GNUC__ >= 4)
100# define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
101# else
102# define LZ4LIB_VISIBILITY
103# endif
104#endif
105#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
106# define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
107#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
108# define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
109#else
110# define LZ4LIB_API LZ4LIB_VISIBILITY
111#endif
112
113/*------ Version ------*/
114#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
115#define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
116#define LZ4_VERSION_RELEASE 2 /* for tweaks, bug-fixes, or development */
117
118#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
119
120#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
121#define LZ4_QUOTE(str) #str
122#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
123#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
124
125LZ4_BEGIN_NAMESPACE // EPIC MOD : Wrap library in an optional namespace
126
127LZ4LIB_API int LZ4_versionNumber (void);
128LZ4LIB_API const char* LZ4_versionString (void);
131/*-************************************
132* Tuning parameter
133**************************************/
141#ifndef LZ4_MEMORY_USAGE
142# define LZ4_MEMORY_USAGE 14
143#endif
144
145
146/*-************************************
147* Simple Functions
148**************************************/
163LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
164
179LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
180
181
182/*-************************************
183* Advanced Functions
184**************************************/
185#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
186#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
187
198
206LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
207
208
216LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
217
218
231LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
232
233
258LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
259
260
261/*-*********************************************
262* Streaming Compression Functions
263***********************************************/
264typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
265
268
292
304LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
305
330
339
340
341/*-**********************************************
342* Streaming Decompression Functions
343* Bufferless synchronous API
344************************************************/
345typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
346
353
361LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
362
375#define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
376
403
404
413LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize);
414
415LZ4_END_NAMESPACE // EPIC MOD : Wrap library in an optional namespace
416
417#endif /* LZ4_H_2983827168210 */
418
419
420/*^*************************************
421 * !!!!!! STATIC LINKING ONLY !!!!!!
422 ***************************************/
423
424/*-****************************************************************************
425 * Experimental section
426 *
427 * Symbols declared in this section must be considered unstable. Their
428 * signatures or semantics may change, or they may be removed altogether in the
429 * future. They are therefore only safe to depend on when the caller is
430 * statically linked against the library.
431 *
432 * To protect against unsafe usage, not only are the declarations guarded,
433 * the definitions are hidden by default
434 * when building LZ4 as a shared/dynamic library.
435 *
436 * In order to access these declarations,
437 * define LZ4_STATIC_LINKING_ONLY in your application
438 * before including LZ4's headers.
439 *
440 * In order to make their implementations accessible dynamically, you must
441 * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
442 ******************************************************************************/
443
444#ifdef LZ4_STATIC_LINKING_ONLY
445
446#ifndef LZ4_STATIC_3504398509
447#define LZ4_STATIC_3504398509
448
449#ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
450#define LZ4LIB_STATIC_API LZ4LIB_API
451#else
452#define LZ4LIB_STATIC_API
453#endif
454
455LZ4_BEGIN_NAMESPACE // EPIC MOD : Wrap library in an optional namespace
456
457
468LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
469
497
498
550#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32)
551#define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize))
553#ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */
554# define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
555#endif
556
557#define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */
558#define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN)
560LZ4_END_NAMESPACE // EPIC MOD : Wrap library in an optional namespace
561
562#endif /* LZ4_STATIC_3504398509 */
563#endif /* LZ4_STATIC_LINKING_ONLY */
564
565
566
567#ifndef LZ4_H_98237428734687
568#define LZ4_H_98237428734687
569
570/*-************************************************************
571 * PRIVATE DEFINITIONS
572 **************************************************************
573 * Do not use these definitions directly.
574 * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
575 * Accessing members will expose code to API and/or ABI break in future versions of the library.
576 **************************************************************/
577#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
578#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
579#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
580
581#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
582#include <stdint.h>
583
584LZ4_BEGIN_NAMESPACE // EPIC MOD : Wrap library in an optional namespace
585
592 const uint8_t* dictionary;
595};
596
597typedef struct {
598 const uint8_t* externalDict;
599 size_t extDictSize;
600 const uint8_t* prefixEnd;
601 size_t prefixSize;
603
604#else
605
609 unsigned int currentOffset;
610 unsigned short dirty;
611 unsigned short tableType;
612 const unsigned char* dictionary;
614 unsigned int dictSize;
615};
616
617typedef struct {
618 const unsigned char* externalDict;
619 const unsigned char* prefixEnd;
623
624#endif
625
635#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4 + ((sizeof(void*)==16) ? 4 : 0) /*AS-400*/ )
636#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
637union LZ4_stream_u {
638 unsigned long long table[LZ4_STREAMSIZE_U64];
640} ; /* previously typedef'd to LZ4_stream_t */
641
656LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size);
657
658
666#define LZ4_STREAMDECODESIZE_U64 (4 + ((sizeof(void*)==16) ? 2 : 0) /*AS-400*/ )
667#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
668union LZ4_streamDecode_u {
669 unsigned long long table[LZ4_STREAMDECODESIZE_U64];
671} ; /* previously typedef'd to LZ4_streamDecode_t */
672
673
674
675/*-************************************
676* Obsolete Functions
677**************************************/
678
690#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
691# define LZ4_DEPRECATED(message) /* disable deprecation warnings */
692#else
693# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
694# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
695# define LZ4_DEPRECATED(message) [[deprecated(message)]]
696# elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
697# define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
698# elif (LZ4_GCC_VERSION >= 301)
699# define LZ4_DEPRECATED(message) __attribute__((deprecated))
700# elif defined(_MSC_VER)
701# define LZ4_DEPRECATED(message) __declspec(deprecated(message))
702# else
703# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
704# define LZ4_DEPRECATED(message)
705# endif
706#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
707
708/* Obsolete compression functions */
709LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize);
715
716/* Obsolete decompression functions */
719
720/* Obsolete streaming functions; degraded functionality; do not use!
721 *
722 * In order to perform streaming compression, these functions depended on data
723 * that is no longer tracked in the state. They have been preserved as well as
724 * possible: using them will still produce a correct output. However, they don't
725 * actually retain any history between compression calls. The compression ratio
726 * achieved will therefore be no better than compressing each chunk
727 * independently.
728 */
733
734/* Obsolete streaming decoding functions */
737
766LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
767LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
771LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
772
780
781LZ4_END_NAMESPACE // EPIC MOD : Wrap library in an optional namespace
782
783
784#endif /* LZ4_H_98237428734687 */
785
786
787#if defined (__cplusplus)
788}
789#endif
OODEFFUNC typedef const int const char * function
Definition oodle2.h:710
#define LZ4LIB_API
Definition lz4.h:84
LZ4LIB_API LZ4_stream_t * LZ4_initStream(void *buffer, size_t size)
Definition lz4.cpp:1505
LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.cpp:1414
LZ4LIB_API const char * LZ4_versionString(void)
Definition lz4.cpp:726
LZ4LIB_API int LZ4_versionNumber(void)
Definition lz4.cpp:725
LZ4LIB_API int LZ4_sizeofState(void)
Definition lz4.cpp:728
LZ4LIB_API int LZ4_compressBound(int inputSize)
Definition lz4.cpp:727
LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst, int compressedSize, int dstCapacity)
Definition lz4.cpp:2343
LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.cpp:1344
LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst, int srcSize, int targetOutputSize, int dstCapacity)
Definition lz4.cpp:2351
LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr)
Definition lz4.cpp:1517
LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize, int dstCapacity)
Definition lz4.cpp:1433
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *src, char *dst, int originalSize, const char *dictStart, int dictSize)
Definition lz4.cpp:2640
const char * source
Definition lz4.h:711
LZ4LIB_API int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.cpp:1630
LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst, int srcSize, int dstCapcity, const char *dictStart, int dictSize)
Definition lz4.cpp:2610
char int srcSize
Definition lz4.h:709
char int compressedSize
Definition lz4.h:735
LZ4LIB_API void LZ4_resetStream_fast(LZ4_stream_t *streamPtr)
Definition lz4.cpp:1523
LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize)
Definition lz4.cpp:2506
LZ4LIB_API int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream)
Definition lz4.cpp:2466
LZ4LIB_API int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int originalSize)
Definition lz4.cpp:2562
#define LZ4_STREAMDECODESIZE_U64
Definition lz4.h:666
LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int maxDictSize)
Definition lz4.cpp:1737
LZ4LIB_API LZ4_stream_t * LZ4_createStream(void)
Definition lz4.cpp:1484
char int int maxDstSize
Definition lz4.h:735
char * inputBuffer
Definition lz4.h:731
#define LZ4_HASH_SIZE_U32
Definition lz4.h:579
LZ4LIB_API int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
Definition lz4.cpp:2480
LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr)
Definition lz4.cpp:1528
const char char int inputSize
Definition lz4.h:711
char * dst
Definition lz4.h:735
LZ4LIB_API LZ4_streamDecode_t * LZ4_createStreamDecode(void)
Definition lz4.cpp:2460
char int int maxOutputSize
Definition lz4.h:710
LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize)
Definition lz4.cpp:1539
LZ4LIB_API int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int srcSize, int dstCapacity)
Definition lz4.cpp:2522
#define LZ4_BEGIN_NAMESPACE
Definition lz4.h:47
char int originalSize
Definition lz4.h:736
#define LZ4_STREAMSIZE_U64
Definition lz4.h:635
#define LZ4_END_NAMESPACE
Definition lz4.h:48
LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst, int *srcSizePtr, int targetDstSize)
Definition lz4.cpp:1459
LZ4LIB_API int LZ4_decompress_fast(const char *src, char *dst, int originalSize)
Definition lz4.cpp:2360
char int outputSize
Definition lz4.h:717
char int isize
Definition lz4.h:718
char * dest
Definition lz4.h:709
#define LZ4_DEPRECATED(message)
Definition lz4.h:704
Definition UnrealType.h:3087
LZ4_FORCE_O2 int LZ4_decompress_safe_withPrefix64k(const char *source, char *dest, int compressedSize, int maxOutputSize)
Definition lz4.cpp:2371
int LZ4_compress_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize)
Definition lz4.cpp:2655
int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_stream, const char *src, char *dst, int srcSize, int dstCapacity)
Definition lz4.cpp:2671
int LZ4_compress(const char *src, char *dest, int srcSize)
Definition lz4.cpp:2659
int LZ4_uncompress(const char *source, char *dest, int outputSize)
Definition lz4.cpp:2686
char * LZ4_slideInputBuffer(void *state)
Definition lz4.cpp:2714
int LZ4_compress_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize)
Definition lz4.cpp:2675
int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize)
Definition lz4.cpp:2690
int LZ4_sizeofStreamState(void)
Definition lz4.cpp:2697
int LZ4_compress_withState(void *state, const char *src, char *dst, int srcSize)
Definition lz4.cpp:2667
int LZ4_compress_limitedOutput_withState(void *state, const char *src, char *dst, int srcSize, int dstSize)
Definition lz4.cpp:2663
int LZ4_resetStreamState(void *state, char *inputBuffer)
Definition lz4.cpp:2699
int LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
Definition lz4.cpp:1376
void LZ4_attach_dictionary(LZ4_stream_t *workingStream, const LZ4_stream_t *dictionaryStream)
Definition lz4.cpp:1581
int LZ4_decompress_fast_withPrefix64k(const char *source, char *dest, int originalSize)
Definition lz4.cpp:2388
void * LZ4_create(char *inputBuffer)
Definition lz4.cpp:2707
Definition lz4.h:702
size_t prefixSize
Definition lz4.h:621
size_t extDictSize
Definition lz4.h:620
const unsigned char * externalDict
Definition lz4.h:618
const unsigned char * prefixEnd
Definition lz4.h:619
Definition lz4.h:663
unsigned short tableType
Definition lz4.h:611
unsigned int currentOffset
Definition lz4.h:609
unsigned int dictSize
Definition lz4.h:614
unsigned short dirty
Definition lz4.h:610
LZ4_u32 tableType
Definition lz4.h:668
LZ4_u32 currentOffset
Definition lz4.h:667
const LZ4_byte * dictionary
Definition lz4.h:665
const unsigned char * dictionary
Definition lz4.h:612
const LZ4_stream_t_internal * dictCtx
Definition lz4.h:666
LZ4_u32 dictSize
Definition lz4.h:669
LZ4_u32 hashTable[LZ4_HASH_SIZE_U32]
Definition lz4.h:664
Definition lz4.h:710
LZ4_streamDecode_t_internal internal_donotuse
Definition lz4.h:712
unsigned long long table[LZ4_STREAMDECODESIZE_U64]
Definition lz4.h:669
Definition lz4.h:674
LZ4_stream_t_internal internal_donotuse
Definition lz4.h:676
unsigned long long table[LZ4_STREAMSIZE_U64]
Definition lz4.h:638