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

◆ process()

void MayaFlux::Kakshya::FrameSeekProcessor::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.

Reimplemented from MayaFlux::Kakshya::FrameAccessProcessor.

Definition at line 79 of file FrameSeekProcessor.cpp.

80{
81 auto source = m_source_container_weak.lock();
82 auto video = std::dynamic_pointer_cast<VideoStreamContainer>(source);
83
84 if (video) {
85 m_total_frames = video->get_num_frames();
86 }
87
88 if (!m_time_map || !m_time_map->fn) {
90 return;
91 }
92
93 if (!m_prepared) {
95 "FrameSeekProcessor not prepared for processing");
96 return;
97 }
98
99 if (!video || source.get() != container.get()) {
101 "FrameSeekProcessor: source container mismatch, expired or not a VideoStreamContainer");
102 return;
103 }
104
105 if (m_total_frames == 0 || m_frame_byte_size == 0) {
106 return;
107 }
108
109 m_is_processing = true;
110
111 auto lo = 0.0;
112 auto hi = static_cast<double>(m_total_frames);
113
114 if (m_looping_enabled) {
115 if (!m_loop_region.start_coordinates.empty()) {
116 lo = static_cast<double>(m_loop_region.start_coordinates[0]);
117 }
118 if (!m_loop_region.end_coordinates.empty()) {
119 hi = std::min(hi, static_cast<double>(m_loop_region.end_coordinates[0] + 1));
120 }
121 if (hi <= lo) {
122 lo = 0.0;
123 hi = static_cast<double>(m_total_frames);
124 }
125 }
126
127 auto& processed = container->get_processed_data();
128 processed.resize(1);
129
130 auto* dest = std::get_if<std::vector<uint8_t>>(&processed[0]);
131 if (!dest) {
132 processed[0] = std::vector<uint8_t>();
133 dest = std::get_if<std::vector<uint8_t>>(&processed[0]);
134 }
136
137 uint8_t* out = dest->data();
138 uint64_t last_frame = 0;
139 bool all_ok = true;
140
141 for (uint64_t k = 0; k < m_frames_per_batch; ++k, out += m_frame_byte_size) {
142 const double position = position_at(m_ticks + k);
143 const double s = m_looping_enabled
144 ? Kinesis::wrap<double>(position, lo, hi)
145 : std::clamp(position, lo, hi - 1.0);
146 const double whole = std::floor(s);
147 const double weight = s - whole;
148 const auto first = static_cast<uint64_t>(whole);
149 last_frame = first;
150
151 const auto a = video->get_frame_pixels(first);
152 if (a.empty()) {
153 std::memset(out, 0, m_frame_byte_size);
154 all_ok = false;
155 continue;
156 }
157
158 if (m_blend && weight > 0.0) {
159 auto next = first + 1;
160 if (static_cast<double>(next) >= hi) {
161 next = m_looping_enabled ? static_cast<uint64_t>(lo) : first;
162 }
163
164 const auto b = video->get_frame_pixels(next);
165 if (!b.empty() && blend_frames(video->get_format(), a, b, out, weight)) {
166 continue;
167 }
168 }
169
170 std::memcpy(out, a.data(), m_frame_byte_size);
171 }
172
173 if (!all_ok) {
175 "FrameSeekProcessor: one or more frames unavailable near frame {}", last_frame);
176 }
177
179 m_current_frame = last_frame;
180 video->update_read_position_for_channel(0, last_frame);
181
182 m_is_processing = false;
183}
#define MF_RT_ERROR(comp, ctx,...)
std::optional< glm::vec3 > position
Definition Decoder.cpp:93
size_t a
double weight
size_t b
std::vector< float > * out
void process(const std::shared_ptr< SignalSourceContainer > &container) override
Extract the current frame(s) into the container's processed_data.
std::weak_ptr< SignalSourceContainer > m_source_container_weak
std::shared_ptr< const Kinesis::TimeMap > m_time_map
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
bool blend_frames(ImageFormat format, std::span< const uint8_t > a, std::span< const uint8_t > b, uint8_t *out, double weight)
Linearly blend two frames of the same size and format.
void clamp(std::span< double > data, double lo, double hi) noexcept
Clamp values to [lo, hi] in-place.
Definition Transform.cpp:44
Source source()
Begin a Source chain.
Definition Plot.hpp:127
std::vector< uint64_t > end_coordinates
Ending frame index (inclusive)
Definition Region.hpp:78
std::vector< uint64_t > start_coordinates
Starting frame index (inclusive)
Definition Region.hpp:75

References a, b, MayaFlux::Kakshya::blend_frames(), MayaFlux::Journal::ContainerProcessing, MayaFlux::Kakshya::Region::end_coordinates, MayaFlux::Journal::Kakshya, m_blend, MayaFlux::Kakshya::FrameAccessProcessor::m_current_frame, MayaFlux::Kakshya::FrameAccessProcessor::m_frame_byte_size, MayaFlux::Kakshya::FrameAccessProcessor::m_frames_per_batch, MayaFlux::Kakshya::FrameAccessProcessor::m_is_processing, MayaFlux::Kakshya::FrameAccessProcessor::m_loop_region, MayaFlux::Kakshya::FrameAccessProcessor::m_looping_enabled, MayaFlux::Kakshya::FrameAccessProcessor::m_prepared, MayaFlux::Kakshya::FrameAccessProcessor::m_source_container_weak, m_ticks, m_time_map, MayaFlux::Kakshya::FrameAccessProcessor::m_total_frames, MF_RT_ERROR, out, position, position_at(), MayaFlux::Kakshya::FrameAccessProcessor::process(), MayaFlux::Kakshya::Region::start_coordinates, and weight.

+ Here is the call graph for this function: