Lines Matching refs:rate

2  *  Linear rate converter plugin
42 void (*func)(struct rate_linear *rate,
51 struct rate_linear *rate = obj;
55 return muldiv_near(frames, LINEAR_DIV, rate->pitch);
60 struct rate_linear *rate = obj;
64 return muldiv_near(frames, rate->pitch, LINEAR_DIV);
67 static void linear_expand(struct rate_linear *rate,
78 void *get = get16_labels[rate->get_idx];
79 void *put = put16_labels[rate->put_idx];
80 unsigned int get_threshold = rate->pitch;
87 for (channel = 0; channel < rate->channels; ++channel) {
102 new_sample = rate->old_sample[channel];
117 new_weight = (pos << (16 - rate->pitch_shift)) / (get_threshold >> rate->pitch_shift);
133 rate->old_sample[channel] = new_sample;
138 static void linear_expand_s16(struct rate_linear *rate,
147 unsigned int get_threshold = rate->pitch;
150 for (channel = 0; channel < rate->channels; ++channel) {
165 new_sample = rate->old_sample[channel];
174 new_weight = (pos << (16 - rate->pitch_shift)) / (get_threshold >> rate->pitch_shift);
185 rate->old_sample[channel] = new_sample;
189 static void linear_shrink(struct rate_linear *rate,
200 void *get = get16_labels[rate->get_idx];
201 void *put = put16_labels[rate->put_idx];
202 unsigned int get_increment = rate->pitch;
209 for (channel = 0; channel < rate->channels; ++channel) {
259 static void linear_shrink_s16(struct rate_linear *rate,
265 unsigned int get_increment = rate->pitch;
271 for (channel = 0; channel < rate->channels; ++channel) {
316 struct rate_linear *rate = obj;
317 rate->func(rate, dst_areas, dst_offset, dst_frames,
323 struct rate_linear *rate = obj;
325 free(rate->old_sample);
326 rate->old_sample = NULL;
331 struct rate_linear *rate = obj;
333 rate->get_idx = snd_pcm_linear_get_index(info->in.format, SND_PCM_FORMAT_S16);
334 rate->put_idx = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, info->out.format);
335 if (info->in.rate < info->out.rate) {
337 rate->func = linear_expand_s16;
339 rate->func = linear_expand;
343 rate->func = linear_shrink_s16;
345 rate->func = linear_shrink;
348 rate->pitch = (((uint64_t)info->out.rate * LINEAR_DIV) +
349 (info->in.rate / 2)) / info->in.rate;
350 rate->channels = info->channels;
352 free(rate->old_sample);
353 rate->old_sample = malloc(sizeof(*rate->old_sample) * rate->channels);
354 if (! rate->old_sample)
362 struct rate_linear *rate = obj;
365 rate->pitch = (((uint64_t)info->out.period_size * LINEAR_DIV) +
368 cframes = input_frames(rate, info->out.period_size);
372 rate->pitch++;
374 rate->pitch--;
375 cframes_new = input_frames(rate, info->out.period_size);
384 if (rate->pitch >= LINEAR_DIV) {
386 rate->pitch_shift = 0;
387 while ((rate->pitch >> rate->pitch_shift) >= (1 << 16))
388 rate->pitch_shift++;
395 struct rate_linear *rate = obj;
398 if (rate->old_sample)
399 memset(rate->old_sample, 0, sizeof(*rate->old_sample) * rate->channels);
407 static int get_supported_rates(ATTRIBUTE_UNUSED void *rate,
415 static void linear_dump(ATTRIBUTE_UNUSED void *rate, snd_output_t *out)
437 struct rate_linear *rate;
439 rate = calloc(1, sizeof(*rate));
440 if (! rate)
443 *objp = rate;