diff options
Diffstat (limited to 'plugins/gpulib')
-rw-r--r-- | plugins/gpulib/cspace.c | 30 | ||||
-rw-r--r-- | plugins/gpulib/cspace.h | 1 |
2 files changed, 30 insertions, 1 deletions
diff --git a/plugins/gpulib/cspace.c b/plugins/gpulib/cspace.c index 8e3bee9..f0c4912 100644 --- a/plugins/gpulib/cspace.c +++ b/plugins/gpulib/cspace.c @@ -91,6 +91,35 @@ void bgr_to_uyvy_init(void) } } +void rgb565_to_uyvy(void *d, const void *s, int pixels) +{ + unsigned int *dst = d; + const unsigned short *src = s; + const unsigned char *yu = yuv_u + 32; + const unsigned char *yv = yuv_v + 32; + int r0, g0, b0, r1, g1, b1; + int y0, y1, u, v; + + for (; pixels > 0; src += 2, dst++, pixels -= 2) + { + r0 = (src[0] >> 11) & 0x1f; + g0 = (src[0] >> 6) & 0x1f; + b0 = src[0] & 0x1f; + r1 = (src[1] >> 11) & 0x1f; + g1 = (src[1] >> 6) & 0x1f; + b1 = src[1] & 0x1f; + y0 = (yuv_ry[r0] + yuv_gy[g0] + yuv_by[b0]) >> 16; + y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; + u = yu[b0 - y0]; + v = yv[r0 - y0]; + // valid Y range seems to be 16..235 + y0 = 16 + 219 * y0 / 31; + y1 = 16 + 219 * y1 / 31; + + *dst = (y1 << 24) | (v << 16) | (y0 << 8) | u; + } +} + void bgr555_to_uyvy(void *d, const void *s, int pixels) { unsigned int *dst = d; @@ -112,7 +141,6 @@ void bgr555_to_uyvy(void *d, const void *s, int pixels) y1 = (yuv_ry[r1] + yuv_gy[g1] + yuv_by[b1]) >> 16; u = yu[b0 - y0]; v = yv[r0 - y0]; - // valid Y range seems to be 16..235 y0 = 16 + 219 * y0 / 31; y1 = 16 + 219 * y1 / 31; diff --git a/plugins/gpulib/cspace.h b/plugins/gpulib/cspace.h index 95eae85..1a9e339 100644 --- a/plugins/gpulib/cspace.h +++ b/plugins/gpulib/cspace.h @@ -9,6 +9,7 @@ void bgr888_to_rgb565(void *dst, const void *src, int bytes); void rgb888_to_rgb565(void *dst, const void *src, int bytes); void bgr_to_uyvy_init(void); +void rgb565_to_uyvy(void *d, const void *s, int pixels); void bgr555_to_uyvy(void *d, const void *s, int pixels); void bgr888_to_uyvy(void *d, const void *s, int pixels); |