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

◆ build_chunks()

void MayaFlux::Kinesis::CurveEvaluator::build_chunks ( Eigen::Index  num_samples,
Eigen::Index  num_segments,
Eigen::Index  active_count 
)
private

Definition at line 567 of file MotionCurves.cpp.

571{
572 const auto segments = static_cast<size_t>(num_segments);
573
574 m_seg_first.assign(segments, -1);
575 m_seg_total.assign(segments, 0);
576
577 for (Eigen::Index i = 0; i < num_samples; ++i) {
578 const double t_global = static_cast<double>(i) / static_cast<double>(num_samples - 1);
579 const double segment_float = t_global * static_cast<double>(num_segments);
580 auto seg_idx = static_cast<Eigen::Index>(std::floor(segment_float));
581
582 if (i == num_samples - 1 || seg_idx >= num_segments) {
583 seg_idx = num_segments - 1;
584 }
585
586 const auto s = static_cast<size_t>(seg_idx);
587 if (m_seg_first[s] < 0) {
588 m_seg_first[s] = i;
589 }
590 ++m_seg_total[s];
591 }
592
593 m_chunks.clear();
594
595 for (Eigen::Index seg_idx = 0; seg_idx < num_segments; ++seg_idx) {
596 const auto s = static_cast<size_t>(seg_idx);
597 if (m_seg_total[s] == 0) {
598 continue;
599 }
600
601 Eigen::Index start_col = seg_idx * (m_points_per_segment - m_overlap);
602 const bool clamp = (start_col + m_points_per_segment > active_count);
603 if (clamp) {
604 start_col = active_count - m_points_per_segment;
605 }
606
607 for (Eigen::Index off = 0; off < m_seg_total[s]; off += k_chunk_samples) {
608 m_chunks.push_back({ .segment = seg_idx,
609 .start_col = start_col,
610 .sample_begin = m_seg_first[s] + off,
611 .sample_count = std::min(k_chunk_samples, m_seg_total[s] - off),
612 .clamp_t_high = clamp });
613 }
614 }
615}
std::vector< Eigen::Index > m_seg_total
std::vector< CurveChunk > m_chunks
std::vector< Eigen::Index > m_seg_first
void clamp(std::span< double > data, double lo, double hi) noexcept
Clamp values to [lo, hi] in-place.
Definition Transform.cpp:44

References m_chunks, m_overlap, m_points_per_segment, m_seg_first, and m_seg_total.

Referenced by evaluate_planar().

+ Here is the caller graph for this function: