2 |
- |
1 |
/* Copyright (C) 1994 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
|
|
|
3 |
This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
implied.
|
|
|
5 |
|
|
|
6 |
This software is distributed under license and may not be copied,
|
|
|
7 |
modified or distributed except as expressly authorized under the terms
|
|
|
8 |
of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
|
|
|
10 |
For more information about licensing, please refer to
|
|
|
11 |
http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
/* $Id: shcgen.h,v 1.5 2002/06/16 05:00:54 lpd Exp $ */
|
|
|
18 |
/* Interface for Huffman code generation */
|
|
|
19 |
/* Requires shc.h */
|
|
|
20 |
|
|
|
21 |
#ifndef shcgen_INCLUDED
|
|
|
22 |
# define shcgen_INCLUDED
|
|
|
23 |
|
|
|
24 |
/* Compute an optimal Huffman code from an input data set. */
|
|
|
25 |
/* The client must have set all the elements of *def. */
|
|
|
26 |
/* The definition is guaranteed to be well-behaved. */
|
|
|
27 |
int hc_compute(hc_definition * def, const long *freqs, gs_memory_t * mem);
|
|
|
28 |
|
|
|
29 |
/* Convert a definition to a byte string. */
|
|
|
30 |
/* The caller must provide the byte string, of length def->num_values. */
|
|
|
31 |
/* Assume (do not check) that the definition is well-behaved. */
|
|
|
32 |
/* Return the actual length of the string. */
|
|
|
33 |
int hc_bytes_from_definition(byte * dbytes, const hc_definition * def);
|
|
|
34 |
|
|
|
35 |
/* Extract num_counts and num_values from a byte string. */
|
|
|
36 |
void hc_sizes_from_bytes(hc_definition * def, const byte * dbytes, int num_bytes);
|
|
|
37 |
|
|
|
38 |
/* Convert a byte string back to a definition. */
|
|
|
39 |
/* The caller must initialize *def, including allocating counts and values. */
|
|
|
40 |
void hc_definition_from_bytes(hc_definition * def, const byte * dbytes);
|
|
|
41 |
|
|
|
42 |
/* Generate the encoding table from the definition. */
|
|
|
43 |
/* The size of the encode array is def->num_values. */
|
|
|
44 |
void hc_make_encoding(hce_code * encode, const hc_definition * def);
|
|
|
45 |
|
|
|
46 |
/* Calculate the size of the decoding table. */
|
|
|
47 |
uint hc_sizeof_decoding(const hc_definition * def, int initial_bits);
|
|
|
48 |
|
|
|
49 |
/* Generate the decoding tables. */
|
|
|
50 |
void hc_make_decoding(hcd_code * decode, const hc_definition * def,
|
|
|
51 |
int initial_bits);
|
|
|
52 |
|
|
|
53 |
#endif /* shcgen_INCLUDED */
|