MayaFlux 0.5.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 82 of file VideoStreamContainer.cpp.

90{
91 {
92 Memory::SeqlockWriteGuard g(m_data_lock);
93
94 m_width = width;
96 m_channels = channels;
97 m_frame_rate = frame_rate;
98 m_total_source_frames = total_frames;
99 m_ring_capacity = ring_capacity;
100 m_num_frames = total_frames;
101 m_cache_head.store(0, std::memory_order_relaxed);
102 m_refill_threshold = refill_threshold;
103 m_io_reader_id = reader_id;
104
106 .get_service<Registry::Service::IOService>();
107
108 const size_t frame_bytes = get_frame_byte_size();
109
110 m_data.resize(1);
111 auto& pixels = m_data[0].emplace<std::vector<uint8_t>>();
112 pixels.resize(frame_bytes * ring_capacity, 0);
113
114 m_slot_frame = std::vector<std::atomic<uint64_t>>(ring_capacity);
115 for (auto& sf : m_slot_frame)
116 sf.store(UINT64_MAX, std::memory_order_relaxed);
117
118 m_ready_queue.reset();
120 }
121
122 if (m_float_frame_cache.size() != ring_capacity) {
123 m_float_frame_cache.resize(ring_capacity);
124 m_float_frame_dirty = std::vector<std::atomic<bool>>(ring_capacity);
125
126 for (auto& flag : m_float_frame_dirty)
127 flag.store(true, std::memory_order_relaxed);
128 }
129
131}
uint32_t width
Definition Decoder.cpp:66
const std::vector< float > * pixels
Definition Decoder.cpp:65
uint32_t height
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::vector< std::atomic< bool > > m_float_frame_dirty
std::vector< std::vector< float > > m_float_frame_cache
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.
std::shared_ptr< T > store(std::shared_ptr< T > obj)
Transfer ownership of an existing object to the persistent store for process lifetime.
Definition Persist.hpp:28

References get_frame_byte_size(), MayaFlux::Registry::BackendRegistry::get_service(), height, MayaFlux::Kakshya::IDLE, MayaFlux::Registry::BackendRegistry::instance(), m_cache_head, m_channels, m_data, m_data_lock, m_float_frame_cache, m_float_frame_dirty, 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, pixels, setup_dimensions(), update_processing_state(), and width.

+ Here is the call graph for this function: