[3365] | 1 | /**************************************************************************
|
---|
| 2 | *
|
---|
| 3 | * huffman.h -- Huffman coding functions
|
---|
| 4 | * Copyright (C) 1994 Neil Sharman
|
---|
| 5 | *
|
---|
| 6 | * This program is free software; you can redistribute it and/or modify
|
---|
| 7 | * it under the terms of the GNU General Public License as published by
|
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 9 | * (at your option) any later version.
|
---|
| 10 | *
|
---|
| 11 | * This program is distributed in the hope that it will be useful,
|
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | * GNU General Public License for more details.
|
---|
| 15 | *
|
---|
| 16 | * You should have received a copy of the GNU General Public License
|
---|
| 17 | * along with this program; if not, write to the Free Software
|
---|
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 19 | *
|
---|
| 20 | **************************************************************************/
|
---|
| 21 |
|
---|
| 22 | #ifndef H_HUFFMAN
|
---|
| 23 | #define H_HUFFMAN
|
---|
| 24 |
|
---|
[16353] | 25 | #include <sys/types.h>
|
---|
| 26 |
|
---|
[3365] | 27 | #include "sysfuncs.h"
|
---|
| 28 | #include "bitio_m_abstract.h"
|
---|
| 29 |
|
---|
| 30 | #define MAX_HUFFCODE_LEN 31
|
---|
| 31 |
|
---|
| 32 | struct huff_data {
|
---|
| 33 | int num_codes;
|
---|
| 34 | int mincodelen;
|
---|
| 35 | int maxcodelen;
|
---|
| 36 | int lencount[MAX_HUFFCODE_LEN + 1];
|
---|
| 37 | unsigned long min_code[MAX_HUFFCODE_LEN + 1];
|
---|
| 38 | char *clens;
|
---|
| 39 | };
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | huff_data *Generate_Huffman_Data (int num, long *freqs, huff_data * data,
|
---|
| 43 | u_long * mem);
|
---|
| 44 |
|
---|
| 45 | unsigned long *Generate_Huffman_Codes (huff_data * data, u_long * mem);
|
---|
| 46 |
|
---|
| 47 | unsigned long **Generate_Huffman_Vals (huff_data * data, u_long * mem);
|
---|
| 48 |
|
---|
| 49 | int Write_Huffman_Data (FILE * f, huff_data * hd);
|
---|
| 50 |
|
---|
| 51 | int Read_Huffman_Data (FILE * f, huff_data * hd, u_long * mem, u_long * disk);
|
---|
| 52 |
|
---|
| 53 | /* Calculate the number of bits required to code the data with the
|
---|
| 54 | specified frequencies. Normally freqs and counts should point to
|
---|
| 55 | the same array. */
|
---|
| 56 | double Calculate_Huffman_Size (int num, long *freqs, long *counts);
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | #endif
|
---|