Create data variants for a specific modality.
422 {
423 std::vector<DataVariant> variants;
424
426 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
427 variants.emplace_back(std::vector<T>(total, default_value));
428 return variants;
429 }
430
431 switch (modality) {
433 variants.emplace_back(std::vector<T>(shape[0], default_value));
434 break;
435
437 uint64_t samples = shape[0];
438 uint64_t channels = shape[1];
439 variants.reserve(channels);
440 for (uint64_t ch = 0; ch < channels; ++ch) {
441 variants.emplace_back(std::vector<T>(samples, default_value));
442 }
443 break;
444 }
445
447 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
448 break;
449
451 uint64_t height = shape[0];
452 uint64_t
width = shape[1];
453 uint64_t channels = shape[2];
455 variants.reserve(channels);
456 for (uint64_t ch = 0; ch < channels; ++ch) {
457 variants.emplace_back(std::vector<T>(
pixels, default_value));
458 }
459 break;
460 }
461
463 variants.emplace_back(std::vector<T>(shape[0] * shape[1], default_value));
464 break;
465
467 variants.emplace_back(std::vector<T>(shape[0] * shape[1] * shape[2], default_value));
468 break;
469
471 uint64_t frames = shape[0];
472 uint64_t height = shape[1];
473 uint64_t
width = shape[2];
474 uint64_t frame_size = height *
width;
475 variants.reserve(frames);
476 for (uint64_t f = 0; f < frames; ++f) {
477 variants.emplace_back(std::vector<T>(frame_size, default_value));
478 }
479 break;
480 }
481
483 uint64_t frames = shape[0];
484 uint64_t height = shape[1];
485 uint64_t
width = shape[2];
486 uint64_t channels = shape[3];
487 uint64_t frame_size = height *
width;
488 variants.reserve(frames * channels);
489 for (uint64_t f = 0; f < frames; ++f) {
490 for (uint64_t ch = 0; ch < channels; ++ch) {
491 variants.emplace_back(std::vector<T>(frame_size, default_value));
492 }
493 }
494 break;
495 }
496
497 default:
498 uint64_t total = std::accumulate(shape.begin(), shape.end(), uint64_t(1), std::multiplies<>());
499 variants.emplace_back(std::vector<T>(total, default_value));
500 break;
501 }
502
503 return variants;
504 }
const std::vector< float > * pixels
@ AUDIO_MULTICHANNEL
Multi-channel audio.
@ SPECTRAL_2D
2D spectral data (time + frequency)
@ AUDIO_1D
1D audio signal
@ 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)