Changeset 16888
- Timestamp:
- 06/22/13 15:30:59 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/zfits.h
r16882 r16888 14 14 #include "huffman.h" 15 15 16 /*17 #define FACT_RAW 0x018 #define FACT_SMOOTHING 0x119 #define FACT_HUFFMAN16 0x220 21 #define FACT_COL_MAJOR 'C'22 #define FACT_ROW_MAJOR 'R'23 */24 25 26 16 #ifndef __MARS__ 27 17 namespace std … … 29 19 #endif 30 20 31 enum FACT_COMPRESSION_PROCESS32 {33 FACT_RAW = 0x0,34 FACT_SMOOTHING = 0x1,35 FACT_HUFFMAN16 = 0x236 };37 38 enum FACT_ROW_ORDERING39 {40 FACT_COL_MAJOR = 'C',41 FACT_ROW_MAJOR = 'R'42 };43 44 21 class zfits : public fits 45 22 { 46 23 public: 24 25 enum CompressionProcess_t 26 { 27 kFactRaw = 0x0, 28 kFactSmoothing = 0x1, 29 kFactHuffman16 = 0x2 30 }; 31 32 enum RowOrdering_t 33 { 34 kOrderByCol = 'C', 35 kOrderByRow = 'R' 36 }; 47 37 48 38 // Basic constructor … … 122 112 123 113 BlockHeader(uint64_t s=0, 124 char o= FACT_ROW_MAJOR,114 char o=kOrderByRow, 125 115 unsigned char n=1) : size(s), 126 116 ordering(o), … … 140 130 141 131 if (fTable.isCompressed) 142 for (auto it=fTable.sortedCols.begin(); it!= fTable.sortedCols.end(); it++) 143 if (it->comp != FACT) 144 { 145 clear(rdstate()|ios::badbit); 132 { 133 for (auto it=fTable.sortedCols.begin(); it!= fTable.sortedCols.end(); it++) 134 { 135 if (it->comp == kCompFACT) 136 continue; 137 138 clear(rdstate()|ios::badbit); 146 139 #ifdef __EXCEPTIONS 147 140 throw runtime_error("Only the FACT compression scheme is handled by this reader."); 148 141 #else 149 gLog << ___err___ << "ERROR - Only the FACT compression scheme is handled by this reader." << endl; 150 return; 151 #endif 152 } 142 gLog << ___err___ << "ERROR - Only the FACT compression scheme is handled by this reader." << endl; 143 return; 144 #endif 145 } 146 } 153 147 154 148 fColumnOrdering.resize(fTable.sortedCols.size()); 155 149 for (auto it=fColumnOrdering.begin(); it != fColumnOrdering.end(); it++) 156 (*it) = FACT_ROW_MAJOR;150 (*it) = kOrderByRow; 157 151 //Get compressed specific keywords 158 152 fNumTiles = fTable.isCompressed ? GetInt("NAXIS2") : 0; … … 193 187 streamoff fHeapFromDataStart; ///< offset from the beginning of the data table 194 188 195 vector<vector<pair<int64_t, int64_t> >> fCatalog;///< Catalog, i.e. the main table that points to the compressed data.196 vector<size_t> 197 vector<vector<size_t> >fTileOffsets; ///< offset from start of tile of a given compressed column189 vector<vector<pair<int64_t, int64_t>>> fCatalog;///< Catalog, i.e. the main table that points to the compressed data. 190 vector<size_t> fTileSize; ///< size in bytes of each compressed tile 191 vector<vector<size_t>> fTileOffsets; ///< offset from start of tile of a given compressed column 198 192 199 193 // Get buffer space … … 346 340 switch (fColumnOrdering[i]) 347 341 { 348 case FACT_ROW_MAJOR:342 case kOrderByRow: 349 343 // regular, "semi-transposed" copy 350 344 for (char *dest=buffer; dest<buffer+thisRoundNumRows*fTable.bytes_per_row; dest+=fTable.bytes_per_row) // row-by-row … … 355 349 break; 356 350 357 case FACT_COL_MAJOR:351 case kOrderByCol: 358 352 // transposed copy 359 353 for (char *elem=buffer; elem<buffer+it->bytes; elem+=it->size) // element-by-element (arrays) … … 452 446 fColumnOrdering[i] = head->ordering; 453 447 454 const uint32_t numRows = (head->ordering== FACT_ROW_MAJOR) ? thisRoundNumRows : col.num;455 const uint32_t numCols = (head->ordering== FACT_COL_MAJOR) ? thisRoundNumRows : col.num;448 const uint32_t numRows = (head->ordering==kOrderByRow) ? thisRoundNumRows : col.num; 449 const uint32_t numCols = (head->ordering==kOrderByCol) ? thisRoundNumRows : col.num; 456 450 457 451 const char *src = fCompressedBuffer.data()+compressedOffset+sizeof(BlockHeader)+sizeof(uint16_t)*head->numProcs; … … 463 457 switch (head->processings[j]) 464 458 { 465 case FACT_RAW: 466 sizeWritten = UncompressUNCOMPRESSED(dest, src, numRows*numCols, col.size); 467 break; 468 case FACT_SMOOTHING: 469 sizeWritten = UnApplySMOOTHING(reinterpret_cast<int16_t*>(dest), numRows*numCols); 470 break; 471 case FACT_HUFFMAN16: 472 sizeWritten = UncompressHUFFMAN16(dest, src, numRows); 473 break; 474 default: 475 clear(rdstate()|ios::badbit); 459 case kFactRaw: 460 sizeWritten = UncompressUNCOMPRESSED(dest, src, numRows*numCols, col.size); 461 break; 462 463 case kFactSmoothing: 464 sizeWritten = UnApplySMOOTHING(reinterpret_cast<int16_t*>(dest), numRows*numCols); 465 break; 466 467 case kFactHuffman16: 468 sizeWritten = UncompressHUFFMAN16(dest, src, numRows); 469 break; 470 471 default: 472 clear(rdstate()|ios::badbit); 476 473 #ifdef __EXCEPTIONS 477 474 throw runtime_error("Unknown processing applied to data. Aborting"); … … 482 479 } 483 480 //increment destination counter only when processing done. 484 if (j==0) dest+= sizeWritten; 481 if (j==0) 482 dest+= sizeWritten; 485 483 } 486 484 }
Note:
See TracChangeset
for help on using the changeset viewer.