implement conv_rgba4444_rgb565

This commit is contained in:
notaz 2015-03-07 02:34:47 +02:00
parent e1dca5de36
commit 7f5a08e2cb
3 changed files with 29 additions and 0 deletions

View File

@ -359,6 +359,29 @@ void conv_rgba4444_argb8888(void *output_, const void *input_,
}
}
void conv_rgba4444_rgb565(void *output_, const void *input_,
int width, int height,
int out_stride, int in_stride)
{
int h, w;
const uint16_t *input = (const uint16_t*)input_;
uint16_t *output = (uint16_t*)output_;
for (h = 0; h < height;
h++, output += out_stride >> 1, input += in_stride >> 1)
{
for (w = 0; w < width; w++)
{
uint32_t col = input[w];
uint32_t r = (col >> 12) & 0xf;
uint32_t g = (col >> 8) & 0xf;
uint32_t b = (col >> 4) & 0xf;
output[w] = (r << 12) | (g << 7) | (b << 1);
}
}
}
#if defined(__SSE2__)
/* :( TODO: Make this saner. */
static inline void store_bgr24_sse2(void *output, __m128i a,

View File

@ -150,6 +150,8 @@ static bool set_direct_pix_conv(struct scaler_ctx *ctx)
case SCALER_FMT_RGBA4444:
if (ctx->out_fmt == SCALER_FMT_ARGB8888)
ctx->direct_pixconv = conv_rgba4444_argb8888;
else if (ctx->out_fmt == SCALER_FMT_RGB565)
ctx->direct_pixconv = conv_rgba4444_rgb565;
break;
case SCALER_FMT_ABGR8888:
/* FIXME/TODO */

View File

@ -45,6 +45,10 @@ void conv_rgba4444_argb8888(void *output, const void *input,
int width, int height,
int out_stride, int in_stride);
void conv_rgba4444_rgb565(void *output, const void *input,
int width, int height,
int out_stride, int in_stride);
void conv_bgr24_argb8888(void *output, const void *input,
int width, int height,
int out_stride, int in_stride);