source: thirdparty/SZ/sz/include/Huffman.h @ 2c47b73

Revision 2c47b73, 2.9 KB checked in by Hal Finkel <hfinkel@…>, 6 years ago (diff)

more work on adding SZ (latest version)

  • Property mode set to 100644
RevLine 
[2c47b73]1/**
2 *  @file Huffman.h
3 *  @author Sheng Di
4 *  @date Aug., 2016
5 *  @brief Header file for the exponential segment constructor.
6 *  (C) 2016 by Mathematics and Computer Science (MCS), Argonne National Laboratory.
7 *      See COPYRIGHT in top-level directory.
8 */
9
10#ifndef _Huffman_H
11#define _Huffman_H
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17//Note: when changing the following settings, intvCapacity in sz.h should be changed as well.
18//#define allNodes 131072
19//#define stateNum 65536
20
21typedef struct node_t {
22        struct node_t *left, *right;
23        size_t freq;
24        char t; //in_node:0; otherwise:1
25        unsigned int c;
26} *node;
27
28typedef struct HuffmanTree {
29        int stateNum;
30        int allNodes;
31        struct node_t* pool;
32        node *qqq, *qq; //the root node of the HuffmanTree is qq[1]
33        int n_nodes; //n_nodes is for compression
34        int qend; 
35        unsigned long **code;
36        unsigned char *cout;
37        int n_inode; //n_inode is for decompression
38} HuffmanTree;
39
40HuffmanTree* createHuffmanTree(int stateNum);
41HuffmanTree* createDefaultHuffmanTree();
42
43node new_node(HuffmanTree *huffmanTree, size_t freq, unsigned int c, node a, node b);
44node new_node2(HuffmanTree *huffmanTree, unsigned int c, unsigned char t);
45void qinsert(HuffmanTree *huffmanTree, node n);
46node qremove(HuffmanTree *huffmanTree);
47void build_code(HuffmanTree *huffmanTree, node n, int len, unsigned long out1, unsigned long out2);
48void init(HuffmanTree *huffmanTree, int *s, size_t length);
49void encode(HuffmanTree *huffmanTree, int *s, size_t length, unsigned char *out, size_t *outSize);
50void decode(unsigned char *s, size_t targetLength, node t, int *out);
51void pad_tree_uchar(HuffmanTree* huffmanTree, unsigned char* L, unsigned char* R, unsigned int* C, unsigned char* t, unsigned int i, node root);
52void pad_tree_ushort(HuffmanTree* huffmanTree, unsigned short* L, unsigned short* R, unsigned int* C, unsigned char* t, unsigned int i, node root);
53void pad_tree_uint(HuffmanTree* huffmanTree, unsigned int* L, unsigned int* R, unsigned int* C, unsigned char* t, unsigned int i, node root);
54unsigned int convert_HuffTree_to_bytes_anyStates(HuffmanTree* huffmanTree, int nodeCount, unsigned char** out);
55void unpad_tree_uchar(HuffmanTree* huffmanTree, unsigned char* L, unsigned char* R, unsigned int* C, unsigned char *t, unsigned int i, node root);
56void unpad_tree_ushort(HuffmanTree* huffmanTree, unsigned short* L, unsigned short* R, unsigned int* C, unsigned char* t, unsigned int i, node root);
57void unpad_tree_uint(HuffmanTree* huffmanTree, unsigned int* L, unsigned int* R, unsigned int* C, unsigned char* t, unsigned int i, node root);
58node reconstruct_HuffTree_from_bytes_anyStates(HuffmanTree *huffmanTree, unsigned char* bytes, int nodeCount);
59
60void encode_withTree(HuffmanTree* huffmanTree, int *s, size_t length, unsigned char **out, size_t *outSize);
61void decode_withTree(HuffmanTree* huffmanTree, unsigned char *s, size_t targetLength, int *out);
62
63void SZ_ReleaseHuffman(HuffmanTree* huffmanTree);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif
Note: See TracBrowser for help on using the repository browser.