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

◆ get_frame()

std::span< const double > MayaFlux::Kakshya::WindowContainer::get_frame ( uint64_t  frame_index) const
overridevirtual

Get a single frame of data efficiently.

Parameters
frame_indexIndex of the frame (in the temporal dimension)
Returns
Span of data representing one complete frame

Implements MayaFlux::Kakshya::NDDataContainer.

Definition at line 563 of file WindowContainer.cpp.

564{
565 std::shared_lock lock(m_data_mutex);
566
567 const uint64_t h = m_structure.get_height();
568 if (frame_index >= h || m_processed_data.empty())
569 return {};
570
571 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_processed_data[0]);
572 if (!pixels || pixels->empty())
573 return {};
574
575 const uint64_t w = m_structure.get_width();
576 const uint64_t c = m_structure.get_channel_count();
577 const uint64_t row_elems = w * c;
578 const uint64_t offset = frame_index * row_elems;
579
580 if (offset + row_elems > pixels->size())
581 return {};
582
583 auto& cache = m_frame_cache;
584 cache.resize(row_elems);
585 for (uint64_t i = 0; i < row_elems; ++i)
586 cache[i] = static_cast<double>((*pixels)[offset + i]) / 255.0;
587
588 return { cache.data(), cache.size() };
589}
uint32_t h
Definition InkPress.cpp:25
const std::vector< float > * pixels
void lock() override
Acquire a lock for thread-safe access.
std::vector< DataVariant > m_processed_data
static uint64_t get_height(const std::vector< DataDimension > &dimensions)
Extract height from image/video dimensions.
static uint64_t get_channel_count(const std::vector< DataDimension > &dimensions)
Extract channel count from dimensions.
static uint64_t get_width(const std::vector< DataDimension > &dimensions)
Extract width from image/video dimensions.

References MayaFlux::Kakshya::ContainerDataStructure::get_channel_count(), MayaFlux::Kakshya::ContainerDataStructure::get_height(), MayaFlux::Kakshya::ContainerDataStructure::get_width(), h, lock(), m_data_mutex, m_frame_cache, m_processed_data, m_structure, and pixels.

+ Here is the call graph for this function: