Add a inflateEnd() call to free up the stream in the re-init block.
[obnox/wireshark/wip.git] / epan / reedsolomon.h
1 #ifdef __cplusplus
2 extern "C" {
3 #endif
4
5 /* Global definitions for Reed-Solomon encoder/decoder
6  * Phil Karn KA9Q, September 1996
7  */
8 /* Set one of these to enable encoder/decoder debugging and error checking,
9  * at the expense of speed */
10 /* #undef DEBUG 1*/
11 /* #undef DEBUG 2*/
12 #undef DEBUG
13
14 /* To select the CCSDS standard (255,223) code, define CCSDS. This
15  * implies standard values for MM, KK, B0 and PRIM.
16  */
17 /* #undef CCSDS 1*/
18 #undef CCSDS
19 #ifndef CCSDS
20
21 /* Otherwise, leave CCSDS undefined and set the parameters below:
22  *
23  * Set MM to be the size of each code symbol in bits. The Reed-Solomon
24  * block size will then be NN = 2**M - 1 symbols. Supported values are
25  * defined in rs.c.
26  */
27 #define MM 8 /* Symbol size in bits */
28
29 /*
30  * Set KK to be the number of data symbols in each block, which must be
31  * less than the block size. The code will then be able to correct up
32  * to NN-KK erasures or (NN-KK)/2 errors, or combinations thereof with
33  * each error counting as two erasures.
34  */
35 #define KK 207 /* Number of data symbols per block */
36
37 /* Set B0 to the first root of the generator polynomial, in alpha form, and
38  * set PRIM to the power of alpha used to generate the roots of the
39  * generator polynomial. The generator polynomial will then be
40  * @**PRIM*B0, @**PRIM*(B0+1), @**PRIM*(B0+2)...@**PRIM*(B0+NN-KK)
41  * where "@" represents a lower case alpha.
42  */
43 #define B0 1 /* First root of generator polynomial, alpha form */
44 #define PRIM 1 /* power of alpha used to generate roots of generator poly */
45 #define STANDARD_ORDER
46
47 /* If you want to select your own field generator polynomial, you'll have
48  * to edit that in rs.c.
49  */
50
51 #else /* CCSDS */
52 /* Don't change these, they're CCSDS standard */
53 #define MM 8
54 #define KK 223
55 #define B0 112
56 #define PRIM 11
57 #endif
58
59 #define NN ((1 << MM) - 1)
60
61 #if MM <= 8
62 typedef unsigned char dtype;
63 #else
64 typedef unsigned int dtype;
65 #endif
66
67 /* Reed-Solomon encoding
68  * data[] is the input block, parity symbols are placed in bb[]
69  * bb[] may lie past the end of the data, e.g., for (255,223):
70  *      encode_rs(&data[0],&data[223]);
71  */
72 int encode_rs(dtype data[], dtype bb[]);
73
74 /* Reed-Solomon erasures-and-errors decoding
75  * The received block goes into data[], and a list of zero-origin
76  * erasure positions, if any, goes in eras_pos[] with a count in no_eras.
77  *
78  * The decoder corrects the symbols in place, if possible and returns
79  * the number of corrected symbols. If the codeword is illegal or
80  * uncorrectible, the data array is unchanged and -1 is returned
81  */
82 int eras_dec_rs(dtype data[], int eras_pos[], int no_eras);
83
84 #ifdef __cplusplus
85 }
86 #endif