Changeset 41474 for trunk/Ohana/src/libfits/matrix/F_compress_utils.c
- Timestamp:
- Jan 24, 2021, 3:37:52 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/libfits/matrix/F_compress_utils.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libfits/matrix/F_compress_utils.c
r39457 r41474 104 104 // fprintf (stderr, "swapping %d bytes in pix of size %d bytes...\n", Nzdata, pixsize); 105 105 switch (pixsize) { 106 case 0: 106 107 case 1: 107 108 break; … … 186 187 } 187 188 188 int gfits_uncompressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 189 // the size of the compressed data pixels, needed to perform swaps 190 int gfits_compressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 191 192 // NONE should be swapped to mimic swapping types 193 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_1")) { 194 if (out_bitpix == 8) return (1); 195 if (out_bitpix == 16) return (2); 196 if (out_bitpix == 32) return (4); 197 if (out_bitpix == -32) return (4); 198 if (out_bitpix == -64) return (8); 199 return (1); 200 } 201 202 // GZIP_1, GZIP_2 should not be swapped after compression / before decompression 203 if (!strcasecmp(cmptype, "GZIP_1") || 204 !strcasecmp(cmptype, "GZIP_2") || 205 !strcasecmp(cmptype, "NONE_2")) { 206 if (out_bitpix == 8) return (1); 207 if (out_bitpix == 16) return (1); 208 if (out_bitpix == 32) return (1); 209 if (out_bitpix == -32) return (1); 210 if (out_bitpix == -64) return (1); 211 return (1); 212 } 213 214 // RICE_1 should not be swapped after compression / before decompression 215 if (!strcasecmp(cmptype, "RICE_1") || 216 !strcasecmp(cmptype, "RICE_ONE")) { 217 return (1); 218 } 219 220 // PLIO_1 always results in 4-byte ints (not 2 byte ints?) 221 if (!strcasecmp(cmptype, "PLIO_1")) { 222 return (4); 223 } 224 225 if (!strcasecmp(cmptype, "HCOMPRESS_1")) { 226 if (out_bitpix == 8) return (4); 227 if (out_bitpix == 16) return (4); 228 return (8); 229 } 230 return (0); 231 } 232 233 int gfits_uncompressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions, int rice_use_bitpix) { 189 234 190 235 int i, Nbyte; … … 207 252 if (!strcasecmp(cmptype, "RICE_1") || 208 253 !strcasecmp(cmptype, "RICE_ONE")) { 254 // on compression, user may set BYTEPIX based on header.bitpix: 255 if (rice_use_bitpix) { 256 if (out_bitpix == 8) return (1); 257 if (out_bitpix == 16) return (2); 258 if (out_bitpix == 32) return (4); 259 } 209 260 // if BYTEPIX option is specified, use that for Nbyte 210 261 for (i = 0; i < Noptions; i++) { … … 214 265 } 215 266 } 216 if (out_bitpix == 8) return (1); 217 if (out_bitpix == 16) return (2); 218 if (out_bitpix == 32) return (4); 219 return (4); 267 return (4); // RICE_1 default is 4 byte int if BYTEPIX undefined (White et al 6.2) 220 268 } 221 269 … … 233 281 } 234 282 235 int gfits_compressed_data_pixsize (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 236 237 int i, Nbyte; 238 239 // NONE should be swapped to mimic swapping types 240 if (!strcasecmp(cmptype, "NONE") || !strcasecmp(cmptype, "NONE_1")) { 241 if (out_bitpix == 8) return (1); 242 if (out_bitpix == 16) return (2); 243 if (out_bitpix == 32) return (4); 244 if (out_bitpix == -32) return (4); 245 if (out_bitpix == -64) return (8); 246 return (1); 247 } 248 249 // GZIP_1, GZIP_2 should not be swapped after compression 250 if (!strcasecmp(cmptype, "GZIP_1") || 251 !strcasecmp(cmptype, "GZIP_2") || 252 !strcasecmp(cmptype, "NONE_2")) { 253 if (out_bitpix == 8) return (1); 254 if (out_bitpix == 16) return (1); 255 if (out_bitpix == 32) return (1); 256 if (out_bitpix == -32) return (1); 257 if (out_bitpix == -64) return (1); 258 return (1); 259 } 260 261 // RICE_1 must operate on integer pixels 262 if (!strcasecmp(cmptype, "RICE_1") || 263 !strcasecmp(cmptype, "RICE_ONE")) { 264 // if BYTEPIX option is specified, use that for Nbyte 265 for (i = 0; i < Noptions; i++) { 266 if (!strcmp(optname[i], "BYTEPIX")) { 267 Nbyte = atoi (optvalue[i]); 268 return (Nbyte); 269 } 270 } 271 if (out_bitpix == 8) return (1); 272 if (out_bitpix == 16) return (2); 273 if (out_bitpix == 32) return (4); 274 return (4); 275 } 276 277 // PLIO_1 always results in 4-byte ints (not 2 byte ints?) 278 if (!strcasecmp(cmptype, "PLIO_1")) { 279 return (4); 280 } 281 282 if (!strcasecmp(cmptype, "HCOMPRESS_1")) { 283 if (out_bitpix == 8) return (4); 284 if (out_bitpix == 16) return (4); 285 return (8); 286 } 287 return (0); 288 } 289 290 int gfits_uncompressed_data_bitpix (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions) { 283 int gfits_uncompressed_data_bitpix (char *cmptype, int out_bitpix, char **optname, char **optvalue, int Noptions, int rice_use_bitpix) { 291 284 292 285 int i, Nbyte; … … 304 297 if (!strcasecmp(cmptype, "RICE_1") || 305 298 !strcasecmp(cmptype, "RICE_ONE")) { 299 if (rice_use_bitpix) { 300 if (out_bitpix == 8) return (out_bitpix); 301 if (out_bitpix == 16) return (out_bitpix); 302 if (out_bitpix == 32) return (out_bitpix); 303 } 306 304 // if BYTEPIX option is specified, use that for Nbyte 307 305 for (i = 0; i < Noptions; i++) { … … 311 309 } 312 310 } 313 if (out_bitpix == 8) return (out_bitpix);314 if (out_bitpix == 16) return (out_bitpix);315 if (out_bitpix == 32) return (out_bitpix);316 311 return (32); 317 312 }
Note:
See TracChangeset
for help on using the changeset viewer.
