Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ADApp/ADSrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ INC += ADCoreVersion.h
INC += NDAttribute.h
INC += NDAttributeList.h
INC += NDArray.h
INC += Codec.h
INC += NDCodec.h
INC += PVAttribute.h
INC += paramAttribute.h
INC += functAttribute.h
Expand All @@ -44,6 +44,7 @@ LIB_SRCS += NDAttribute.cpp
LIB_SRCS += NDAttributeList.cpp
LIB_SRCS += NDArrayPool.cpp
LIB_SRCS += NDArray.cpp
LIB_SRCS += NDCodec.cpp
LIB_SRCS += asynNDArrayDriver.cpp
LIB_SRCS += ADDriver.cpp
LIB_SRCS += paramAttribute.cpp
Expand Down
4 changes: 2 additions & 2 deletions ADApp/ADSrc/NDArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "NDAttribute.h"
#include "NDAttributeList.h"
#include "Codec.h"
#include "NDCodec.h"

/** The maximum number of dimensions in an NDArray */
#define ND_ARRAY_MAX_DIMS 10
Expand Down Expand Up @@ -132,7 +132,7 @@ class ADCORE_API NDArray {
* The data is assumed to be stored in the order of dims[0] changing fastest, and
* dims[ndims-1] changing slowest. */
NDAttributeList *pAttributeList; /**< Linked list of attributes */
Codec_t codec; /**< Definition of codec used to compress the data. */
NDCodec_t codec; /**< Definition of codec used to compress the data. */
size_t compressedSize; /**< Size of the compressed data. Should be equal to dataSize if pData is uncompressed. */
};

Expand Down
20 changes: 20 additions & 0 deletions ADApp/ADSrc/NDCodec.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "NDCodec.h"

const std::string NDCodecName[NDCODEC_NUM_CODECS] = {
"",
"jpeg",
"zlib",
"blosc",
"lz4",
"lz4hdf5",
"bslz4"
};

const std::string NDCodecBloscCompName[NDCODEC_BLOSC_NUM_COMPRESSORS] = {
"blosclz",
"lz4",
"lz4hc",
"snappy",
"zlib",
"zstd",
};
48 changes: 28 additions & 20 deletions ADApp/ADSrc/Codec.h → ADApp/ADSrc/NDCodec.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#ifndef Codec_H
#define Codec_H
#ifndef NDCodec_H
#define NDCodec_H

#include <string>

static std::string codecName[] = {
"",
"jpeg",
"zlib",
"blosc",
"lz4",
"lz4hdf5",
"bslz4"
};
#include "ADCoreAPI.h"

typedef enum {
NDCODEC_NONE,
Expand All @@ -23,28 +14,45 @@ typedef enum {
NDCODEC_BSLZ4
} NDCodecCompressor_t;

typedef struct Codec_t {
#define NDCODEC_NUM_CODECS 7

extern ADCORE_API const std::string NDCodecName[NDCODEC_NUM_CODECS];

typedef enum {
NDCODEC_BLOSC_BLOSCLZ,
NDCODEC_BLOSC_LZ4,
NDCODEC_BLOSC_LZ4HC,
NDCODEC_BLOSC_SNAPPY,
NDCODEC_BLOSC_ZLIB,
NDCODEC_BLOSC_ZSTD
} NDCodecBloscComp_t;

#define NDCODEC_BLOSC_NUM_COMPRESSORS 6

extern ADCORE_API const std::string NDCodecBloscCompName[NDCODEC_BLOSC_NUM_COMPRESSORS];

typedef struct NDCodec_t {
std::string name; /**< Name of the codec used to compress the data. codecName[NDCODEC_NONE] if uncompressed. */
int level; /**< Compression level. */
int shuffle; /**< Shuffle type. */
int compressor; /**< Compressor type. For codecs that support more than one compressor. */

Codec_t() {
NDCodec_t() {
clear();
}

void clear() {
name = codecName[NDCODEC_NONE];
name = NDCodecName[NDCODEC_NONE];
level = -1;
shuffle = -1;
compressor = -1;
}

bool empty() {
return this->name == codecName[NDCODEC_NONE];
return this->name == NDCodecName[NDCODEC_NONE];
}

bool operator==(const Codec_t& other) {
bool operator==(const NDCodec_t& other) {
if (name == other.name &&
level == other.level &&
shuffle == other.shuffle &&
Expand All @@ -54,9 +62,9 @@ typedef struct Codec_t {
return false;
}
}
bool operator!=(const Codec_t& other) {
bool operator!=(const NDCodec_t& other) {
return ! (*this == other);
}
} Codec_t;
} NDCodec_t;

#endif //Codec_H
#endif //NDCodec_H
24 changes: 12 additions & 12 deletions ADApp/pluginSrc/NDFileHDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3318,21 +3318,21 @@ asynStatus NDFileHDF5::configureCompression(NDArray *pArray)
asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW,
"%s::%s Overriding compression settings from pre-compressed NDArray\n",
driverName, functionName);
if (pArray->codec.name == codecName[NDCODEC_BLOSC]) {
if (pArray->codec.name == NDCodecName[NDCODEC_BLOSC]) {
setIntegerParam(NDFileHDF5_compressionType, HDF5CompressBlosc);
setIntegerParam(NDFileHDF5_bloscCompressLevel, pArray->codec.level);
setIntegerParam(NDFileHDF5_bloscShuffleType, pArray->codec.shuffle);
setIntegerParam(NDFileHDF5_bloscCompressor, pArray->codec.compressor);
} else if (pArray->codec.name == codecName[NDCODEC_ZLIB]) {
} else if (pArray->codec.name == NDCodecName[NDCODEC_ZLIB]) {
setIntegerParam(NDFileHDF5_compressionType, HDF5CompressZlib);
setIntegerParam(NDFileHDF5_zCompressLevel, pArray->codec.level);
} else if (pArray->codec.name == codecName[NDCODEC_BSLZ4]) {
} else if (pArray->codec.name == NDCodecName[NDCODEC_BSLZ4]) {
setIntegerParam(NDFileHDF5_compressionType, HDF5CompressBshuf);
} else if (pArray->codec.name == codecName[NDCODEC_LZ4]) {
} else if (pArray->codec.name == NDCodecName[NDCODEC_LZ4]) {
setIntegerParam(NDFileHDF5_compressionType, HDF5CompressLZ4);
} else if (pArray->codec.name == codecName[NDCODEC_LZ4HDF5]) {
} else if (pArray->codec.name == NDCodecName[NDCODEC_LZ4HDF5]) {
setIntegerParam(NDFileHDF5_compressionType, HDF5CompressLZ4HDF5);
} else if (pArray->codec.name == codecName[NDCODEC_JPEG]) {
} else if (pArray->codec.name == NDCodecName[NDCODEC_JPEG]) {
setIntegerParam(NDFileHDF5_compressionType, HDF5CompressJPEG);
}
}
Expand Down Expand Up @@ -3384,7 +3384,7 @@ asynStatus NDFileHDF5::configureCompression(NDArray *pArray)
"%s::%s Setting zlib compression filter level=%d\n",
driverName, functionName, zLevel);
H5Pset_deflate(this->cparms, zLevel);
this->codec.name = codecName[NDCODEC_ZLIB];
this->codec.name = NDCodecName[NDCODEC_ZLIB];
this->codec.level = zLevel;
break;
case HDF5CompressBlosc: {
Expand All @@ -3401,7 +3401,7 @@ asynStatus NDFileHDF5::configureCompression(NDArray *pArray)
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "Failed to set h5 blosc filter\n");
break;
}
this->codec.name = codecName[NDCODEC_BLOSC];
this->codec.name = NDCodecName[NDCODEC_BLOSC];
this->codec.level = bloscLevel;
this->codec.shuffle = bloscShuffle;
this->codec.compressor = bloscCompressor;
Expand All @@ -3416,7 +3416,7 @@ asynStatus NDFileHDF5::configureCompression(NDArray *pArray)
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "Failed to set h5 bitshuffle filter\n");
break;
}
this->codec.name = codecName[NDCODEC_BSLZ4];
this->codec.name = NDCodecName[NDCODEC_BSLZ4];
}
break;
case HDF5CompressLZ4:
Expand All @@ -3430,9 +3430,9 @@ asynStatus NDFileHDF5::configureCompression(NDArray *pArray)
break;
}
if (compressionScheme == HDF5CompressLZ4) {
this->codec.name = codecName[NDCODEC_LZ4];
this->codec.name = NDCodecName[NDCODEC_LZ4];
} else {
this->codec.name = codecName[NDCODEC_LZ4HDF5];
this->codec.name = NDCodecName[NDCODEC_LZ4HDF5];
}
}
break;
Expand Down Expand Up @@ -3461,7 +3461,7 @@ asynStatus NDFileHDF5::configureCompression(NDArray *pArray)
asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "Failed to set h5 jpeg filter\n");
break;
}
this->codec.name = codecName[NDCODEC_JPEG];
this->codec.name = NDCodecName[NDCODEC_JPEG];
}
break;
}
Expand Down
4 changes: 2 additions & 2 deletions ADApp/pluginSrc/NDFileHDF5.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "NDFileHDF5LayoutXML.h"
#include "NDFileHDF5AttributeDataset.h"
#include "NDFileHDF5VersionCheck.h"
#include "Codec.h"
#include "NDCodec.h"

