[babl] babl: add performance flag to intent, issue #21



commit c153fec67e0eb15d8ca15d5f019d239c01e0c12b
Author: Øyvind Kolås <pippin gimp org>
Date:   Tue Aug 21 18:08:47 2018 +0200

    babl: add performance flag to intent, issue #21
    
    Add BABL_ICC_INTENT_PERFORMANCE which can be ored into the intente
    num when requesting that babl constructs a space using
    babl_space_from_icc, when PERFORMANCE is requested babl will permit
    matrix+trc over cLUT, and when it is an intent without a performance
    modifier this does not apply.

 babl/babl-icc.c | 38 +++++++++++++++++++++-----------------
 babl/babl.h     |  5 ++++-
 2 files changed, 25 insertions(+), 18 deletions(-)
---
diff --git a/babl/babl-icc.c b/babl/babl-icc.c
index 8363885..f463e9e 100644
--- a/babl/babl-icc.c
+++ b/babl/babl-icc.c
@@ -734,10 +734,10 @@ babl_space_from_icc (const char   *icc_data,
   const Babl *trc_blue  = NULL;
   const char *int_err;
   Babl *ret = NULL;
+  int speed_over_accuracy = intent & BABL_ICC_INTENT_PERFORMANCE;
 
   sign_t profile_class, color_space, pcs;
 
-
   if (!error) error = &int_err;
   *error = NULL;
 
@@ -745,23 +745,17 @@ babl_space_from_icc (const char   *icc_data,
   {
     *error = "icc profile length inconsistency";
   }
-#if 0
-  else if (icc_ver_major > 2)
-  {
-    *error = "only ICC v2 profiles supported";
-  }
-#endif
-  else
-  {
-  profile_class = icc_read (sign, 12);
-  if (strcmp (profile_class.str, "mntr"))
-    *error = "not a monitor-class profile";
   else
   {
-    color_space = icc_read (sign, 16);
-    if (strcmp (color_space.str, "RGB "))
-      *error = "not defining an RGB space";
-  }
+    profile_class = icc_read (sign, 12);
+    if (strcmp (profile_class.str, "mntr"))
+      *error = "not a monitor-class profile";
+     else
+    {
+      color_space = icc_read (sign, 16);
+      if (strcmp (color_space.str, "RGB "))
+        *error = "not defining an RGB space";
+    }
   }
 
   if (!*error)
@@ -771,11 +765,21 @@ babl_space_from_icc (const char   *icc_data,
       *error = "PCS is not XYZ";
   }
 
-  switch (intent)
+  if (!*error)
+  switch (intent & 7) /* enum of intent is in lowest bits */
   {
     case BABL_ICC_INTENT_RELATIVE_COLORIMETRIC:
       /* that is what we do well */
 
+      if (!speed_over_accuracy)
+      {
+        if (icc_tag (state, "A2B0", NULL, NULL) &&
+            icc_tag (state, "B2A0", NULL, NULL))
+        {
+          *error = "use lcms, accuracy desired and cluts are present";
+        }
+      }
+
       break;
     case BABL_ICC_INTENT_PERCEPTUAL:
       /* if there is an A2B0 and B2A0 tags, we do not do what that
diff --git a/babl/babl.h b/babl/babl.h
index baddd44..2e0735d 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -104,7 +104,9 @@ typedef enum {
   BABL_ICC_INTENT_PERCEPTUAL             = 0,
   BABL_ICC_INTENT_RELATIVE_COLORIMETRIC  = 1,
   BABL_ICC_INTENT_SATURATION             = 2,
-  BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC  = 3
+  BABL_ICC_INTENT_ABSOLUTE_COLORIMETRIC  = 3,
+  BABL_ICC_INTENT_PERFORMANCE            = 32
+  // black-point compensation toggle will be added if/when support exist in babl
 } BablIccIntent;
 
 /**
@@ -135,6 +137,7 @@ const Babl *babl_space_from_icc (const char       *icc_data,
                                  BablIccIntent     intent,
                                  const char      **error);
 
+
 // XXX : deprecated
 const Babl *babl_icc_make_space (const char       *icc_data,
                                  int               icc_length,


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