Commit 59f0d5ec authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/jorgen.lind/revertErrorChecking with refs/heads/master...

Merge branch feature/jorgen.lind/revertErrorChecking with refs/heads/master into refs/merge-requests/38/train
parents 53dc2c9c d498a287
Pipeline #652 passed with stages
in 19 minutes and 10 seconds
......@@ -479,22 +479,6 @@ bool VolumeDataStore::CreateConstantValueDataBlock(VolumeDataChunk const &volume
bool VolumeDataStore::DeserializeVolumeData(const VolumeDataChunk &volumeDataChunk, const std::vector<uint8_t>& serializedData, const std::vector<uint8_t>& metadata, CompressionMethod compressionMethod, int32_t adaptiveLevel, VolumeDataChannelDescriptor::Format loadFormat, DataBlock &dataBlock, std::vector<uint8_t>& target, Error& error)
{
uint64_t volumeDataHashValue = VolumeDataHash::UNKNOWN;
memcpy(&volumeDataHashValue, metadata.data(), sizeof(uint64_t));
VolumeDataHash volumeDataHash(volumeDataHashValue);
const VolumeDataLayer* volumeDataLayer = volumeDataChunk.layer;
if (volumeDataHash.IsConstant())
{
if (!CreateConstantValueDataBlock(volumeDataChunk, volumeDataLayer->GetFormat(), volumeDataLayer->GetNoValue(), volumeDataLayer->GetComponents(), volumeDataHash, dataBlock, target, error))
{
error.code = 31;
error.string = fmt::format("Failed to create constant value data block. Chunk index: {}.", volumeDataChunk.index);
return false;
}
return true;
}
bool isWaveletAdaptive = false;
......@@ -509,29 +493,46 @@ bool VolumeDataStore::DeserializeVolumeData(const VolumeDataChunk &volumeDataChu
return false;
}
volumeDataHash = uint64_t(volumeDataHash) ^ (uint64_t(adaptiveLevel) + 1) * 0x4068934683409867ULL;
memcpy(&volumeDataHashValue, metadata.data(), sizeof(uint64_t));
VolumeDataHash volumeDataHash(volumeDataHashValue);
//create a value range from scale and offset so that conversion to 8 or 16 bit is done correctly inside deserialization
FloatRange deserializeValueRange = volumeDataLayer->GetValueRange();
const VolumeDataLayer* volumeDataLayer = volumeDataChunk.layer;
if (volumeDataLayer->GetFormat() == VolumeDataChannelDescriptor::Format_U16 || volumeDataLayer->GetFormat() == VolumeDataChannelDescriptor::Format_U8)
if (volumeDataHash.IsConstant())
{
if (loadFormat == VolumeDataChannelDescriptor::Format_U16)
{
deserializeValueRange.Min = volumeDataLayer->GetIntegerOffset();
deserializeValueRange.Max = volumeDataLayer->GetIntegerScale() * (volumeDataLayer->IsUseNoValue() ? 65534.0f : 65535.0f) + volumeDataLayer->GetIntegerOffset();
}
else if (loadFormat == VolumeDataChannelDescriptor::Format_U8 && volumeDataLayer->GetFormat() != VolumeDataChannelDescriptor::Format_U16)
if (!CreateConstantValueDataBlock(volumeDataChunk, volumeDataLayer->GetFormat(), volumeDataLayer->GetNoValue(), volumeDataLayer->GetComponents(), volumeDataHash, dataBlock, target, error))
return false;
}
else
{
volumeDataHash = uint64_t(volumeDataHash) ^ (uint64_t(adaptiveLevel) + 1) * 0x4068934683409867ULL;
{
deserializeValueRange.Min = volumeDataLayer->GetIntegerOffset();
deserializeValueRange.Max = volumeDataLayer->GetIntegerScale() * (volumeDataLayer->IsUseNoValue() ? 254.0f : 255.0f) + volumeDataLayer->GetIntegerOffset();
//create a value range from scale and offset so that conversion to 8 or 16 bit is done correctly inside deserialization
FloatRange deserializeValueRange = volumeDataLayer->GetValueRange();
if (volumeDataLayer->GetFormat() == VolumeDataChannelDescriptor::Format_U16 || volumeDataLayer->GetFormat() == VolumeDataChannelDescriptor::Format_U8)
{
if (loadFormat == VolumeDataChannelDescriptor::Format_U16)
{
deserializeValueRange.Min = volumeDataLayer->GetIntegerOffset();
deserializeValueRange.Max = volumeDataLayer->GetIntegerScale() * (volumeDataLayer->IsUseNoValue() ? 65534.0f : 65535.0f) + volumeDataLayer->GetIntegerOffset();
}
else if (loadFormat == VolumeDataChannelDescriptor::Format_U8 && volumeDataLayer->GetFormat() != VolumeDataChannelDescriptor::Format_U16)
{
deserializeValueRange.Min = volumeDataLayer->GetIntegerOffset();
deserializeValueRange.Max = volumeDataLayer->GetIntegerScale() * (volumeDataLayer->IsUseNoValue() ? 254.0f : 255.0f) + volumeDataLayer->GetIntegerOffset();
}
}
if (!OpenVDS::DeserializeVolumeData(serializedData, loadFormat, compressionMethod, deserializeValueRange, volumeDataLayer->GetIntegerScale(), volumeDataLayer->GetIntegerOffset(), volumeDataLayer->IsUseNoValue(), volumeDataLayer->GetNoValue(), adaptiveLevel, dataBlock, target, error))
return false;
}
}
if (!OpenVDS::DeserializeVolumeData(serializedData, loadFormat, compressionMethod, deserializeValueRange, volumeDataLayer->GetIntegerScale(), volumeDataLayer->GetIntegerOffset(), volumeDataLayer->IsUseNoValue(), volumeDataLayer->GetNoValue(), adaptiveLevel, dataBlock, target, error))
return false;
return true;
return true;
}
bool VolumeDataStore::SerializeVolumeData(const VolumeDataChunk& chunk, const DataBlock& dataBlock, const std::vector<uint8_t>& chunkData, CompressionMethod compressionMethod, std::vector<uint8_t>& destinationBuffer, uint64_t& outputHash, Error& error)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment