Get raw pixel data for a single frame as uint8_t span.
174{
177 return {};
178
181
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
std::shared_mutex m_data_mutex
std::vector< DataVariant > m_data
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.