MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ snapshot_pixels()

std::optional< WindowContainer::PixelSnapshot > MayaFlux::Kakshya::WindowContainer::snapshot_pixels ( std::optional< uint32_t >  frame_index = std::nullopt) const
private

Definition at line 318 of file WindowContainer.cpp.

320{
321 auto snapshot = seqlock_read(m_data_lock, 8, [&]() -> PixelSnapshot {
322 const auto& data = frame_index ? m_data : m_processed_data;
323 const auto index = frame_index.value_or(0);
324
325 if (index >= data.size())
326 return {};
327
328 const auto* source = std::get_if<std::vector<uint8_t>>(&data[index]);
329
330 if (!source)
331 return {};
332
333 return {
334 .pixels = *source,
335 .dimensions = m_structure.dimensions,
336 .width = static_cast<uint32_t>(m_structure.get_width()),
337 .height = static_cast<uint32_t>(m_structure.get_height())
338 };
339 });
340
341 if (!snapshot || snapshot->pixels.empty()) {
343 "WindowContainer : no usable pixel data for '{}'",
344 m_window->get_create_info().title);
345 return std::nullopt;
346 }
347 return snapshot;
348}
#define MF_RT_WARN(comp, ctx,...)
uint32_t index
Definition VKDevice.cpp:122
uint32_t height
std::shared_ptr< Core::Window > m_window
std::vector< DataVariant > m_processed_data
std::vector< DataVariant > m_data
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
auto seqlock_read(const Seqlock &lock, uint32_t max_attempts, Fn &&fn) -> std::optional< std::invoke_result_t< Fn > >
Invoke a read functor under a Seqlock with a bounded retry count.
Definition SeqLock.hpp:237
Source source()
Begin a Source chain.
Definition Plot.hpp:127
static uint64_t get_height(const std::vector< DataDimension > &dimensions)
Extract height from image/video dimensions.
static uint64_t get_width(const std::vector< DataDimension > &dimensions)
Extract width from image/video dimensions.

References MayaFlux::Journal::ContainerProcessing, MayaFlux::Kakshya::ContainerDataStructure::dimensions, MayaFlux::Kakshya::ContainerDataStructure::get_height(), MayaFlux::Kakshya::ContainerDataStructure::get_width(), height, index, MayaFlux::Journal::Kakshya, m_data, m_data_lock, m_processed_data, m_structure, m_window, and MF_RT_WARN.

Referenced by image_at(), image_at(), region_to_image(), to_image(), and to_image().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: