From 45c917afa47805b7ede900694e4fe119c389b688 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 16 Apr 2014 02:09:09 +0200 Subject: [PATCH] Compile in filters for console ports (HAVE_DYLIB not defined in Griffin) --- driver.c | 7 ------- frontend/menu/menu_settings.c | 2 ++ gfx/filter.c | 9 ++++++++ gfx/filters/2xbr.c | 33 ++++++++--------------------- gfx/filters/darken.c | 37 +++++++++++---------------------- gfx/filters/scale2x.c | 39 +++++++++++------------------------ gfx/filters/softfilter.h | 19 +++++++++++++++++ griffin/griffin.c | 11 ++++++++-- retroarch.c | 5 ----- 9 files changed, 72 insertions(+), 90 deletions(-) diff --git a/driver.c b/driver.c index 734bebcf94..b696b2e46e 100644 --- a/driver.c +++ b/driver.c @@ -1281,7 +1281,6 @@ void uninit_audio(void) compute_audio_buffer_statistics(); } -#ifdef HAVE_DYLIB void rarch_deinit_filter(void) { rarch_softfilter_free(g_extern.filter.filter); @@ -1291,7 +1290,6 @@ void rarch_deinit_filter(void) void rarch_init_filter(enum retro_pixel_format colfmt) { - unsigned i; rarch_deinit_filter(); if (!*g_settings.video.filter_path) return; @@ -1343,7 +1341,6 @@ error: RARCH_ERR("Softfilter init failed.\n"); rarch_deinit_filter(); } -#endif static void deinit_shader_dir(void) { @@ -1407,9 +1404,7 @@ static bool init_video_pixel_converter(unsigned size) void init_video_input(void) { -#ifdef HAVE_DYLIB rarch_init_filter(g_extern.system.pix_fmt); -#endif init_shader_dir(); @@ -1590,9 +1585,7 @@ void uninit_video_input(void) deinit_pixel_converter(); -#ifdef HAVE_DYLIB rarch_deinit_filter(); -#endif deinit_shader_dir(); compute_monitor_fps_statistics(); diff --git a/frontend/menu/menu_settings.c b/frontend/menu/menu_settings.c index ba2a1a4a08..a4882e6c4e 100644 --- a/frontend/menu/menu_settings.c +++ b/frontend/menu/menu_settings.c @@ -777,6 +777,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action) case RGUI_SETTINGS_VIDEO_SOFTFILTER: switch (action) { +#ifdef HAVE_DYLIB case RGUI_ACTION_OK: file_list_push(rgui->menu_stack, g_settings.video.filter_dir, setting, rgui->selection_ptr); menu_clear_navigation(rgui); @@ -788,6 +789,7 @@ int menu_set_settings(void *data, unsigned setting, unsigned action) break; default: break; +#endif } break; diff --git a/gfx/filter.c b/gfx/filter.c index 55e81f5e96..300b792663 100644 --- a/gfx/filter.c +++ b/gfx/filter.c @@ -64,7 +64,9 @@ static void filter_thread_loop(void *data) struct rarch_softfilter { +#ifdef HAVE_DYLIB dylib_t lib; +#endif const struct softfilter_implementation *impl; void *impl_data; @@ -93,11 +95,16 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_path, if (!filt) return NULL; + (void)cb; +#ifdef HAVE_DYLIB filt->lib = dylib_load(filter_path); if (!filt->lib) goto error; cb = (softfilter_get_implementation_t)dylib_proc(filt->lib, "softfilter_get_implementation"); +#else + // FIXME - TODO - implement for non-HAVE_DYLIB +#endif if (!cb) { RARCH_ERR("Couldn't find softfilter symbol.\n"); @@ -218,8 +225,10 @@ void rarch_softfilter_free(rarch_softfilter_t *filt) free(filt->packets); if (filt->impl && filt->impl_data) filt->impl->destroy(filt->impl_data); +#ifdef HAVE_DYLIB if (filt->lib) dylib_close(filt->lib); +#endif #ifdef HAVE_THREADS for (i = 0; i < filt->threads; i++) { diff --git a/gfx/filters/2xbr.c b/gfx/filters/2xbr.c index 842b053815..b437cfd7d9 100644 --- a/gfx/filters/2xbr.c +++ b/gfx/filters/2xbr.c @@ -259,25 +259,6 @@ static unsigned twoxbr_generic_output_fmts(unsigned input_fmts) return input_fmts; } -struct thread_data -{ - void *out_data; - const void *in_data; - size_t out_pitch; - size_t in_pitch; - unsigned width; - unsigned height; - - int first, last; -}; - -struct filter_data -{ - unsigned threads; - struct thread_data *workers; - unsigned in_fmt; -}; - static unsigned twoxbr_generic_threads(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -293,7 +274,7 @@ static void *twoxbr_generic_create(unsigned in_fmt, unsigned out_fmt, struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); if (!filt) return NULL; - filt->workers = (struct thread_data*)calloc(threads, sizeof(struct thread_data)); + filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)); filt->threads = threads; filt->in_fmt = in_fmt; if (!filt->workers) @@ -318,9 +299,9 @@ static void twoxbr_generic_destroy(void *data) free(filt); } -static void work_cb_rgb565(void *data, void *thread_data) +static void twoxbr_work_cb_rgb565(void *data, void *thread_data) { - struct thread_data *thr = (struct thread_data*)thread_data; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; unsigned width = thr->width; @@ -339,7 +320,7 @@ static void twoxbr_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct thread_data *thr = &filt->workers[i]; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; @@ -355,7 +336,7 @@ static void twoxbr_generic_packets(void *data, thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = work_cb_rgb565; + packets[i].work = twoxbr_work_cb_rgb565; packets[i].thread_data = thr; } } @@ -379,3 +360,7 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter (void)simd; return &twoxbr_generic; } + +#ifdef RARCH_INTERNAL +#undef softfilter_get_implementation +#endif diff --git a/gfx/filters/darken.c b/gfx/filters/darken.c index 854a82018a..c93b0cbd28 100644 --- a/gfx/filters/darken.c +++ b/gfx/filters/darken.c @@ -34,23 +34,6 @@ static unsigned darken_output_fmts(unsigned input_fmts) return input_fmts; } -struct thread_data -{ - void *out_data; - const void *in_data; - size_t out_pitch; - size_t in_pitch; - unsigned width; - unsigned height; -}; - -struct filter_data -{ - unsigned threads; - struct thread_data *workers; - unsigned in_fmt; -}; - static unsigned darken_threads(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -66,7 +49,7 @@ static void *darken_create(unsigned in_fmt, unsigned out_fmt, struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); if (!filt) return NULL; - filt->workers = calloc(threads, sizeof(struct thread_data)); + filt->workers = calloc(threads, sizeof(struct softfilter_thread_data)); filt->threads = threads; filt->in_fmt = in_fmt; if (!filt->workers) @@ -91,9 +74,9 @@ static void darken_destroy(void *data) free(filt); } -static void work_cb_xrgb8888(void *data, void *thread_data) +static void darken_work_cb_xrgb8888(void *data, void *thread_data) { - struct thread_data *thr = (struct thread_data*)thread_data; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint32_t *input = (const uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; unsigned width = thr->width; @@ -105,9 +88,9 @@ static void work_cb_xrgb8888(void *data, void *thread_data) output[x] = (input[x] >> 2) & (0x3f * 0x01010101); } -static void work_cb_rgb565(void *data, void *thread_data) +static void darken_work_cb_rgb565(void *data, void *thread_data) { - struct thread_data *thr = (struct thread_data*)thread_data; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; unsigned width = thr->width; @@ -128,7 +111,7 @@ static void darken_packets(void *data, struct filter_data *filt = (struct filter_data*)data; for (i = 0; i < filt->threads; i++) { - struct thread_data *thr = (struct thread_data*)&filt->workers[i]; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; thr->out_data = (uint8_t*)output + y_start * output_stride; @@ -139,9 +122,9 @@ static void darken_packets(void *data, thr->height = y_end - y_start; if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = work_cb_xrgb8888; + packets[i].work = darken_work_cb_xrgb8888; else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = work_cb_rgb565; + packets[i].work = darken_work_cb_rgb565; packets[i].thread_data = thr; } } @@ -165,3 +148,7 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter (void)simd; return &darken; } + +#ifdef RARCH_INTERNAL +#undef softfilter_get_implementation +#endif diff --git a/gfx/filters/scale2x.c b/gfx/filters/scale2x.c index 043934646c..4725ca73ba 100644 --- a/gfx/filters/scale2x.c +++ b/gfx/filters/scale2x.c @@ -93,25 +93,6 @@ static unsigned scale2x_generic_output_fmts(unsigned input_fmts) return input_fmts; } -struct thread_data -{ - void *out_data; - const void *in_data; - size_t out_pitch; - size_t in_pitch; - unsigned width; - unsigned height; - - int first, last; -}; - -struct filter_data -{ - unsigned threads; - struct thread_data *workers; - unsigned in_fmt; -}; - static unsigned scale2x_generic_threads(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -127,7 +108,7 @@ static void *scale2x_generic_create(unsigned in_fmt, unsigned out_fmt, struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); if (!filt) return NULL; - filt->workers = (struct thread_data*)calloc(threads, sizeof(struct thread_data)); + filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)); filt->threads = threads; filt->in_fmt = in_fmt; if (!filt->workers) @@ -152,9 +133,9 @@ static void scale2x_generic_destroy(void *data) free(filt); } -static void work_cb_xrgb8888(void *data, void *thread_data) +static void scale2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct thread_data *thr = (struct thread_data*)thread_data; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint32_t *input = (const uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; unsigned width = thr->width; @@ -164,9 +145,9 @@ static void work_cb_xrgb8888(void *data, void *thread_data) thr->first, thr->last, input, thr->in_pitch / SOFTFILTER_BPP_XRGB8888, output, thr->out_pitch / SOFTFILTER_BPP_XRGB8888); } -static void work_cb_rgb565(void *data, void *thread_data) +static void scale2x_work_cb_rgb565(void *data, void *thread_data) { - struct thread_data *thr = (struct thread_data*)thread_data; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; unsigned width = thr->width; @@ -185,7 +166,7 @@ static void scale2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct thread_data *thr = &filt->workers[i]; + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; @@ -201,9 +182,9 @@ static void scale2x_generic_packets(void *data, thr->last = y_end == height; if (filt->in_fmt == SOFTFILTER_FMT_XRGB8888) - packets[i].work = work_cb_xrgb8888; + packets[i].work = scale2x_work_cb_xrgb8888; else if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = work_cb_rgb565; + packets[i].work = scale2x_work_cb_rgb565; packets[i].thread_data = thr; } } @@ -227,3 +208,7 @@ const struct softfilter_implementation *softfilter_get_implementation(softfilter (void)simd; return &scale2x_generic; } + +#ifdef RARCH_INTERNAL +#undef softfilter_get_implementation +#endif diff --git a/gfx/filters/softfilter.h b/gfx/filters/softfilter.h index 48b0eba8cd..ee83bfd97f 100644 --- a/gfx/filters/softfilter.h +++ b/gfx/filters/softfilter.h @@ -98,6 +98,25 @@ typedef void (*softfilter_get_work_packets_t)(void *data, typedef unsigned (*softfilter_query_num_threads_t)(void *data); ///// +struct softfilter_thread_data +{ + void *out_data; + const void *in_data; + size_t out_pitch; + size_t in_pitch; + unsigned width; + unsigned height; + int first; + int last; +}; + +struct filter_data +{ + unsigned threads; + struct softfilter_thread_data *workers; + unsigned in_fmt; +}; + struct softfilter_implementation { softfilter_query_input_formats_t query_input_formats; diff --git a/griffin/griffin.c b/griffin/griffin.c index 23d3bd7670..9eb99c127f 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -468,14 +468,21 @@ SCALERS #include "../gfx/scaler/scaler.c" #include "../gfx/scaler/scaler_int.c" +/*============================================================ +FILTERS +============================================================ */ +#ifndef HAVE_DYLIB +#include "../gfx/filters/2xbr.c" +#include "../gfx/filters/darken.c" +#include "../gfx/filters/scale2x.c" +#endif /*============================================================ DYNAMIC ============================================================ */ #include "../dynamic.c" #include "../dynamic_dummy.c" -#ifdef HAVE_DYLIB #include "../gfx/filter.c" -#endif + /*============================================================ FILE diff --git a/retroarch.c b/retroarch.c index 8a2562bd05..f7cb695bfb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -304,7 +304,6 @@ static void video_frame(const void *data, unsigned width, unsigned height, size_ const char *msg = msg_queue_pull(g_extern.msg_queue); driver.current_msg = msg; -#ifdef HAVE_DYLIB if (g_extern.filter.filter && data) { unsigned owidth = 0; @@ -332,10 +331,6 @@ static void video_frame(const void *data, unsigned width, unsigned height, size_ } else if (!video_frame_func(data, width, height, pitch, msg)) g_extern.video_active = false; -#else - if (!video_frame_func(data, width, height, pitch, msg)) - g_extern.video_active = false; -#endif } void rarch_render_cached_frame(void)