Begin implementation of softfilter API.

This commit is contained in:
Themaister 2014-04-14 22:56:15 +02:00
parent fb579c24be
commit 5cb3438389
6 changed files with 236 additions and 0 deletions

View File

@ -299,6 +299,7 @@ endif
ifeq ($(HAVE_DYLIB), 1) ifeq ($(HAVE_DYLIB), 1)
LIBS += $(DYLIB_LIB) LIBS += $(DYLIB_LIB)
OBJ += gfx/filter.o
endif endif
ifeq ($(HAVE_FREETYPE), 1) ifeq ($(HAVE_FREETYPE), 1)

View File

@ -194,6 +194,7 @@ endif
ifeq ($(HAVE_DYLIB), 1) ifeq ($(HAVE_DYLIB), 1)
DEFINES += -DHAVE_DYLIB DEFINES += -DHAVE_DYLIB
OBJ += gfx/filter.o
endif endif
ifeq ($(HAVE_STDIN_CMD), 1) ifeq ($(HAVE_STDIN_CMD), 1)

View File

@ -34,6 +34,7 @@
#include "performance.h" #include "performance.h"
#include "core_options.h" #include "core_options.h"
#include "miscellaneous.h" #include "miscellaneous.h"
#include "gfx/filter.h"
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
@ -504,6 +505,8 @@ struct global
struct struct
{ {
rarch_softfilter_t *filter;
bool active; bool active;
uint32_t *buffer; uint32_t *buffer;
uint32_t *colormap; uint32_t *colormap;

102
gfx/filter.c Normal file
View File

@ -0,0 +1,102 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "filter.h"
#include "../dynamic.h"
#include "../general.h"
#include <stdlib.h>
struct rarch_softfilter
{
dylib_t *lib;
const struct softfilter_implementation *impl;
void *impl_data;
unsigned max_width, max_height;
unsigned threads;
enum retro_pixel_format pix_fmt, out_pix_fmt;
};
rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
unsigned threads,
enum retro_pixel_format in_pixel_format,
unsigned max_width, unsigned max_height)
{
rarch_softfilter_t *filt = (rarch_softfilter_t*)calloc(1, sizeof(*filt));
if (!filt)
return NULL;
filt->lib = dylib_load(filter_path);
if (!filt->lib)
goto error;
softfilter_get_implementation_t cb = (softfilter_get_implementation_t)dylib_proc(filt->lib, "softfilter_get_implementation");
if (!cb)
{
RARCH_ERR("Couldn't find softfilter symbol.\n");
goto error;
}
filt->impl = cb(0);
if (!filt->impl)
goto error;
filt->max_width = max_width;
filt->max_height = max_height;
filt->pix_fmt = in_pixel_format;
filt->threads = threads;
return filt;
error:
rarch_softfilter_free(filt);
return NULL;
}
void rarch_softfilter_free(rarch_softfilter_t *filt)
{
if (!filt)
return;
if (filt->impl && filt->impl_data)
filt->impl->destroy(filt->impl_data);
if (filt->lib)
dylib_close(filt->lib);
free(filt);
}
void rarch_softfilter_get_max_output_size(rarch_softfilter_t *filt,
unsigned *width, unsigned *height)
{
}
void rarch_softfilter_get_output_size(rarch_softfilter_t *filt,
unsigned *out_width, unsigned *out_height,
unsigned width, unsigned height)
{
}
enum retro_pixel_format rarch_softfilter_get_output_format(rarch_softfilter_t *filt)
{
return filt->out_pix_fmt;
}
void rarch_softfilter_process(rarch_softfilter_t *filt,
void *output, size_t output_stride,
const void *input, unsigned width, unsigned height, size_t input_stride)
{
}

48
gfx/filter.h Normal file
View File

@ -0,0 +1,48 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RARCH_FILTER_H__
#define RARCH_FILTER_H__
#include "../libretro.h"
#include <stddef.h>
#include "softfilter.h"
#define RARCH_CPU_FILTER_THREADS_AUTO 0
typedef struct rarch_softfilter rarch_softfilter_t;
rarch_softfilter_t *rarch_softfilter_new(const char *filter_path,
unsigned threads,
enum retro_pixel_format in_pixel_format,
unsigned max_width, unsigned max_height);
void rarch_softfilter_free(rarch_softfilter_t *filt);
void rarch_softfilter_get_max_output_size(rarch_softfilter_t *filt,
unsigned *width, unsigned *height);
void rarch_softfilter_get_output_size(rarch_softfilter_t *filt,
unsigned *out_width, unsigned *out_height,
unsigned width, unsigned height);
enum retro_pixel_format rarch_softfilter_get_output_format(rarch_softfilter_t *filt);
void rarch_softfilter_process(rarch_softfilter_t *filt,
void *output, size_t output_stride,
const void *input, unsigned width, unsigned height, size_t input_stride);
#endif

81
gfx/softfilter.h Normal file
View File

@ -0,0 +1,81 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOFTFILTER_API_H__
#define SOFTFILTER_API_H__
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned softfilter_simd_mask_t;
// Dynamic library entrypoint.
typedef const struct softfilter_implementation *(*softfilter_get_implementation_t)(softfilter_simd_mask_t);
const struct softfilter_implementation *softfilter_get_implementation(softfilter_simd_mask_t simd);
#define SOFTFILTER_API_VERSION 1
#define SOFTFILTER_FMT_NONE 0
#define SOFTFILTER_FMT_RGB565 (1 << 0)
#define SOFTFILTER_FMT_XRGB8888 (1 << 1)
typedef unsigned (*softfilter_query_input_formats_t)(void);
typedef unsigned (*softfilter_query_output_formats_t)(unsigned input_format);
typedef void (*softfilter_work_t)(void *userdata, void *thread_data);
typedef void (*softfilter_submit_t)(softfilter_work_t work, void *userdata);
typedef void *(*softfilter_create_t)(unsigned in_fmt, unsigned out_fmt,
unsigned max_width, unsigned max_height,
unsigned threads);
typedef void (*softfilter_destroy_t)(void *data);
typedef void (*softfilter_query_output_size_t)(void *data,
unsigned *out_width, unsigned *out_height,
unsigned width, unsigned height);
typedef void (*softfilter_process_t)(void *data,
softfilter_submit_t callback,
void *output, size_t output_stride,
const void *input, unsigned width, unsigned height, size_t input_stride);
typedef unsigned (*softfilter_query_num_threads_t)(void *data, unsigned desired_threads);
struct softfilter_implementation
{
softfilter_query_input_formats_t query_input_formats;
softfilter_query_output_formats_t query_output_format;
softfilter_create_t create;
softfilter_destroy_t destroy;
softfilter_query_num_threads_t query_num_threads;
softfilter_query_output_size_t query_output_size;
softfilter_process_t process;
const char *ident;
unsigned api_version;
};
#ifdef __cplusplus
}
#endif
#endif