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

◆ transform_quantize() [2/2]

template<OperationReadyData DataType>
DataType MayaFlux::Yantra::transform_quantize ( DataType &  input,
uint8_t  bits,
std::vector< std::vector< double > > &  working_buffer 
)

Quantization transformation (bit reduction) using C++20 features (OUT-OF-PLACE)

Template Parameters
DataTypeOperationReadyData type
Parameters
inputInput data - will NOT be modified
bitsNumber of bits for quantization
working_bufferBuffer for operations (will be resized if needed)
Returns
Quantized data

Definition at line 411 of file MathematicalHelper.hpp.

412{
413 auto [target_data, structure_info] = OperationHelper::setup_operation_buffer(input, working_buffer);
414
415 const double levels = std::pow(2.0, bits) - 1.0;
416
417 for (auto& span : target_data) {
418 std::ranges::transform(span, span.begin(),
419 [levels](double x) {
420 double clamped = std::clamp(x, -1.0, 1.0);
421 return std::round(clamped * levels) / levels;
422 });
423 }
424
425 return OperationHelper::reconstruct_from_double<DataType>(working_buffer, structure_info);
426}

References transform_quantize().

+ Here is the call graph for this function: