MayaFlux 0.1.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 202 of file CoordUtils.cpp.

208{
209 uint64_t num_channels = structure.get_channel_count();
210 uint64_t total_frames = structure.get_samples_count_per_channel();
211
212 if (current_positions.size() != num_channels || frames_per_channel.size() != num_channels) {
213 throw std::invalid_argument("All vectors must match channel count");
214 }
215
216 std::vector<uint64_t> new_positions;
217 new_positions.reserve(num_channels);
218
219 for (size_t ch = 0; ch < num_channels; ++ch) {
220 uint64_t current_frame = current_positions[ch];
221 uint64_t frames_to_advance = frames_per_channel[ch];
222 uint64_t new_frame = current_frame + frames_to_advance;
223
224 if (new_frame >= total_frames) {
225 if (looping_enabled && !loop_region.start_coordinates.empty()) {
226 uint64_t loop_start = (ch < loop_region.start_coordinates.size())
227 ? loop_region.start_coordinates[ch]
228 : loop_region.start_coordinates[0];
229 uint64_t loop_end = (ch < loop_region.end_coordinates.size())
230 ? loop_region.end_coordinates[ch]
231 : loop_region.end_coordinates[0];
232
233 if (loop_end > loop_start) {
234 uint64_t loop_length = loop_end - loop_start + 1;
235 uint64_t overflow = new_frame - total_frames;
236 new_frame = loop_start + (overflow % loop_length);
237 } else {
238 new_frame = loop_start;
239 }
240 } else {
241 new_frame = total_frames - 1;
242 }
243 }
244
245 new_positions.push_back(new_frame);
246 }
247
248 return new_positions;
249}
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:72
std::vector< uint64_t > start_coordinates
Starting frame index (inclusive)
Definition Region.hpp:69

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

+ Here is the call graph for this function: