CaptureMoment 0.1.0
Free and open-source non-destructive photo editor
Loading...
Searching...
No Matches
working_image_halide.cpp
Go to the documentation of this file.
1
9#include <spdlog/spdlog.h>
10
12
14{
15 if (data.empty()) {
16 spdlog::error("[WorkingImageHalide::initializeHalide]: Cannot initialize Halide buffer: data span is empty.");
17 return;
18 }
19
20 // Create Halide Buffer View (Zero-Copy)
21 // std::span::data() returns the underlying pointer safely.
22 // Transform from Chunky OIIO to Plannar Halide layout is handled by Halide::Buffer<float>::make_interleaved.
23 m_halide_buffer = Halide::Buffer<float>::make_interleaved(data.data(), width, height, channels);
24
25 if (!m_halide_buffer.defined()) {
26 spdlog::error("[WorkingImageHalide::initializeHalide]: Failed to define Halide::Buffer.");
27 } else {
28 spdlog::debug("[WorkingImageHalide::initializeHalide]: Halide buffer initialized ({}x{}, {} ch, zero-copy).",
29 width, height, channels);
30 }
31}
32
33std::pair<Common::ImageDim, Common::ImageDim> WorkingImageHalide::getSizeByHalide() const noexcept
34{
35 if (!m_halide_buffer.defined()) {
36 return {0, 0};
37 }
38 return {static_cast<Common::ImageDim>(m_halide_buffer.width()),
39 static_cast<Common::ImageDim>(m_halide_buffer.height())};
40}
41
43{
44 if (!m_halide_buffer.defined()) {
45 return 0;
46 }
47 return static_cast<Common::ImageChan>(m_halide_buffer.channels());
48}
49
51{
52 if (!m_halide_buffer.defined()) {
53 return 0;
54 }
55 return static_cast<Common::ImageSize>(m_halide_buffer.width()) * static_cast<Common::ImageSize>(m_halide_buffer.height());
56}
57
59{
60 if (!m_halide_buffer.defined()) {
61 return 0;
62 }
63 return static_cast<Common::ImageSize>(m_halide_buffer.size_in_bytes() / sizeof(float));
64}
65
67{
68 return m_halide_buffer.defined();
69}
70
71} // namespace CaptureMoment::Core::ImageProcessing
Common::ImageSize getDataSizeByHalide() const noexcept
Gets the total data element count from the Halide buffer.
void initializeHalide(std::span< float > data, Common::ImageDim width, Common::ImageDim height, Common::ImageChan channels)
Creates a Halide buffer view over existing pixel data.
Halide::Buffer< float > m_halide_buffer
Internal Halide buffer holding the image data. Managed directly by this object. Halide::Buffer handle...
Common::ImageChan getChannelsByHalide() const noexcept
Gets the number of color channels from the Halide buffer.
Common::ImageSize getPixelCountByHalide() const noexcept
Gets the total pixel count from the Halide buffer.
std::pair< Common::ImageDim, Common::ImageDim > getSizeByHalide() const noexcept
bool isHalideBufferValid() const noexcept
Checks if the Halide buffer is defined.
std::size_t ImageSize
Type for data size (element count).
Definition image_types.h:38
std::uint8_t ImageChan
Type for channel count.
Definition image_types.h:26
std::size_t ImageDim
Type for image dimensions (width, height).
Definition image_types.h:20
Base class for Halide-based working image implementations.
CaptureMoment — footer