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

◆ process()

void FrameAccessProcessor::process ( const std::shared_ptr< SignalSourceContainer > &  container)
overridevirtual

Extract the current frame(s) into the container's processed_data.

Builds a Region spanning [m_current_frame .. m_current_frame + m_frames_per_batch) across the full spatial extent, delegates to get_region_data(), and copies the result into processed_data as a single interleaved DataVariant. Advances the frame cursor if auto-advance is enabled.

Parameters
containerThe SignalSourceContainer to process.

Implements MayaFlux::Kakshya::DataProcessor.

Definition at line 140 of file FrameAccessProcessor.cpp.

141{
142 if (!m_prepared) {
144 "FrameAccessProcessor not prepared for processing");
145 return;
146 }
147
148 auto source_container = m_source_container_weak.lock();
149 if (!source_container || source_container.get() != container.get()) {
151 "FrameAccessProcessor: source container mismatch or expired");
152 return;
153 }
154
155 m_is_processing = true;
156 m_last_process_time = std::chrono::steady_clock::now();
157
158 try {
159 uint64_t frames_to_extract = std::min(m_frames_per_batch,
161
162 if (frames_to_extract == 0 && m_looping_enabled && m_total_frames > 0) {
163 m_current_frame = 0;
164 if (!m_loop_region.start_coordinates.empty()) {
166 }
167 frames_to_extract = std::min(m_frames_per_batch, m_total_frames - m_current_frame);
168 }
169
170 if (frames_to_extract == 0) {
171 m_is_processing = false;
172 return;
173 }
174
175 auto video_container = std::dynamic_pointer_cast<VideoStreamContainer>(source_container);
176 if (!video_container) {
178 "FrameAccessProcessor: container is not a VideoStreamContainer");
179 m_is_processing = false;
180 return;
181 }
182
183 const uint64_t byte_count = frames_to_extract * m_frame_byte_size;
184
185 auto& processed_data_vector = container->get_processed_data();
186 processed_data_vector.resize(1);
187
188 auto* dest = std::get_if<std::vector<uint8_t>>(&processed_data_vector[0]);
189 if (!dest) {
190 processed_data_vector[0] = std::vector<uint8_t>();
191 dest = std::get_if<std::vector<uint8_t>>(&processed_data_vector[0]);
192 }
193 dest->resize(byte_count);
194
195 uint8_t* write_ptr = dest->data();
196 bool all_ok = true;
197
198 for (uint64_t i = 0; i < frames_to_extract; ++i) {
199 auto pixels = video_container->get_frame_pixels(m_current_frame + i);
200 if (pixels.empty()) {
201 std::memset(write_ptr, 0, m_frame_byte_size);
202 all_ok = false;
203 } else {
204 std::memcpy(write_ptr, pixels.data(), m_frame_byte_size);
205 }
206 write_ptr += m_frame_byte_size;
207 }
208
209 if (!all_ok) {
211 "FrameAccessProcessor: one or more frames unavailable at frame {}",
213 }
214
215 if (m_auto_advance) {
216 if (!all_ok) {
218 "FrameAccessProcessor: auto-advance enabled but frame data was incomplete. Waiting for next process call without advancing frame.");
219 }
220 if (m_frame_rate > 0.0) {
222 auto frames_to_advance = static_cast<uint64_t>(m_frame_accumulator);
223 if (frames_to_advance > 0) {
224 m_frame_accumulator -= static_cast<double>(frames_to_advance);
225 advance_frame(frames_to_advance);
226 }
227 } else {
228 advance_frame(frames_to_extract);
229 }
230 }
231
232 } catch (const std::exception& e) {
234 "FrameAccessProcessor::process failed: {}", e.what());
235 }
236
237 m_is_processing = false;
238}
#define MF_RT_ERROR(comp, ctx,...)
const std::vector< float > * pixels
Definition Decoder.cpp:65
std::chrono::steady_clock::time_point m_last_process_time
void advance_frame(uint64_t frames_to_advance)
Advance the frame cursor, respecting loop boundaries.
std::weak_ptr< SignalSourceContainer > m_source_container_weak
double m_frame_accumulator
Sub-frame accumulator for wall-clock-driven advancement.
double m_frame_rate
Cached video frame rate in frames per second.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::vector< uint64_t > start_coordinates
Starting frame index (inclusive)
Definition Region.hpp:75

References advance_frame(), MayaFlux::Journal::ContainerProcessing, MayaFlux::Journal::Kakshya, m_auto_advance, m_current_frame, m_frame_accumulator, m_frame_byte_size, m_frame_rate, m_frames_per_batch, m_global_fps, m_is_processing, m_last_process_time, m_loop_region, m_looping_enabled, m_prepared, m_source_container_weak, m_total_frames, MF_RT_ERROR, pixels, and MayaFlux::Kakshya::Region::start_coordinates.

+ Here is the call graph for this function: