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
2 changes: 1 addition & 1 deletion eigerApp/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif
PROD += test_lz4
test_lz4_SRCS += test_lz4.cpp
test_lz4_LIBS += dectrisCompression
test_lz4_SYS_LIBS += lz4
test_lz4_LIBS += bitshuffle lz4hdf5

include $(ADCORE)/ADApp/commonLibraryMakefile

Expand Down
19 changes: 7 additions & 12 deletions eigerApp/src/stream2Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <epicsStdio.h>
#include <epicsString.h>
#include <string.h>
#include <lz4.h>
#include <lz4hdf5.h>
#include <bitshuffle.h>
#include <compression.h>

Expand All @@ -36,6 +36,7 @@ static int uncompress (const unsigned char *pInput, char *dest, char *encoding,
orig_size = be64toh(orig_size);
uint32_t block_size = *(uint32_t *)(pInput + 8);
block_size = be32toh(block_size);
int result;
switch (dataType)
{
case NDUInt32: elemSize=4; break;
Expand All @@ -46,17 +47,11 @@ static int uncompress (const unsigned char *pInput, char *dest, char *encoding,
return STREAM_ERROR;
}
if (strcmp(encoding, "lz4") == 0) {
// ERR("calling LZ4_decompress_fast");
// size_t result = LZ4_decompress_fast((const char *)pInput, dest, (int)uncompressedSize);
size_t result = compression_decompress_buffer(COMPRESSION_LZ4,
dest,
uncompressedSize,
(const char *)pInput,
compressedSize,
elemSize);
if (result < 0)
result = decompress_lz4hdf5((const char *)pInput, dest, uncompressedSize);

if (result <= 0)
{
ERR_ARGS("LZ4_decompress failed, result=%lu\n", result);
ERR_ARGS("decompress_lz4hdf5 failed, result=%d\n", result);
return STREAM_ERROR;
}
}
Expand Down Expand Up @@ -289,7 +284,7 @@ int Stream2API::getFrame (NDArray **pArrayOut, NDArrayPool *pNDArrayPool, int th
const unsigned char *pInput = pSB->ptr;
if (strcmp(encoding, "lz4") == 0)
{
pArray->codec.name = "lz4";
pArray->codec.name = "lz4hdf5";
}
else if (strcmp(encoding, "bslz4") == 0)
{
Expand Down
5 changes: 3 additions & 2 deletions eigerApp/src/test_lz4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <lz4.h>
#include <lz4hdf5.h>
#include <compression.h>

int main(int argc, char *argv[])
Expand All @@ -29,8 +30,8 @@ int main(int argc, char *argv[])

compressedSize = fread(compressedBuff, 1, MAX_COMPRESSED_SIZE, fp);
fclose(fp);
decompressedSize = LZ4_decompress_safe(compressedBuff, (char *)decompressedBuff, compressedSize, MAX_DECOMPRESSED_SIZE);
printf("Stream2_lz4_data decompressed with lz4_decompress_safe, compressedSize=%d, decompressedSize=%d\n", (int)compressedSize, (int)decompressedSize);
decompressedSize = decompress_lz4hdf5(compressedBuff, (char *)decompressedBuff, MAX_DECOMPRESSED_SIZE);
printf("Stream2_lz4_data decompressed with decompress_lz4hdf5, compressedSize=%d, decompressedSize=%d\n", (int)compressedSize, (int)decompressedSize);

// Decompress with the Dectris routine
decompressedSize = compression_decompress_buffer(COMPRESSION_LZ4, decompressedBuff, MAX_DECOMPRESSED_SIZE, compressedBuff, compressedSize, 4);
Expand Down