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 678 of file WindowContainer.cpp.

679{
680 std::shared_lock lock(m_data_mutex);
681
682 const uint64_t h = m_structure.get_height();
683 if (frame_index >= h || m_processed_data.empty())
684 return {};
685
686 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_processed_data[0]);
687 if (!pixels || pixels->empty())
688 return {};
689
690 const uint64_t w = m_structure.get_width();
691 const uint64_t c = m_structure.get_channel_count();
692 const uint64_t row_elems = w * c;
693 const uint64_t offset = frame_index * row_elems;
694
695 if (offset + row_elems > pixels->size())
696 return {};
697
698 auto& cache = m_frame_cache;
699 cache.resize(row_elems);
700 for (uint64_t i = 0; i < row_elems; ++i)
701 cache[i] = static_cast<double>((*pixels)[offset + i]) / 255.0;
702
703 return { cache.data(), cache.size() };
704}
const std::vector< float > * pixels
Definition Decoder.cpp:58
uint32_t h
Definition InkPress.cpp:28
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: