MayaFlux 0.2.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 173 of file VideoStreamContainer.cpp.

174{
175 const size_t frame_bytes = get_frame_byte_size();
176 if (frame_bytes == 0 || frame_index >= m_num_frames)
177 return {};
178
179 if (m_ring_capacity == 0) {
180 std::shared_lock lock(m_data_mutex);
181
182 if (m_data.empty())
183 return {};
184
185 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[0]);
186 if (!pixels)
187 return {};
188
189 const size_t offset = frame_index * frame_bytes;
190 if (offset + frame_bytes > pixels->size())
191 return {};
192
193 return { pixels->data() + offset, frame_bytes };
194 }
195
196 uint32_t slot = slot_for(frame_index);
197
198 if (m_slot_frame[slot].load(std::memory_order_acquire) == frame_index) {
199 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[0]);
200 if (!pixels)
201 return {};
202 return { pixels->data() + slot * frame_bytes, frame_bytes };
203 }
204
205 return {};
206}
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).
void lock() override
Acquire a lock for thread-safe access.

References get_frame_byte_size(), lock(), m_data, m_data_mutex, m_num_frames, m_ring_capacity, m_slot_frame, and slot_for().

+ Here is the call graph for this function: