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
131 131
132#define LINEAR_INTERPOLATION8(s, f) \132#define LINEAR_INTERPOLATION8(s, f) \
133{ \133{ \
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 */ \
135 dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 128.0); \138 dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 128.0); \
136} \139} \
137 140
138#define LINEAR_INTERPOLATION16(s, f) \141#define LINEAR_INTERPOLATION16(s, f) \
139{ \142{ \
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 */ \
141 dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 32768.0); \147 dSample = ((s[0] + (s[1]-s[0]) * dFrac)) * (1.0 / 32768.0); \
142} \148} \
143 149

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