[babl] extension: make rgb8 to rgba8 conversion faster



commit 721cc3f835fc506694aa1a4ad186471093634a5e
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jun 29 20:15:11 2014 +0200

    extension: make rgb8 to rgba8 conversion faster
    
    For all pixels but the last one, do a 32bit load/store + 8bit immediate store
    instead of byte by byte copying.

 extensions/gggl.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
---
diff --git a/extensions/gggl.c b/extensions/gggl.c
index 29b4c51..5588759 100644
--- a/extensions/gggl.c
+++ b/extensions/gggl.c
@@ -943,20 +943,18 @@ conv_rgbA8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 static long
 conv_rgb8_rgba8 (unsigned char *src, unsigned char *dst, long samples)
 {
-  long n = samples;
-
+  long n = samples-1;
   while (n--)
     {
-      /**(unsigned int *) dst = *(unsigned int *) src;
-         dst[3] = 255;*/
-
-      dst[0] = src[0];
-      dst[1] = src[1];
-      dst[2] = src[2];
+      *(unsigned int *) dst = *(unsigned int *) src;
       dst[3] = 255;
       src   += 3;
       dst   += 4;
     }
+  dst[0] = src[0];
+  dst[1] = src[1];
+  dst[2] = src[2];
+  dst[3] = 255;
   return samples;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]