genesys: Support more than 2 columns in ImagePipelineNodePixelShiftLines

merge-requests/463/head
Povilas Kanapickas 2020-05-22 01:23:48 +03:00
rodzic d980da1ff7
commit 1bae94fd1e
3 zmienionych plików z 46 dodań i 16 usunięć

Wyświetl plik

@ -542,17 +542,6 @@ ImagePipelineNodePixelShiftLines::ImagePipelineNodePixelShiftLines(
pixel_shifts_{shifts},
buffer_{get_row_bytes()}
{
DBG_HELPER(dbg);
DBG(DBG_proc, "%s: shifts={", __func__);
for (auto el : pixel_shifts_) {
DBG(DBG_proc, " %zu", el);
}
DBG(DBG_proc, " }\n");
if (pixel_shifts_.size() > MAX_SHIFTS) {
throw SaneException("Unsupported number of shift configurations %zu", pixel_shifts_.size());
}
extra_height_ = *std::max_element(pixel_shifts_.begin(), pixel_shifts_.end());
height_ = source_.get_height();
if (extra_height_ > height_) {
@ -577,7 +566,8 @@ bool ImagePipelineNodePixelShiftLines::get_next_row_data(std::uint8_t* out_data)
auto format = get_format();
auto shift_count = pixel_shifts_.size();
std::array<std::uint8_t*, MAX_SHIFTS> rows;
std::vector<std::uint8_t*> rows;
rows.resize(shift_count, nullptr);
for (std::size_t irow = 0; irow < shift_count; ++irow) {
rows[irow] = buffer_.get_row_ptr(pixel_shifts_[irow]);

Wyświetl plik

@ -414,8 +414,6 @@ private:
class ImagePipelineNodePixelShiftLines : public ImagePipelineNode
{
public:
constexpr static std::size_t MAX_SHIFTS = 2;
ImagePipelineNodePixelShiftLines(ImagePipelineNode& source,
const std::vector<std::size_t>& shifts);

Wyświetl plik

@ -480,7 +480,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>;
@ -511,6 +511,47 @@ 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_calibrate_8bit()
{
using Data = std::vector<std::uint8_t>;
@ -599,7 +640,8 @@ void test_image_pipeline()
test_node_merge_mono_lines();
test_node_split_mono_lines();
test_node_component_shift_lines();
test_node_pixel_shift_lines();
test_node_pixel_shift_lines_2lines();
test_node_pixel_shift_lines_4lines();
test_node_calibrate_8bit();
test_node_calibrate_16bit();
}