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

◆ setup_ring()

void MayaFlux::Kakshya::VideoStreamContainer::setup_ring ( uint64_t  total_frames,
uint32_t  ring_capacity,
uint32_t  width,
uint32_t  height,
uint32_t  channels,
double  frame_rate,
uint32_t  refill_threshold,
uint64_t  reader_id = 0 
)

Allocate m_data[0] as a ring of ring_capacity frames.

Switches the container from flat mode to ring mode. m_data[0] is resized to ring_capacity x frame_byte_size. m_num_frames is set to total_frames so processors see the full temporal extent. Pixel data is indexed by frame_index % ring_capacity.

Parameters
total_framesTotal frames in the source (file, stream, etc).
ring_capacityNumber of frame slots (must be power of 2).
widthFrame width in pixels.
heightFrame height in pixels.
channelsColour channels per pixel.
frame_rateFrame rate in fps.
refill_thresholdFrames of look-ahead below which refill callback fires.
reader_idThe current class ID registered at the stream/file-read source

Definition at line 79 of file VideoStreamContainer.cpp.

87{
88 std::unique_lock data_lock(m_data_mutex);
89
90 m_width = width;
91 m_height = height;
92 m_channels = channels;
93 m_frame_rate = frame_rate;
94 m_total_source_frames = total_frames;
95 m_ring_capacity = ring_capacity;
96 m_num_frames = total_frames;
97 m_cache_head.store(0, std::memory_order_relaxed);
98 m_refill_threshold = refill_threshold;
99 m_io_reader_id = reader_id;
100
102 .get_service<Registry::Service::IOService>();
103
104 const size_t frame_bytes = get_frame_byte_size();
105
106 m_data.resize(1);
107 auto& pixels = m_data[0].emplace<std::vector<uint8_t>>();
108 pixels.resize(frame_bytes * ring_capacity, 0);
109
110 m_slot_frame = std::vector<std::atomic<uint64_t>>(ring_capacity);
111 for (auto& sf : m_slot_frame)
112 sf.store(UINT64_MAX, std::memory_order_relaxed);
113
114 m_ready_queue.reset();
115
118}
uint32_t m_refill_threshold
Trigger refill when (m_cache_head - read_position) drops below this.
std::vector< std::atomic< uint64_t > > m_slot_frame
Memory::LockFreeQueue< uint64_t, READY_QUEUE_CAPACITY > m_ready_queue
std::atomic< uint64_t > m_cache_head
Highest frame index committed by the decode thread.
size_t get_frame_byte_size() const
Get the total byte size of one frame (width * height * channels).
void update_processing_state(ProcessingState new_state) override
Update the processing state of the container.
Registry::Service::IOService * m_io_service
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
@ IDLE
Container is inactive with no data or not ready for processing.

References get_frame_byte_size(), MayaFlux::Registry::BackendRegistry::get_service(), MayaFlux::Kakshya::IDLE, MayaFlux::Registry::BackendRegistry::instance(), m_cache_head, m_channels, m_data, m_data_mutex, m_frame_rate, m_height, m_io_reader_id, m_io_service, m_num_frames, m_ready_queue, m_refill_threshold, m_ring_capacity, m_slot_frame, m_total_source_frames, m_width, setup_dimensions(), and update_processing_state().

+ Here is the call graph for this function: