v1.0.0-rc.36
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "CBORStream2Deserializer.h"
|
||||
#include "CborErr.h"
|
||||
#include "CborUtil.h"
|
||||
#include "../compression/JFJochDecompress.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace {
|
||||
@@ -542,6 +543,8 @@ namespace {
|
||||
message.min_viable_pixel_value = GetCBORInt(value);
|
||||
else if (key == "max_viable_pixel_value")
|
||||
message.max_viable_pixel_value = GetCBORInt(value);
|
||||
else if (key == "resolution_estimate")
|
||||
message.resolution_estimate = GetCBORFloat(value);
|
||||
else if (key == "data_collection_efficiency")
|
||||
message.image_collection_efficiency = GetCBORFloat(value);
|
||||
else if (key == "packets_expected")
|
||||
@@ -706,17 +709,26 @@ namespace {
|
||||
CompressedImage image;
|
||||
image.channel = key;
|
||||
GetCBORMultidimTypedArray(image, map_value);
|
||||
message.pixel_mask.emplace_back(std::move(image));
|
||||
|
||||
if (image.pixel_is_float || image.pixel_is_signed || (image.pixel_depth_bytes != sizeof(uint32_t)))
|
||||
continue;
|
||||
|
||||
std::vector<uint32_t> mask_uncompressed;
|
||||
JFJochDecompress(mask_uncompressed, image.algorithm, image.data, image.size,
|
||||
image.xpixel * image.ypixel);
|
||||
message.pixel_mask[key] = mask_uncompressed;
|
||||
}
|
||||
cborErr(cbor_value_leave_container(&value, &map_value));
|
||||
}
|
||||
|
||||
std::optional<FileWriterFileFormat> ProcessHDF5Format(int input) {
|
||||
auto tmp = static_cast<FileWriterFileFormat>(input);
|
||||
std::optional<FileWriterFormat> ProcessHDF5Format(int input) {
|
||||
auto tmp = static_cast<FileWriterFormat>(input);
|
||||
switch (tmp) {
|
||||
case FileWriterFileFormat::DataOnly:
|
||||
case FileWriterFileFormat::NXmxLegacy:
|
||||
case FileWriterFileFormat::NXmxVDS:
|
||||
case FileWriterFormat::DataOnly:
|
||||
case FileWriterFormat::NXmxLegacy:
|
||||
case FileWriterFormat::NXmxVDS:
|
||||
case FileWriterFormat::CBF:
|
||||
case FileWriterFormat::TIFF:
|
||||
return tmp;
|
||||
default:
|
||||
// don't throw exception, just do default
|
||||
@@ -778,8 +790,8 @@ namespace {
|
||||
message.overwrite = j["overwrite"];
|
||||
if (j.contains("xfel_pulse_id"))
|
||||
message.overwrite = j["xfel_pulse_id"];
|
||||
if (j.contains("hdf5_format_version"))
|
||||
message.hdf5_format_version = ProcessHDF5Format(j["hdf5_format_version"]);
|
||||
if (j.contains("file_format"))
|
||||
message.file_format = ProcessHDF5Format(j["file_format"]);
|
||||
} catch (const std::exception &e) {
|
||||
throw JFJochException(JFJochExceptionCategory::CBORError,
|
||||
"Cannot parse user_data as valid JSON " + std::string(e.what()));
|
||||
@@ -1042,3 +1054,7 @@ std::shared_ptr<CBORStream2DeserializerOutput> CBORStream2Deserialize(const uint
|
||||
cborErr(cbor_value_leave_container(&value, &map_value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::shared_ptr<CBORStream2DeserializerOutput> CBORStream2Deserialize(const std::vector<uint8_t>& msg) {
|
||||
return CBORStream2Deserialize(msg.data(), msg.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user