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

◆ advance_position() [1/2]

std::vector< uint64_t > MayaFlux::Kakshya::advance_position ( const std::vector< uint64_t > &  current_positions,
const std::vector< uint64_t > &  frames_per_channel,
const ContainerDataStructure structure,
bool  looping_enabled,
const Region loop_region 
)

Advance current positions by specified frames per channel, with optional looping.

Parameters
current_positionsCurrent positions per channel.
frames_per_channelFrames to advance per channel.
structureContainer data structure (for total frames).
looping_enabledWhether looping is enabled.
loop_regionLoop region for wrapping.
Returns
New advanced positions per channel.

Definition at line 206 of file CoordUtils.cpp.

212{
213 uint64_t num_channels = structure.get_channel_count();
214 uint64_t total_frames = structure.get_samples_count_per_channel();
215
216 if (current_positions.size() != num_channels || frames_per_channel.size() != num_channels) {
217 error<std::invalid_argument>(Journal::Component::Kakshya, Journal::Context::Runtime, std::source_location::current(),
218 "Position and frames vectors must match channel count {}. Got positions size {}, frames size {}",
219 num_channels, current_positions.size(), frames_per_channel.size());
220 }
221
222 std::vector<uint64_t> new_positions;
223 new_positions.reserve(num_channels);
224
225 for (size_t ch = 0; ch < num_channels; ++ch) {
226 uint64_t current_frame = current_positions[ch];
227 uint64_t frames_to_advance = frames_per_channel[ch];
228 uint64_t new_frame = current_frame + frames_to_advance;
229
230 if (new_frame >= total_frames) {
231 if (looping_enabled && !loop_region.start_coordinates.empty()) {
232 uint64_t loop_start = (ch < loop_region.start_coordinates.size())
233 ? loop_region.start_coordinates[ch]
234 : loop_region.start_coordinates[0];
235 uint64_t loop_end = (ch < loop_region.end_coordinates.size())
236 ? loop_region.end_coordinates[ch]
237 : loop_region.end_coordinates[0];
238
239 if (loop_end > loop_start) {
240 uint64_t loop_length = loop_end - loop_start + 1;
241 uint64_t overflow = new_frame - total_frames;
242 new_frame = loop_start + (overflow % loop_length);
243 } else {
244 new_frame = loop_start;
245 }
246 } else {
247 new_frame = total_frames - 1;
248 }
249 }
250
251 new_positions.push_back(new_frame);
252 }
253
254 return new_positions;
255}
static uint64_t get_channel_count(const std::vector< DataDimension > &dimensions)
Extract channel count from dimensions.
static uint64_t get_samples_count_per_channel(const std::vector< DataDimension > &dimensions)
Get samples per channel (time dimension only).
std::vector< uint64_t > end_coordinates
Ending frame index (inclusive)
Definition Region.hpp:78
std::vector< uint64_t > start_coordinates
Starting frame index (inclusive)
Definition Region.hpp:75

References MayaFlux::Kakshya::Region::end_coordinates, MayaFlux::Kakshya::ContainerDataStructure::get_channel_count(), MayaFlux::Kakshya::ContainerDataStructure::get_samples_count_per_channel(), MayaFlux::Journal::Kakshya, MayaFlux::Journal::Runtime, and MayaFlux::Kakshya::Region::start_coordinates.

+ Here is the call graph for this function: