(SoftFilter) Refactor HQ2x somewhat

This commit is contained in:
twinaphex 2014-04-16 17:43:52 +02:00
parent 390d198812
commit 6cd2cb4abe
2 changed files with 15 additions and 9 deletions

View File

@ -228,12 +228,10 @@ static uint16_t blend(unsigned colfmt, unsigned rule, uint16_t E, uint16_t A,
mask = HQ2X_565_MASK; mask = HQ2X_565_MASK;
shift = HQ2X_565_SHIFT; shift = HQ2X_565_SHIFT;
break; break;
#if 0
case SOFTFILTER_FMT_RGB4444: case SOFTFILTER_FMT_RGB4444:
mask = HQ2X_4444_MASK; mask = HQ2X_4444_MASK;
shift = HQ2X_4444_SHIFT; shift = HQ2X_4444_SHIFT;
break; break;
#endif
} }
switch (rule) 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; struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data;
uint16_t *input = (uint16_t*)thr->in_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->last = y_end == height;
thr->colfmt = SOFTFILTER_FMT_RGB565; thr->colfmt = SOFTFILTER_FMT_RGB565;
if (filt->in_fmt == SOFTFILTER_FMT_RGB565) if (
packets[i].work = hq2x_work_cb_rgb565; filt->in_fmt == SOFTFILTER_FMT_RGB565 ||
filt->in_fmt == SOFTFILTER_FMT_RGB4444
)
packets[i].work = hq2x_work_cb_16bit;
packets[i].thread_data = thr; packets[i].thread_data = thr;
} }
} }

View File

@ -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. // 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); 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 // Required base color formats
#define SOFTFILTER_FMT_RGB565 (1 << 0)
#define SOFTFILTER_FMT_NONE 0
#define SOFTFILTER_FMT_RGB565 (1 << 0)
#define SOFTFILTER_FMT_XRGB8888 (1 << 1) #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 #define SOFTFILTER_BPP_XRGB8888 4
// Softfilter implementation. // Softfilter implementation.