[babl] babl: performance improvement in model-gray



commit 788564e25e0629858216363b642e918a6f61c136
Author: Thomas Manni <thomas manni free fr>
Date:   Mon Jun 24 12:12:38 2019 +0200

    babl: performance improvement in model-gray
    
    Use multiplication by the inverse instead of division in
    premultiplied to non-premultiplied alpha conversion functions.

 babl/base/model-gray.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/babl/base/model-gray.c b/babl/base/model-gray.c
index 2031b22..cfc251e 100644
--- a/babl/base/model-gray.c
+++ b/babl/base/model-gray.c
@@ -565,10 +565,11 @@ premultiplied_to_non_premultiplied (Babl  *conversion,
       int    band;
       double alpha = *(double *) src[src_bands-1];
       double used_alpha = babl_epsilon_for_zero (alpha);
+      double recip_alpha = 1.0 / used_alpha;
 
       for (band = 0; band < src_bands - 1; band++)
         {
-          *(double *) dst[band] = *(double *) src[band] / used_alpha;
+          *(double *) dst[band] = *(double *) src[band] * recip_alpha;
         }
       *(double *) dst[dst_bands - 1] = alpha;
 
@@ -1398,10 +1399,11 @@ premultiplied_to_non_premultiplied_float (Babl  *conversion,
       int    band;
       float alpha = *(float *) src[src_bands-1];
       float used_alpha = babl_epsilon_for_zero_float (alpha);
+      float recip_alpha  = 1.0f / used_alpha;
 
       for (band = 0; band < src_bands - 1; band++)
         {
-          *(float *) dst[band] = *(float *) src[band] / used_alpha;
+          *(float *) dst[band] = *(float *) src[band] * recip_alpha;
         }
       *(float *) dst[dst_bands - 1] = alpha;
 


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