- Timestamp:
- Jun 3, 2015, 7:00:55 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/libfits/matrix/F_compress_M.c
r38355 r38356 2 2 # include <gfitsio.h> 3 3 # include <zlib.h> 4 # define VERBOSE_DUMP 0 4 5 5 6 // the user needs to specify the various compression options: … … 33 34 34 35 Header *theader = ftable->header; 36 37 if (!gfits_cmptype_valid(zcmptype)) ESCAPE; 35 38 36 39 // determine the number of tiles (from ztile[] and image size) … … 147 150 int max_tile_size = gfits_imtile_maxsize (matrix, ztile); 148 151 149 // size of a pixel in the image tile -- this is probably not needed150 int tile_pixsize = abs(header[0].bitpix) / 8;151 152 152 // size of a pixel in the raw pixel buffer (before compression) 153 153 int raw_pixsize = gfits_uncompressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0); … … 155 155 int cmp_pixsize = gfits_compressed_data_pixsize (zcmptype, header[0].bitpix, NULL, NULL, 0); 156 156 157 fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", 158 raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix); 157 // size of a pixel in the image tile -- this is probably not needed 158 // int tile_pixsize = abs(header[0].bitpix) / 8; 159 // fprintf (stderr, "raw_pixsize: %d, cmp_pixsize: %d, tile_pixsize: %d, raw_bitpix: %d\n", raw_pixsize, cmp_pixsize, tile_pixsize, raw_bitpix); 159 160 160 161 // allocate the buffer for compression work … … 177 178 if (!gfits_collect_data (matrix, raw, Nraw, raw_bitpix, otile, oblank, ztile, zblank, zscale, zzero)) ESCAPE; 178 179 179 if ( 0&& (i == 0)) {180 if (VERBOSE_DUMP && (i == 0)) { 180 181 int k; 181 182 fprintf (stderr, "cmp mat: "); … … 189 190 // gzip compresses bytes which are in BIG-ENDIAN order 190 191 if (!strcasecmp(zcmptype, "GZIP_1")) { 191 if (!gfits_byteswap_zdata (raw, Nraw, raw_pixsize)) ESCAPE; 192 } 193 if (0 && (i == 0)) { 192 // Nraw is number of pixels 193 if (!gfits_byteswap_zdata (raw, Nraw * raw_pixsize, raw_pixsize)) ESCAPE; 194 } 195 int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression 196 197 if (VERBOSE_DUMP && (i == 0)) { 194 198 int k; 195 199 fprintf (stderr, "cmp swp: "); 196 200 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", raw[k]); } 197 201 fprintf (stderr, "\n"); 202 fprintf (stderr, "Nzdata: %d -> ", Nzdata); 198 203 } 199 204 200 205 // optname, optvalue = NULL, Noptions = 0 : defaults for RICE_1, HCOMPRESS_1 201 206 202 int Nzdata = Nzdata_alloc; // available space, replaced with actual output size on compression203 207 if (!gfits_compress_data (zdata, &Nzdata, zcmptype, NULL, NULL, 0, raw, Nraw, raw_pixsize, ztile[1], ztile[0])) ESCAPE; 204 if (0 && (i == 0)) { 208 if (VERBOSE_DUMP && (i == 0)) { 209 int k; 210 fprintf (stderr, "%d\n", Nzdata); 211 fprintf (stderr, "cmp SWP: "); 212 for (k = 0; k < 32; k++) { fprintf (stderr, "0x%02hhx ", zdata[k]); } 213 fprintf (stderr, "\n"); 214 } 215 216 // all other compression modes require swapping after compression 217 // (compresssion & decompression operate on native ENDIAN) 218 if (strcasecmp(zcmptype, "GZIP_1")) { 219 // Nzdata is number of bytes 220 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE; 221 } 222 223 if (VERBOSE_DUMP && (i == 0)) { 205 224 int k; 206 225 fprintf (stderr, "cmp dat: "); … … 208 227 fprintf (stderr, "\n"); 209 228 } 210 211 229 if (!gfits_varlength_column_add_data (ftable, zdata, Nzdata, i, &zdef)) ESCAPE; 212 213 // all other compression modes require swapping after compression214 // (compresssion & decompression operate on native ENDIAN)215 if (strcasecmp(zcmptype, "GZIP_1")) {216 if (!gfits_byteswap_zdata (zdata, Nzdata, cmp_pixsize)) ESCAPE;217 }218 230 219 231 // update the otile[] counters, carrying to the next dimension if needed … … 222 234 223 235 if (!gfits_varlength_column_finish (ftable, &zdef)) ESCAPE; 224 if ( 0) {236 if (VERBOSE_DUMP) { 225 237 int k; 226 238 fprintf (stderr, "cmp tbl: ");
Note:
See TracChangeset
for help on using the changeset viewer.
