VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tracy_lz4.hpp
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 #ifndef TRACY_LZ4_H_2983827168210
37 #define TRACY_LZ4_H_2983827168210
38 
39 /* --- Dependency --- */
40 #include <stddef.h> /* size_t */
41 #include <stdint.h>
42 
43 
74 /*^***************************************************************
75 * Export parameters
76 *****************************************************************/
77 /*
78 * LZ4_DLL_EXPORT :
79 * Enable exporting of functions when building a Windows DLL
80 * LZ4LIB_VISIBILITY :
81 * Control library symbols visibility.
82 */
83 #ifndef LZ4LIB_VISIBILITY
84 # if defined(__GNUC__) && (__GNUC__ >= 4)
85 # define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
86 # else
87 # define LZ4LIB_VISIBILITY
88 # endif
89 #endif
90 #if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
91 # define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
92 #elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
93 # 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.*/
94 #else
95 # define LZ4LIB_API LZ4LIB_VISIBILITY
96 #endif
97 
98 /*------ Version ------*/
99 #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
100 #define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
101 #define LZ4_VERSION_RELEASE 3 /* for tweaks, bug-fixes, or development */
102 
103 #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
104 
105 #define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
106 #define LZ4_QUOTE(str) #str
107 #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
108 #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
109 
110 namespace tracy
111 {
112 
113 LZ4LIB_API int LZ4_versionNumber (void);
114 LZ4LIB_API const char* LZ4_versionString (void);
117 /*-************************************
118 * Tuning parameter
119 **************************************/
127 #ifndef LZ4_MEMORY_USAGE
128 # define LZ4_MEMORY_USAGE 14
129 #endif
130 
131 
132 /*-************************************
133 * Simple Functions
134 **************************************/
149 LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
150 
165 LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
166 
167 
168 /*-************************************
169 * Advanced Functions
170 **************************************/
171 #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
172 #define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
173 
184 
193 LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
194 
195 
202 LZ4LIB_API int LZ4_sizeofState(void);
203 LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
204 
205 
229 LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
230 
231 
266 LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
267 
268 
269 /*-*********************************************
270 * Streaming Compression Functions
271 ***********************************************/
272 typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
273 
275 LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
276 
300 
312 LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
313 
337 LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
338 
346 LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
347 
348 
349 /*-**********************************************
350 * Streaming Decompression Functions
351 * Bufferless synchronous API
352 ************************************************/
353 typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
354 
361 
369 LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
370 
382 LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
383 #define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
384 
410 LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int srcSize, int dstCapacity);
411 
412 
421 LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize);
422 
423 }
424 
425 #endif /* LZ4_H_2983827168210 */
426 
427 
428 /*^*************************************
429  * !!!!!! STATIC LINKING ONLY !!!!!!
430  ***************************************/
431 
432 /*-****************************************************************************
433  * Experimental section
434  *
435  * Symbols declared in this section must be considered unstable. Their
436  * signatures or semantics may change, or they may be removed altogether in the
437  * future. They are therefore only safe to depend on when the caller is
438  * statically linked against the library.
439  *
440  * To protect against unsafe usage, not only are the declarations guarded,
441  * the definitions are hidden by default
442  * when building LZ4 as a shared/dynamic library.
443  *
444  * In order to access these declarations,
445  * define LZ4_STATIC_LINKING_ONLY in your application
446  * before including LZ4's headers.
447  *
448  * In order to make their implementations accessible dynamically, you must
449  * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
450  ******************************************************************************/
451 
452 #ifdef LZ4_STATIC_LINKING_ONLY
453 
454 #ifndef TRACY_LZ4_STATIC_3504398509
455 #define TRACY_LZ4_STATIC_3504398509
456 
457 #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
458 #define LZ4LIB_STATIC_API LZ4LIB_API
459 #else
460 #define LZ4LIB_STATIC_API
461 #endif
462 
463 namespace tracy
464 {
465 
476 LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
477 
504 LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const LZ4_stream_t* dictionaryStream);
505 
506 
558 #define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32)
559 #define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize))
561 #ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */
562 # define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
563 #endif
564 
565 #define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */
566 #define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN)
568 }
569 
570 #endif /* LZ4_STATIC_3504398509 */
571 #endif /* LZ4_STATIC_LINKING_ONLY */
572 
573 #ifndef TRACY_LZ4_H_98237428734687
574 #define TRACY_LZ4_H_98237428734687
575 
576 namespace tracy
577 {
578 
579 /*-************************************************************
580  * Private Definitions
581  **************************************************************
582  * Do not use these definitions directly.
583  * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
584  * Accessing members will expose user code to API and/or ABI break in future versions of the library.
585  **************************************************************/
586 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
587 #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
588 #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
589 
590 #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
591  typedef int8_t LZ4_i8;
592  typedef uint8_t LZ4_byte;
593  typedef uint16_t LZ4_u16;
594  typedef uint32_t LZ4_u32;
595 #else
596  typedef signed char LZ4_i8;
597  typedef unsigned char LZ4_byte;
598  typedef unsigned short LZ4_u16;
599  typedef unsigned int LZ4_u32;
600 #endif
601 
610 };
611 
612 typedef struct {
614  size_t extDictSize;
616  size_t prefixSize;
618 
619 
630 #define LZ4_STREAMSIZE 16416 /* static size, for inter-version compatibility */
631 #define LZ4_STREAMSIZE_VOIDP (LZ4_STREAMSIZE / sizeof(void*))
635 }; /* previously typedef'd to LZ4_stream_t */
636 
637 
653 
654 
662 #define LZ4_STREAMDECODESIZE_U64 (4 + ((sizeof(void*)==16) ? 2 : 0) /*AS-400*/ )
663 #define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
665  unsigned long long table[LZ4_STREAMDECODESIZE_U64];
667 } ; /* previously typedef'd to LZ4_streamDecode_t */
668 
669 
670 
671 /*-************************************
672 * Obsolete Functions
673 **************************************/
674 
686 #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
687 # define LZ4_DEPRECATED(message) /* disable deprecation warnings */
688 #else
689 # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
690 # define LZ4_DEPRECATED(message) [[deprecated(message)]]
691 # elif defined(_MSC_VER)
692 # define LZ4_DEPRECATED(message) __declspec(deprecated(message))
693 # elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
694 # define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
695 # elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
696 # define LZ4_DEPRECATED(message) __attribute__((deprecated))
697 # else
698 # pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
699 # define LZ4_DEPRECATED(message) /* disabled */
700 # endif
701 #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
702 
704 LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize);
705 LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize);
706 LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
707 LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
708 LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
709 LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
710 
712 LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize);
713 LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
714 
715 /* Obsolete streaming functions (since v1.7.0)
716  * degraded functionality; do not use!
717  *
718  * In order to perform streaming compression, these functions depended on data
719  * that is no longer tracked in the state. They have been preserved as well as
720  * possible: using them will still produce a correct output. However, they don't
721  * actually retain any history between compression calls. The compression ratio
722  * achieved will therefore be no better than compressing each chunk
723  * independently.
724  */
725 LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer);
726 LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
727 LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer);
728 LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state);
729 
731 LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
732 LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
733 
760 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
761 LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
762 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
763 LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
764 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
765 LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
766 
773 LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
774 
775 }
776 
777 #endif /* LZ4_H_98237428734687 */


Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)