12 const int32_t *durations,
13 size_t expanded_frames,
15 size_t output_elements,
16 size_t output_stride) {
17 if (!features || !durations || !output || !channels || !phoneme_count ||
18 !expanded_frames || input_stride < channels ||
20 if (phoneme_count - 1 > (SIZE_MAX - channels) / input_stride ||
21 channels - 1 > (SIZE_MAX - expanded_frames) / output_stride)
23 const size_t required_input = (phoneme_count - 1) * input_stride + channels;
24 const size_t required_output = (channels - 1) * output_stride + expanded_frames;
25 if (required_input > SIZE_MAX /
sizeof(
float) ||
27 if (input_elements < required_input || output_elements < required_output)
33 if ((
size_t)durations[
token] > expanded_frames - sum)
35 sum += (size_t)durations[
token];
41 const float *row = features +
token * input_stride;
42 for (int32_t repeat = 0; repeat < durations[
token]; ++repeat) {
43 for (
size_t channel = 0; channel < channels; ++channel)
44 output[channel * output_stride + frame] = row[channel];
int audio_duration_expand_token_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)