mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Separate the into multiple files similar to the vogl zip64 version of the library.
If anyone wants to have a minified version of if a script could be written to do this automatically.
This commit is contained in:
		
							
								
								
									
										94
									
								
								miniz_tinfl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								miniz_tinfl.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,94 @@ | ||||
| #pragma once | ||||
| #include "miniz_common.h" | ||||
| // ------------------- Low-level Decompression API Definitions | ||||
|  | ||||
| // Decompression flags used by tinfl_decompress(). | ||||
| // TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream. | ||||
| // TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input. | ||||
| // TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB). | ||||
| // TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes. | ||||
| enum | ||||
| { | ||||
|   TINFL_FLAG_PARSE_ZLIB_HEADER = 1, | ||||
|   TINFL_FLAG_HAS_MORE_INPUT = 2, | ||||
|   TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4, | ||||
|   TINFL_FLAG_COMPUTE_ADLER32 = 8 | ||||
| }; | ||||
|  | ||||
| // High level decompression functions: | ||||
| // tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc(). | ||||
| // On entry: | ||||
| //  pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress. | ||||
| // On return: | ||||
| //  Function returns a pointer to the decompressed data, or NULL on failure. | ||||
| //  *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. | ||||
| //  The caller must call mz_free() on the returned block when it's no longer needed. | ||||
| void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags); | ||||
|  | ||||
| // tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. | ||||
| // Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. | ||||
| #define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1)) | ||||
| size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags); | ||||
|  | ||||
| // tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. | ||||
| // Returns 1 on success or 0 on failure. | ||||
| typedef int (*tinfl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); | ||||
| int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); | ||||
|  | ||||
| struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor; | ||||
|  | ||||
| // Max size of LZ dictionary. | ||||
| #define TINFL_LZ_DICT_SIZE 32768 | ||||
|  | ||||
| // Return status. | ||||
| typedef enum | ||||
| { | ||||
|   TINFL_STATUS_BAD_PARAM = -3, | ||||
|   TINFL_STATUS_ADLER32_MISMATCH = -2, | ||||
|   TINFL_STATUS_FAILED = -1, | ||||
|   TINFL_STATUS_DONE = 0, | ||||
|   TINFL_STATUS_NEEDS_MORE_INPUT = 1, | ||||
|   TINFL_STATUS_HAS_MORE_OUTPUT = 2 | ||||
| } tinfl_status; | ||||
|  | ||||
| // Initializes the decompressor to its initial state. | ||||
| #define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END | ||||
| #define tinfl_get_adler32(r) (r)->m_check_adler32 | ||||
|  | ||||
| // Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. | ||||
| // This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. | ||||
| tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags); | ||||
|  | ||||
| // Internal/private bits follow. | ||||
| enum | ||||
| { | ||||
|   TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19, | ||||
|   TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS | ||||
| }; | ||||
|  | ||||
| typedef struct | ||||
| { | ||||
|   mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0]; | ||||
|   mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2]; | ||||
| } tinfl_huff_table; | ||||
|  | ||||
| #if MINIZ_HAS_64BIT_REGISTERS | ||||
|   #define TINFL_USE_64BIT_BITBUF 1 | ||||
| #endif | ||||
|  | ||||
| #if TINFL_USE_64BIT_BITBUF | ||||
|   typedef mz_uint64 tinfl_bit_buf_t; | ||||
|   #define TINFL_BITBUF_SIZE (64) | ||||
| #else | ||||
|   typedef mz_uint32 tinfl_bit_buf_t; | ||||
|   #define TINFL_BITBUF_SIZE (32) | ||||
| #endif | ||||
|  | ||||
| struct tinfl_decompressor_tag | ||||
| { | ||||
|   mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES]; | ||||
|   tinfl_bit_buf_t m_bit_buf; | ||||
|   size_t m_dist_from_out_buf_start; | ||||
|   tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES]; | ||||
|   mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137]; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user