From 6cd2cb4abeb48345900f794b1949d96e601c4b3f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 16 Apr 2014 17:43:52 +0200 Subject: [PATCH] (SoftFilter) Refactor HQ2x somewhat --- gfx/filters/hq2x.c | 11 ++++++----- gfx/filters/softfilter.h | 13 +++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gfx/filters/hq2x.c b/gfx/filters/hq2x.c index 4b92ce24ab..e824d82306 100644 --- a/gfx/filters/hq2x.c +++ b/gfx/filters/hq2x.c @@ -228,12 +228,10 @@ static uint16_t blend(unsigned colfmt, unsigned rule, uint16_t E, uint16_t A, mask = HQ2X_565_MASK; shift = HQ2X_565_SHIFT; break; -#if 0 case SOFTFILTER_FMT_RGB4444: mask = HQ2X_4444_MASK; shift = HQ2X_4444_SHIFT; break; -#endif } switch (rule) @@ -346,7 +344,7 @@ static void hq2x_16bit_generic(unsigned width, unsigned height, } } -static void hq2x_work_cb_rgb565(void *data, void *thread_data) +static void hq2x_work_cb_16bit(void *data, void *thread_data) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; @@ -384,8 +382,11 @@ static void hq2x_generic_packets(void *data, thr->last = y_end == height; thr->colfmt = SOFTFILTER_FMT_RGB565; - if (filt->in_fmt == SOFTFILTER_FMT_RGB565) - packets[i].work = hq2x_work_cb_rgb565; + if ( + filt->in_fmt == SOFTFILTER_FMT_RGB565 || + filt->in_fmt == SOFTFILTER_FMT_RGB4444 + ) + packets[i].work = hq2x_work_cb_16bit; packets[i].thread_data = thr; } } diff --git a/gfx/filters/softfilter.h b/gfx/filters/softfilter.h index c82d1e9fbc..a5be796d1b 100644 --- a/gfx/filters/softfilter.h +++ b/gfx/filters/softfilter.h @@ -48,13 +48,18 @@ typedef const struct softfilter_implementation *(*softfilter_get_implementation_ // The same SIMD mask argument is forwarded to create() callback as well to avoid having to keep lots of state around. const struct softfilter_implementation *softfilter_get_implementation(softfilter_simd_mask_t simd); -#define SOFTFILTER_API_VERSION 1 +#define SOFTFILTER_API_VERSION 1 -#define SOFTFILTER_FMT_NONE 0 -#define SOFTFILTER_FMT_RGB565 (1 << 0) +// Required base color formats + +#define SOFTFILTER_FMT_NONE 0 +#define SOFTFILTER_FMT_RGB565 (1 << 0) #define SOFTFILTER_FMT_XRGB8888 (1 << 1) -#define SOFTFILTER_BPP_RGB565 2 +// Optional color formats +#define SOFTFILTER_FMT_RGB4444 (1 << 2) + +#define SOFTFILTER_BPP_RGB565 2 #define SOFTFILTER_BPP_XRGB8888 4 // Softfilter implementation.