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

◆ transform_slice() [2/2]

template<OperationReadyData DataType>
DataType MayaFlux::Yantra::transform_slice ( DataType &  input,
double  start_ratio,
double  end_ratio,
std::vector< std::vector< double > > &  working_buffer 
)

Slice transformation to extract a portion of the data based on ratios (OUT-OF-PLACE)

Template Parameters
DataTypeOperationReadyData type
Parameters
inputInput data - will NOT be modified
start_ratioStart ratio (0.0 to 1.0)
end_ratioEnd ratio (0.0 to 1.0)
working_bufferBuffer for operations (will be resized if needed)
Returns
Sliced data

Definition at line 311 of file TemporalHelper.hpp.

312{
313 auto [target_data, structure_info] = OperationHelper::setup_operation_buffer(input, working_buffer);
314
315 for (size_t i = 0; i < target_data.size(); ++i) {
316 size_t start_idx = static_cast<size_t>(target_data[i].size() * std::clamp(start_ratio, 0.0, 1.0));
317 size_t end_idx = static_cast<size_t>(target_data[i].size() * std::clamp(end_ratio, 0.0, 1.0));
318
319 if (start_idx >= end_idx || end_idx > target_data[i].size()) {
320 working_buffer[i] = { 0.0 };
321 } else {
322 working_buffer[i].assign(target_data[i].begin() + start_idx, target_data[i].begin() + end_idx);
323 }
324 }
325
326 return OperationHelper::reconstruct_from_double<DataType>(working_buffer, structure_info);
327}

References MayaFlux::Yantra::OperationHelper::setup_operation_buffer().

+ Here is the call graph for this function: