mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-02 23:14:34 +00:00
(audio conversion) Optimize array accesses
This commit is contained in:
parent
b4d2f2a7ed
commit
8613ece7f5
@ -50,7 +50,9 @@ void convert_float_s16_asm(int16_t *out, const float *in, size_t samples);
|
||||
void convert_float_to_s16(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
{
|
||||
size_t i = 0;
|
||||
int16_t *out_ptr = NULL;
|
||||
const float *in_ptr = NULL;
|
||||
size_t i = 0;
|
||||
#if defined(__SSE2__)
|
||||
__m128 factor = _mm_set1_ps((float)0x8000);
|
||||
|
||||
@ -135,10 +137,13 @@ void convert_float_to_s16(int16_t *out,
|
||||
|
||||
#endif
|
||||
|
||||
for (; i < samples; i++)
|
||||
for (
|
||||
out_ptr = &out[i], in_ptr = &in[i]
|
||||
; i < samples
|
||||
; out_ptr++, in_ptr++, i++)
|
||||
{
|
||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||
out[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||
int32_t val = (int32_t)(*in_ptr * 0x8000);
|
||||
*out_ptr = (val > 0x7FFF) ? 0x7FFF :
|
||||
(val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,9 @@ void convert_s16_float_asm(float *out, const int16_t *in,
|
||||
void convert_s16_to_float(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
unsigned i = 0;
|
||||
float *out_ptr = NULL;
|
||||
const int16_t *in_ptr = NULL;
|
||||
unsigned i = 0;
|
||||
|
||||
#if defined(__SSE2__)
|
||||
float fgain = gain / UINT32_C(0x80000000);
|
||||
@ -169,8 +171,11 @@ void convert_s16_to_float(float *out,
|
||||
|
||||
#endif
|
||||
|
||||
for (; i < samples; i++)
|
||||
out[i] = (float)in[i] * gain;
|
||||
for (
|
||||
out_ptr = &out[i], in_ptr = &in[i]
|
||||
; i < samples
|
||||
; out_ptr++, in_ptr++, i++)
|
||||
*out_ptr = (float)*in_ptr * gain;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user