user lrint() and friends in inner loops instead of normal C casts to speed up a few things

This commit is contained in:
Lennart Poettering 2008-10-03 02:34:59 +02:00
parent 1bb5e58fb3
commit 33b186e74d
5 changed files with 13 additions and 13 deletions

View file

@ -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);
}
}