FZGPUModules 2.0
GPU-accelerated modular compression pipelines
Loading...
Searching...
No Matches
hf.h
1// Adapted from PHF reference (origin/v1.1.0_dev:modules/codec/huffman/hf.h)
2// Changes: removed C management API (phf_codec, phf_create/release/buildbook/encode/decode),
3// removed pszanalysis_hf_buildtree; kept types, constants, and helper declarations.
4
5#ifndef PHF_HF_H
6#define PHF_HF_H
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#include <stddef.h>
12#include <stdint.h>
13
14typedef void* phf_stream_t;
15
16#define PHF_SUCCESS 0
17#define PHF_WRONG_DTYPE 1
18#define PHF_FAIL_GPU_MALLOC 2
19#define PHF_FAIL_GPU_MEMCPY 3
20#define PHF_FAIL_GPU_ILLEGAL_ACCESS 4
21#define PHF_FAIL_GPU_OUT_OF_MEMORY 5
22#define PHF_NOT_IMPLEMENTED 99
23
24typedef enum { HF_U1, HF_U2, HF_U4, HF_U8, HF_ULL, HF_INVALID } phf_dtype;
25
26#define PHFHEADER_FORCED_ALIGN 128
27#define PHFHEADER_HEADER 0
28#define PHFHEADER_REVBK 1
29#define PHFHEADER_PAR_NBIT 2
30#define PHFHEADER_PAR_ENTRY 3
31#define PHFHEADER_BITSTREAM 4
32#define PHFHEADER_END 5
33
34typedef uint32_t PHF_METADATA;
35typedef uint8_t PHF_BIN;
36typedef uint8_t PHF_BYTE;
37
38typedef struct {
39 int bklen : 16;
40 int sublen, pardeg;
41 size_t original_len;
42 size_t total_nbit, total_ncell;
43 uint32_t entry[PHFHEADER_END + 1];
44} phf_header;
45
46// phf_encoded_bytes: total byte length of a PHF-encoded bitstream
47#define phf_encoded_bytes capi_phf_encoded_bytes
48uint32_t capi_phf_encoded_bytes(phf_header* h);
49
50// phf_reverse_book_bytes: byte size of the reverse codebook for a given bklen
51#define phf_reverse_book_bytes capi_phf_reverse_book_bytes
52size_t capi_phf_reverse_book_bytes(uint16_t bklen, size_t BK_UNIT_BYTES, size_t SYM_BYTES);
53
54// Partition tuning helpers used by Buf<E> constructor
55size_t capi_phf_coarse_tune_sublen(size_t inlen);
56void capi_phf_coarse_tune(size_t len, int* sublen, int* pardeg);
57
58#ifdef __cplusplus
59}
60#endif
61#endif /* PHF_HF_H */