History

[x86/x86_64] Speed up linear interpolation resampler

Olav Sørensen committed 5 years ago

Commit a2ad39d1 parent 7fe7a351 file · +8 −2Browse files

Unified · Split

src/mixer/ft2_mix_macros.h+8−2
@@ -131,13 +131,19 @@ · 130 unmodified lines
131131
132132 #define LINEAR_INTERPOLATION8(s, f) \
133133 { \
134− const double dFrac = (const double)((uint32_t)f * (1.0 / (UINT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \
134+ /* uint32_t -> int32_t so that we can use SIMD for fast int->double conversion */ \
135+ const int32_t frac = (uint32_t)(f) >> 1; /* (2^32)-1 -> (2^31)-1 */ \
136+ \
137+ const double dFrac = (double)(frac * (1.0 / (INT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \
135138 dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 128.0); \
136139 } \
137140
138141 #define LINEAR_INTERPOLATION16(s, f) \
139142 { \
140− const double dFrac = (const double)((uint32_t)f * (1.0 / (UINT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \
143+ /* uint32_t -> int32_t so that we can use SIMD for fast int->double conversion */ \
144+ const int32_t frac = (uint32_t)(f) >> 1; /* (2^32)-1 -> (2^31)-1 */ \
145+ \
146+ const double dFrac = (double)(frac * (1.0 / (INT32_MAX+1.0))); /* 0.0 .. 0.999999999 */ \
141147 dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 32768.0); \
142148 } \
143149

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t