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