Add TNG writing and reading support
[alexxy/gromacs.git] / src / external / tng_io / include / compression / bwlzh.h
1 /* This code is part of the tng compression routines.
2  *
3  * Written by Daniel Spangberg
4  * Copyright (c) 2010, 2013, The GROMACS development team.
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the Revised BSD License.
9  */
10
11
12 #ifndef BWLZH_H
13 #define BWLZH_H
14
15 /* Compress the integers (positive, small integers are preferable)
16    using bwlzh compression.  The unsigned char *output should be
17    allocated to be able to hold worst case. You can obtain this length
18    conveniently by calling comp_get_buflen()
19 */
20 void DECLSPECDLLEXPORT bwlzh_compress(unsigned int *vals, int nvals,
21                   unsigned char *output, int *output_len);
22
23 void DECLSPECDLLEXPORT bwlzh_compress_no_lz77(unsigned int *vals, int nvals,
24                   unsigned char *output, int *output_len);
25
26 int DECLSPECDLLEXPORT bwlzh_get_buflen(int nvals);
27
28 void DECLSPECDLLEXPORT bwlzh_decompress(unsigned char *input, int nvals,
29                     unsigned int *vals);
30
31
32 /* The routines below are mostly useful for testing, and for internal
33    use by the library. */
34
35 void DECLSPECDLLEXPORT bwlzh_compress_verbose(unsigned int *vals, int nvals,
36                           unsigned char *output, int *output_len);
37
38 void DECLSPECDLLEXPORT bwlzh_compress_no_lz77_verbose(unsigned int *vals, int nvals,
39                   unsigned char *output, int *output_len);
40
41 void DECLSPECDLLEXPORT bwlzh_decompress_verbose(unsigned char *input, int nvals,
42                             unsigned int *vals);
43
44 /* Compress the integers (positive, small integers are preferable)
45    using huffman coding, with automatic selection of how to handle the
46    huffman dictionary.  The unsigned char *huffman should be allocated
47    to be able to hold worst case. You can obtain this length
48    conveniently by calling comp_huff_buflen()
49 */
50 void Ptngc_comp_huff_compress(unsigned int *vals, int nvals,
51                         unsigned char *huffman, int *huffman_len);
52
53 int Ptngc_comp_huff_buflen(int nvals);
54
55 void Ptngc_comp_huff_decompress(unsigned char *huffman, int huffman_len,
56                           unsigned int *vals);
57
58
59 /* the value pointed to by chosen_algo should be
60    sent as -1 for autodetect. */
61 void Ptngc_comp_huff_compress_verbose(unsigned int *vals, int nvals,
62                                 unsigned char *huffman, int *huffman_len,
63                                 int *huffdatalen,
64                                 int *huffman_lengths,int *chosen_algo,
65                                 int isvals16);
66
67 #define N_HUFFMAN_ALGO 3
68 char *Ptngc_comp_get_huff_algo_name(int algo);
69 char *Ptngc_comp_get_algo_name(int algo);
70
71
72 #endif