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

◆ create_variants()

template<typename T >
static std::vector< DataVariant > MayaFlux::Kakshya::DataDimension::create_variants ( DataModality  modality,
const std::vector< uint64_t > &  shape,
default_value,
OrganizationStrategy  org = OrganizationStrategy::PLANAR 
)
inlinestaticprivate

Create data variants for a specific modality.

Template Parameters
TData type for storage
Parameters
modalityTarget data modality
shapeDimensional sizes
default_valueInitial value for elements
orgOrganization strategy
Returns
Vector of DataVariant objects

Definition at line 414 of file NDData.hpp.

419 {
420 std::vector<DataVariant> variants;
421
423 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
424 variants.emplace_back(std::vector<T>(total, default_value));
425 return variants;
426 }
427
428 switch (modality) {
430 variants.emplace_back(std::vector<T>(shape[0], default_value));
431 break;
432
434 uint64_t samples = shape[0];
435 uint64_t channels = shape[1];
436 variants.reserve(channels);
437 for (uint64_t ch = 0; ch < channels; ++ch) {
438 variants.emplace_back(std::vector<T>(samples, default_value));
439 }
440 break;
441 }
442
444 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
445 break;
446
448 uint64_t height = shape[0];
449 uint64_t width = shape[1];
450 uint64_t channels = shape[2];
451 uint64_t pixels = height * width;
452 variants.reserve(channels);
453 for (uint64_t ch = 0; ch < channels; ++ch) {
454 variants.emplace_back(std::vector<T>(pixels, default_value));
455 }
456 break;
457 }
458
460 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
461 break;
462
464 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
465 break;
466
468 uint64_t frames = shape[0];
469 uint64_t height = shape[1];
470 uint64_t width = shape[2];
471 uint64_t frame_size = height * width;
472 variants.reserve(frames);
473 for (uint64_t f = 0; f < frames; ++f) {
474 variants.emplace_back(std::vector<T>(frame_size, default_value));
475 }
476 break;
477 }
478
480 uint64_t frames = shape[0];
481 uint64_t height = shape[1];
482 uint64_t width = shape[2];
483 uint64_t channels = shape[3];
484 uint64_t frame_size = height * width;
485 variants.reserve(frames * channels);
486 for (uint64_t f = 0; f < frames; ++f) {
487 for (uint64_t ch = 0; ch < channels; ++ch) {
488 variants.emplace_back(std::vector<T>(frame_size, default_value));
489 }
490 }
491 break;
492 }
493
494 default:
495 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
496 variants.emplace_back(std::vector<T>(total, default_value));
497 break;
498 }
499
500 return variants;
501 }
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ VOLUMETRIC_3D
3D volumetric data
@ VIDEO_GRAYSCALE
3D video (time + 2D grayscale)
@ VIDEO_COLOR
4D video (time + 2D + color)
@ IMAGE_COLOR
2D RGB/RGBA image
@ IMAGE_2D
2D image (grayscale or single channel)
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)