(resamplers) Turn some 1-line inline functions into macros

This commit is contained in:
twinaphex 2015-07-10 19:46:52 +02:00
parent 7bcd4dd04d
commit 33feed8aa7
2 changed files with 48 additions and 60 deletions

View File

@ -419,10 +419,7 @@ static INLINE float cc_int(float x, float b)
return (val > M_PI) ? M_PI : (val < -M_PI) ? -M_PI : val;
}
static INLINE float cc_kernel(float x, float b)
{
return (cc_int(x + 0.5, b) - cc_int(x - 0.5, b)) / (2.0 * M_PI);
}
#define cc_kernel(x, b) ((cc_int((x) + 0.5, (b)) - cc_int((x) - 0.5, (b))) / (2.0 * M_PI))
#else
static INLINE float cc_int(float x, float b)
{
@ -433,10 +430,7 @@ static INLINE float cc_int(float x, float b)
return (val > 0.5) ? 0.5 : (val < -0.5) ? -0.5 : val;
}
static INLINE float cc_kernel(float x, float b)
{
return (cc_int(x + 0.5, b) - cc_int(x - 0.5, b));
}
#define cc_kernel(x, b) ((cc_int((x) + 0.5, (b)) - cc_int((x) - 0.5, (b))))
#endif
static INLINE void add_to(const audio_frame_float_t *source,
@ -503,13 +497,13 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data)
while (re->distance < 1.0)
{
int i;
float temp;
outp->l = 0.0;
outp->r = 0.0;
for (i = 0; i < 4; i++)
{
temp = cc_kernel(re->distance + 1.0 - i, b);
float temp = cc_kernel(re->distance + 1.0 - i, b);
outp->l += re->buffer[i].l * temp;
outp->r += re->buffer[i].r * temp;
}

View File

@ -121,10 +121,7 @@ static INLINE double sinc(double val)
}
#if defined(SINC_WINDOW_LANCZOS)
static INLINE double window_function(double idx)
{
return sinc(M_PI * idx);
}
#define window_function(idx) (sinc(M_PI * (idx)))
#elif defined(SINC_WINDOW_KAISER)
/* Modified Bessel function of first order.
* Check Wiki for mathematical definition ... */
@ -153,10 +150,7 @@ static INLINE double besseli0(double x)
return sum;
}
static INLINE double window_function(double idx)
{
return besseli0(SINC_WINDOW_KAISER_BETA * sqrt(1 - idx * idx));
}
#define window_function(idx) (besseli0(SINC_WINDOW_KAISER_BETA * sqrt(1 - (idx) * (idx))))
#else
#error "No SINC window function defined."
#endif
@ -251,13 +245,13 @@ static INLINE void process_sinc_C(rarch_sinc_resampler_t *resamp,
float sum_r = 0.0f;
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
float delta = (float)(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD;
float delta = (float)
(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD;
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
@ -335,6 +329,7 @@ static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
{
unsigned i;
__m128 sum;
__m128 sum_l = _mm_setzero_ps();
__m128 sum_r = _mm_setzero_ps();
@ -351,7 +346,6 @@ static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
__m128 sum;
for (i = 0; i < taps; i += 4)
{