7 const float *input,
size_t input_elements,
float *output,
8 size_t output_elements,
size_t frames,
size_t channels,
size_t factor)
11 if (!factor || factor > 65536 || frames > 16777216 ||
13 ni > SIZE_MAX / factor || input_elements < ni)
16 if (output_elements < no)
return -2;
19 for (
size_t i = 0; i < ni; ++i)
20 if (!isfinite(input[i]))
return -3;
22 for (
int pass = 0; pass < 2; ++pass) {
23 for (
size_t row = 0; row < frames * factor; ++row) {
26 double position = ((double)row + 0.5) / (
double)factor - 0.5;
27 if (position < 0) position = 0;
28 size_t left = (size_t)position;
30 float weight = (float)(position - (
double)
left);
31 for (
size_t c = 0; c < channels; ++c) {
32 float value = (1.0f - weight) * input[
left * channels + c]
33 + weight * input[
right * channels + c];
34 if (!isfinite(value))
return -3;
35 if (pass) output[row * channels + c] = value;
int audio_upsample_linear_frames_f32_checked(const float *input, size_t input_elements, float *output, size_t output_elements, size_t frames, size_t channels, size_t factor)