From 5ad02f701b8a34f4f7fada49989953b3c22e86e5 Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Sun, 18 Jan 2009 02:45:22 +0000 Subject: use multiply-shift to scale reciprocals for rgb16 output, instead of multiply-divide git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19788 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/pictureflow.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index b107227..2c59e1a 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c @@ -397,6 +397,9 @@ static inline PFreal fcos(int iangle) return fsin(iangle + (IANGLE_MAX >> 2)); } +#define RB_DIV ((31ULL << 32) / 255 + 1) +#define G_DIV ((63ULL << 32) / 255 + 1) + static void output_row_transposed(uint32_t row, void * row_in, struct scaler_context *ctx) { @@ -408,11 +411,11 @@ static void output_row_transposed(uint32_t row, void * row_in, *dest = ((*qp++) + ctx->round) * (uint64_t)ctx->divisor >> 32; #else struct uint32_rgb *qp = (struct uint32_rgb*)row_in; - uint32_t rb_mul = ((uint64_t)ctx->divisor * 31 + 127) / 255, - rb_rnd = ((uint64_t)ctx->round * 31 + 127) / 255, - g_mul = ((uint64_t)ctx->divisor * 63 + 127) / 255, - g_rnd = ((uint64_t)ctx->round * 63 + 127) / 255; - unsigned int r, g, b; + uint32_t rb_mul = ctx->divisor * (uint64_t)RB_DIV >> 32, + rb_rnd = ctx->round * (uint64_t)RB_DIV >> 32, + g_mul = ctx->divisor * (uint64_t)G_DIV >> 32, + g_rnd = ctx->round * (uint64_t)G_DIV >> 32; + int r, g, b; for (; dest < end; dest += ctx->bm->height) { r = (qp->r + rb_rnd) * (uint64_t)rb_mul >> 32; -- cgit v1.1