-
Notifications
You must be signed in to change notification settings - Fork 194
Open
Description
The current implementation of src_short_to_float looks like this:
libsamplerate/src/samplerate.c
Lines 427 to 435 in 2ccde95
| void | |
| src_short_to_float_array (const short *in, float *out, int len) | |
| { | |
| for (int i = 0 ; i < len ; i++) | |
| { out [i] = (float) (in [i] / (1.0 * 0x8000)) ; | |
| } ; | |
| return ; | |
| } /* src_short_to_float_array */ |
(1.0 * 0x8000) yields a double and so the division is done in doubles, requiring a few extra casts. This can be avoided by doing it in floats like this:
void
src_short_to_float_array (const short *in, float *out, int len)
{
for (int i = 0 ; i < len ; i++)
{ out [i] = (float) (in [i] / (1.0f * 0x8000)) ;
} ;
return ;
} /* src_short_to_float_array */This should yield identical results because 1/32768 is an exact power of 2.
Metadata
Metadata
Assignees
Labels
No labels