mirror of
https://github.com/libretro/RetroArch
synced 2025-02-27 09:41:14 +00:00
Rename audio_convert_s16_to_float
This commit is contained in:
parent
c21f84fd9b
commit
3725644ce6
@ -310,7 +310,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
audio_convert_init_simd();
|
||||
convert_init_simd();
|
||||
|
||||
/* Accomodate rewind since at some point we might have two full buffers. */
|
||||
outsamples_max = max_bufsamples * AUDIO_MAX_RATIO *
|
||||
@ -539,7 +539,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
||||
|
||||
performance_counter_init(&audio_convert_s16, "audio_convert_s16");
|
||||
performance_counter_start(&audio_convert_s16);
|
||||
audio_convert_s16_to_float(audio_driver_data.data, data, samples,
|
||||
convert_s16_to_float(audio_driver_data.data, data, samples,
|
||||
audio_driver_data.volume_gain);
|
||||
performance_counter_stop(&audio_convert_s16);
|
||||
|
||||
|
@ -23,25 +23,19 @@
|
||||
#include <features/features_cpu.h>
|
||||
#include <conversion/float_to_s16.h>
|
||||
|
||||
#include "audio_utils.h"
|
||||
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "../performance_counters.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_C:
|
||||
* convert_s16_to_float_C:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* C implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_C(float *out,
|
||||
void convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t i;
|
||||
@ -52,18 +46,18 @@ void audio_convert_s16_to_float_C(float *out,
|
||||
|
||||
#if defined(__SSE2__)
|
||||
/**
|
||||
* audio_convert_s16_to_float_SSE2:
|
||||
* convert_s16_to_float_SSE2:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* SSE2 implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_SSE2(float *out,
|
||||
void convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t i;
|
||||
@ -82,23 +76,23 @@ void audio_convert_s16_to_float_SSE2(float *out,
|
||||
_mm_storeu_ps(out + 4, output_r);
|
||||
}
|
||||
|
||||
audio_convert_s16_to_float_C(out, in, samples - i, gain);
|
||||
convert_s16_to_float_C(out, in, samples - i, gain);
|
||||
}
|
||||
|
||||
#elif defined(__ALTIVEC__)
|
||||
/**
|
||||
* audio_convert_s16_to_float_altivec:
|
||||
* convert_s16_to_float_altivec:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* AltiVec implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_altivec(float *out,
|
||||
void convert_s16_to_float_altivec(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t samples_in = samples;
|
||||
@ -125,52 +119,52 @@ void audio_convert_s16_to_float_altivec(float *out,
|
||||
|
||||
samples_in -= i;
|
||||
}
|
||||
audio_convert_s16_to_float_C(out, in, samples_in, gain);
|
||||
convert_s16_to_float_C(out, in, samples_in, gain);
|
||||
}
|
||||
|
||||
#elif defined(__ARM_NEON__) && !defined(VITA)
|
||||
/* Avoid potential hard-float/soft-float ABI issues. */
|
||||
void audio_convert_s16_float_asm(float *out, const int16_t *in,
|
||||
void convert_s16_float_asm(float *out, const int16_t *in,
|
||||
size_t samples, const float *gain);
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_neon:
|
||||
* convert_s16_to_float_neon:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* ARM NEON implementation callback function.
|
||||
**/
|
||||
static void audio_convert_s16_to_float_neon(float *out,
|
||||
static void convert_s16_to_float_neon(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
size_t aligned_samples = samples & ~7;
|
||||
if (aligned_samples)
|
||||
audio_convert_s16_float_asm(out, in, aligned_samples, &gain);
|
||||
convert_s16_float_asm(out, in, aligned_samples, &gain);
|
||||
|
||||
/* Could do all conversion in ASM, but keep it simple for now. */
|
||||
audio_convert_s16_to_float_C(out + aligned_samples, in + aligned_samples,
|
||||
convert_s16_to_float_C(out + aligned_samples, in + aligned_samples,
|
||||
samples - aligned_samples, gain);
|
||||
}
|
||||
#elif defined(_MIPS_ARCH_ALLEGREX)
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_ALLEGREX:
|
||||
* convert_s16_to_float_ALLEGREX:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* MIPS ALLEGREX implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_ALLEGREX(float *out,
|
||||
void convert_s16_to_float_ALLEGREX(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -230,25 +224,25 @@ void audio_convert_s16_to_float_ALLEGREX(float *out,
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned audio_convert_get_cpu_features(void)
|
||||
static unsigned convert_get_cpu_features(void)
|
||||
{
|
||||
return cpu_features_get();
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_convert_init_simd:
|
||||
* convert_init_simd:
|
||||
*
|
||||
* Sets up function pointers for audio conversion
|
||||
* Sets up function pointers for conversion
|
||||
* functions based on CPU features.
|
||||
**/
|
||||
void audio_convert_init_simd(void)
|
||||
void convert_init_simd(void)
|
||||
{
|
||||
unsigned cpu = audio_convert_get_cpu_features();
|
||||
unsigned cpu = convert_get_cpu_features();
|
||||
|
||||
(void)cpu;
|
||||
#if defined(__ARM_NEON__) && !defined(VITA)
|
||||
audio_convert_s16_to_float_arm = (cpu & RETRO_SIMD_NEON) ?
|
||||
audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C;
|
||||
convert_s16_to_float_arm = (cpu & RETRO_SIMD_NEON) ?
|
||||
convert_s16_to_float_neon : convert_s16_to_float_C;
|
||||
convert_float_to_s16_arm = (cpu & RETRO_SIMD_NEON) ?
|
||||
convert_float_to_s16_neon : convert_float_to_s16_C;
|
||||
#endif
|
||||
|
@ -28,90 +28,90 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__SSE2__)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_SSE2
|
||||
#define convert_s16_to_float convert_s16_to_float_SSE2
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_SSE2:
|
||||
* convert_s16_to_float_SSE2:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* SSE2 implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_SSE2(float *out,
|
||||
void convert_s16_to_float_SSE2(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
#elif defined(__ALTIVEC__)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_altivec
|
||||
#define convert_s16_to_float convert_s16_to_float_altivec
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_altivec:
|
||||
* convert_s16_to_float_altivec:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* AltiVec implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_altivec(float *out,
|
||||
void convert_s16_to_float_altivec(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
#elif defined(__ARM_NEON__) && !defined(VITA)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_arm
|
||||
#define convert_s16_to_float convert_s16_to_float_arm
|
||||
|
||||
void (*audio_convert_s16_to_float_arm)(float *out,
|
||||
void (*convert_s16_to_float_arm)(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
#elif defined(_MIPS_ARCH_ALLEGREX)
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_ALLEGREX
|
||||
#define convert_s16_to_float convert_s16_to_float_ALLEGREX
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_ALLEGREX:
|
||||
* convert_s16_to_float_ALLEGREX:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* MIPS ALLEGREX implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_ALLEGREX(float *out,
|
||||
void convert_s16_to_float_ALLEGREX(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
#else
|
||||
#define audio_convert_s16_to_float audio_convert_s16_to_float_C
|
||||
#define convert_s16_to_float convert_s16_to_float_C
|
||||
#endif
|
||||
|
||||
/**
|
||||
* audio_convert_s16_to_float_C:
|
||||
* convert_s16_to_float_C:
|
||||
* @out : output buffer
|
||||
* @in : input buffer
|
||||
* @samples : size of samples to be converted
|
||||
* @gain : gain applied to the audio volume
|
||||
* @gain : gain applied (.e.g. audio volume)
|
||||
*
|
||||
* Converts audio samples from signed integer 16-bit
|
||||
* Converts from signed integer 16-bit
|
||||
* to floating point.
|
||||
*
|
||||
* C implementation callback function.
|
||||
**/
|
||||
void audio_convert_s16_to_float_C(float *out,
|
||||
void convert_s16_to_float_C(float *out,
|
||||
const int16_t *in, size_t samples, float gain);
|
||||
|
||||
/**
|
||||
* audio_convert_init_simd:
|
||||
* convert_init_simd:
|
||||
*
|
||||
* Sets up function pointers for audio conversion
|
||||
* Sets up function pointers for conversion
|
||||
* functions based on CPU features.
|
||||
**/
|
||||
void audio_convert_init_simd(void);
|
||||
void convert_init_simd(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
#endif
|
||||
|
||||
.align 4
|
||||
.globl audio_convert_s16_float_asm
|
||||
.globl _audio_convert_s16_float_asm
|
||||
# audio_convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)
|
||||
audio_convert_s16_float_asm:
|
||||
_audio_convert_s16_float_asm:
|
||||
.globl convert_s16_float_asm
|
||||
.globl _convert_s16_float_asm
|
||||
# convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)
|
||||
convert_s16_float_asm:
|
||||
_convert_s16_float_asm:
|
||||
# Hacky way to get a constant of 2^-15.
|
||||
# Might be faster to just load a constant from memory.
|
||||
# It's just done once however ...
|
||||
|
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
|
||||
uniform = (2.0 * rand()) / RAND_MAX - 1.0;
|
||||
rate_mod = 1.0 + ratio_max_deviation * uniform;
|
||||
|
||||
audio_convert_s16_to_float(input_f, input_i, 1024, 1.0f);
|
||||
convert_s16_to_float(input_f, input_i, 1024, 1.0f);
|
||||
|
||||
data.data_in = input_f;
|
||||
data.data_out = output_f;
|
||||
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
output_samples = data.output_frames * 2;
|
||||
|
||||
audio_convert_float_to_s16(output_i, output_f, output_samples);
|
||||
convert_float_to_s16(output_i, output_f, output_samples);
|
||||
|
||||
if (fwrite(output_i, sizeof(int16_t), output_samples, stdout) != output_samples)
|
||||
break;
|
||||
|
@ -1169,7 +1169,7 @@ static void ffmpeg_audio_resample(ffmpeg_t *handle,
|
||||
|
||||
if (handle->audio.use_float || handle->audio.resampler)
|
||||
{
|
||||
audio_convert_s16_to_float(handle->audio.float_conv,
|
||||
convert_s16_to_float(handle->audio.float_conv,
|
||||
(const int16_t*)aud->data, aud->frames * handle->params.channels, 1.0);
|
||||
aud->data = handle->audio.float_conv;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user