static uint32_t resampler_process(resampler_t *state, uint32_t frames, float *out_data) { uint32_t frames_used = 0; uint64_t pos_out; double pos_in = 0.0; for (uint64_t x = state->sum_output_frames; x < state->sum_output_frames + frames; x++) { pos_out = x - state->sum_output_frames; pos_in = ((double)x / state->ratio) - (double)state->sum_input_frames; float poly[3]; float data[3]; float x_val; if ((int)pos_in == 0) { data[0] = state->data[0]; data[1] = state->data[AUDIO_CHANNELS]; data[2] = state->data[2 + AUDIO_CHANNELS]; x_val = pos_in; } else { data[0] = state->data[((int)pos_in - 1) * AUDIO_CHANNELS]; data[1] = state->data[((int)pos_in + 0) * AUDIO_CHANNELS]; data[2] = state->data[((int)pos_in + 1) * AUDIO_CHANNELS]; x_val = pos_in - (int)pos_in + 1.0; } poly_create_3(poly, data); out_data[pos_out * AUDIO_CHANNELS] = poly[2] * x_val * x_val + poly[1] * x_val + poly[0]; float poly1[3]; float data1[3]; float x_val1; if ((int)pos_in == 0) { data1[0] = state->data[1]; data1[1] = state->data[AUDIO_CHANNELS + 1]; data1[2] = state->data[5]; x_val1 = pos_in; } else { data1[0] = state->data[((int)pos_in - 1) * AUDIO_CHANNELS + 1]; data1[1] = state->data[((int)pos_in + 0) * AUDIO_CHANNELS + 1]; data1[2] = state->data[((int)pos_in + 1) * AUDIO_CHANNELS + 1]; x_val1 = pos_in - (int)pos_in + 1.0; } poly_create_3(poly1, data); out_data[pos_out * AUDIO_CHANNELS + 1] = poly1[2] * x_val1 * x_val1 + poly1[1] * x_val1 + poly1[0]; } frames_used = (int)pos_in; return frames_used; }
static uint32_t resampler_process(resampler_t *state, uint32_t frames, float *out_data) { uint32_t frames_used = 0; uint64_t pos_out; double pos_in = 0.0; for (uint64_t x = state->sum_output_frames; x < state->sum_output_frames + frames; x++) { pos_out = x - state->sum_output_frames; pos_in = ((double)x / state->ratio) - (double)state->sum_input_frames; for (int c = 0; c < state->channels; c++) { float poly[3]; float data[3]; float x_val; if ((int)pos_in == 0) { data[0] = state->data[0 * state->channels + c]; data[1] = state->data[1 * state->channels + c]; data[2] = state->data[2 * state->channels + c]; x_val = pos_in; } else { data[0] = state->data[((int)pos_in - 1) * state->channels + c]; data[1] = state->data[((int)pos_in + 0) * state->channels + c]; data[2] = state->data[((int)pos_in + 1) * state->channels + c]; x_val = pos_in - (int)pos_in + 1.0; } poly_create_3(poly, data); out_data[pos_out * state->channels + c] = poly[2] * x_val * x_val + poly[1] * x_val + poly[0]; } } frames_used = (int)pos_in; return frames_used; }