use PA_FLOAT32_SWAP where useful

This commit is contained in:
Lennart Poettering 2008-10-03 02:33:44 +02:00
parent 7d442e3276
commit 1bb5e58fb3

View file

@ -153,8 +153,7 @@ void pa_sconv_s16le_to_float32re(unsigned n, const int16_t *a, float *b) {
for (; n > 0; n--) { for (; n > 0; n--) {
int16_t s = *(a++); int16_t s = *(a++);
float k = ((float) INT16_FROM(s))/0x7FFF; float k = ((float) INT16_FROM(s))/0x7FFF;
uint32_t *j = (uint32_t*) &k; k = PA_FLOAT32_SWAP(k);
*j = PA_UINT32_SWAP(*j);
*(b++) = k; *(b++) = k;
} }
} }
@ -166,8 +165,7 @@ void pa_sconv_s32le_to_float32re(unsigned n, const int32_t *a, float *b) {
for (; n > 0; n--) { for (; n > 0; n--) {
int32_t s = *(a++); int32_t s = *(a++);
float k = (float) (((double) INT32_FROM(s))/0x7FFFFFFF); float k = (float) (((double) INT32_FROM(s))/0x7FFFFFFF);
uint32_t *j = (uint32_t*) &k; k = PA_FLOAT32_SWAP(k);
*j = PA_UINT32_SWAP(*j);
*(b++) = k; *(b++) = k;
} }
} }
@ -179,8 +177,7 @@ void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b) {
for (; n > 0; n--) { for (; n > 0; n--) {
int16_t s; int16_t s;
float v = *(a++); float v = *(a++);
uint32_t *j = (uint32_t*) &v; v = PA_FLOAT32_SWAP(v);
*j = PA_UINT32_SWAP(*j);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f); v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int16_t) (v * 0x7FFF); s = (int16_t) (v * 0x7FFF);
*(b++) = INT16_TO(s); *(b++) = INT16_TO(s);
@ -194,8 +191,7 @@ void pa_sconv_s32le_from_float32re(unsigned n, const float *a, int32_t *b) {
for (; n > 0; n--) { for (; n > 0; n--) {
int32_t s; int32_t s;
float v = *(a++); float v = *(a++);
uint32_t *j = (uint32_t*) &v; v = PA_FLOAT32_SWAP(v);
*j = PA_UINT32_SWAP(*j);
v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f); v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f);
s = (int32_t) ((double) v * 0x7FFFFFFF); s = (int32_t) ((double) v * 0x7FFFFFFF);
*(b++) = INT32_TO(s); *(b++) = INT32_TO(s);