kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Add a way to debug image pipelines
rodzic
cd712f9f99
commit
9cd1de5c52
|
@ -44,6 +44,7 @@
|
||||||
#define DEBUG_DECLARE_ONLY
|
#define DEBUG_DECLARE_ONLY
|
||||||
|
|
||||||
#include "genesys_image_pipeline.h"
|
#include "genesys_image_pipeline.h"
|
||||||
|
#include "genesys_low.h"
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
ImagePipelineNode::~ImagePipelineNode() {}
|
ImagePipelineNode::~ImagePipelineNode() {}
|
||||||
|
@ -560,6 +561,36 @@ void ImagePipelineNodeExtract::get_next_row_data(std::uint8_t* out_data)
|
||||||
current_line_++;
|
current_line_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImagePipelineNodeDebug::ImagePipelineNodeDebug(ImagePipelineNode& source,
|
||||||
|
const std::string& path) :
|
||||||
|
source_(source),
|
||||||
|
path_{path},
|
||||||
|
buffer_{source_.get_row_bytes()}
|
||||||
|
{}
|
||||||
|
|
||||||
|
ImagePipelineNodeDebug::~ImagePipelineNodeDebug()
|
||||||
|
{
|
||||||
|
catch_all_exceptions(__func__, [&]()
|
||||||
|
{
|
||||||
|
if (buffer_.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto format = get_format();
|
||||||
|
buffer_.linearize();
|
||||||
|
sanei_genesys_write_pnm_file(path_.c_str(), buffer_.get_front_row_ptr(),
|
||||||
|
get_pixel_format_depth(format),
|
||||||
|
get_pixel_channels(format),
|
||||||
|
get_width(), buffer_.height());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImagePipelineNodeDebug::get_next_row_data(std::uint8_t* out_data)
|
||||||
|
{
|
||||||
|
buffer_.push_back();
|
||||||
|
source_.get_next_row_data(out_data);
|
||||||
|
std::memcpy(buffer_.get_back_row_ptr(), out_data, get_row_bytes());
|
||||||
|
}
|
||||||
|
|
||||||
std::size_t ImagePipelineStack::get_input_width() const
|
std::size_t ImagePipelineStack::get_input_width() const
|
||||||
{
|
{
|
||||||
ensure_node_exists();
|
ensure_node_exists();
|
||||||
|
@ -615,6 +646,16 @@ void ImagePipelineStack::ensure_node_exists() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImagePipelineStack::clear()
|
||||||
|
{
|
||||||
|
// we need to destroy the nodes back to front, so that the destructors still have valid
|
||||||
|
// references to sources
|
||||||
|
for (auto it = nodes_.rbegin(); it != nodes_.rend(); ++it) {
|
||||||
|
it->reset();
|
||||||
|
}
|
||||||
|
nodes_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::uint8_t> ImagePipelineStack::get_all_data()
|
std::vector<std::uint8_t> ImagePipelineStack::get_all_data()
|
||||||
{
|
{
|
||||||
auto row_bytes = get_output_row_bytes();
|
auto row_bytes = get_output_row_bytes();
|
||||||
|
|
|
@ -402,6 +402,24 @@ private:
|
||||||
std::vector<uint8_t> cached_line_;
|
std::vector<uint8_t> cached_line_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ImagePipelineNodeDebug : public ImagePipelineNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ImagePipelineNodeDebug(ImagePipelineNode& source, const std::string& path);
|
||||||
|
~ImagePipelineNodeDebug() override;
|
||||||
|
|
||||||
|
std::size_t get_width() const override { return source_.get_width(); }
|
||||||
|
std::size_t get_height() const override { return source_.get_height(); }
|
||||||
|
PixelFormat get_format() const override { return source_.get_format(); }
|
||||||
|
|
||||||
|
void get_next_row_data(std::uint8_t* out_data) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
ImagePipelineNode& source_;
|
||||||
|
std::string path_;
|
||||||
|
RowBuffer buffer_;
|
||||||
|
};
|
||||||
|
|
||||||
class ImagePipelineStack
|
class ImagePipelineStack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -417,10 +435,7 @@ public:
|
||||||
PixelFormat get_output_format() const;
|
PixelFormat get_output_format() const;
|
||||||
std::size_t get_output_row_bytes() const;
|
std::size_t get_output_row_bytes() const;
|
||||||
|
|
||||||
void clear()
|
void clear();
|
||||||
{
|
|
||||||
nodes_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Node, class... Args>
|
template<class Node, class... Args>
|
||||||
void push_first_node(Args&&... args)
|
void push_first_node(Args&&... args)
|
||||||
|
|
Ładowanie…
Reference in New Issue