Changeset 16443 for trunk/FACT++
- Timestamp:
- 05/29/13 22:02:43 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fitsCompressor.cc
r16418 r16443 633 633 { 634 634 _transposedBuffer[i] = new char[_rowWidth*_numRowsPerTile]; 635 _compressedBuffer[i] = new char[_rowWidth*_numRowsPerTile + 1024*1024]; //use a bit more memory, in case the compression algorithms uses more635 _compressedBuffer[i] = new char[_rowWidth*_numRowsPerTile + _columns.size()]; //use a bit more memory for compression flags 636 636 if (_transposedBuffer[i] == NULL || _compressedBuffer[i] == NULL) 637 637 return false; … … 736 736 header.push_back(HeaderEntry("CHECKSUM", "'0000000000000000' ", "Checksum for the whole HDU")); 737 737 header.push_back(HeaderEntry("DATASUM" , " 0" , "Checksum for the data block")); 738 header.push_back(HeaderEntry("EXTNAME" , "' DrsCalib'", "name of this binary table extension"));738 header.push_back(HeaderEntry("EXTNAME" , "'IntCalibration' ", "name of this binary table extension")); 739 739 header.push_back(HeaderEntry("TTYPE1" , "'OffsetCalibration' ", "label for field 1")); 740 740 header.push_back(HeaderEntry("TFORM1" , "'1474560I' ", "data format of field: 2-byte INTEGER")); … … 1071 1071 setHeaderKey(HeaderEntry("TFIELDS", _columns.size(), "number of fields in each row")); 1072 1072 int64_t heapSize = 0; 1073 uint32_t compressedOffset = 0;1073 int64_t compressedOffset = 0; 1074 1074 for (uint32_t i=0;i<_catalog.size();i++) 1075 1075 for (uint32_t j=0;j<_catalog[i].size();j++) … … 1077 1077 heapSize += _catalog[i][j].first; 1078 1078 //set the catalog offsets to their actual values 1079 if (compressedOffset < 0) return false; 1079 1080 _catalog[i][j].second = compressedOffset; 1080 1081 compressedOffset += _catalog[i][j].first; … … 1198 1199 previousHuffmanSize = huffmanOutput.size(); 1199 1200 } 1200 memcpy(&dest[huffmanOffset], huffmanOutput.data(), huffmanOutput.size()); 1201 return huffmanOutput.size() + huffmanOffset; 1201 const size_t totalSize = huffmanOutput.size() + huffmanOffset; 1202 1203 //only copy if not larger than not-compressed size 1204 if (totalSize < numRows*sizeOfElems*numRowElems) 1205 memcpy(&dest[huffmanOffset], huffmanOutput.data(), huffmanOutput.size()); 1206 1207 return totalSize; 1202 1208 } 1203 1209 … … 1731 1737 for (int j=0;j<1440;j++) 1732 1738 { 1733 int thisStartCell = reinterpret_cast<int16_t*>(&buffer[startCellOffset])[j]; 1739 const int thisStartCell = reinterpret_cast<int16_t*>(&buffer[startCellOffset])[j]; 1740 if (thisStartCell > -1) 1734 1741 for (int k=0;k<numSlices;k++) 1735 1742 reinterpret_cast<int16_t*>(&buffer[dataOffset])[numSlices*j + k] -= drsCalib16[1024*j + (thisStartCell+k)%1024]; … … 1745 1752 1746 1753 inFile.close(); 1747 outFile.close(); 1754 if (!outFile.close()) 1755 { 1756 cout << "Something went wrong while writing the catalog: negative index" << endl; 1757 return false; 1758 } 1759 1748 1760 delete[] drsCalib16; 1749 1761 … … 1762 1774 1763 1775 //get a compressed reader 1764 factfits verifyFile(fileNameOut, tableName, false); 1776 //TEMP try to copy the file too 1777 // string copyName("/scratch/copyFile.fz"); 1778 string copyName(""); 1779 factfits verifyFile(fileNameOut, copyName, tableName, false); 1765 1780 1766 1781 //and the header of the compressed file
Note:
See TracChangeset
for help on using the changeset viewer.