FrameTransformation: Split packing and compression

This commit is contained in:
2023-05-01 21:27:08 +02:00
parent dce186f9f9
commit 9d5be2a4e9
7 changed files with 44 additions and 63 deletions

View File

@@ -39,14 +39,12 @@ TEST_CASE("FrameTransformation_Raw_NoCompression" ,"") {
std::vector<int16_t> output(experiment.GetPixelsNum());
transformation.SetOutput(output.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
REQUIRE(transformation.PackStandardOutput() == experiment.GetPixelDepth() * experiment.GetPixelsNum());
transformation.Pack();
REQUIRE(transformation.SaveCompressedImage(output.data()) == experiment.GetPixelDepth() * experiment.GetPixelsNum());
uint32_t diff_0 = 0;
uint32_t diff_1 = 0;
@@ -81,14 +79,13 @@ TEST_CASE("FrameTransformation_Converted_NoCompression" ,"") {
std::vector<int16_t> output(experiment.GetPixelsNum());
transformation.SetOutput(output.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
REQUIRE(transformation.PackStandardOutput() == experiment.GetPixelDepth() * experiment.GetPixelsNum());
transformation.Pack();
REQUIRE(transformation.SaveCompressedImage(output.data()) == experiment.GetPixelDepth() * experiment.GetPixelsNum());
REQUIRE(input_0[511*1024] == output[CONVERTED_MODULE_SIZE * (2 * nmodules - 2) + 0]);
REQUIRE(input_0[511*1024+256]/2 == output[CONVERTED_MODULE_SIZE * (2 * nmodules - 2) + 258]);
@@ -134,15 +131,14 @@ TEST_CASE("FrameTransformation_Converted_bshuf_lz4" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
transformation.Pack();
REQUIRE_NOTHROW(compressed_size = transformation.SaveCompressedImage(output_compressed.data()));
output_compressed.resize(compressed_size);
REQUIRE(bshuf_read_uint64_BE(output_compressed.data()) == experiment.GetPixelsNum() * experiment.GetPixelDepth());
@@ -195,16 +191,14 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -257,15 +251,14 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_bin_2x2" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -305,16 +298,14 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_rle" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -369,8 +360,6 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
@@ -392,7 +381,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation" ,"") {
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -440,8 +430,6 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int frame = 0; frame < experiment.GetSummation(); frame++) {
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
@@ -450,7 +438,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_bin_2x2" ,"") {
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -493,15 +482,14 @@ TEST_CASE("FrameTransformation_Converted_16bit_preview_summation" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
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;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -561,9 +549,7 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
@@ -574,7 +560,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
transformation.Pack();
REQUIRE_NOTHROW(compressed_size = transformation.SaveCompressedImage(output_compressed.data()));
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
@@ -596,7 +583,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_2frames" ,"") {
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());
@@ -644,8 +632,6 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_negatives" ,"") {
std::vector<char> output_compressed(experiment.GetMaxCompressedSize());
transformation.SetOutput(output_compressed.data());
for (int i = 0; i < nmodules; i++) {
REQUIRE_NOTHROW(transformation.ProcessModule(input_0.data() + i * RAW_MODULE_SIZE, i, 0));
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
@@ -666,7 +652,8 @@ TEST_CASE("FrameTransformation_Converted_bshuf_zstd_summation_negatives" ,"") {
REQUIRE_NOTHROW(transformation.ProcessModule(input_1.data() + i * RAW_MODULE_SIZE, i, 1));
}
size_t compressed_size;
REQUIRE_NOTHROW(compressed_size = transformation.PackStandardOutput());
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());