OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
rice.h
Go to the documentation of this file.
1 /* BEGIN THIRD_PARTY_COPYRIGHT */
2 /*==============================================================
3 The SZIP Science Data Lossless Compression Program is Copyright (C) 2001
4 Science & Technology Corporation @ UNM. All rights released.
5 Copyright (C) 2003 Lowell H. Miles and Jack A. Venbrux. Licensed to ICs, LLC,
6 for distribution by the University of Illinois' National Center for
7 Supercomputing Applications as a part of the HDF data storage and retrieval
8 file format and software library products package. All rights reserved.
9 Do not modify or use for other purposes.
10 
11 SZIP implements an extended Rice adaptive lossless compression algorithm for
12 sample data. The primary algorithm was developed by R. F. Rice at Jet
13 Propulsion Laboratory.
14 
15 SZIP embodies certain inventions patented by the National Aeronautics &
16 Space Administration. United States Patent Nos. 5,448,642, 5,687,255,
17 and 5,822,457 have been licensed to ICs, LLC, for distribution with the
18 HDF data storage and retrieval file format and software library products.
19 All rights reserved.
20 
21 Revocable, royalty-free, nonexclusive sublicense to use SZIP decompression
22 software routines and underlying patents is hereby granted by ICs, LLC, to
23 all users of and in conjunction with HDF data storage and retrieval file
24 format and software library products.
25 
26 Revocable, royalty-free, nonexclusive sublicense to use SZIP compression
27 software routines and underlying patents for non-commercial, scientific use
28 only is hereby granted by ICs, LLC, to users of and in conjunction with HDF
29 data storage and retrieval file format and software library products.
30 
31 For commercial use license to SZIP compression software routines and
32 underlying patents please contact ICs, LLC, at:
33  ICs, LLC
34  2600-A E. Seltice Way #234,
35  Post Falls, ID 83854
36 
37  Phone: (208) 755-8990
38  Fax: (208) 773-5747.
39 
40 *************Begin NPOESS Specific Permission *******************
41 NPOESS Permissions: Email correspondence, dated February 6, 2007, from
42 Dr. Joseph J. Feeley, Chief Executive Officer, of ICs, LLC
43 2040 Warren Wagon Road, PO Box 2236, McCall ID 83638, USA, grants:
44 1. Raytheon Company is granted Royalty free permission to use this code
45 file (as modified) for the compression and decompression of all NPOESS data
46 packets.
47 2. Same permission is granted to the NPOESS Integrated Program Office,
48 all NPOESS contractors, and all U.S. Government agencies using NPOESS data.
49  **
50 3. NPOESS data users may use SZIP decompression software routines and
51 underlying patents only in conjunction with decompressing NPOESS data in
52 accordance with and as limited by the above Third Party License.
53 
54 4. All other rights reserved. Do not modify or use for other purposes.
55 Further information available at http://www.hdfgroup.org/doc.resource/SZIP/
56 or by contacting ICs, LLC, at support@ICs4chips.com
57 *************End NPOESS Specific Permission *******************
58 
59 ==============================================================================*/
60 /* END THIRD_PARTY_COPYRIGHT */
61 
62 /* BEGIN GOVERNMENT RIGHTS */
63 /**************************************************************************
64 * This code was partially developed under NASA, and other
65 * U.S. Government contracts.
66 *
67 * Patent/copyrights are retained as described in THIRD_PARTY_COPYRIGHT above.
68 *
69 * Please also see "LIMITATIONS" below.
70 *
71 ****************************************************************************/
72 /* END GOVERNMENT RIGHTS */
73 
74 /* BEGIN ITAR */
75 /* END ITAR CONTROL */
76 
77 /* BEGIN CATEGORY */
78 /**************************************************************************
79 * CATEGORY: 1 (see SEN for definitions)
80 *
81 * rice.cpp
82 *
83 * Refer to Software Standards and Practices Manual (SSPM) for
84 * coding standards.
85 *
86 * NOTE: This code is exempt from NPOESS SSPM because it is Third Party,
87 * copyrighted code. (Please see THIRD_PARTY_COPYRIGHT above)
88 *
89 **************************************************************************/
90 /* END CATEGORY */
91 
92 /**************************************************************************
93 *
94 * NAME: rice.h
95 *
96 * REVISION/EVENT HISTORY:
97 * DATE PR# AUTHOR Build DESCRIPTION
98 * --------- --- ------ ----- -----------
99 * 29AUG2006 Miles 1.5 received source from L. Miles
100 * at ICs Corp. Source is same as
101 * U. of Illinois HDF Library.
102 * 25SEP2006 Arbeiter 1.5 inserted modifications
103 * developed by Jennings, SBRS
104 * 27SEP2006 Arbeiter 1.5 added NPOESS headings
105 * 16FEB2007 Arbeiter 1.5 added NPOESS specific
106 * permissions to 3rd Party
107 * copyright Notices.
108 * 16APR2007 Arbeiter 1.5 Updated header comments
109 * 21DEC2007 Arbeiter 1.5 Updated header comments
110 * and LIMITATIONS notes
111 * 31JAN2008 Arbeiter 1.5x1 Limatations updated
112 * 21NOV2008 Arbeiter 1.5x1 comment udpates
113 * --------- --- ------ ----- -----------
114 *
115 * REFERENCES: None.
116 *
117 *
118 * LIMITATIONS:
119 * 1. This code is not generalized Rice Compress/Uncompress. It will only
120 * work with the VIIRS sensor data.
121 *
122 * 2. Use of this software for data from satellites other than NPP or NPOESS
123 * is prohibited.
124 *
125 * 3. This code has only been tested with the numbers of pixels in the VIIRS
126 * aggregation or compression zones, or the number of calibration pixels:
127 * 16, 48, 64, 96, 368, 488, 592, 640, 736, 760, 784, 1184, 1280, and 1776.
128 * Results with other numbers of pixels may be unreliable.
129 *
130 * 4. Raytheon has only tested this code with settings for 15 bits per pixel,
131 * 8 pixels per block, and option mask for NN, MSB, RAW, and CHIP. Results with
132 * other settings may be unreliable. (These are the settings used by
133 * the VIIRS sensor for all compressions.)
134 *
135 * NOTES (MISCELLANEOUS) SECTION:
136 * Raytheon Company, Bellevue, Nebraska
137 * 2007 Raytheon Company. All Rights Reserved.
138 * 2008 Raytheon Company. All Rights Reserved.
139 *
140 * Comment marking "MJJ" is code written by Michael J. Jennings,
141 * of Raytheon SBRS, Goleta, California, 04/28/2004.
142 *
143 * Comment marking "RGA" is code written by Randolph G. Arbeiter,
144 * of Raytheon IIS, Omaha, Nebraska, September 2006.
145 *
146 *******************************************************************************/
147 
148 /* ## start code added for VIIRS - RGA 14SEP2006 */
149 #ifndef _RICE_H
150 #define _RICE_H
151 
152 #ifdef __cplusplus
153 extern "C" /* prevents name dithering by C++ compiler RGA */
154 {
155 #endif
156 /* ## end code added for VIIRS - RGA 14SEP2006 */
157 
158 #if !defined(__MWERKS__)
159 typedef int boolean;
160 #endif
161 
162 #define VIIRS_BLOCKS_PER_REFERENCE 128 /* RGA */
163 
164 #define FALSE 0
165 #define TRUE 1
166 
167 #define eq(a, b) (!strcmp((a), (b)))
168 #define eqn(a, b, n) (!strncmp((a), (b), (n)))
169 #define MIN(x,y) ((x)<(y)? (x): (y))
170 
171 #define EC_MODE 0
172 #define NN_MODE 1
173 
174 #define DEFAULT_BITS_PER_PIXEL 8
175 #define DEFAULT_BLOCKS_PER_SCANLINE 32
176 #define DEFAULT_PIXELS_PER_BLOCK 16
177 #define DEFAULT_PIXELS_PER_SCANLINE (DEFAULT_BLOCKS_PER_SCANLINE)*(DEFAULT_PIXELS_PER_BLOCK)
178 
179 #define MAX_EXT2 7
180 #define MAX_EXT2_SUM (MAX_EXT2*(MAX_EXT2+1)/2 + MAX_EXT2)
181 
182 #define MAX_COMMAND_LINE_FILES 256
183 #define MAX_FILENAME_SIZE 256
184 
185 #define MAX_ZERO_BLOCKS 64 /*** Must be a power of two ***/
186 
187  //#define MAX_BLOCKS_PER_SCANLINE 128
188 #define MAX_BLOCKS_PER_SCANLINE 256
189 #define MAX_PIXELS_PER_BLOCK 32
190 #define MAX_PIXELS_PER_SCANLINE (MAX_BLOCKS_PER_SCANLINE)*(MAX_PIXELS_PER_BLOCK)
191 
192 #define ID_ZERO -1
193 #define ID_LOW 0
194 #define ID_FS 1
195 #define ID_K1 2
196 #define ID_K2 3
197 #define ID_K3 4
198 #define ID_K4 5
199 #define ID_K5 6
200 #define ID_K6 7
201 #define ID_K7 8
202 #define ID_K8 9
203 #define ID_K9 10
204 #define ID_K10 11
205 #define ID_K11 12
206 #define ID_K12 13
207 #define ID_K13 14
208 #define ID_K14 15
209 #define ID_K15 16
210 #define ID_K16 17
211 #define ID_K17 18
212 #define ID_K18 19
213 #define ID_K19 20
214 #define ID_K20 21
215 #define ID_K21 22
216 #define ID_K22 23
217 #define ID_K23 24
218 #define ID_DEFAULT 31
219 
220 #define ID_DEFAULT1 7
221 #define ID_DEFAULT2 15
222 #define ID_DEFAULT3 31
223 
224 #define K_FACTOR 1
225 
226 #define FILE_DATA 1
227 #define MEMORY_DATA 2
228 /* This doesn't work when scaline is set to max value 4K EIP 2004/8/05
229 #define INPUT_BUFFER_SIZE 16*1024
230 #define OUTPUT_BUFFER_SIZE 16*1024
231 */
232 //#define INPUT_BUFFER_SIZE 2*MAX_PIXELS_PER_SCANLINE*4
233 //#define OUTPUT_BUFFER_SIZE 2*MAX_PIXELS_PER_SCANLINE*4
234 
235 //JMG 10/17/14
236 #define INPUT_BUFFER_SIZE 65536*2
237 #define OUTPUT_BUFFER_SIZE 65536*2
238 
239 static struct
240  {
245  } short_header =
246 {
247  {7, 8, 9, 10, 12, 14, 15, 16},
248  {8, 10, 12, 16, 18, 20, 24, 32},
249  {1, 2, 4, 6, 8, 10, 12, 16, 18, 20, 24, 32, 34, 36, 40, 48},
250  { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096,
251  3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072,
252  5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560,
253  9, 18, 36, 72, 144, 288, 576, 1152, 2304,
254  17, 34, 68, 136, 272, 544, 1088, 2176,
255  25, 50, 75, 100, 125, 150, 175, 200, 225, 250,
256  275, 300, 325, 350, 375, 400, 425, 450, 475, 500,
257  550, 600, 650, 700, 750, 800, 850, 900, 950, 1000,
258  1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500,
259  1550, 1600, 1650, 1700, 1750, 1800, 1850, 1900, 1950, 2000,
260  2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000,
261  3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000}
262 };
263 
264 #define ALLOW_K13_OPTION_MASK 1
265 #define CHIP_OPTION_MASK 2
266 #define EC_OPTION_MASK 4
267 #define LSB_OPTION_MASK 8
268 #define MSB_OPTION_MASK 16
269 #define NN_OPTION_MASK 32
270 #define OVERWRITE_OPTION_MASK 64
271 #define RAW_OPTION_MASK 128
272 #define KEEP_IMAGE_OPTION_MASK 256
273 #define KEEP_COMPRESSED_OPTION_MASK 512
274 
275 #define SZIP_PROGRAM_NAME "szip"
276 #define SUNZIP_PROGRAM_NAME "sunzip"
277 
278 #define MEMORY_ERROR (-2)
279 #define PARAM_ERROR (-4)
280 #define NO_ENCODER_ERROR (-5)
281 
282 /* ## start code added for VIIRS - RGA 14SEP2006 */
283 #ifdef __cplusplus
284 }
285 #endif
286 
287 #endif
288 /* ## end code added for VIIRS - RGA 14SEP2006 */
int scanlines_per_file[128]
Definition: rice.h:244
int pixels_per_block[8]
Definition: rice.h:242
int pixels_per_block_mult[16]
Definition: rice.h:243
int bits_per_pixel[8]
Definition: rice.h:241
int boolean
Definition: rice.h:159