mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-01 22:58:47 -04:00
user lrint() and friends in inner loops instead of normal C casts to speed up a few things
This commit is contained in:
parent
1bb5e58fb3
commit
33b186e74d
5 changed files with 13 additions and 13 deletions
|
|
@ -96,7 +96,7 @@ pa_volume_t pa_sw_volume_from_dB(double dB) {
|
|||
if (isinf(dB) < 0 || dB <= -USER_DECIBEL_RANGE)
|
||||
return PA_VOLUME_MUTED;
|
||||
|
||||
return (pa_volume_t) ((dB/USER_DECIBEL_RANGE+1)*PA_VOLUME_NORM);
|
||||
return (pa_volume_t) lrint((dB/USER_DECIBEL_RANGE+1)*PA_VOLUME_NORM);
|
||||
}
|
||||
|
||||
double pa_sw_volume_to_dB(pa_volume_t v) {
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ static void calc_linear_integer_volume(int32_t linear[], const pa_cvolume *volum
|
|||
pa_assert(volume);
|
||||
|
||||
for (channel = 0; channel < volume->channels; channel++)
|
||||
linear[channel] = (int32_t) (pa_sw_volume_to_linear(volume->values[channel]) * 0x10000);
|
||||
linear[channel] = lrint(pa_sw_volume_to_linear(volume->values[channel]) * 0x10000);
|
||||
}
|
||||
|
||||
static void calc_linear_float_volume(float linear[], const pa_cvolume *volume) {
|
||||
|
|
@ -132,7 +132,7 @@ static void calc_linear_integer_stream_volumes(pa_mix_info streams[], unsigned n
|
|||
|
||||
for (channel = 0; channel < spec->channels; channel++) {
|
||||
pa_mix_info *m = streams + k;
|
||||
m->linear[channel].i = (int32_t) (pa_sw_volume_to_linear(m->volume.values[channel]) * linear[channel] * 0x10000);
|
||||
m->linear[channel].i = lrint(pa_sw_volume_to_linear(m->volume.values[channel]) * linear[channel] * 0x10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {
|
|||
float v = *(a++);
|
||||
|
||||
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.f);
|
||||
s = (int16_t) (v * 0x7FFF);
|
||||
s = (int16_t) lrintf(v * 0x7FFF);
|
||||
*(b++) = INT16_TO(s);
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b) {
|
|||
float v = *(a++);
|
||||
|
||||
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
|
||||
s = (int32_t) ((double) v * (double) 0x7FFFFFFF);
|
||||
s = (int32_t) lrint((double) v * (double) 0x7FFFFFFF);
|
||||
*(b++) = INT32_TO(s);
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b) {
|
|||
float v = *(a++);
|
||||
v = PA_FLOAT32_SWAP(v);
|
||||
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
|
||||
s = (int16_t) (v * 0x7FFF);
|
||||
s = (int16_t) lrintf(v * 0x7FFF);
|
||||
*(b++) = INT16_TO(s);
|
||||
}
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ void pa_sconv_s32le_from_float32re(unsigned n, const float *a, int32_t *b) {
|
|||
float v = *(a++);
|
||||
v = PA_FLOAT32_SWAP(v);
|
||||
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
|
||||
s = (int32_t) ((double) v * 0x7FFFFFFF);
|
||||
s = (int32_t) lrint((double) v * 0x7FFFFFFF);
|
||||
*(b++) = INT32_TO(s);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ static void ulaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
|
|||
float v = *(a++);
|
||||
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
|
||||
v *= 0x1FFF;
|
||||
*(b++) = st_14linear2ulaw((int16_t) v);
|
||||
*(b++) = st_14linear2ulaw((int16_t) lrintf(v));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ static void alaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
|
|||
float v = *a;
|
||||
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
|
||||
v *= 0xFFF;
|
||||
*b = st_13linear2alaw((int16_t) v);
|
||||
*b = st_13linear2alaw((int16_t) lrintf(v));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
|
|||
/* The requested point is right of the point where we wanted
|
||||
* to be on track again, thus just linearly estimate */
|
||||
|
||||
t = (int64_t) s->py + (int64_t) (s->dp * (double) (x - s->px));
|
||||
t = (int64_t) s->py + (int64_t) llrint(s->dp * (double) (x - s->px));
|
||||
|
||||
if (t < 0)
|
||||
t = 0;
|
||||
|
|
@ -313,7 +313,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
|
|||
/* Move back from origin */
|
||||
ty += (double) s->ey;
|
||||
|
||||
*y = ty >= 0 ? (pa_usec_t) ty : 0;
|
||||
*y = ty >= 0 ? (pa_usec_t) lrint(ty) : 0;
|
||||
|
||||
/* Horner scheme */
|
||||
if (deriv)
|
||||
|
|
@ -360,7 +360,7 @@ void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y) {
|
|||
|
||||
/* And calculate when we want to be on track again */
|
||||
s->px = s->ex + s->adjust_time;
|
||||
s->py = s->ry + (pa_usec_t) (s->dp * (double) s->adjust_time);
|
||||
s->py = s->ry + (pa_usec_t) lrint(s->dp * (double) s->adjust_time);
|
||||
|
||||
s->abc_valid = FALSE;
|
||||
|
||||
|
|
@ -456,7 +456,7 @@ pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay)
|
|||
|
||||
/* pa_log_debug("translate(%llu) = %llu (%0.2f)", (unsigned long long) y_delay, (unsigned long long) ((double) y_delay / nde), nde); */
|
||||
|
||||
return (pa_usec_t) ((double) y_delay / nde);
|
||||
return (pa_usec_t) lrint((double) y_delay / nde);
|
||||
}
|
||||
|
||||
void pa_smoother_reset(pa_smoother *s) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue