mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-11 12:35:08 +00:00
Start preparing runtime toggleable resampler quality settings
This commit is contained in:
parent
0dd2f075fe
commit
b9248cf3af
@ -21,7 +21,6 @@
|
||||
#include <lists/string_list.h>
|
||||
#include <audio/conversion/float_to_s16.h>
|
||||
#include <audio/conversion/s16_to_float.h>
|
||||
#include <audio/audio_resampler.h>
|
||||
#include <audio/dsp_filter.h>
|
||||
#include <file/file_path.h>
|
||||
#include <lists/dir_list.h>
|
||||
@ -182,6 +181,21 @@ static void *audio_driver_resampler_data = NULL;
|
||||
static const audio_driver_t *current_audio = NULL;
|
||||
static void *audio_driver_context_audio_data = NULL;
|
||||
|
||||
enum resampler_quality audio_driver_get_resampler_quality(void)
|
||||
{
|
||||
#if defined(SINC_LOWEST_QUALITY)
|
||||
return RESAMPLER_QUALITY_LOWEST;
|
||||
#elif defined(SINC_LOWER_QUALITY)
|
||||
return RESAMPLER_QUALITY_LOWER;
|
||||
#elif defined(SINC_HIGHER_QUALITY)
|
||||
return RESAMPLER_QUALITY_HIGHER;
|
||||
#elif defined(SINC_HIGHEST_QUALITY)
|
||||
return RESAMPLER_QUALITY_HIGHEST;
|
||||
#else
|
||||
return RESAMPLER_QUALITY_NORMAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* compute_audio_buffer_statistics:
|
||||
*
|
||||
@ -449,6 +463,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
|
||||
&audio_driver_resampler_data,
|
||||
&audio_driver_resampler,
|
||||
settings->arrays.audio_resampler,
|
||||
audio_driver_get_resampler_quality(),
|
||||
audio_source_ratio_original))
|
||||
{
|
||||
RARCH_ERR("Failed to initialize resampler \"%s\".\n",
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <boolean.h>
|
||||
#include <audio/audio_mixer.h>
|
||||
#include <audio/audio_resampler.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
@ -255,6 +256,8 @@ bool audio_driver_init(void);
|
||||
|
||||
bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params);
|
||||
|
||||
enum resampler_quality audio_driver_get_resampler_quality(void);
|
||||
|
||||
extern audio_driver_t audio_rsound;
|
||||
extern audio_driver_t audio_oss;
|
||||
extern audio_driver_t audio_alsa;
|
||||
|
@ -151,7 +151,9 @@ done:
|
||||
}
|
||||
|
||||
static void *resampler_CC_init(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
double bandwidth_mod,
|
||||
enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
(void)mask;
|
||||
(void)bandwidth_mod;
|
||||
@ -492,7 +494,9 @@ static void resampler_CC_process(void *re_, struct resampler_data *data)
|
||||
|
||||
|
||||
static void *resampler_CC_init(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
double bandwidth_mod,
|
||||
enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
int i;
|
||||
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)
|
||||
|
@ -192,6 +192,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate)
|
||||
retro_resampler_realloc(&chunk->resampler_data,
|
||||
&chunk->resampler,
|
||||
NULL,
|
||||
RESAMPLER_QUALITY_DONTCARE,
|
||||
chunk->ratio);
|
||||
|
||||
if (chunk->resampler && chunk->resampler_data)
|
||||
|
@ -219,7 +219,8 @@ static bool one_shot_resample(const float* in, size_t samples_in,
|
||||
const retro_resampler_t* resampler = NULL;
|
||||
float ratio = (double)s_rate / (double)rate;
|
||||
|
||||
if (!retro_resampler_realloc(&data, &resampler, NULL, ratio))
|
||||
if (!retro_resampler_realloc(&data, &resampler, NULL,
|
||||
RESAMPLER_QUALITY_DONTCARE, ratio))
|
||||
return false;
|
||||
|
||||
/*
|
||||
@ -430,7 +431,8 @@ static bool audio_mixer_play_ogg(
|
||||
ratio = (double)s_rate / (double)info.sample_rate;
|
||||
|
||||
if (!retro_resampler_realloc(&resampler_data,
|
||||
&resamp, NULL, ratio))
|
||||
&resamp, NULL, RESAMPLER_QUALITY_DONTCARE,
|
||||
ratio))
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -127,12 +127,13 @@ static const retro_resampler_t *find_resampler_driver(const char *ident)
|
||||
**/
|
||||
static bool resampler_append_plugs(void **re,
|
||||
const retro_resampler_t **backend,
|
||||
enum resampler_quality quality,
|
||||
double bw_ratio)
|
||||
{
|
||||
resampler_simd_mask_t mask = (resampler_simd_mask_t)cpu_features_get();
|
||||
|
||||
if (*backend)
|
||||
*re = (*backend)->init(&resampler_config, bw_ratio, mask);
|
||||
*re = (*backend)->init(&resampler_config, bw_ratio, quality, mask);
|
||||
|
||||
if (!*re)
|
||||
return false;
|
||||
@ -152,7 +153,7 @@ static bool resampler_append_plugs(void **re,
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
|
||||
const char *ident, double bw_ratio)
|
||||
const char *ident, enum resampler_quality quality, double bw_ratio)
|
||||
{
|
||||
if (*re && *backend)
|
||||
(*backend)->free(*re);
|
||||
@ -160,7 +161,7 @@ bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
|
||||
*re = NULL;
|
||||
*backend = find_resampler_driver(ident);
|
||||
|
||||
if (!resampler_append_plugs(re, backend, bw_ratio))
|
||||
if (!resampler_append_plugs(re, backend, quality, bw_ratio))
|
||||
{
|
||||
if (!*re)
|
||||
*backend = NULL;
|
||||
|
@ -62,7 +62,9 @@ static void resampler_nearest_free(void *re_)
|
||||
}
|
||||
|
||||
static void *resampler_nearest_init(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
double bandwidth_mod,
|
||||
enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
rarch_nearest_resampler_t *re = (rarch_nearest_resampler_t*)
|
||||
calloc(1, sizeof(rarch_nearest_resampler_t));
|
||||
|
@ -41,7 +41,9 @@ static void resampler_null_free(void *re_)
|
||||
}
|
||||
|
||||
static void *resampler_null_init(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
double bandwidth_mod,
|
||||
enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
return (void*)0;
|
||||
}
|
||||
|
@ -558,9 +558,9 @@ static void sinc_init_table_lanczos(rarch_sinc_resampler_t *resamp, double cutof
|
||||
}
|
||||
|
||||
static void *resampler_sinc_new(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
double bandwidth_mod, enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask)
|
||||
{
|
||||
enum resampler_quality quality = RESAMPLER_QUALITY_DONTCARE;
|
||||
double cutoff = 0.0;
|
||||
size_t phase_elems = 0;
|
||||
size_t elems = 0;
|
||||
@ -571,18 +571,6 @@ static void *resampler_sinc_new(const struct resampler_config *config,
|
||||
if (!re)
|
||||
return NULL;
|
||||
|
||||
#if defined(SINC_LOWEST_QUALITY)
|
||||
quality = RESAMPLER_QUALITY_LOWEST;
|
||||
#elif defined(SINC_LOWER_QUALITY)
|
||||
quality = RESAMPLER_QUALITY_LOWER;
|
||||
#elif defined(SINC_HIGHER_QUALITY)
|
||||
quality = RESAMPLER_QUALITY_HIGHER;
|
||||
#elif defined(SINC_HIGHEST_QUALITY)
|
||||
quality = RESAMPLER_QUALITY_HIGHEST;
|
||||
#else
|
||||
quality = RESAMPLER_QUALITY_NORMAL;
|
||||
#endif
|
||||
|
||||
re->window_type = SINC_WINDOW_NONE;
|
||||
|
||||
switch (quality)
|
||||
|
@ -118,7 +118,8 @@ struct resampler_config
|
||||
/* Bandwidth factor. Will be < 1.0 for downsampling, > 1.0 for upsampling.
|
||||
* Corresponds to expected resampling ratio. */
|
||||
typedef void *(*resampler_init_t)(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask);
|
||||
double bandwidth_mod, enum resampler_quality quality,
|
||||
resampler_simd_mask_t mask);
|
||||
|
||||
/* Frees the handle. */
|
||||
typedef void (*resampler_free_t)(void *data);
|
||||
@ -187,7 +188,7 @@ const char *audio_resampler_driver_find_ident(int index);
|
||||
* Returns: true (1) if successful, otherwise false (0).
|
||||
**/
|
||||
bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
|
||||
const char *ident, double bw_ratio);
|
||||
const char *ident, enum resampler_quality quality, double bw_ratio);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
@ -348,6 +348,7 @@ static bool ffmpeg_init_audio(ffmpeg_t *handle)
|
||||
retro_resampler_realloc(&audio->resampler_data,
|
||||
&audio->resampler,
|
||||
settings->arrays.audio_resampler,
|
||||
RESAMPLER_QUALITY_DONTCARE,
|
||||
audio->ratio);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user