diff --git a/Makefile b/Makefile
index 02728b4ce3..2037456f97 100644
--- a/Makefile
+++ b/Makefile
@@ -299,6 +299,7 @@ endif
ifeq ($(HAVE_DYLIB), 1)
LIBS += $(DYLIB_LIB)
+ OBJ += gfx/filter.o
endif
ifeq ($(HAVE_FREETYPE), 1)
diff --git a/Makefile.win b/Makefile.win
index 5535d0aa6a..fb75ce499d 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -194,6 +194,7 @@ endif
ifeq ($(HAVE_DYLIB), 1)
DEFINES += -DHAVE_DYLIB
+ OBJ += gfx/filter.o
endif
ifeq ($(HAVE_STDIN_CMD), 1)
diff --git a/general.h b/general.h
index c3bd7da20f..0189e381de 100644
--- a/general.h
+++ b/general.h
@@ -34,6 +34,7 @@
#include "performance.h"
#include "core_options.h"
#include "miscellaneous.h"
+#include "gfx/filter.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -504,6 +505,8 @@ struct global
struct
{
+ rarch_softfilter_t *filter;
+
bool active;
uint32_t *buffer;
uint32_t *colormap;
diff --git a/gfx/filter.c b/gfx/filter.c
new file mode 100644
index 0000000000..7d0657e140
--- /dev/null
+++ b/gfx/filter.c
@@ -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 .
+ */
+
+#include "filter.h"
+#include "../dynamic.h"
+#include "../general.h"
+#include
+
+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)
+{
+}
+
diff --git a/gfx/filter.h b/gfx/filter.h
new file mode 100644
index 0000000000..65fc0fdf86
--- /dev/null
+++ b/gfx/filter.h
@@ -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 .
+ */
+
+#ifndef RARCH_FILTER_H__
+#define RARCH_FILTER_H__
+
+#include "../libretro.h"
+#include
+
+#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
+
diff --git a/gfx/softfilter.h b/gfx/softfilter.h
new file mode 100644
index 0000000000..d0f8816815
--- /dev/null
+++ b/gfx/softfilter.h
@@ -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 .
+ */
+
+#ifndef SOFTFILTER_API_H__
+#define SOFTFILTER_API_H__
+
+#include
+#include
+
+#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
+