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

◆ apply_per_channel()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
template<typename Func >
output_type MayaFlux::Yantra::TemporalTransformer< InputType, OutputType >::apply_per_channel ( input_type input,
Func &&  func 
)
inlineprivate

Extracts per-channel spans, applies func to each, and reconstructs.

Template Parameters
FuncCallable matching either void(std::span<double>) for same-size operations or std::vector<double>(std::span<const double>) for operations that may resize the channel.

In-place: results are copied back into the original channel spans of input. Out-of-place: input is not mutated.

Definition at line 187 of file TemporalTransformer.hpp.

188 {
189 auto [channels, structure_info] = OperationHelper::extract_structured_double(input);
190 m_working_buffer.resize(channels.size());
191 for (size_t i = 0; i < channels.size(); ++i) {
192 if constexpr (std::is_void_v<std::invoke_result_t<Func, std::span<double>>>) {
193 m_working_buffer[i].assign(channels[i].begin(), channels[i].end());
194 func(std::span<double> { m_working_buffer[i] });
195 } else {
196 m_working_buffer[i] = func(std::span<const double> { channels[i] });
197 }
198 }
199
200 if (this->is_in_place())
201 for (size_t i = 0; i < channels.size(); ++i)
202 std::ranges::copy(m_working_buffer[i], channels[i].begin());
203 return create_output(
204 OperationHelper::reconstruct_from_double<InputType>(m_working_buffer, structure_info));
205 }
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...
output_type create_output(const input_type &input)
Creates output with proper type conversion.
std::vector< std::vector< double > > m_working_buffer
Buffer for out-of-place temporal operations.
virtual bool is_in_place() const
Indicates whether the transformation modifies the input data directly.