Commit 24a1e1c6 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by operator for beamline
Browse files

Add BSLZ4 support for Stream, allow free LZ4/BSLZ4 selection

parent 101e2148
......@@ -118,6 +118,7 @@ target_link_libraries(eiger PUBLIC
${ZMQ_LIBRARIES}
JsonCpp::JsonCpp
limacore
h5bshuf_objects
)
if(WIN32)
......
......@@ -20,6 +20,7 @@
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include "lz4.h"
#include "bitshuffle.h"
#include "EigerDecompress.h"
#include "EigerStream.h"
......@@ -63,7 +64,8 @@ Data _DecompressTask::process(Data& src)
throw ProcessException("_DecompressTask: can't find compressed message");
void* dst;
int size;
if(src.depth() == 4 && depth == 2)
bool expand_16_to_32bit = ((src.depth() == 4) && (depth == 2));
if(expand_16_to_32bit)
{
if(posix_memalign(&dst,16,src.size() / 2))
throw ProcessException("Can't allocate temporary memory");
......@@ -72,10 +74,18 @@ Data _DecompressTask::process(Data& src)
else
dst = src.data(),size = src.size();
int return_code = LZ4_decompress_fast((const char*)msg_data,(char*)dst,size);
Camera::CompressionType type;
m_stream.getCompressionType(type);
int return_code;
if (type == Camera::LZ4) {
return_code = LZ4_decompress_fast((const char*)msg_data,(char*)dst,size);
} else {
size_t nb_elements = size / depth;
return_code = bshuf_decompress_lz4(msg_data, dst, nb_elements, depth, 0);
}
if(return_code < 0)
{
if(src.depth() == 4 && depth == 2) free(dst);
if(expand_16_to_32bit) free(dst);
char ErrorBuff[1024];
snprintf(ErrorBuff,sizeof(ErrorBuff),
......@@ -83,7 +93,7 @@ Data _DecompressTask::process(Data& src)
return_code,src.size());
throw ProcessException(ErrorBuff);
}
if(src.depth() == 4 && depth == 2)
if(expand_16_to_32bit)
{
_expend(dst,src);
free(dst);
......
......@@ -99,9 +99,6 @@ void Interface::prepareAcq()
m_stream->setActive(!use_filewriter);
m_decompress->setActive(!use_filewriter);
Camera::CompressionType c = use_filewriter ? Camera::BSLZ4 : Camera::LZ4;
m_cam.setCompressionType(c);
m_cam.prepareAcq();
int serie_id; m_cam.getSerieId(serie_id);
m_saving->setSerieId(serie_id);
......
......@@ -214,6 +214,11 @@ bool Stream::isRunning() const
return m_running;
}
void Stream::getCompressionType(Camera::CompressionType& type) const
{
m_cam.getCompressionType(type);
}
void Stream::getHeaderDetail(Stream::HeaderDetail& detail) const
{
AutoMutex lock(m_cond.mutex());
......
......@@ -44,7 +44,9 @@ namespace lima
void start();
void stop();
bool isRunning() const;
void getCompressionType(Camera::CompressionType& type) const;
void getHeaderDetail(HeaderDetail&) const;
void setHeaderDetail(HeaderDetail);
......
......@@ -83,6 +83,8 @@ class Eiger(PyTango.Device_4Impl):
'OFF':False}
self.__PixelMask = {'ON':True,
'OFF':False}
self.__CompressionType = {'LZ4': EigerAcq.Camera.LZ4,
'BSLZ4': EigerAcq.Camera.BSLZ4}
#------------------------------------------------------------------
......@@ -201,6 +203,10 @@ class EigerClass(PyTango.DeviceClass):
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE]],
'compression_type':
[[PyTango.DevString,
PyTango.SCALAR,
PyTango.READ_WRITE]],
'threshold_energy':
[[PyTango.DevFloat,
PyTango.SCALAR,
......
Supports Markdown
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