mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 19:24:46 +00:00
(Resampler) Start hooking up config code bit by bit
This commit is contained in:
parent
3e33697dc8
commit
d4fcdba6cd
@ -545,8 +545,8 @@ static void resampler_CC_free(void *re_)
|
||||
memalign_free__(re);
|
||||
}
|
||||
|
||||
static void *resampler_CC_init(double bandwidth_mod,
|
||||
resampler_simd_mask_t mask)
|
||||
static void *resampler_CC_init(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
{
|
||||
int i;
|
||||
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)
|
||||
@ -557,6 +557,7 @@ static void *resampler_CC_init(double bandwidth_mod,
|
||||
* C codepath or NEON codepath. This will help out
|
||||
* Android. */
|
||||
(void)mask;
|
||||
(void)config;
|
||||
|
||||
if (!re)
|
||||
return NULL;
|
||||
|
@ -52,12 +52,13 @@ static void resampler_nearest_free(void *re_)
|
||||
free(re);
|
||||
}
|
||||
|
||||
static void *resampler_nearest_init(double bandwidth_mod,
|
||||
resampler_simd_mask_t mask)
|
||||
static void *resampler_nearest_init(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
{
|
||||
rarch_nearest_resampler_t *re = (rarch_nearest_resampler_t*)
|
||||
calloc(1, sizeof(rarch_nearest_resampler_t));
|
||||
|
||||
(void)config;
|
||||
(void)mask;
|
||||
|
||||
if (!re)
|
||||
|
@ -17,12 +17,9 @@
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "../../performance.h"
|
||||
#endif
|
||||
#include "../../conf/config_file_userdata.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
static const rarch_resampler_t *resampler_drivers[] = {
|
||||
&sinc_resampler,
|
||||
&CC_resampler,
|
||||
@ -30,6 +27,15 @@ static const rarch_resampler_t *resampler_drivers[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct resampler_config resampler_config = {
|
||||
config_userdata_get_float,
|
||||
config_userdata_get_int,
|
||||
config_userdata_get_float_array,
|
||||
config_userdata_get_int_array,
|
||||
config_userdata_get_string,
|
||||
config_userdata_free,
|
||||
};
|
||||
|
||||
static int find_resampler_driver_index(const char *driver)
|
||||
{
|
||||
unsigned i;
|
||||
@ -95,7 +101,7 @@ static bool resampler_append_plugs(void **re,
|
||||
{
|
||||
resampler_simd_mask_t mask = rarch_get_cpu_features();
|
||||
|
||||
*re = (*backend)->init(bw_ratio, mask);
|
||||
*re = (*backend)->init(&resampler_config, bw_ratio, mask);
|
||||
|
||||
if (!*re)
|
||||
return false;
|
||||
|
@ -49,7 +49,7 @@ extern "C" {
|
||||
|
||||
/* A bit-mask of all supported SIMD instruction sets.
|
||||
* Allows an implementation to pick different
|
||||
* dspfilter_implementation structs.
|
||||
* resampler_implementation structs.
|
||||
*/
|
||||
typedef unsigned resampler_simd_mask_t;
|
||||
|
||||
@ -66,10 +66,49 @@ struct resampler_data
|
||||
double ratio;
|
||||
};
|
||||
|
||||
/* Returns true if config key was found. Otherwise,
|
||||
* returns false, and sets value to default value.
|
||||
*/
|
||||
typedef int (*resampler_config_get_float_t)(void *userdata,
|
||||
const char *key, float *value, float default_value);
|
||||
|
||||
typedef int (*resampler_config_get_int_t)(void *userdata,
|
||||
const char *key, int *value, int default_value);
|
||||
|
||||
/* Allocates an array with values. free() with resampler_config_free_t. */
|
||||
typedef int (*resampler_config_get_float_array_t)(void *userdata,
|
||||
const char *key, float **values, unsigned *out_num_values,
|
||||
const float *default_values, unsigned num_default_values);
|
||||
|
||||
typedef int (*resampler_config_get_int_array_t)(void *userdata,
|
||||
const char *key, int **values, unsigned *out_num_values,
|
||||
const int *default_values, unsigned num_default_values);
|
||||
|
||||
typedef int (*resampler_config_get_string_t)(void *userdata,
|
||||
const char *key, char **output, const char *default_output);
|
||||
|
||||
/* Calls free() in host runtime. Sometimes needed on Windows.
|
||||
* free() on NULL is fine. */
|
||||
typedef void (*resampler_config_free_t)(void *ptr);
|
||||
|
||||
struct resampler_config
|
||||
{
|
||||
resampler_config_get_float_t get_float;
|
||||
resampler_config_get_int_t get_int;
|
||||
|
||||
resampler_config_get_float_array_t get_float_array;
|
||||
resampler_config_get_int_array_t get_int_array;
|
||||
|
||||
resampler_config_get_string_t get_string;
|
||||
/* Avoid problems where resampler plug and host are
|
||||
* linked against different C runtimes. */
|
||||
resampler_config_free_t free;
|
||||
};
|
||||
|
||||
/* Bandwidth factor. Will be < 1.0 for downsampling, > 1.0 for upsampling.
|
||||
* Corresponds to expected resampling ratio. */
|
||||
typedef void *(*resampler_init_t)(double bandwidth_mod,
|
||||
resampler_simd_mask_t mask);
|
||||
typedef void *(*resampler_init_t)(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask);
|
||||
|
||||
/* Frees the handle. */
|
||||
typedef void (*resampler_free_t)(void *data);
|
||||
|
@ -484,13 +484,15 @@ static void resampler_sinc_free(void *re)
|
||||
free(resampler);
|
||||
}
|
||||
|
||||
static void *resampler_sinc_new(double bandwidth_mod,
|
||||
resampler_simd_mask_t mask)
|
||||
static void *resampler_sinc_new(const struct resampler_config *config,
|
||||
double bandwidth_mod, resampler_simd_mask_t mask)
|
||||
{
|
||||
size_t phase_elems, elems;
|
||||
double cutoff;
|
||||
rarch_sinc_resampler_t *re = (rarch_sinc_resampler_t*)
|
||||
calloc(1, sizeof(*re));
|
||||
(void)config;
|
||||
|
||||
if (!re)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user