summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-01-18 02:45:22 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-01-18 02:45:22 +0000
commit5ad02f701b8a34f4f7fada49989953b3c22e86e5 (patch)
tree5242e51cd8575c14e767a5cb3a1b83aeca6b2eca /apps
parent0229ec679bc46c1f50e0222c91818e6c6356ae92 (diff)
downloadrockbox-5ad02f701b8a34f4f7fada49989953b3c22e86e5.zip
rockbox-5ad02f701b8a34f4f7fada49989953b3c22e86e5.tar.gz
rockbox-5ad02f701b8a34f4f7fada49989953b3c22e86e5.tar.bz2
rockbox-5ad02f701b8a34f4f7fada49989953b3c22e86e5.tar.xz
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
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/pictureflow.c13
1 files changed, 8 insertions, 5 deletions
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;