Get raw pixel data for a single frame as a byte span.
- Parameters
-
| frame_index | Zero-based frame index. |
- Returns
- Span of pixel bytes for the frame, empty if out of range.
Definition at line 238 of file VideoStreamContainer.cpp.
239{
242 return {};
243
245 std::span<const uint8_t> result;
248 return;
249
252 return;
253
254 const size_t offset = frame_index * frame_bytes;
255 if (
offset + frame_bytes > bytes)
256 return;
257
259 });
260 return result;
261 }
262
263 const uint32_t slot =
slot_for(frame_index);
264 if (
m_slot_frame[slot].load(std::memory_order_acquire) == frame_index) {
266 return {};
267
270 return {};
271
272 const size_t offset =
static_cast<size_t>(slot) * frame_bytes;
273 if (
offset + frame_bytes > bytes)
274 return {};
275
277 }
278
279 return {};
280}
std::vector< std::atomic< uint64_t > > m_slot_frame
Memory::Seqlock m_data_lock
std::vector< DataVariant > m_data
uint32_t slot_for(uint64_t frame_index) const
size_t get_frame_byte_size() const
Total byte size of one frame: width * height * bytes_per_pixel.
std::pair< const uint8_t *, size_t > variant_bytes(const DataVariant &v)
Get a pointer to the raw bytes of a DataVariant and its size.
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.
References get_frame_byte_size(), m_data, m_data_lock, m_num_frames, m_ring_capacity, m_slot_frame, offset, ptr, slot_for(), and MayaFlux::Kakshya::variant_bytes().
Referenced by get_frame_typed(), and get_frames_typed_as().