mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-31 08:33:40 +00:00
Use NEON conditionally for sample conversions.
This commit is contained in:
parent
77207332f1
commit
7ab8eaec02
@ -17,6 +17,7 @@
|
||||
#include "utils.h"
|
||||
|
||||
#include "../general.h"
|
||||
#include "../performance.h"
|
||||
|
||||
#if defined(__SSE2__)
|
||||
#include <emmintrin.h>
|
||||
@ -138,7 +139,7 @@ void audio_convert_float_to_s16_altivec(int16_t *out,
|
||||
}
|
||||
#elif defined(HAVE_NEON)
|
||||
void audio_convert_s16_float_asm(float *out, const int16_t *in, size_t samples);
|
||||
void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t samples,
|
||||
static void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t samples,
|
||||
float gain)
|
||||
{
|
||||
(void)gain; // gain is ignored for now.
|
||||
@ -153,7 +154,7 @@ void audio_convert_s16_to_float_neon(float *out, const int16_t *in, size_t sampl
|
||||
}
|
||||
|
||||
void audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples);
|
||||
void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t samples)
|
||||
static void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t samples)
|
||||
{
|
||||
size_t aligned_samples = samples & ~7;
|
||||
if (aligned_samples)
|
||||
@ -164,6 +165,18 @@ void audio_convert_float_to_s16_neon(int16_t *out, const float *in, size_t sampl
|
||||
}
|
||||
#endif
|
||||
|
||||
void audio_convert_init_simd(void)
|
||||
{
|
||||
#ifdef HAVE_NEON
|
||||
struct rarch_cpu_features cpu;
|
||||
rarch_get_cpu_features(&cpu);
|
||||
audio_convert_s16_to_float_arm = cpu.simd & RARCH_SIMD_NEON ?
|
||||
audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C;
|
||||
audio_convert_float_to_s16_arm = cpu.simd & RARCH_SIMD_NEON ?
|
||||
audio_convert_float_to_s16_neon : audio_convert_float_to_s16_C;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_RSOUND
|
||||
|
||||
bool rarch_rsound_start(const char *ip)
|
||||
|
@ -44,13 +44,12 @@ void audio_convert_float_to_s16_altivec(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#elif defined(HAVE_NEON)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_neon
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_neon
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_arm
|
||||
#define audio_convert_float_to_s16 audio_convert_float_to_s16_arm
|
||||
|
||||
void audio_convert_s16_to_float_neon(float *out,
|
||||
void (*audio_convert_s16_to_float_arm)(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
void audio_convert_float_to_s16_neon(int16_t *out,
|
||||
void (*audio_convert_float_to_s16_arm)(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
#else
|
||||
@ -63,6 +62,8 @@ void audio_convert_s16_to_float_C(float *out,
|
||||
void audio_convert_float_to_s16_C(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
|
||||
void audio_convert_init_simd(void);
|
||||
|
||||
#ifdef HAVE_RSOUND
|
||||
bool rarch_rsound_start(const char *ip);
|
||||
void rarch_rsound_stop(void);
|
||||
|
3
driver.c
3
driver.c
@ -21,6 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "compat/posix_string.h"
|
||||
#include "audio/utils.h"
|
||||
|
||||
#ifdef HAVE_X11
|
||||
#include "gfx/context/x11_common.h"
|
||||
@ -359,6 +360,8 @@ static void deinit_dsp_plugin(void)
|
||||
|
||||
void init_audio(void)
|
||||
{
|
||||
audio_convert_init_simd();
|
||||
|
||||
// Resource leaks will follow if audio is initialized twice.
|
||||
if (driver.audio_data)
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user