Commit af67b249 authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Added DeserializeVolumeDataTest with test data for all compression methods...

Added DeserializeVolumeDataTest with test data for all compression methods except WaveletLossless. Renamed Rle to RLE as it is an abbreviation and not a word.
parent 62ccb20d
......@@ -84,7 +84,7 @@ enum class CompressionMethod
{
None,
Wavelet,
Rle,
RLE,
Zip,
WaveletNormalizeBlock,
WaveletLossless,
......
......@@ -568,7 +568,7 @@ static CompressionMethod compressionMethodFromJson(Json::Value const &jsonCompre
}
else if(compressionMethodString == "RLE")
{
return CompressionMethod::Rle;
return CompressionMethod::RLE;
}
else if(compressionMethodString == "Zip")
{
......
......@@ -262,7 +262,7 @@ CompressionMethod VolumeDataLayer::getEffectiveCompressionMethod() const
}
else
{
return CompressionMethod::Rle;
return CompressionMethod::RLE;
}
}
......
......@@ -81,7 +81,7 @@ bool VolumeDataStore::verify(const VolumeDataChunk &volumeDataChunk, const std::
}
}
else if(compressionMethod == CompressionMethod::None ||
compressionMethod == CompressionMethod::Rle ||
compressionMethod == CompressionMethod::RLE ||
compressionMethod == CompressionMethod::Zip)
{
if(serializedData.size() > sizeof(DataBlockDescriptor))
......@@ -124,7 +124,7 @@ static void copyLinearBufferIntoDataBlock(const void *sourceBuffer, const DataBl
}
}
static bool deserialize(const std::vector<uint8_t> &serializedData, VolumeDataChannelDescriptor::Format format, CompressionMethod compressionMethod, bool isRenderable, const FloatRange &valueRange, float integerScale, float integerOffset, bool isUseNoValue, float noValue, int32_t adaptiveLevel, std::vector<uint8_t> &destination, Error &error)
bool deserializeVolumeData(const std::vector<uint8_t> &serializedData, VolumeDataChannelDescriptor::Format format, CompressionMethod compressionMethod, bool isRenderable, const FloatRange &valueRange, float integerScale, float integerOffset, bool isUseNoValue, float noValue, int32_t adaptiveLevel, std::vector<uint8_t> &destination, Error &error)
{
DataBlock dataBlock;
if(compressionMethodIsWavelet(compressionMethod))
......@@ -168,7 +168,7 @@ static bool deserialize(const std::vector<uint8_t> &serializedData, VolumeDataCh
//pcDataBlock = Wavelet_Decompress(const_cast<void_px>(pxData), (int)cBLOB.GetSize(), eFormat, cValueRange, rIntegerScale, rIntegerOffset, isUseNoValue, rNoValue, isNormalize, ConfigMemoryManagement_Get()->_cCurrent._eBypassCompressionMode, iAdaptiveLevel, isLossless);
}
else if(compressionMethod == CompressionMethod::Rle)
else if(compressionMethod == CompressionMethod::RLE)
{
DataBlockDescriptor *dataBlockDescriptor = (DataBlockDescriptor *)serializedData.data();
......@@ -187,7 +187,7 @@ static bool deserialize(const std::vector<uint8_t> &serializedData, VolumeDataCh
int32_t byteSize = getByteSize(*dataBlockDescriptor);
std::unique_ptr<uint8_t[]>buffer(new uint8_t[byteSize]);
//int32_t decompressedSize = RleDecompress((uint8_t *)buffer, byteSize, (uint8_t *)source);
//int32_t decompressedSize = RLEDecompress((uint8_t *)buffer, byteSize, (uint8_t *)source);
//assert(decompressedSize == byteSize);
copyLinearBufferIntoDataBlock(buffer.get(), dataBlock, destination);
}
......@@ -251,17 +251,17 @@ static bool deserialize(const std::vector<uint8_t> &serializedData, VolumeDataCh
return true;
}
bool VolumeDataStore::deserializeVolumeData(const VolumeDataChunk &chunk, const std::vector<uint8_t>& serializedData, const std::vector<uint8_t>& metadata, CompressionMethod compressionMethod, int32_t adaptiveLevel, VolumeDataChannelDescriptor::Format loadFormat, std::vector<uint8_t>& target, Error& error)
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, std::vector<uint8_t>& target, Error& error)
{
uint64_t volumeDataHashValue = VolumeDataHash::UNKNOWN;
bool isWaveletAdaptive = false;
if (compressionMethodIsWavelet(compressionMethod) && metadata.size() == sizeof(uint64_t) + sizeof(WaveletAdaptiveLevelsMetadata) && VolumeDataStore::verify(chunk, serializedData, compressionMethod, false))
if (compressionMethodIsWavelet(compressionMethod) && metadata.size() == sizeof(uint64_t) + sizeof(WaveletAdaptiveLevelsMetadata) && VolumeDataStore::verify(volumeDataChunk, serializedData, compressionMethod, false))
{
isWaveletAdaptive = true;
}
else if (metadata.size() != sizeof(uint64_t) || !verify(chunk, serializedData, compressionMethod, true))
else if (metadata.size() != sizeof(uint64_t) || !verify(volumeDataChunk, serializedData, compressionMethod, true))
{
return false;
}
......@@ -277,7 +277,7 @@ bool VolumeDataStore::deserializeVolumeData(const VolumeDataChunk &chunk, const
VolumeDataHash volumeDataHash(volumeDataHashValue);
const VolumeDataLayer* volumeDataLayer = chunk.layer;
const VolumeDataLayer* volumeDataLayer = volumeDataChunk.layer;
if (volumeDataHash.isConstant())
{
......@@ -304,7 +304,7 @@ bool VolumeDataStore::deserializeVolumeData(const VolumeDataChunk &chunk, const
}
}
if (!deserialize(serializedData, loadFormat, compressionMethod, false, deserializeValueRange, volumeDataLayer->getIntegerScale(), volumeDataLayer->getIntegerOffset(), volumeDataLayer->isUseNoValue(), volumeDataLayer->getNoValue(), adaptiveLevel, target, error))
if (!OpenVDS::deserializeVolumeData(serializedData, loadFormat, compressionMethod, false, deserializeValueRange, volumeDataLayer->getIntegerScale(), volumeDataLayer->getIntegerOffset(), volumeDataLayer->isUseNoValue(), volumeDataLayer->getNoValue(), adaptiveLevel, target, error))
return false;
}
......
......@@ -40,5 +40,6 @@ target_include_directories(segy_tests PRIVATE ../src/SEG-Y)
add_test_executable(vds_integration_tests
VDS/VDSIntegrationTest.cpp
VDS/ParseVDSJsonTest.cpp
VDS/DeSerializeVolumeDataTest.cpp
)
target_compile_definitions(vds_integration_tests PRIVATE -DTEST_DATA_PATH="${PROJECT_SOURCE_DIR}/tests/VDS")
/****************************************************************************
** Copyright 2019 The Open Group
** Copyright 2019 Bluware, Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
****************************************************************************/
#include <OpenVDS/OpenVDS.h>
#include <VDS/VolumeDataStore.h>
#include <IO/File.h>
#include <cstdlib>
#include <gtest/gtest.h>
namespace OpenVDS
{
bool deserializeVolumeData(const std::vector<uint8_t> &serializedData, VolumeDataChannelDescriptor::Format format, CompressionMethod compressionMethod, bool isRenderable, const FloatRange &valueRange, float integerScale, float integerOffset, bool isUseNoValue, float noValue, int32_t adaptiveLevel, std::vector<uint8_t> &destination, Error &error);
}
GTEST_TEST(OpenVDS_integration, DISABLED_DeSerializeVolumeData)
{
std::vector<uint8_t> serializedData;
{
OpenVDS::File chunkFile;
OpenVDS::IOError error;
chunkFile.open(TEST_DATA_PATH "/chunk.CompressionMethod_None", false, false, false, error);
EXPECT_EQ(error.code, 0);
int64_t
fileSize = chunkFile.size(error);
EXPECT_EQ(error.code, 0);
serializedData.resize(fileSize);
chunkFile.read(&serializedData[0], 0, (int32_t)fileSize, error);
EXPECT_EQ(error.code, 0);
}
std::vector<uint8_t> data;
OpenVDS::Error error;
OpenVDS::deserializeVolumeData(serializedData, OpenVDS::VolumeDataChannelDescriptor::Format_R32, OpenVDS::CompressionMethod::None, true, OpenVDS::FloatRange(-0.07883811742067337f, 0.07883811742067337f), 1.0f, 0.0f, false, 0.0f, 0, data, error);
EXPECT_EQ(error.code, 0);
}
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