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

◆ processed_frame_as_float()

std::span< const float > MayaFlux::Kakshya::VideoStreamContainer::processed_frame_as_float ( uint64_t  frame_index = 0) const

Processed frame at frame_index as a normalised float span.

Valid after FrameAccessProcessor has written processed_data. uint8_t source values are divided by 255.0f. float source is zero-copy. Returns empty span if frame_index is out of range or the variant holds a non-pixel type.

The cache covers the last requested frame_index only. A call with a different index invalidates and recomputes.

Parameters
frame_indexZero-based index into processed_data. Defaults to 0.
Returns
Normalised float span, w * h * channels elements.

Definition at line 692 of file VideoStreamContainer.cpp.

693{
694 if (frame_index >= m_processed_data.size())
695 return {};
696
697 if (frame_index >= m_float_frame_dirty.size()) {
698 const size_t old_size = m_float_frame_dirty.size();
699 const size_t new_size = frame_index + 1;
700 auto new_dirty = std::vector<std::atomic<bool>>(new_size);
701
702 for (size_t i = 0; i < old_size; ++i) {
703 new_dirty[i].store(m_float_frame_dirty[i].load(std::memory_order_relaxed),
704 std::memory_order_relaxed);
705 }
706
707 for (size_t i = old_size; i < new_size; ++i)
708 new_dirty[i].store(true, std::memory_order_relaxed);
709 m_float_frame_dirty = std::move(new_dirty);
710 m_float_frame_cache.resize(new_size);
711 }
712
713 if (!m_float_frame_dirty[frame_index].load(std::memory_order_acquire))
714 return { m_float_frame_cache[frame_index] };
715
716 auto result = as_normalised_float(m_processed_data[frame_index], m_float_frame_cache[frame_index]);
717 if (!result.empty())
718 m_float_frame_dirty[frame_index].store(false, std::memory_order_release);
719
720 return result;
721}
std::vector< std::atomic< bool > > m_float_frame_dirty
std::vector< std::vector< float > > m_float_frame_cache
std::span< const float > as_normalised_float(const DataVariant &variant, std::vector< float > &storage)
Extract a DataVariant holding pixel data as a normalised float span.
Definition DataUtils.cpp:61
std::shared_ptr< T > store(std::shared_ptr< T > obj)
Transfer ownership of an existing object to the persistent store for process lifetime.
Definition Persist.hpp:28

References MayaFlux::Kakshya::as_normalised_float(), m_float_frame_cache, m_float_frame_dirty, m_processed_data, and MayaFlux::store().

+ Here is the call graph for this function: