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 844 of file VideoStreamContainer.cpp.

845{
846 if (frame_index >= m_processed_data.size())
847 return {};
848
849 if (frame_index >= m_float_frame_dirty.size()) {
850 const size_t old_size = m_float_frame_dirty.size();
851 const size_t new_size = frame_index + 1;
852 auto new_dirty = std::vector<std::atomic<bool>>(new_size);
853
854 for (size_t i = 0; i < old_size; ++i) {
855 new_dirty[i].store(m_float_frame_dirty[i].load(std::memory_order_relaxed),
856 std::memory_order_relaxed);
857 }
858
859 for (size_t i = old_size; i < new_size; ++i)
860 new_dirty[i].store(true, std::memory_order_relaxed);
861 m_float_frame_dirty = std::move(new_dirty);
862 m_float_frame_cache.resize(new_size);
863 }
864
865 if (!m_float_frame_dirty[frame_index].load(std::memory_order_acquire))
866 return { m_float_frame_cache[frame_index] };
867
868 auto result = as_normalised_float(m_processed_data[frame_index], m_float_frame_cache[frame_index]);
869 if (!result.empty())
870 m_float_frame_dirty[frame_index].store(false, std::memory_order_release);
871
872 return result;
873}
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: