Lines Matching refs:lr
34 struct linear_resampler *lr; in linear_resampler_create() local
36 lr = (struct linear_resampler *)calloc(1, sizeof(*lr)); in linear_resampler_create()
37 if (!lr) in linear_resampler_create()
39 lr->num_channels = num_channels; in linear_resampler_create()
40 lr->format_bytes = format_bytes; in linear_resampler_create()
42 linear_resampler_set_rates(lr, src_rate, dst_rate); in linear_resampler_create()
44 return lr; in linear_resampler_create()
47 void linear_resampler_destroy(struct linear_resampler *lr) in linear_resampler_destroy() argument
49 if (lr) in linear_resampler_destroy()
50 free(lr); in linear_resampler_destroy()
53 void linear_resampler_set_rates(struct linear_resampler *lr, float from, in linear_resampler_set_rates() argument
56 lr->f = (float)to / from; in linear_resampler_set_rates()
57 lr->to_times_100 = to * 100; in linear_resampler_set_rates()
58 lr->from_times_100 = from * 100; in linear_resampler_set_rates()
59 lr->src_offset = 0; in linear_resampler_set_rates()
60 lr->dst_offset = 0; in linear_resampler_set_rates()
76 unsigned int linear_resampler_out_frames_to_in(struct linear_resampler *lr, in linear_resampler_out_frames_to_in() argument
83 in_frames = (float)(lr->dst_offset + frames) / lr->f; in linear_resampler_out_frames_to_in()
84 if ((in_frames > lr->src_offset)) in linear_resampler_out_frames_to_in()
85 return 1 + (unsigned int)(in_frames - lr->src_offset); in linear_resampler_out_frames_to_in()
90 unsigned int linear_resampler_in_frames_to_out(struct linear_resampler *lr, in linear_resampler_in_frames_to_out() argument
97 out_frames = lr->f * (lr->src_offset + frames - 1); in linear_resampler_in_frames_to_out()
98 if (out_frames > lr->dst_offset) in linear_resampler_in_frames_to_out()
99 return 1 + (unsigned int)(out_frames - lr->dst_offset); in linear_resampler_in_frames_to_out()
104 int linear_resampler_needed(struct linear_resampler *lr) in linear_resampler_needed() argument
106 return lr->from_times_100 != lr->to_times_100; in linear_resampler_needed()
109 unsigned int linear_resampler_resample(struct linear_resampler *lr, in linear_resampler_resample() argument
127 src_pos = (float)(lr->dst_offset + dst_idx) / lr->f; in linear_resampler_resample()
128 if (src_pos > lr->src_offset) in linear_resampler_resample()
129 src_pos -= lr->src_offset; in linear_resampler_resample()
142 in = (int16_t *)(src + src_idx * lr->format_bytes); in linear_resampler_resample()
143 out = (int16_t *)(dst + dst_idx * lr->format_bytes); in linear_resampler_resample()
148 for (ch = 0; ch < lr->num_channels; ch++) in linear_resampler_resample()
151 for (ch = 0; ch < lr->num_channels; ch++) { in linear_resampler_resample()
154 (in[lr->num_channels + ch] - in linear_resampler_resample()
162 lr->src_offset += *src_frames; in linear_resampler_resample()
163 lr->dst_offset += dst_idx; in linear_resampler_resample()
164 while ((lr->src_offset > lr->from_times_100) && in linear_resampler_resample()
165 (lr->dst_offset > lr->to_times_100)) { in linear_resampler_resample()
166 lr->src_offset -= lr->from_times_100; in linear_resampler_resample()
167 lr->dst_offset -= lr->to_times_100; in linear_resampler_resample()