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

◆ get_frame_pixels()

std::span< const uint8_t > MayaFlux::Kakshya::VideoStreamContainer::get_frame_pixels ( uint64_t  frame_index) const

Get raw pixel data for a single frame as uint8_t span.

Parameters
frame_indexZero-based frame index.
Returns
Span of pixel bytes for the frame, empty if out of range.

Definition at line 186 of file VideoStreamContainer.cpp.

187{
188 const size_t frame_bytes = get_frame_byte_size();
189 if (frame_bytes == 0 || frame_index >= m_num_frames)
190 return {};
191
192 if (m_ring_capacity == 0) {
193 std::span<const uint8_t> result;
195 if (m_data.empty())
196 return;
197 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[0]);
198 if (!pixels)
199 return;
200 const size_t offset = frame_index * frame_bytes;
201 if (offset + frame_bytes > pixels->size())
202 return;
203 result = { pixels->data() + offset, frame_bytes };
204 });
205 return result;
206 }
207
208 const uint32_t slot = slot_for(frame_index);
209 if (m_slot_frame[slot].load(std::memory_order_acquire) == frame_index) {
210 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[0]);
211 if (!pixels)
212 return {};
213 return { pixels->data() + slot * frame_bytes, frame_bytes };
214 }
215
216 return {};
217}
const std::vector< float > * pixels
Definition Decoder.cpp:65
float offset
std::vector< std::atomic< uint64_t > > m_slot_frame
uint32_t slot_for(uint64_t frame_index) const
size_t get_frame_byte_size() const
Get the total byte size of one frame (width * height * channels).
bool seqlock_read_void(const Seqlock &lock, uint32_t max_attempts, Fn &&fn)
Invoke a void read functor under a Seqlock with a bounded retry count.
Definition SeqLock.hpp:222

References get_frame_byte_size(), m_data, m_data_lock, m_num_frames, m_ring_capacity, m_slot_frame, offset, pixels, and slot_for().

Referenced by get_value_impl().

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