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

◆ image_at() [2/2]

std::shared_ptr< Core::VKImage > MayaFlux::Kakshya::WindowContainer::image_at ( uint32_t  frame_index) const

Upload m_data[frame_index] to a new VKImage.

Parameters
frame_indexIndex into m_data in [0, frame_capacity).

Definition at line 252 of file WindowContainer.cpp.

253{
254 std::shared_lock lock(m_data_mutex);
255
256 if (frame_index >= m_data.size()) {
258 "WindowContainer::to_image({}) : out of range (capacity={})",
259 frame_index, m_frame_capacity);
260 return nullptr;
261 }
262
263 {
264 const uint64_t written = m_frames_written.load(std::memory_order_acquire);
265 const uint32_t head = m_write_head.load(std::memory_order_acquire);
266 const bool ring_full = written >= m_frame_capacity;
267 const bool slot_valid = ring_full || frame_index < head;
268 if (!slot_valid) {
270 "WindowContainer::image_at({}) : frame index is ahead of write head ({}), data may be stale or uninitialized",
271 frame_index, head);
272 return nullptr;
273 }
274 }
275
276 const auto* pixels = std::get_if<std::vector<uint8_t>>(&m_data[frame_index]);
277 if (!pixels || pixels->empty()) {
279 "WindowContainer::image_at({}) : slot is empty", frame_index);
280 return nullptr;
281 }
282
283 const auto img_fmt = surface_format_to_image_format(query_surface_format(m_window));
285 m_structure.get_width(), m_structure.get_height(), img_fmt, pixels->data());
286
287 if (!img) {
289 "WindowContainer::image_at({}) : TextureLoom::create_2d failed", frame_index);
290 }
291
292 return img;
293}
#define MF_RT_WARN(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
const std::vector< float > * pixels
Definition Decoder.cpp:58
std::shared_ptr< Core::Window > m_window
void lock() override
Acquire a lock for thread-safe access.
std::vector< DataVariant > m_data
std::atomic< uint64_t > m_frames_written
std::shared_ptr< Core::VKImage > create_2d(uint32_t width, uint32_t height, ImageFormat format=ImageFormat::RGBA8, const void *data=nullptr, uint32_t mip_levels=1)
Create a 2D texture.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
Core::GraphicsSurfaceInfo::SurfaceFormat query_surface_format(const std::shared_ptr< Core::Window > &window)
Query the actual vk::Format in use by the window's live swapchain, translated back to the MayaFlux su...
static uint64_t get_height(const std::vector< DataDimension > &dimensions)
Extract height from image/video dimensions.
static uint64_t get_width(const std::vector< DataDimension > &dimensions)
Extract width from image/video dimensions.

References MayaFlux::Journal::ContainerProcessing, MayaFlux::Portal::Graphics::TextureLoom::create_2d(), MayaFlux::Kakshya::ContainerDataStructure::get_height(), MayaFlux::Kakshya::ContainerDataStructure::get_width(), MayaFlux::Portal::Graphics::TextureLoom::instance(), MayaFlux::Journal::Kakshya, lock(), m_data, m_data_mutex, m_frame_capacity, m_frames_written, m_structure, m_window, m_write_head, MF_RT_ERROR, MF_RT_WARN, pixels, and MayaFlux::Kakshya::query_surface_format().

+ Here is the call graph for this function: