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::MathematicalTransformer< InputType, OutputType >::apply_per_channel ( input_type input,
Func &&  func 
)
inlineprivate

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

Template Parameters
FuncCallable matching void(std::span<double>)

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

Definition at line 209 of file MathematicalTransformer.hpp.

210 {
211 auto [channels, structure_info] = OperationHelper::extract_structured_double(input);
212 m_working_buffer.resize(channels.size());
213 for (size_t i = 0; i < channels.size(); ++i) {
214 m_working_buffer[i].assign(channels[i].begin(), channels[i].end());
215 func(std::span<double> { m_working_buffer[i] });
216 }
217 if (this->is_in_place())
218 for (size_t i = 0; i < channels.size(); ++i)
219 std::ranges::copy(m_working_buffer[i], channels[i].begin());
220 return create_output(
221 OperationHelper::reconstruct_from_double<InputType>(m_working_buffer, structure_info));
222 }
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 operations.
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...
virtual bool is_in_place() const
Indicates whether the transformation modifies the input data directly.