1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF.  The full HDF copyright notice, including       *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/.  *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* $Id$ */
15 
16 /*-----------------------------------------------------------------------------
17  * File:    hcomp.h
18  * Purpose: header file for compression information & structures
19  * Dependencies: should be included after hdf.h
20  * Invokes:
21  * Contents:
22  * Structure definitions: comp_info
23  * Constant definitions: lots...
24  *---------------------------------------------------------------------------*/
25 
26 /* avoid re-inclusion */
27 #ifndef __HCOMP_H
28 #define __HCOMP_H
29 
30 /* For determining which type of modeling is being done */
31 typedef enum
32   {
33       COMP_MODEL_STDIO = 0      /* for Standard C I/O model */
34   }
35 comp_model_t;
36 
37 /* For determining which type of encoding is being done */
38 typedef enum
39   {
40       COMP_CODE_NONE = 0,       /* don't encode at all, just store */
41       COMP_CODE_RLE,            /* for simple RLE encoding */
42       COMP_CODE_NBIT,           /* for N-bit encoding */
43       COMP_CODE_SKPHUFF,        /* for Skipping huffman encoding */
44       COMP_CODE_DEFLATE,        /* for gzip 'deflate' encoding */
45       COMP_CODE_SZIP,		/* for szip encoding */
46       COMP_CODE_INVALID,        /* invalid last code, for range checking */
47       COMP_CODE_JPEG,           /* _Ugly_ hack to allow JPEG images to be created with GRsetcompress */
48       COMP_CODE_IMCOMP = 12     /* another _Ugly_ hack to allow IMCOMP images to
49                          be inquired, 12 to be the same as COMP_IMCOMP writing
50                          will not be allowed, however.  -BMR, Jul 2012 */
51   }
52 comp_coder_t;
53 
54 /* Compression types available */
55 #define COMP_NONE       0
56 #define COMP_JPEG       2
57 #define COMP_RLE        11
58 #define COMP_IMCOMP     12
59 
60 /* Compression encoder/decoder configuration */
61 #define COMP_DECODER_ENABLED     1
62 #define COMP_ENCODER_ENABLED     2
63 
64 #ifndef COMPRESS_MASTER
65 extern uint16 compress_map[];
66 #else
67 uint16      compress_map[COMP_MAX_COMP + 1] =
68 {                               /* Mapping from compression types to tags */
69     0,                          /* No corresponding tag for un-compressed data */
70     0,                          /* (1) */
71     DFTAG_JPEG5,                /* COMP_JPEG -> DFTAG_JPEG5 (for JPEG compression) */
72     0,                          /* (3) */
73     0,                          /* (4) */
74     0,                          /* (5) */
75     0,                          /* (6) */
76     0,                          /* (7) */
77     0,                          /* (8) */
78     0,                          /* (9) */
79     0,                          /* (10) */
80     DFTAG_RLE,                  /* COMP_RLE -> DFTAG_RLE (for Run-length compression) */
81     DFTAG_IMC                   /* COMP_IMCOMP -> DFTAG_IMC (for IMCOMP compression) */
82 };
83 #endif
84 
85 typedef union tag_model_info
86   {                             /* Union to contain modeling information */
87       struct
88         {
89             int32       nt;     /* number type */
90             intn        ndim;   /* number of dimensions */
91             int32      *dims;   /* array of dimensions */
92         }
93       dim;
94   }
95 model_info;
96 
97 typedef union tag_comp_info
98   {                             /* Union to contain compression information */
99       struct
100         {   /* Struct to contain information about how to compress */
101             /* or decompress a JPEG encoded 24-bit image */
102             intn    quality;    /* Quality factor for JPEG compression, should be from */
103             /* 0 (terrible) to 100 (very good) */
104             intn    force_baseline;     /* If force_baseline is set to TRUE then */
105             /* quantization tables are limited to */
106             /* 0..255 for JPEG baseline compability */
107             /* This is only an issue for quality */
108             /* settings below 24 */
109         }
110       jpeg;
111       struct
112         {   /* struct to contain information about how to compress */
113             /* or decompress a N-bit encoded dataset */
114             int32   nt;     /* number type of the data to encode */
115             intn    sign_ext;   /* whether to sign extend or not */
116             intn    fill_one;   /* whether to fill with 1's or 0's */
117             intn    start_bit;  /* offset of the start bit in the data */
118             intn    bit_len;    /* number of bits to store */
119         }
120       nbit;
121       struct
122         {   /* struct to contain info about how to compress */
123             /* or decompress a "skipping" huffman encoded dataset */
124             intn    skp_size;   /* size of the individual elements when skipping */
125         }
126       skphuff;
127       struct
128         {   /* struct to contain info about how to compress */
129             /* or decompress a gzip encoded dataset */
130             intn    level;   /* how hard to work when compressing the data */
131         }
132       deflate;
133       struct
134         {
135             int32 options_mask;   /* IN */
136             int32 pixels_per_block;   /* IN */
137             int32 pixels_per_scanline; /* OUT: computed */
138 	    int32 bits_per_pixel; /* OUT: size of NT */
139             int32 pixels; /* OUT: size of dataset or chunk */
140          }
141        szip;  /* for szip encoding */
142 
143   }
144 comp_info;
145 
146 #endif /* __HCOMP_H */
147 
148