Commit 2d179d8a authored by Morten Ofstad's avatar Morten Ofstad
Browse files

Merge branch feature/morten.ofstad/VDSWaveletDataFormatUpgrade with...

Merge branch feature/morten.ofstad/VDSWaveletDataFormatUpgrade with refs/heads/master into refs/merge-requests/495/train
parents 877f33f3 6e2da541
Pipeline #77391 passed with stages
in 20 minutes and 43 seconds
......@@ -82,7 +82,7 @@ bool VolumeDataStore::Verify(const VolumeDataChunk &volumeDataChunk, const std::
int32_t dimensions = waveletHeader[5] & 0xff;
isValid = dataVersion >= WAVELET_DATA_VERSION_1_4 &&
dataVersion <= WAVELET_DATA_VERSION_1_5 &&
dataVersion <= WAVELET_DATA_VERSION_1_6 &&
(compressedSize <= int32_t(serializedData.size()) || !isFullyRead) &&
(createSizeX == voxelSize[0] ) &&
(createSizeY == voxelSize[1] || dimensions < 2) &&
......@@ -282,7 +282,7 @@ bool DeserializeVolumeData(const std::vector<uint8_t> &serializedData, VolumeDat
int32_t dataVersion = ((int32_t *)data)[0];
(void)dataVersion;
assert(dataVersion >= WAVELET_DATA_VERSION_1_4 && dataVersion <= WAVELET_DATA_VERSION_1_5);
assert(dataVersion >= WAVELET_DATA_VERSION_1_4 && dataVersion <= WAVELET_DATA_VERSION_1_6);
bool isNormalize = false;
bool isLossless = false;
......
......@@ -88,7 +88,7 @@ bool Wavelet_Decompress(const void *compressedData, int nCompressedAdaptiveDataS
uint32_t integerInfo = (intHeaderPtr[5] >> 8) & 0xff;
if (dataVersion < WAVELET_DATA_VERSION_1_4 ||
dataVersion > WAVELET_DATA_VERSION_1_5 ||
dataVersion > WAVELET_DATA_VERSION_1_6 ||
dimensions < 1 ||
dimensions > 3 ||
createSize[0] < 0 ||
......@@ -758,7 +758,7 @@ static void DecompressZerosAlongX(const uint8_t *in, void *pic, int elementSize,
bool Wavelet::DeCompress(bool isTransform, int32_t decompressInfo, float decompressSlice, int32_t decompressFlip, float* startThreshold, float* threshold, VolumeDataChannelDescriptor::Format dataBlockFormat, const FloatRange& valueRange, float integerScale, float integerOffset, bool isUseNoValue, float noValue, bool* isAnyNoValue, float* waveletNoValue, bool isNormalize, int decompressLevel, bool isLossless, int compressedAdaptiveDataSize, DataBlock& dataBlock, std::vector<uint8_t>& target, Error& error)
{
assert(m_dataVersion >= WAVELET_DATA_VERSION_1_4 && m_dataVersion <= WAVELET_DATA_VERSION_1_5);
assert(m_dataVersion >= WAVELET_DATA_VERSION_1_4 && m_dataVersion <= WAVELET_DATA_VERSION_1_6);
InitCoder();
int32_t *startOfCompressedData = (int32_t *)m_readCompressedData;
......@@ -830,7 +830,8 @@ bool Wavelet::DeCompress(bool isTransform, int32_t decompressInfo, float decompr
DecompressAdaptiveMode
decompressAdaptiveMode = DecompressAdaptiveMode::AssumeNoOverwrite;
if(WaveletAdaptiveLL_IsWaveletStreamEncodedWithBug(transformData, m_transformIterations, m_transformMask))
if(m_dataVersion < WAVELET_DATA_VERSION_1_6 &&
WaveletAdaptiveLL_IsWaveletStreamEncodedWithBug(transformData, m_transformIterations, m_transformMask))
{
decompressAdaptiveMode = isLossless ? DecompressAdaptiveMode::AllowOverwrite : DecompressAdaptiveMode::PreventOverwrite;
}
......@@ -841,7 +842,7 @@ bool Wavelet::DeCompress(bool isTransform, int32_t decompressInfo, float decompr
cpuTempData.resize(cpuTempDecodeSizeNeeded);
bool isInteger = m_integerInfo & WAVELET_INTEGERINFO_ISINTEGER;
WaveletAdaptiveLL_DecodeIterator decodeIterator = WaveletAdaptiveLL_CreateDecodeIterator((uint8_t*)m_readCompressedData, floatReadWriteData, m_dimensions, m_allocatedSizeX, m_allocatedSizeY, m_allocatedSizeZ, *threshold, *startThreshold, m_transformMask, transformData, m_transformIterations,
WaveletAdaptiveLL_DecodeIterator decodeIterator = WaveletAdaptiveLL_CreateDecodeIterator(m_dataVersion, (uint8_t*)m_readCompressedData, floatReadWriteData, m_dimensions, m_allocatedSizeX, m_allocatedSizeY, m_allocatedSizeZ, *threshold, *startThreshold, m_transformMask, transformData, m_transformIterations,
m_pixelSetChildren.get(), m_pixelSetChildrenCount, m_pixelSetPixelInSignificant.get(), m_pixelSetPixelInSignificantCount,
m_allocatedHalfSizeX, m_allocatedHalfSizeX * m_allocatedHalfSizeY, cpuTempData.data(), m_allocatedHalfSizeX * m_allocatedHalfSizeY * m_allocatedHalfSizeZ, m_allocatedSizeX * m_allocatedSizeY * m_allocatedSizeZ, decompressLevel, isInteger);
......
......@@ -59,7 +59,7 @@ static uint8_t* AssignPtrAndIncrementOffset(int nSize, uint8_t*& workBuffer)
return returnBuffer;
}
int32_t AddSubBand(uint8_t* out, Wavelet_TransformData* transformData, int32_t transformIndex, int32_t iSector, int32_t subBandOffset[][8], bool* isAllNormal)
int32_t AddSubBand(bool isStreamFix, uint8_t* out, Wavelet_TransformData* transformData, int32_t transformIndex, int32_t iSector, int32_t subBandOffset[][8], bool* isAllNormal)
{
Wavelet_Compiled_SubBandInfo* band = (Wavelet_Compiled_SubBandInfo*)out;
......@@ -77,17 +77,30 @@ int32_t AddSubBand(uint8_t* out, Wavelet_TransformData* transformData, int32_t t
// check if this band is actually normal!
if (!isNormal && transformData[transformIndex].subBandInfo[iSector].childSubBand == 1)
{
// any extra childs?
// any extra children?
if (transformData[transformIndex].subBandInfo[iSector].extraChildEdge[0][0] == -1 &&
transformData[transformIndex].subBandInfo[iSector].extraChildEdge[0][1] == -1 &&
transformData[transformIndex].subBandInfo[iSector].extraChildEdge[0][2] == -1)
{
// all dividable by two?
if (!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][0] & 1) &&
!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][1] & 1) &&
(!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][2] & 1) || transformData[transformIndex].child == 4))
if (!isStreamFix)
{
isNormal = true;
// all divisible by two?
if (!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][0] & 1) &&
!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][1] & 1) &&
(!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][2] & 1) || transformData[transformIndex].child == 4))
{
isNormal = true;
}
}
else
{
// all divisible by two or no children?
if ( (!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][0] & 1) || (transformData[transformIndex].childCount[0] == 1)) &&
(!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][1] & 1) || (transformData[transformIndex].childCount[1] == 1)) &&
(!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][2] & 1) || (transformData[transformIndex].childCount[2] == 1)))
{
isNormal = true;
}
}
}
}
......@@ -148,7 +161,7 @@ int32_t AddSubBand(uint8_t* out, Wavelet_TransformData* transformData, int32_t t
return size;
}
static int32_t CompileTransformData(uint8_t* compiledTransformData, int32_t* firstSubBand, const Wavelet_PixelSetChildren* pixelSetChildren, int32_t pixelSetChildrenCount, Wavelet_TransformData* transformData, int32_t transformDataCount, int32_t* transformMask, bool* isAllNormal)
static int32_t CompileTransformData(bool isStreamFix, uint8_t* compiledTransformData, int32_t* firstSubBand, const Wavelet_PixelSetChildren* pixelSetChildren, int32_t pixelSetChildrenCount, Wavelet_TransformData* transformData, int32_t transformDataCount, int32_t* transformMask, bool* isAllNormal)
{
int subBand[32][8];
......@@ -162,7 +175,7 @@ static int32_t CompileTransformData(uint8_t* compiledTransformData, int32_t* fir
{
if ((iSector & transformMask[iTransform]) == iSector)
{
int size = AddSubBand(compiledTransformData + writePos, transformData, iTransform, iSector, subBand, isAllNormal);
int size = AddSubBand(isStreamFix, compiledTransformData + writePos, transformData, iTransform, iSector, subBand, isAllNormal);
if (size == 0)
{
......@@ -204,7 +217,7 @@ static int32_t CompileTransformData(uint8_t* compiledTransformData, int32_t* fir
return writePos;
}
WaveletAdaptiveLL_DecodeIterator WaveletAdaptiveLL_CreateDecodeIterator(uint8_t* stream, float* picture, int dimensions, int sizeX, int sizeY, int sizeZ,
WaveletAdaptiveLL_DecodeIterator WaveletAdaptiveLL_CreateDecodeIterator(int dataVersion, uint8_t* stream, float* picture, int dimensions, int sizeX, int sizeY, int sizeZ,
const float threshold, const float startThreshold, int* transformMask, Wavelet_TransformData* transformData, int transformDataCount,
Wavelet_PixelSetChildren* pixelSetChildren, int pixelSetChildrenCount, Wavelet_PixelSetPixel* pixelSetPixelInSignificant, int pixelSetPixelInsignificantCount,
int maxSizeX, int maxSizeXY, uint8_t* tempBufferCPU, int maxChildren, int maxPixels, int decompressLevel, bool isInteger)
......@@ -213,6 +226,7 @@ WaveletAdaptiveLL_DecodeIterator WaveletAdaptiveLL_CreateDecodeIterator(uint8_t*
WaveletAdaptiveLL_DecodeIterator decodeIterator;
decodeIterator.dataVersion = dataVersion;
decodeIterator.isInteger = isInteger;
decodeIterator.sizeX = sizeX;
decodeIterator.sizeY = sizeY;
......@@ -303,7 +317,10 @@ WaveletAdaptiveLL_DecodeIterator WaveletAdaptiveLL_CreateDecodeIterator(uint8_t*
// And compile tree traversal data based on wavelet tranfsform for this item
bool isAllNormal = true;
int compiledTransformData = CompileTransformData((uint8_t*)decodeIterator.compiledTransformData, decodeIterator.firstSubBand, pixelSetChildren, pixelSetChildrenCount, transformData, transformDataCount, transformMask, &isAllNormal);
bool
isStreamFix = decodeIterator.dataVersion >= WAVELET_DATA_VERSION_1_6 ? true : false;
int compiledTransformData = CompileTransformData(isStreamFix, (uint8_t*)decodeIterator.compiledTransformData, decodeIterator.firstSubBand, pixelSetChildren, pixelSetChildrenCount, transformData, transformDataCount, transformMask, &isAllNormal);
(void) compiledTransformData;
......@@ -1034,6 +1051,11 @@ static void DecodeAllBits(const WaveletAdaptiveLL_DecodeIterator& decodeIterator
int32_t WaveletAdaptiveLL_DecompressAdaptive(WaveletAdaptiveLL_DecodeIterator decodeIterator, DecompressAdaptiveMode decompressAdaptiveMode)
{
if (decodeIterator.dataVersion >= WAVELET_DATA_VERSION_1_6)
{
assert(decompressAdaptiveMode == DecompressAdaptiveMode::AssumeNoOverwrite);
}
int streamSize = 0;
if (decodeIterator.isAllNormal)
......@@ -1253,7 +1275,7 @@ bool CheckIfWaveletSectorHasStreamBug(Wavelet_TransformData * transformData, int
transformData[transformIndex].subBandInfo[iSector].extraChildEdge[0][1] == -1 &&
transformData[transformIndex].subBandInfo[iSector].extraChildEdge[0][2] == -1)
{
// all dividable by two?
// all divisible by two?
if (!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][0] & 1) &&
!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][1] & 1) &&
(!(transformData[transformIndex].subBandInfo[iSector].legalChildEdge[0][2] & 1) || transformData[transformIndex].child == 4))
......
......@@ -34,6 +34,8 @@ enum class DecompressAdaptiveMode
struct WaveletAdaptiveLL_DecodeIterator
{
int32_t dataVersion;
Wavelet_FastDecodeInsig *insig;
Wavelet_FastDecodeInsig *sig;
......@@ -89,7 +91,7 @@ struct WaveletAdaptiveLL_DecodeIterator
int32_t pixelSetPixelInsignificantCount;
};
WaveletAdaptiveLL_DecodeIterator WaveletAdaptiveLL_CreateDecodeIterator(uint8_t *streamCPU, float *pictureCPU, int dimensions, int sizeX, int sizeY, int sizeZ,
WaveletAdaptiveLL_DecodeIterator WaveletAdaptiveLL_CreateDecodeIterator(int dataVersion, uint8_t *streamCPU, float *pictureCPU, int dimensions, int sizeX, int sizeY, int sizeZ,
const float threshold, const float startThreshold, int *transformMask, Wavelet_TransformData *transformData, int transformDataCount,
Wavelet_PixelSetChildren *pixelSetChildren, int pixelSetChildrenCount, Wavelet_PixelSetPixel *pixelSetPixelInSignificant, int pixelSetPixelInsignificantCount,
int maxSizeX, int maxSizeXY, uint8_t *tempBufferCPU, int maxChildren, int maxPixels, int decompressLevel, bool isInteger);
......
......@@ -28,6 +28,7 @@
#define WAVELET_DATA_VERSION_1_4 (671) // progressive wavelet transform
#define WAVELET_DATA_VERSION_1_5 (672) // U8, U16 and U32 native/lossless compression
#define WAVELET_DATA_VERSION_1_6 (673) // Fixed stream encoding case for rare cases
#define WAVELET_MIN_COMPRESSED_HEADER (6 * 4)
......
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