[babl] babl-icc: implement LUT TRC place holder code
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] babl-icc: implement LUT TRC place holder code
- Date: Wed, 23 Aug 2017 20:45:19 +0000 (UTC)
commit 84f151f0f0bc2af27f4a2a5a5bc8b27203727277
Author: Øyvind Kolås <pippin gimp org>
Date: Wed Aug 23 22:16:51 2017 +0200
babl-icc: implement LUT TRC place holder code
babl/babl-icc.c | 3 ---
babl/babl-trc.c | 8 +++++++-
babl/babl-trc.h | 19 +++++++++++++++++--
3 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/babl/babl-icc.c b/babl/babl-icc.c
index e526480..f48a9e0 100644
--- a/babl/babl-icc.c
+++ b/babl/babl-icc.c
@@ -325,9 +325,6 @@ static const Babl *babl_trc_lut_find (float *lut, int lut_size)
{
for (i = 0; match && i < lut_size; i++)
{
- fprintf (stderr, "%i: %f %f\n",
- i, lut[i], gamma_2_2_to_linear (i / (lut_size-1.0)));
-
if (fabs (lut[i] - gamma_2_2_to_linear (i / (lut_size-1.0))) > 0.015)
match = 0;
}
diff --git a/babl/babl-trc.c b/babl/babl-trc.c
index e2f9838..49ff6fd 100644
--- a/babl/babl-trc.c
+++ b/babl/babl-trc.c
@@ -90,11 +90,17 @@ babl_trc_new (const char *name,
if (n_lut)
{
+ int j;
trc_db[i].lut_size = n_lut;
trc_db[i].lut = babl_calloc (sizeof (float), n_lut);
memcpy (trc_db[i].lut, lut, sizeof (float) * n_lut);
+ trc_db[i].inv_lut = babl_calloc (sizeof (float), n_lut);
+ for (j = 0; j < n_lut; j++)
+ trc_db[i].inv_lut[j] =
+ babl_trc_to_linear (BABL(&trc_db[i]), trc_db[i].lut[(int) ( j/(n_lut-1.0) * (n_lut-1))]);
+
}
-
+
return (Babl*)&trc_db[i];
}
diff --git a/babl/babl-trc.h b/babl/babl-trc.h
index abcf2e2..abdf52a 100644
--- a/babl/babl-trc.h
+++ b/babl/babl-trc.h
@@ -38,16 +38,31 @@ typedef struct
double gamma;
char name[128];
float *lut;
+ float *inv_lut;
} BablTRC;
static inline double babl_trc_lut_from_linear (const Babl *trc_, double value)
{
- return 0;
+ BablTRC *trc = (void*)trc_;
+ int entry = value * trc->lut_size + 0.5;
+ double ret = trc->inv_lut[
+ (entry >= 0 && entry < trc->lut_size) ?
+ entry :
+ trc->lut_size-1];
+ /* XXX: fixme, do linear interpolation */
+ return ret;
}
static inline double babl_trc_lut_to_linear (const Babl *trc_, double value)
{
- return 0;
+ BablTRC *trc = (void*)trc_;
+ int entry = value * trc->lut_size + 0.5;
+ double ret = trc->lut[
+ (entry >= 0 && entry < trc->lut_size) ?
+ entry :
+ trc->lut_size-1];
+ /* XXX: fixme, do linear interpolation */
+ return ret;
}
static inline double _babl_trc_from_linear (const Babl *trc_, double value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]