-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoder.h
39 lines (29 loc) · 850 Bytes
/
encoder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef DATA_COMPRESSOR_ENCODER_H
#define DATA_COMPRESSOR_ENCODER_H
struct node {
char data;
int freq;
struct node *left;
struct node *right;
int is_leaf;
};
union buffer {
struct {
unsigned char bit0: 1;
unsigned char bit1: 1;
unsigned char bit2: 1;
unsigned char bit3: 1;
unsigned char bit4: 1;
unsigned char bit5: 1;
unsigned char bit6: 1;
unsigned char bit7: 1;
} bits;
unsigned char byte;
};
int encode(char *filename1, char *filename2);
struct node *char_freq(FILE *f, int *size);
void sort_by_freq(struct node *tab, int size);
struct node *delete_first_element(struct node *tab, int *size);
int write_huffman_tree(struct node *node, FILE *out);
char *code_of_char(struct node *root, unsigned char ch);
#endif //DATA_COMPRESSOR_ENCODER_H