mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 00:32:38 +01:00 
			
		
		
		
	Add vogl .clang-format and reformat library source.
This commit is contained in:
		
							
								
								
									
										124
									
								
								miniz_tdef.h
									
									
									
									
									
								
							
							
						
						
									
										124
									
								
								miniz_tdef.h
									
									
									
									
									
								
							| @@ -10,7 +10,9 @@ | ||||
| // TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression). | ||||
| enum | ||||
| { | ||||
|   TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF | ||||
|     TDEFL_HUFFMAN_ONLY = 0, | ||||
|     TDEFL_DEFAULT_MAX_PROBES = 128, | ||||
|     TDEFL_MAX_PROBES_MASK = 0xFFF | ||||
| }; | ||||
|  | ||||
| // TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data. | ||||
| @@ -24,14 +26,14 @@ enum | ||||
| // The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK). | ||||
| enum | ||||
| { | ||||
|   TDEFL_WRITE_ZLIB_HEADER             = 0x01000, | ||||
|   TDEFL_COMPUTE_ADLER32               = 0x02000, | ||||
|   TDEFL_GREEDY_PARSING_FLAG           = 0x04000, | ||||
|   TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, | ||||
|   TDEFL_RLE_MATCHES                   = 0x10000, | ||||
|   TDEFL_FILTER_MATCHES                = 0x20000, | ||||
|   TDEFL_FORCE_ALL_STATIC_BLOCKS       = 0x40000, | ||||
|   TDEFL_FORCE_ALL_RAW_BLOCKS          = 0x80000 | ||||
|     TDEFL_WRITE_ZLIB_HEADER = 0x01000, | ||||
|     TDEFL_COMPUTE_ADLER32 = 0x02000, | ||||
|     TDEFL_GREEDY_PARSING_FLAG = 0x04000, | ||||
|     TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000, | ||||
|     TDEFL_RLE_MATCHES = 0x10000, | ||||
|     TDEFL_FILTER_MATCHES = 0x20000, | ||||
|     TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000, | ||||
|     TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000 | ||||
| }; | ||||
|  | ||||
| // High level compression functions: | ||||
| @@ -63,64 +65,90 @@ void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int | ||||
| void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out); | ||||
|  | ||||
| // Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. | ||||
| typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser); | ||||
| typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser); | ||||
|  | ||||
| // tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. | ||||
| mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags); | ||||
|  | ||||
| enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 }; | ||||
| enum | ||||
| { | ||||
|     TDEFL_MAX_HUFF_TABLES = 3, | ||||
|     TDEFL_MAX_HUFF_SYMBOLS_0 = 288, | ||||
|     TDEFL_MAX_HUFF_SYMBOLS_1 = 32, | ||||
|     TDEFL_MAX_HUFF_SYMBOLS_2 = 19, | ||||
|     TDEFL_LZ_DICT_SIZE = 32768, | ||||
|     TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, | ||||
|     TDEFL_MIN_MATCH_LEN = 3, | ||||
|     TDEFL_MAX_MATCH_LEN = 258 | ||||
| }; | ||||
|  | ||||
| // TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes). | ||||
| #if TDEFL_LESS_MEMORY | ||||
| enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; | ||||
| enum | ||||
| { | ||||
|     TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, | ||||
|     TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, | ||||
|     TDEFL_MAX_HUFF_SYMBOLS = 288, | ||||
|     TDEFL_LZ_HASH_BITS = 12, | ||||
|     TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, | ||||
|     TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, | ||||
|     TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS | ||||
| }; | ||||
| #else | ||||
| enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS }; | ||||
| enum | ||||
| { | ||||
|     TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, | ||||
|     TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13) / 10, | ||||
|     TDEFL_MAX_HUFF_SYMBOLS = 288, | ||||
|     TDEFL_LZ_HASH_BITS = 15, | ||||
|     TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, | ||||
|     TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, | ||||
|     TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS | ||||
| }; | ||||
| #endif | ||||
|  | ||||
| // The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions. | ||||
| typedef enum | ||||
| { | ||||
|   TDEFL_STATUS_BAD_PARAM = -2, | ||||
|   TDEFL_STATUS_PUT_BUF_FAILED = -1, | ||||
|   TDEFL_STATUS_OKAY = 0, | ||||
|   TDEFL_STATUS_DONE = 1, | ||||
| typedef enum { | ||||
|     TDEFL_STATUS_BAD_PARAM = -2, | ||||
|     TDEFL_STATUS_PUT_BUF_FAILED = -1, | ||||
|     TDEFL_STATUS_OKAY = 0, | ||||
|     TDEFL_STATUS_DONE = 1, | ||||
| } tdefl_status; | ||||
|  | ||||
| // Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums | ||||
| typedef enum | ||||
| { | ||||
|   TDEFL_NO_FLUSH = 0, | ||||
|   TDEFL_SYNC_FLUSH = 2, | ||||
|   TDEFL_FULL_FLUSH = 3, | ||||
|   TDEFL_FINISH = 4 | ||||
| typedef enum { | ||||
|     TDEFL_NO_FLUSH = 0, | ||||
|     TDEFL_SYNC_FLUSH = 2, | ||||
|     TDEFL_FULL_FLUSH = 3, | ||||
|     TDEFL_FINISH = 4 | ||||
| } tdefl_flush; | ||||
|  | ||||
| // tdefl's compression state structure. | ||||
| typedef struct | ||||
| { | ||||
|   tdefl_put_buf_func_ptr m_pPut_buf_func; | ||||
|   void *m_pPut_buf_user; | ||||
|   mz_uint m_flags, m_max_probes[2]; | ||||
|   int m_greedy_parsing; | ||||
|   mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; | ||||
|   mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; | ||||
|   mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; | ||||
|   mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; | ||||
|   tdefl_status m_prev_return_status; | ||||
|   const void *m_pIn_buf; | ||||
|   void *m_pOut_buf; | ||||
|   size_t *m_pIn_buf_size, *m_pOut_buf_size; | ||||
|   tdefl_flush m_flush; | ||||
|   const mz_uint8 *m_pSrc; | ||||
|   size_t m_src_buf_left, m_out_buf_ofs; | ||||
|   mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; | ||||
|   mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; | ||||
|   mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; | ||||
|   mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; | ||||
|   mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; | ||||
|   mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; | ||||
|   mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; | ||||
|   mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; | ||||
|     tdefl_put_buf_func_ptr m_pPut_buf_func; | ||||
|     void *m_pPut_buf_user; | ||||
|     mz_uint m_flags, m_max_probes[2]; | ||||
|     int m_greedy_parsing; | ||||
|     mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size; | ||||
|     mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end; | ||||
|     mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer; | ||||
|     mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish; | ||||
|     tdefl_status m_prev_return_status; | ||||
|     const void *m_pIn_buf; | ||||
|     void *m_pOut_buf; | ||||
|     size_t *m_pIn_buf_size, *m_pOut_buf_size; | ||||
|     tdefl_flush m_flush; | ||||
|     const mz_uint8 *m_pSrc; | ||||
|     size_t m_src_buf_left, m_out_buf_ofs; | ||||
|     mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1]; | ||||
|     mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; | ||||
|     mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; | ||||
|     mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS]; | ||||
|     mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE]; | ||||
|     mz_uint16 m_next[TDEFL_LZ_DICT_SIZE]; | ||||
|     mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE]; | ||||
|     mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE]; | ||||
| } tdefl_compressor; | ||||
|  | ||||
| // Initializes the compressor. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user