#define MAXEXTRADIMS 10
#define MAX_CHUNK_DIMS ND_ARRAY_MAX_DIMS
Expand Down Expand Up @@ -127,7 +127,7 @@ class NDPLUGIN_API NDFileHDF5 : public NDPluginFile
std::string ndDsetName; // Name of NDAttribute that specifies the destination data set
std::map<std::string, hdf5::Element *> onOpenMap; // Map of handles to elements with onOpen ndattributes, indexed by fullname
std::map<std::string, hdf5::Element *> onCloseMap; // Map of handles to elements with onClose ndattributes, indexed by fullname
Codec_t codec; // Definition of codec used to compress the data.
NDCodec_t codec; // Definition of codec used to compress the data.

protected:
/* plugin parameters */
Expand Down
6 changes: 3 additions & 3 deletions ADApp/pluginSrc/NDFileHDF5Dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ asynStatus NDFileHDF5Dataset::verifyChunking(NDArray *pArray)
* Store codec definition
* \param[in] codec - Codec definition.
*/
void NDFileHDF5Dataset::configureCompression(Codec_t codec)
void NDFileHDF5Dataset::configureCompression(NDCodec_t codec)
{
this->codec = codec;
}
Expand Down Expand Up @@ -296,7 +296,7 @@ asynStatus NDFileHDF5Dataset::writeFile(NDArray *pArray, hid_t datatype, hid_t d
if (pArray->codec.empty()) {
size = info.totalBytes;
}
else if (pArray->codec.name == codecName[NDCODEC_LZ4]) {
else if (pArray->codec.name == NDCodecName[NDCODEC_LZ4]) {
// We need to add a 16-byte header to the lz4 compressed data
temp = (char *)malloc(16 + size);
// First 8 bytes is the uncompressed array size
Expand All @@ -313,7 +313,7 @@ asynStatus NDFileHDF5Dataset::writeFile(NDArray *pArray, hid_t datatype, hid_t d
pData = temp;
size += 16;
}
else if (pArray->codec.name == codecName[NDCODEC_BSLZ4]) {
else if (pArray->codec.name == NDCodecName[NDCODEC_BSLZ4]) {
// We need to add a 12-byte header to the bs/lz4 compressed data
temp = (char *)malloc(12 + size);
// First 8 bytes is the uncompressed array size
Expand Down
4 changes: 2 additions & 2 deletions ADApp/pluginSrc/NDFileHDF5Dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NDPLUGIN_API NDFileHDF5Dataset
asynStatus extendDataSet(int extradims);
asynStatus extendDataSet(int extradims, hsize_t *offsets);
asynStatus verifyChunking(NDArray *pArray);
void configureCompression(Codec_t codec);
void configureCompression(NDCodec_t codec);
asynStatus writeFile(NDArray *pArray, hid_t datatype, hid_t dataspace, hsize_t *framesize);
hid_t getHandle();
asynStatus flushDataset();
Expand All @@ -44,7 +44,7 @@ class NDPLUGIN_API NDFileHDF5Dataset
// 0 offset but additional dimensions may grow as new frames are added.
hsize_t *virtualdims_; // The desired sizes of the extra (virtual) dimensions: {Y, X, n}
hsize_t *virtualchunkdims_; // The chunk sizes of the extra (virtual) dimensions: {Y, X, n}
Codec_t codec; // Definition of codec used to compress the data.
NDCodec_t codec; // Definition of codec used to compress the data.
};


Expand Down
Loading
Loading