[babl] extensions: use more integer instructions for float lookups
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] extensions: use more integer instructions for float lookups
- Date: Sun, 29 Jun 2014 19:25:48 +0000 (UTC)
commit d528f05d2d3571201a85231664471a02119127e1
Author: Øyvind Kolås <pippin gimp org>
Date: Sun Jun 29 21:22:14 2014 +0200
extensions: use more integer instructions for float lookups
extensions/gggl.c | 53 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 43 insertions(+), 10 deletions(-)
---
diff --git a/extensions/gggl.c b/extensions/gggl.c
index 5588759..e9fc1d9 100644
--- a/extensions/gggl.c
+++ b/extensions/gggl.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <math.h>
#include <string.h>
+#include <stdint.h>
#include "babl.h"
#include "extensions/util.h"
@@ -58,6 +59,7 @@ static float table_16_F[1 << 16];
static unsigned char table_F_8[1 << 16];
static unsigned short table_F_16[1 << 16];
+static uint32_t *table_8_F_int = NULL;
static int table_inited = 0;
@@ -66,6 +68,9 @@ table_init (void)
{
if (table_inited)
return;
+
+ table_8_F_int = (void*)(table_8_F);
+
table_inited = 1;
/* fill tables for conversion from integer to float */
@@ -189,7 +194,7 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
table_init ();
while (n--)
{
- (*(float *) dst) = table_8_F[*(unsigned char *) src];
+ (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
dst += 4;
src += 1;
}
@@ -197,6 +202,30 @@ conv_8_F (unsigned char *src, unsigned char *dst, long samples)
}
static long
+conv_rgb8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
+{
+ long n = samples;
+
+ if (!table_inited)
+ table_init ();
+ while (n--)
+ {
+ (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+ dst += 4;
+ src += 1;
+ (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+ dst += 4;
+ src += 1;
+ (*(uint32_t *) dst) = table_8_F_int[*(unsigned char *) src];
+ dst += 4;
+ src += 1;
+ (*(float *) dst) = 1.0;
+ dst += 4;
+ }
+ return samples;
+}
+
+static long
conv_16_F (unsigned char *src, unsigned char *dst, long samples)
{
long n = samples;
@@ -459,6 +488,7 @@ conv_rgba8_rgbaF (unsigned char *src, unsigned char *dst, long samples)
return conv_8_F (src, dst, samples * 4) / 4;
}
+
static long
conv_rgb8_rgbF (unsigned char *src, unsigned char *dst, long samples)
{
@@ -613,13 +643,13 @@ conv_rgbaF_rgbF (unsigned char *src, unsigned char *dst, long samples)
while (n--)
{
- *(float *) dst = (*(float *) src);
+ *(uint32_t *) dst = (*(uint32_t *) src);
dst += 4;
src += 4;
- *(float *) dst = (*(float *) src);
+ *(uint32_t *) dst = (*(uint32_t *) src);
dst += 4;
src += 4;
- *(float *) dst = (*(float *) src);
+ *(uint32_t *) dst = (*(uint32_t *) src);
dst += 4;
src += 4;
src += 4;
@@ -634,21 +664,24 @@ conv_rgbF_rgbaF (unsigned char *src, unsigned char *dst, long samples)
while (n--)
{
- *(float *) dst = (*(float *) src);
+ *(uint32_t *) dst = (*(uint32_t *) src);
src += 4;
dst += 4;
- *(float *) dst = (*(float *) src);
+ *(uint32_t *) dst = (*(uint32_t *) src);
src += 4;
dst += 4;
- *(float *) dst = (*(float *) src);
+ *(uint32_t *) dst = (*(uint32_t *) src);
src += 4;
dst += 4;
- *(float *) dst = 1.0;
+ *(uint32_t *) dst = 1.0;
dst += 4;
}
return samples;
}
+#define conv_rgbF_rgbAF conv_rgbF_rgbaF
+
+
static long
conv_gaF_gF (unsigned char *src, unsigned char *dst, long samples)
{
@@ -946,8 +979,7 @@ conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
long n = samples-1;
while (n--)
{
- *(unsigned int *) dst = *(unsigned int *) src;
- dst[3] = 255;
+ *(unsigned int *) dst = (*(unsigned int *) src) | (255 << 24);
src += 3;
dst += 4;
}
@@ -1308,6 +1340,7 @@ init (void)
o (rgbA16, rgbaF);
o (rgbaF, rgbaD);
o (rgbaD, rgbaF);
+ o (rgb8, rgbaF);
#ifdef USE_TABLES
if (!table_inited)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]