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

◆ validate()

uint64_t MayaFlux::Kakshya::DynamicSoundStream::validate ( std::vector< std::span< const double > > &  data,
uint64_t  start_frame = 0 
)
private

Definition at line 14 of file DynamicSoundStream.cpp.

15{
16 if (data.empty() || data[0].empty()) {
17 return 0;
18 }
19
20 uint64_t num_frames {};
22 num_frames = data[0].size() / get_num_channels();
23
24 } else {
25 if (data.size() < get_num_channels()) {
26 MF_ERROR(Journal::Component::Kakshya, Journal::Context::ContainerProcessing, "Insufficient channel data for planar organization: expected {}, got {}", get_num_channels(), data.size());
27
28 return 0;
29 }
30 num_frames = data[0].size();
31
32 if (!std::ranges::all_of(data | std::views::drop(1) | std::views::take(get_num_channels() - 1),
33 [num_frames](const auto& span) { return span.size() == num_frames; })) {
34 MF_ERROR(Journal::Component::Kakshya, Journal::Context::ContainerProcessing, "Mismatched frame counts across channels in planar organization. Expected {} frames, but found a channel with a different frame count.", num_frames);
35 return 0;
36 }
37 }
38
39 if (num_frames == 0) {
40 MF_WARN(Journal::Component::Kakshya, Journal::Context::ContainerProcessing, "Attempting to write with insufficient data for complete frame. Data frames: {}, Channels: {}. Returning without writing.", num_frames, get_num_channels());
41 return 0;
42 }
43
44 if (uint64_t required_end_frame = start_frame + num_frames; m_auto_resize) {
45 if (required_end_frame > get_num_frames()) {
46 expand_to(required_end_frame);
47 }
48 } else {
49 uint64_t available_frames = (start_frame < get_num_frames()) ? (get_num_frames() - start_frame) : 0;
50
51 if (available_frames == 0) {
52 return 0;
53 }
54
55 if (num_frames > available_frames) {
56 num_frames = available_frames;
57 }
58
59 if (required_end_frame > m_num_frames) {
60 m_num_frames = required_end_frame;
62 }
63 }
64 return num_frames;
65}
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
bool m_auto_resize
Enable automatic capacity expansion.
uint64_t get_num_frames() const override
Get the number of frames in the primary (temporal) dimension.
@ ContainerProcessing
Container operations (Kakshya - file/stream/region processing)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
@ INTERLEAVED
Single DataVariant with interleaved data (LRLRLR for stereo)

References MayaFlux::Journal::ContainerProcessing, expand_to(), MayaFlux::Kakshya::SoundStreamContainer::get_num_channels(), MayaFlux::Kakshya::SoundStreamContainer::get_num_frames(), MayaFlux::Kakshya::INTERLEAVED, MayaFlux::Journal::Kakshya, m_auto_resize, MayaFlux::Kakshya::SoundStreamContainer::m_num_frames, MayaFlux::Kakshya::SoundStreamContainer::m_structure, MF_ERROR, MF_WARN, MayaFlux::Kakshya::ContainerDataStructure::organization, and MayaFlux::Kakshya::SoundStreamContainer::setup_dimensions().

Referenced by write_frames().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: