Commit 1a6161f0 authored by Michael Natterer's avatar Michael Natterer 😴

Pull the pointer into the GeglLookupFunction typedef; formatting

parent b0d8f540
......@@ -23,11 +23,12 @@
#include "gegl.h"
#include "gegl-lookup.h"
GeglLookup *gegl_lookup_new_full (GeglLookupFunction *function,
gpointer data,
gfloat start,
gfloat end,
gfloat precision)
GeglLookup *
gegl_lookup_new_full (GeglLookupFunction function,
gpointer data,
gfloat start,
gfloat end,
gfloat precision)
{
GeglLookup *lookup;
union
......@@ -106,13 +107,13 @@ GeglLookup *gegl_lookup_new_full (GeglLookupFunction *function,
positive_min = positive_max = negative_min = negative_max = 0;
}
if ((positive_max-positive_min)+ (negative_max-negative_min) > GEGL_LOOKUP_MAX_ENTRIES)
if ((positive_max-positive_min) + (negative_max-negative_min) > GEGL_LOOKUP_MAX_ENTRIES)
{
/* Reduce the size of the cache tables to fit within the bittable
* budget (the maximum allocation is around 2.18mb of memory
*/
gint diff = (positive_max-positive_min)+ (negative_max-negative_min) - GEGL_LOOKUP_MAX_ENTRIES;
gint diff = (positive_max-positive_min) + (negative_max-negative_min) - GEGL_LOOKUP_MAX_ENTRIES;
if (negative_max - negative_min > 0)
{
......@@ -131,10 +132,10 @@ GeglLookup *gegl_lookup_new_full (GeglLookupFunction *function,
positive_max-=diff;
}
lookup = g_malloc0 (sizeof (GeglLookup) + sizeof (gfloat) *
lookup = g_malloc0 (sizeof (GeglLookup) + sizeof (gfloat) *
((positive_max-positive_min)+
(negative_max-negative_min)));
(negative_max-negative_min)));
lookup->positive_min = positive_min;
lookup->positive_max = positive_max;
lookup->negative_min = negative_min;
......@@ -142,11 +143,13 @@ GeglLookup *gegl_lookup_new_full (GeglLookupFunction *function,
lookup->shift = shift;
lookup->function = function;
lookup->data = data;
return lookup;
}
GeglLookup *gegl_lookup_new (GeglLookupFunction *function,
gpointer data)
GeglLookup *
gegl_lookup_new (GeglLookupFunction function,
gpointer data)
{
return gegl_lookup_new_full (function, data, 0, 1.0, 0.000010);
}
......
......@@ -21,29 +21,30 @@
G_BEGIN_DECLS
typedef gfloat (GeglLookupFunction) (float, gpointer data);
typedef gfloat (* GeglLookupFunction) (gfloat value,
gpointer data);
#define GEGL_LOOKUP_MAX_ENTRIES (819200)
typedef struct GeglLookup
{
GeglLookupFunction *function;
gpointer data;
gint shift;
guint32 positive_min, positive_max, negative_min, negative_max;
guint32 bitmask[GEGL_LOOKUP_MAX_ENTRIES/32];
gfloat table[];
GeglLookupFunction function;
gpointer data;
gint shift;
guint32 positive_min, positive_max, negative_min, negative_max;
guint32 bitmask[GEGL_LOOKUP_MAX_ENTRIES/32];
gfloat table[];
} GeglLookup;
GeglLookup *gegl_lookup_new_full (GeglLookupFunction *function,
gpointer data,
gfloat start,
gfloat end,
gfloat precision);
GeglLookup *gegl_lookup_new (GeglLookupFunction *function,
gpointer data);
void gegl_lookup_free (GeglLookup *lookup);
GeglLookup *gegl_lookup_new_full (GeglLookupFunction function,
gpointer data,
gfloat start,
gfloat end,
gfloat precision);
GeglLookup *gegl_lookup_new (GeglLookupFunction function,
gpointer data);
void gegl_lookup_free (GeglLookup *lookup);
static inline gfloat
......@@ -73,7 +74,8 @@ gegl_lookup (GeglLookup *lookup,
{
lookup->table[index]= lookup->function (number, lookup->data);
lookup->bitmask[index/32] |= (1<<(index & 31));
}
}
return lookup->table[index];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment