11 const int32_t *durations,
12 size_t expanded_frames,
14 size_t output_elements,
15 size_t output_stride) {
16 if (!features || !durations || !output || !channels || !phoneme_count ||
17 !expanded_frames || input_stride < phoneme_count ||
19 if (channels - 1 > (SIZE_MAX - phoneme_count) / input_stride ||
20 channels - 1 > (SIZE_MAX - expanded_frames) / output_stride)
22 const size_t required_input = (channels - 1) * input_stride + phoneme_count;
23 const size_t required_output = (channels - 1) * output_stride + expanded_frames;
24 if (required_input > SIZE_MAX /
sizeof(
float) ||
26 if (input_elements < required_input || output_elements < required_output)
32 if ((
size_t)durations[
token] > expanded_frames - sum)
34 sum += (size_t)durations[
token];
38 for (
size_t channel = 0; channel < channels; ++channel) {
41 const float value = features[channel * input_stride +
token];
42 for (int32_t j = 0; j < durations[
token]; ++j) {
43 output[channel * output_stride + frame++] = value;
int audio_duration_expand_channel_major_f32(const float *features, size_t input_elements, size_t channels, size_t phoneme_count, size_t input_stride, const int32_t *durations, size_t expanded_frames, float *output, size_t output_elements, size_t output_stride)