VR-Vantage 2.7 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
37 #ifndef TRACY_LZ4_H_2983827168210
38 #define TRACY_LZ4_H_2983827168210
39 
40 /* --- Dependency --- */
41 #include <stddef.h> /* size_t */
42 #include <stdint.h>
43 
44 namespace tracy
45 {
46 
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 1 /* 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 LZ4LIB_API int LZ4_versionNumber (void);
111 LZ4LIB_API const char* LZ4_versionString (void);
114 /*-************************************
115 * Tuning parameter
116 **************************************/
124 #ifndef LZ4_MEMORY_USAGE
125 # define LZ4_MEMORY_USAGE 14
126 #endif
127 
128 
129 /*-************************************
130 * Simple Functions
131 **************************************/
146 LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
147 
156 LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
157 
158 
159 /*-************************************
160 * Advanced Functions
161 **************************************/
162 #define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
163 #define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
164 
175 
183 LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
184 
185 
192 LZ4LIB_API int LZ4_sizeofState(void);
193 LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
194 
195 
208 LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize);
209 
210 
235 LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
236 
237 
238 /*-*********************************************
239 * Streaming Compression Functions
240 ***********************************************/
241 typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
242 
244 LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
245 
269 
281 LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
282 
306 LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
307 
315 LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
316 
317 
318 /*-**********************************************
319 * Streaming Decompression Functions
320 * Bufferless synchronous API
321 ************************************************/
322 typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
323 
330 
338 LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
339 
351 LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
352 #define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
353 
379 LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int srcSize, int dstCapacity);
380 
381 
390 LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize);
391 
392 
393 /*^*************************************
394  * !!!!!! STATIC LINKING ONLY !!!!!!
395  ***************************************/
396 
397 /*-****************************************************************************
398  * Experimental section
399  *
400  * Symbols declared in this section must be considered unstable. Their
401  * signatures or semantics may change, or they may be removed altogether in the
402  * future. They are therefore only safe to depend on when the caller is
403  * statically linked against the library.
404  *
405  * To protect against unsafe usage, not only are the declarations guarded,
406  * the definitions are hidden by default
407  * when building LZ4 as a shared/dynamic library.
408  *
409  * In order to access these declarations,
410  * define LZ4_STATIC_LINKING_ONLY in your application
411  * before including LZ4's headers.
412  *
413  * In order to make their implementations accessible dynamically, you must
414  * define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
415  ******************************************************************************/
416 
417 #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
418 #define LZ4LIB_STATIC_API LZ4LIB_API
419 #else
420 #define LZ4LIB_STATIC_API
421 #endif
422 
423 #ifdef LZ4_STATIC_LINKING_ONLY
424 
425 
436 LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
437 
464 LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const LZ4_stream_t* dictionaryStream);
465 
466 #endif
467 
468 
469 /*-************************************************************
470  * PRIVATE DEFINITIONS
471  **************************************************************
472  * Do not use these definitions directly.
473  * They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
474  * Accessing members will expose code to API and/or ABI break in future versions of the library.
475  **************************************************************/
476 #define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
477 #define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
478 #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
479 
480 #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
481 #include <stdint.h>
482 
484 struct LZ4_stream_t_internal {
487  uint16_t dirty;
489  const uint8_t* dictionary;
492 };
493 
494 typedef struct {
495  const uint8_t* externalDict;
496  size_t extDictSize;
497  const uint8_t* prefixEnd;
498  size_t prefixSize;
500 
501 #else
502 
506  unsigned int currentOffset;
507  unsigned short dirty;
508  unsigned short tableType;
509  const unsigned char* dictionary;
511  unsigned int dictSize;
512 };
513 
514 typedef struct {
515  const unsigned char* externalDict;
516  const unsigned char* prefixEnd;
517  size_t extDictSize;
518  size_t prefixSize;
520 
521 #endif
522 
532 #define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4 + ((sizeof(void*)==16) ? 4 : 0) /*AS-400*/ )
533 #define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long))
535  unsigned long long table[LZ4_STREAMSIZE_U64];
537 } ; /* previously typedef'd to LZ4_stream_t */
538 
554 
555 
563 #define LZ4_STREAMDECODESIZE_U64 (4 + ((sizeof(void*)==16) ? 2 : 0) /*AS-400*/ )
564 #define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
566  unsigned long long table[LZ4_STREAMDECODESIZE_U64];
568 } ; /* previously typedef'd to LZ4_streamDecode_t */
569 
570 
571 /*-************************************
572 * Obsolete Functions
573 **************************************/
574 
586 #ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
587 # define LZ4_DEPRECATED(message) /* disable deprecation warnings */
588 #else
589 # define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
590 # if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
591 # define LZ4_DEPRECATED(message) [[deprecated(message)]]
592 # elif (LZ4_GCC_VERSION >= 405) || defined(__clang__)
593 # define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
594 # elif (LZ4_GCC_VERSION >= 301)
595 # define LZ4_DEPRECATED(message) __attribute__((deprecated))
596 # elif defined(_MSC_VER)
597 # define LZ4_DEPRECATED(message) __declspec(deprecated(message))
598 # else
599 # pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
600 # define LZ4_DEPRECATED(message)
601 # endif
602 #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
603 
604 /* Obsolete compression functions */
605 LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* source, char* dest, int sourceSize);
606 LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
607 LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize);
608 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);
609 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);
610 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);
611 
612 /* Obsolete decompression functions */
613 LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize);
614 LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
615 
616 /* Obsolete streaming functions; degraded functionality; do not use!
617  *
618  * In order to perform streaming compression, these functions depended on data
619  * that is no longer tracked in the state. They have been preserved as well as
620  * possible: using them will still produce a correct output. However, they don't
621  * actually retain any history between compression calls. The compression ratio
622  * achieved will therefore be no better than compressing each chunk
623  * independently.
624  */
625 LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer);
626 LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
627 LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer);
628 LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state);
629 
630 /* Obsolete streaming decoding functions */
631 LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
632 LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
633 
662 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
663 LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize);
664 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
665 LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
666 LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
667 LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
668 
675 LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr);
676 
677 }
678 
679 #endif /* LZ4_H_2983827168210 */


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