Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Michael A. (Mike) Iovine
p1
Commits
067d8524
Commit
067d8524
authored
5 years ago
by
Mike Iovine
Browse files
Options
Download
Email Patches
Plain Diff
Add header file for inflate
parent
2bac0fe7
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inflate.h
+68
-0
inflate.h
with
68 additions
and
0 deletions
+68
-0
inflate.h
0 → 100644
View file @
067d8524
#ifndef _INFLATE_C_
#define _INFLATE_C_
/* Maximum length for any Huffman code */
#define MAX_LENGTH 15
typedef
struct
huffman
{
/* bl_counts[i] = number of codes of length i */
int
bl_counts
[
MAX_LENGTH
+
1
];
/* This stores the alphabet.
* alphabet[i] returns an array of alphabet symbols of length bl_counts[i].
*/
int
*
alphabet
[
MAX_LENGTH
+
1
];
/* Suppose we are reading a code and we want an index into the alphabet array.
* These are basically the numerical offsets for such an index.
* So if the code we are reading has value c and is of length i,
* its alphabet character is indexed by (c - min_codes[i]).
*/
int
min_codes
[
MAX_LENGTH
+
1
];
}
huffman_t
;
/* Create a Huffman mapping from a sequence of lengths. */
huffman_t
*
make_huffman
(
int
*
lens
,
int
*
alphabet
,
int
n_symbols
);
/* Clean up a heap allocated Huffman map */
void
destroy_huffman
(
huffman_t
*
hf
);
/* Get the next bit from a buffer of bytes read from memory */
int
get_next_bit
(
char
*
buf
);
/*
* Get the numerical value of n bits read from a buffer.
* If reverse is set true, interpret the bytes in
* reverse stream order.
*/
int
get_n_bits
(
char
*
buf
,
int
n
,
bool
reverse
);
/*
* Given a Huffman map, read ONE code from the buffer and
* return its numerical value in stream order.
*/
int
read_chunk
(
char
*
buf
,
huffman_t
hf
);
/*
* For the DYNAMIC Huffman type.
* Read a sequence of code lengths (between 0 and 18) from the buffer.
* The number of codes read is specified by "num_codes", however,
* the returned sequence of lengths is 0-padded to the length
* of the whole alphabet given by "num_symbols".
*/
int
*
read_lens
(
char
*
buf
,
huffman_t
*
hf_codes
,
int
num_symbols
,
int
num_codes
);
/*
* Read a single block from the buffer, and write the deflated
* results to "out".
*/
void
read_block
(
char
*
buf
,
FILE
*
out
);
/*
* Inflate the file fp.
*/
void
inflate
(
FILE
*
fp
,
char
*
fname
);
#endif
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help