ZMQPreviewPublisher: Support both 16-bit and 32-bit images in preview

This commit is contained in:
2023-11-03 17:38:23 +01:00
parent 50556932fb
commit e6442f6384
7 changed files with 11 additions and 101 deletions

View File

@@ -571,73 +571,6 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
REQUIRE(output[(514/2)*(1030/2) * 2] == 4 * (1024 + 1025 + 1025 + 1026)); // line 1024 + 1025
}
TEST_CASE("FrameTransformation_Converted_16bit_preview_summation" ,"") {
const uint16_t nmodules = 1;
const uint16_t ndatastreams = 2;
DiffractionExperiment experiment(DetectorGeometry(ndatastreams * nmodules, 1, 0, 0, false));
experiment.DataStreams(ndatastreams);
experiment.Mode(DetectorMode::Conversion).Summation(4).Compression(JFJochProtoBuf::BSHUF_ZSTD);
REQUIRE(experiment.GetSummation() == 4);
FrameTransformation transformation(experiment);
std::mt19937 g1(15097);
std::uniform_int_distribution<int16_t> dist;
std::vector<int16_t> input_0(RAW_MODULE_SIZE, 55);
input_0[0] = 10000;
input_0[1] = 500;
input_0[2] = INT16_MIN;
input_0[3] = INT16_MAX;
input_0[4] = 345;
input_0[5] = 0;
input_0[256*1024] = 10000;
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data(), 0, 0));
size_t compressed_size;
transformation.Pack();
REQUIRE_NOTHROW(compressed_size = transformation.SaveCompressedImage(output_compressed.data()));
REQUIRE(bshuf_read_uint64_BE(output_compressed.data()) == experiment.GetPixelsNum() * experiment.GetPixelDepth());
REQUIRE(bshuf_read_uint32_BE(output_compressed.data()+8) == JFJochBitShuffleCompressor::DefaultBlockSize * experiment.GetPixelDepth());
output_compressed.resize(compressed_size);
std::vector<int32_t> output;
REQUIRE_NOTHROW(JFJochDecompress(output, experiment.GetCompressionAlgorithmEnum(), output_compressed,
experiment.GetPixelsNum()));
auto output16 = transformation.GetPreview16BitImage();
REQUIRE(output16[0] == INT16_MAX);
REQUIRE(output[0] == 4 * 10000);
REQUIRE(output16[1] == 4 * 500);
REQUIRE(output[1] == 4 * 500);
REQUIRE(output16[2] == INT16_MIN);
REQUIRE(output[2] == experiment.GetUnderflow());
REQUIRE(output16[3] == INT16_MAX);
REQUIRE(output[3] == experiment.GetOverflow());
REQUIRE(output16[4] == 4*345);
REQUIRE(output[4] == 4*345);
REQUIRE(output16[5] == 0);
REQUIRE(output[5] == 0);
REQUIRE(output16[1030*257] == 4 * 5000);
REQUIRE(output[1030*257] == 4 * 5000);
}
TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
// Ensure that previous frame is properly cleaned with PackStandardOutput()
const uint16_t nmodules = 4;