MayaFlux 0.4.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 418 of file NDData.hpp.

423 {
424 std::vector<DataVariant> variants;
425
427 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
428 variants.emplace_back(std::vector<T>(total, default_value));
429 return variants;
430 }
431
432 switch (modality) {
434 variants.emplace_back(std::vector<T>(shape[0], default_value));
435 break;
436
438 uint64_t samples = shape[0];
439 uint64_t channels = shape[1];
440 variants.reserve(channels);
441 for (uint64_t ch = 0; ch < channels; ++ch) {
442 variants.emplace_back(std::vector<T>(samples, default_value));
443 }
444 break;
445 }
446
448 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
449 break;
450
452 uint64_t height = shape[0];
453 uint64_t width = shape[1];
454 uint64_t channels = shape[2];
455 uint64_t pixels = height * width;
456 variants.reserve(channels);
457 for (uint64_t ch = 0; ch < channels; ++ch) {
458 variants.emplace_back(std::vector<T>(pixels, default_value));
459 }
460 break;
461 }
462
464 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
465 break;
466
468 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
469 break;
470
472 uint64_t frames = shape[0];
473 uint64_t height = shape[1];
474 uint64_t width = shape[2];
475 uint64_t frame_size = height * width;
476 variants.reserve(frames);
477 for (uint64_t f = 0; f < frames; ++f) {
478 variants.emplace_back(std::vector<T>(frame_size, default_value));
479 }
480 break;
481 }
482
484 uint64_t frames = shape[0];
485 uint64_t height = shape[1];
486 uint64_t width = shape[2];
487 uint64_t channels = shape[3];
488 uint64_t frame_size = height * width;
489 variants.reserve(frames * channels);
490 for (uint64_t f = 0; f < frames; ++f) {
491 for (uint64_t ch = 0; ch < channels; ++ch) {
492 variants.emplace_back(std::vector<T>(frame_size, default_value));
493 }
494 }
495 break;
496 }
497
498 default:
499 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
500 variants.emplace_back(std::vector<T>(total, default_value));
501 break;
502 }
503
504 return variants;
505 }
uint32_t width
Definition Decoder.cpp:59
const std::vector< float > * pixels
Definition Decoder.cpp:58
@ 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)

References pixels, and width.