summaryrefslogtreecommitdiff
path: root/testsuite/backend/genesys/tests_image_pipeline.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/backend/genesys/tests_image_pipeline.cpp')
-rw-r--r--testsuite/backend/genesys/tests_image_pipeline.cpp522
1 files changed, 480 insertions, 42 deletions
diff --git a/testsuite/backend/genesys/tests_image_pipeline.cpp b/testsuite/backend/genesys/tests_image_pipeline.cpp
index d4853d2..7eed9e6 100644
--- a/testsuite/backend/genesys/tests_image_pipeline.cpp
+++ b/testsuite/backend/genesys/tests_image_pipeline.cpp
@@ -32,72 +32,139 @@
namespace genesys {
-void test_image_buffer_genesys_usb()
+
+void test_image_buffer_exact_reads()
{
std::vector<std::size_t> requests;
- auto on_read_usb = [&](std::size_t x, std::uint8_t* data)
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
{
(void) data;
requests.push_back(x);
+ return true;
};
- FakeBufferModel model;
- model.push_step(453120, 1);
- model.push_step(56640, 3540);
- ImageBufferGenesysUsb buffer{1086780, model, on_read_usb};
+ ImageBuffer buffer{1000, on_read};
+ buffer.set_remaining_size(2500);
std::vector<std::uint8_t> dummy;
- dummy.resize(1086780);
-
- ASSERT_TRUE(buffer.get_data(453120, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
+ dummy.resize(1000);
+
+ ASSERT_TRUE(buffer.get_data(1000, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(1000, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(500, dummy.data()));
std::vector<std::size_t> expected = {
- 453120, 56576, 56576, 56576, 56832, 56576, 56576, 56576, 56832, 56576, 56576, 56576, 11008
+ 1000, 1000, 500
};
ASSERT_EQ(requests, expected);
}
-void test_image_buffer_genesys_usb_capped_remaining_bytes()
+void test_image_buffer_smaller_reads()
{
std::vector<std::size_t> requests;
- auto on_read_usb = [&](std::size_t x, std::uint8_t* data)
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
{
(void) data;
requests.push_back(x);
+ return true;
};
- FakeBufferModel model;
- model.push_step(453120, 1);
- model.push_step(56640, 3540);
- ImageBufferGenesysUsb buffer{1086780, model, on_read_usb};
+ ImageBuffer buffer{1000, on_read};
+ buffer.set_remaining_size(2500);
std::vector<std::uint8_t> dummy;
- dummy.resize(1086780);
+ dummy.resize(700);
+
+ ASSERT_TRUE(buffer.get_data(600, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(600, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(600, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(700, dummy.data()));
+
+ std::vector<std::size_t> expected = {
+ 1000, 1000, 500
+ };
+ ASSERT_EQ(requests, expected);
+}
+
+void test_image_buffer_larger_reads()
+{
+ std::vector<std::size_t> requests;
- ASSERT_TRUE(buffer.get_data(453120, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
- ASSERT_TRUE(buffer.get_data(56640, dummy.data()));
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
+ {
+ (void) data;
+ requests.push_back(x);
+ return true;
+ };
+
+ ImageBuffer buffer{1000, on_read};
+ buffer.set_remaining_size(2500);
+
+ std::vector<std::uint8_t> dummy;
+ dummy.resize(2500);
+
+ ASSERT_TRUE(buffer.get_data(2500, dummy.data()));
+
+ std::vector<std::size_t> expected = {
+ 1000, 1000, 500
+ };
+ ASSERT_EQ(requests, expected);
+}
+
+void test_image_buffer_uncapped_remaining_bytes()
+{
+ std::vector<std::size_t> requests;
+ unsigned request_count = 0;
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
+ {
+ (void) data;
+ requests.push_back(x);
+ request_count++;
+ return request_count < 4;
+ };
+
+ ImageBuffer buffer{1000, on_read};
+
+ std::vector<std::uint8_t> dummy;
+ dummy.resize(3000);
+
+ ASSERT_TRUE(buffer.get_data(3000, dummy.data()));
+ ASSERT_FALSE(buffer.get_data(3000, dummy.data()));
+
+ std::vector<std::size_t> expected = {
+ 1000, 1000, 1000, 1000
+ };
+ ASSERT_EQ(requests, expected);
+}
+
+void test_image_buffer_capped_remaining_bytes()
+{
+ std::vector<std::size_t> requests;
+
+ auto on_read = [&](std::size_t x, std::uint8_t* data)
+ {
+ (void) data;
+ requests.push_back(x);
+ return true;
+ };
+
+ ImageBuffer buffer{1000, on_read};
buffer.set_remaining_size(10000);
- ASSERT_FALSE(buffer.get_data(56640, dummy.data()));
+ buffer.set_last_read_multiple(16);
+
+ std::vector<std::uint8_t> dummy;
+ dummy.resize(2000);
+
+ ASSERT_TRUE(buffer.get_data(2000, dummy.data()));
+ ASSERT_TRUE(buffer.get_data(2000, dummy.data()));
+ buffer.set_remaining_size(100);
+ ASSERT_FALSE(buffer.get_data(200, dummy.data()));
std::vector<std::size_t> expected = {
- // note that the sizes are rounded-up to 256 bytes
- 453120, 56576, 56576, 56576, 56832, 10240
+ // note that the sizes are rounded-up to 16 bytes
+ 1000, 1000, 1000, 1000, 112
};
ASSERT_EQ(requests, expected);
}
@@ -300,6 +367,109 @@ void test_node_swap_16bit_endian()
ASSERT_EQ(out_data, expected_data);
}
+void test_node_invert_16_bits()
+{
+ using Data16 = std::vector<std::uint16_t>;
+ using Data = std::vector<std::uint8_t>;
+
+ Data16 in_data = {
+ 0x1020, 0x3011, 0x2131,
+ 0x1222, 0x3213, 0x2333,
+ 0x1424, 0x3415, 0x2525,
+ 0x1626, 0x3617, 0x2737,
+ };
+
+ Data in_data_8bit;
+ in_data_8bit.resize(in_data.size() * 2);
+ std::memcpy(in_data_8bit.data(), in_data.data(), in_data_8bit.size());
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(4, 1, PixelFormat::RGB161616,
+ std::move(in_data_8bit));
+ stack.push_node<ImagePipelineNodeInvert>();
+
+ ASSERT_EQ(stack.get_output_width(), 4u);
+ ASSERT_EQ(stack.get_output_height(), 1u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 24u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB161616);
+
+ auto out_data_8bit = stack.get_all_data();
+ Data16 out_data;
+ out_data.resize(out_data_8bit.size() / 2);
+ std::memcpy(out_data.data(), out_data_8bit.data(), out_data_8bit.size());
+
+ Data16 expected_data = {
+ 0xefdf, 0xcfee, 0xdece,
+ 0xeddd, 0xcdec, 0xdccc,
+ 0xebdb, 0xcbea, 0xdada,
+ 0xe9d9, 0xc9e8, 0xd8c8,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_invert_8_bits()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x10, 0x20, 0x30, 0x11, 0x21, 0x31,
+ 0x12, 0x22, 0x32, 0x13, 0x23, 0x33,
+ 0x14, 0x24, 0x34, 0x15, 0x25, 0x35,
+ 0x16, 0x26, 0x36, 0x17, 0x27, 0x37,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(8, 1, PixelFormat::RGB888,
+ std::move(in_data));
+ stack.push_node<ImagePipelineNodeInvert>();
+
+ ASSERT_EQ(stack.get_output_width(), 8u);
+ ASSERT_EQ(stack.get_output_height(), 1u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 24u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB888);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0xef, 0xdf, 0xcf, 0xee, 0xde, 0xce,
+ 0xed, 0xdd, 0xcd, 0xec, 0xdc, 0xcc,
+ 0xeb, 0xdb, 0xcb, 0xea, 0xda, 0xca,
+ 0xe9, 0xd9, 0xc9, 0xe8, 0xd8, 0xc8,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_invert_1_bits()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x10, 0x20, 0x30, 0x11, 0x21, 0x31,
+ 0x16, 0x26, 0x36, 0x17, 0x27, 0x37,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(32, 1, PixelFormat::RGB111,
+ std::move(in_data));
+ stack.push_node<ImagePipelineNodeInvert>();
+
+ ASSERT_EQ(stack.get_output_width(), 32u);
+ ASSERT_EQ(stack.get_output_height(), 1u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::RGB111);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0xef, 0xdf, 0xcf, 0xee, 0xde, 0xce,
+ 0xe9, 0xd9, 0xc9, 0xe8, 0xd8, 0xc8,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
void test_node_merge_mono_lines()
{
using Data = std::vector<std::uint8_t>;
@@ -395,7 +565,7 @@ void test_node_component_shift_lines()
ASSERT_EQ(out_data, expected_data);
}
-void test_node_pixel_shift_lines()
+void test_node_pixel_shift_lines_2lines()
{
using Data = std::vector<std::uint8_t>;
@@ -426,6 +596,261 @@ void test_node_pixel_shift_lines()
ASSERT_EQ(out_data, expected_data);
}
+void test_node_pixel_shift_lines_4lines()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 9, PixelFormat::I8,
+ std::move(in_data));
+ stack.push_node<ImagePipelineNodePixelShiftLines>(std::vector<std::size_t>{0, 2, 1, 3});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 6u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x00, 0x21, 0x12, 0x33, 0x04, 0x25, 0x16, 0x37, 0x08, 0x29, 0x1a, 0x3b,
+ 0x10, 0x31, 0x22, 0x43, 0x14, 0x35, 0x26, 0x47, 0x18, 0x39, 0x2a, 0x4b,
+ 0x20, 0x41, 0x32, 0x53, 0x24, 0x45, 0x36, 0x57, 0x28, 0x49, 0x3a, 0x5b,
+ 0x30, 0x51, 0x42, 0x63, 0x34, 0x55, 0x46, 0x67, 0x38, 0x59, 0x4a, 0x6b,
+ 0x40, 0x61, 0x52, 0x73, 0x44, 0x65, 0x56, 0x77, 0x48, 0x69, 0x5a, 0x7b,
+ 0x50, 0x71, 0x62, 0x83, 0x54, 0x75, 0x66, 0x87, 0x58, 0x79, 0x6a, 0x8b,
+ };
+
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_compute_max_width()
+{
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 2, 3}), 0u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {1, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {1, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {1, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {1, 1, 2, 3}), 0u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {2, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {2, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {2, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {2, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {2, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {2, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {2, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {2, 1, 2, 3}), 0u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {3, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {3, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {3, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {3, 1, 2, 3}), 3u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {3, 1, 2, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {3, 1, 2, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {3, 1, 2, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {3, 1, 2, 3}), 3u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {7, 1, 2, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {7, 1, 2, 3}), 5u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {7, 1, 2, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {7, 1, 2, 3}), 7u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {7, 1, 2, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {7, 1, 2, 3}), 5u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {7, 1, 2, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {7, 1, 2, 3}), 7u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 3, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 3, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 3, 3}), 1u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 4, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 4, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 4, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 4, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 4, 3}), 1u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 5, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 5, 3}), 3u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 5, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 5, 3}), 1u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 5, 3}), 2u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 5, 3}), 3u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 5, 3}), 0u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 5, 3}), 1u);
+
+ ASSERT_EQ(compute_pixel_shift_extra_width(12, {0, 1, 9, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(13, {0, 1, 9, 3}), 7u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(14, {0, 1, 9, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(15, {0, 1, 9, 3}), 5u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(16, {0, 1, 9, 3}), 6u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(17, {0, 1, 9, 3}), 7u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(18, {0, 1, 9, 3}), 4u);
+ ASSERT_EQ(compute_pixel_shift_extra_width(19, {0, 1, 9, 3}), 5u);
+}
+
+void test_node_pixel_shift_columns_no_switch()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{0, 1, 2, 3});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ ASSERT_EQ(out_data, in_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{3, 1, 2, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x03, 0x01, 0x02, 0x00, 0x07, 0x05, 0x06, 0x04, 0x0b, 0x09, 0x0a, 0x08,
+ 0x13, 0x11, 0x12, 0x10, 0x17, 0x15, 0x16, 0x14, 0x1b, 0x19, 0x1a, 0x18,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_not_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(13, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{3, 1, 2, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 12u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 12u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x03, 0x01, 0x02, 0x00, 0x07, 0x05, 0x06, 0x04, 0x0b, 0x09, 0x0a, 0x08,
+ 0x13, 0x11, 0x12, 0x10, 0x17, 0x15, 0x16, 0x14, 0x1b, 0x19, 0x1a, 0x18,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_large_offsets_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(12, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{7, 1, 5, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 8u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 8u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x07, 0x01, 0x05, 0x00, 0x0b, 0x05, 0x09, 0x04,
+ 0x17, 0x11, 0x15, 0x10, 0x1b, 0x15, 0x19, 0x14,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
+void test_node_pixel_shift_columns_group_switch_pixel_large_offsets_not_multiple()
+{
+ using Data = std::vector<std::uint8_t>;
+
+ Data in_data = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
+ };
+
+ ImagePipelineStack stack;
+ stack.push_first_node<ImagePipelineNodeArraySource>(13, 2, PixelFormat::I8, in_data);
+ stack.push_node<ImagePipelineNodePixelShiftColumns>(std::vector<std::size_t>{7, 1, 5, 0});
+
+ ASSERT_EQ(stack.get_output_width(), 8u);
+ ASSERT_EQ(stack.get_output_height(), 2u);
+ ASSERT_EQ(stack.get_output_row_bytes(), 8u);
+ ASSERT_EQ(stack.get_output_format(), PixelFormat::I8);
+
+ auto out_data = stack.get_all_data();
+
+ Data expected_data = {
+ 0x07, 0x01, 0x05, 0x00, 0x0b, 0x05, 0x09, 0x04,
+ 0x17, 0x11, 0x15, 0x10, 0x1b, 0x15, 0x19, 0x14,
+ };
+ ASSERT_EQ(out_data, expected_data);
+}
+
void test_node_calibrate_8bit()
{
using Data = std::vector<std::uint8_t>;
@@ -445,7 +870,7 @@ void test_node_calibrate_8bit()
ImagePipelineStack stack;
stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB888,
std::move(in_data));
- stack.push_node<ImagePipelineNodeCalibrate>(bottom, top);
+ stack.push_node<ImagePipelineNodeCalibrate>(bottom, top, 0);
ASSERT_EQ(stack.get_output_width(), 1u);
ASSERT_EQ(stack.get_output_height(), 1u);
@@ -481,7 +906,7 @@ void test_node_calibrate_16bit()
ImagePipelineStack stack;
stack.push_first_node<ImagePipelineNodeArraySource>(1, 1, PixelFormat::RGB161616,
std::move(in_data));
- stack.push_node<ImagePipelineNodeCalibrate>(bottom, top);
+ stack.push_node<ImagePipelineNodeCalibrate>(bottom, top, 0);
ASSERT_EQ(stack.get_output_width(), 1u);
ASSERT_EQ(stack.get_output_height(), 1u);
@@ -500,18 +925,31 @@ void test_node_calibrate_16bit()
void test_image_pipeline()
{
- test_image_buffer_genesys_usb();
- test_image_buffer_genesys_usb_capped_remaining_bytes();
+ test_image_buffer_exact_reads();
+ test_image_buffer_smaller_reads();
+ test_image_buffer_larger_reads();
+ test_image_buffer_uncapped_remaining_bytes();
+ test_image_buffer_capped_remaining_bytes();
test_node_buffered_callable_source();
test_node_format_convert();
test_node_desegment_1_line();
test_node_deinterleave_lines_i8();
test_node_deinterleave_lines_rgb888();
test_node_swap_16bit_endian();
+ test_node_invert_16_bits();
+ test_node_invert_8_bits();
+ test_node_invert_1_bits();
test_node_merge_mono_lines();
test_node_split_mono_lines();
test_node_component_shift_lines();
- test_node_pixel_shift_lines();
+ test_node_pixel_shift_columns_no_switch();
+ test_node_pixel_shift_columns_group_switch_pixel_multiple();
+ test_node_pixel_shift_columns_group_switch_pixel_not_multiple();
+ test_node_pixel_shift_columns_group_switch_pixel_large_offsets_multiple();
+ test_node_pixel_shift_columns_group_switch_pixel_large_offsets_not_multiple();
+ test_node_pixel_shift_lines_2lines();
+ test_node_pixel_shift_lines_4lines();
+ test_node_pixel_shift_columns_compute_max_width();
test_node_calibrate_8bit();
test_node_calibrate_16bit();
}