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::SpectralTransformer< 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 std::vector<double>(std::span<double>)

In-place: results are written back into the channel spans of input before reconstruction, leaving no second allocation of channel data live at the same time. Out-of-place: results land in m_working_buffer; the original channel data in input is not touched.

Definition at line 198 of file SpectralTransformer.hpp.

199 {
200 auto [channels, structure_info] = OperationHelper::extract_structured_double(input);
201 m_working_buffer.resize(channels.size());
202 for (size_t i = 0; i < channels.size(); ++i)
203 m_working_buffer[i] = func(channels[i]);
204
205 if (this->is_in_place())
206 for (size_t i = 0; i < channels.size(); ++i)
207 std::ranges::copy(m_working_buffer[i], channels[i].begin());
208
209 return create_output(
210 OperationHelper::reconstruct_from_double<InputType>(m_working_buffer, structure_info));
211 }
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 spectral operations.
virtual bool is_in_place() const
Indicates whether the transformation modifies the input data directly.