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

◆ snapshot()

std::shared_ptr< DynamicVideoStream > MayaFlux::Kakshya::DynamicVideoStream::snapshot ( uint64_t  frames) const

Copy the most recent frames into a new linear stream, oldest first.

Frames that have already been overwritten come out black. The copy is independent of this stream.

Parameters
framesFrames to keep, capped at the ring capacity, or at the frames written for a linear stream.
Returns
New stream with the same size, format and rate, or null if empty.

Definition at line 157 of file DynamicVideoStream.cpp.

158{
159 const uint64_t available = is_ring_mode()
160 ? std::min<uint64_t>(m_write_head, m_ring_capacity)
161 : m_write_head;
162 const uint64_t count = std::min(frames, available);
163
164 if (count == 0) {
165 return nullptr;
166 }
167
168 auto copy = std::make_shared<DynamicVideoStream>(VideoStreamSpec {
169 .width = m_width,
170 .height = m_height,
171 .format = m_format,
172 .frame_rate = m_frame_rate });
173 copy->ensure_capacity(count);
174
175 const std::vector<uint8_t> blank(get_frame_byte_size(), 0);
176
177 for (uint64_t index = m_write_head - count; index < m_write_head; ++index) {
178 const auto pixels = get_frame_pixels(index);
179 copy->append_frame(pixels.empty() ? std::span<const uint8_t>(blank) : pixels);
180 }
181
182 return copy;
183}
const std::vector< float > * pixels
Definition Decoder.cpp:48
bool available
Definition VKDevice.cpp:41
uint32_t index
Definition VKDevice.cpp:122
size_t count
bool is_ring_mode() const
True if the container is operating in ring mode.
std::span< const uint8_t > get_frame_pixels(uint64_t frame_index) const
Get raw pixel data for a single frame as a byte span.
size_t get_frame_byte_size() const
Total byte size of one frame: width * height * bytes_per_pixel.
CopiedText copy(std::string_view text, const LayoutResult &layout, size_t a, size_t b)
Copy a byte range: the text it spans, and the quads that render it.

References available, count, MayaFlux::Kakshya::VideoStreamContainer::get_frame_byte_size(), MayaFlux::Kakshya::VideoStreamContainer::get_frame_pixels(), index, MayaFlux::Kakshya::VideoStreamContainer::is_ring_mode(), MayaFlux::Kakshya::VideoStreamContainer::m_format, MayaFlux::Kakshya::VideoStreamContainer::m_frame_rate, MayaFlux::Kakshya::VideoStreamContainer::m_height, MayaFlux::Kakshya::VideoStreamContainer::m_ring_capacity, MayaFlux::Kakshya::VideoStreamContainer::m_width, m_write_head, pixels, and MayaFlux::Kakshya::VideoStreamSpec::width.

+ Here is the call graph for this function: