Commit 9e8ee610 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

renamed cpercep_init_conversions() to cpercep_init(); only initialize the

2005-07-05  Sven Neumann  <sven@gimp.org>

	* app/core/cpercep.[ch]: renamed cpercep_init_conversions() to
	cpercep_init(); only initialize the tables on the first call.

	* app/core/gimpimage-convert.c: changed accordingly.
parent 16f5f558
2005-07-05 Sven Neumann <sven@gimp.org>
* app/core/cpercep.[ch]: renamed cpercep_init_conversions() to
cpercep_init(); only initialize the tables on the first call.
* app/core/gimpimage-convert.c: changed accordingly.
2005-07-04 Sven Neumann <sven@gimp.org>
* plug-ins/common/psd_save.c: removed uesless g_malloc() wrapper.
......
......@@ -59,7 +59,7 @@ from the Author.
#ifndef __GLIBC__
/* cbrt() is a GNU extension */
#define cbrt(x) (pow(x, 1.0/3.0))
#define cbrt(x) (pow(x, 1.0/3.0))
#endif
#ifdef GIMP_COMPILATION
......@@ -244,14 +244,14 @@ rgbxyzrgb_init(void)
CMatrix MRC, MRCi;
double C1,C2,C3;
MRC[0][0] = pxr;
MRC[0][1] = pxg;
MRC[0][0] = pxr;
MRC[0][1] = pxg;
MRC[0][2] = pxb;
MRC[1][0] = pyr;
MRC[1][1] = pyg;
MRC[1][0] = pyr;
MRC[1][1] = pyg;
MRC[1][2] = pyb;
MRC[2][0] = 1.0F - (pxr + pyr);
MRC[2][1] = 1.0F - (pxg + pyg);
MRC[2][0] = 1.0F - (pxr + pyr);
MRC[2][1] = 1.0F - (pxg + pyg);
MRC[2][2] = 1.0F - (pxb + pyb);
Minvert (MRC, MRCi);
......@@ -305,15 +305,6 @@ rgb_to_xyz (double *inr_outx,
}
/* call this before using the CPercep function */
void
cpercep_init_conversions(void)
{
rgbxyzrgb_init();
}
static inline double
ffunc(const double t)
{
......@@ -369,7 +360,7 @@ xyz_to_lab (double *inx,
{
g_printerr (" <eek1>%f \007",(float)L);
}
if (L > 100.0F)
{
g_printerr (" <eek2>%f \007",(float)L);
......@@ -384,7 +375,7 @@ xyz_to_lab (double *inx,
ffuncY = ffunc(Y);
a = 500.0F * (ffunc(X/xnn) - ffuncY);
b = 200.0F * (ffuncY - ffunc(Z/znn));
*inx = L;
*iny = a;
*inz = b;
......@@ -446,10 +437,26 @@ lab_to_xyz (double *inl,
/* call this before using the CPercep function */
void
cpercep_init (void)
{
static gboolean initialized = FALSE;
if (! initialized)
{
rgbxyzrgb_init();
initialized = TRUE;
}
}
void
cpercep_rgb_to_space (double inr, double ing, double inb,
double* outr, double* outg, double* outb)
cpercep_rgb_to_space (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb)
{
#ifdef APPROX
#ifdef SANITY
......@@ -525,8 +532,12 @@ cpercep_rgb_to_space (double inr, double ing, double inb,
void
cpercep_space_to_rgb (double inr, double ing, double inb,
double* outr, double* outg, double* outb)
cpercep_space_to_rgb (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb)
{
lab_to_xyz(&inr, &ing, &inb);
......@@ -590,7 +601,7 @@ mix_colours (const double L1, const double a1, const double b1,
double mass1, double mass2)
{
double w1, w2;
#if 0
*rtnL = xscaler (L1, L2, mass1, mass2);
*rtna = xscaler (a1, a2, mass1, mass2);
......@@ -604,7 +615,7 @@ mix_colours (const double L1, const double a1, const double b1,
w1 = mass1 * (L1*L1*L1);
w2 = mass2 * (L2*L2*L2);
#endif
*rtnL = xscaler (L1, L2, mass1, mass2);
if (w1 <= 0.0 &&
......
#ifndef __CPERCEP_H__
#define __CPERCEP_H__
/*
Copyright (C) 1997-2002 Adam D. Moss (the "Author"). All Rights Reserved.
......@@ -33,16 +31,26 @@ from the Author.
TODO: document functions, rename erroneously-named arguments
*/
void
cpercep_init_conversions(void);
#ifndef __CPERCEP_H__
#define __CPERCEP_H__
void cpercep_init (void);
void
cpercep_rgb_to_space (double inr, double ing, double inb,
double* outr, double* outg, double* outb);
void cpercep_rgb_to_space (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb);
void cpercep_space_to_rgb (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb);
void
cpercep_space_to_rgb (double inr, double ing, double inb,
double* outr, double* outg, double* outb);
#if 0
/* This is in the header so that it can potentially be inlined. */
......@@ -53,24 +61,10 @@ cpercep_distance_space (const double L1, const double a1, const double b1,
const double Ld = L1 - L2;
const double ad = a1 - a2;
const double bd = b1 - b2;
return (Ld*Ld + ad*ad + bd*bd);
}
#endif
/* EXPERIMENTAL */
#if 0
void
mix_colours (const double L1, const double a1, const double b1,
const double L2, const double a2, const double b2,
double *rtnL, double *rtna, double *rtnb,
double mass1, double mass2);
/* util function */
const double
xscaler(const double start, const double end,
const double me, const double him);
#define MF(L) ((L)<=0.0 ? 0.0 : 1.0)
#endif /* EXPERIMENTAL */
#endif /* __CPERCEP_H__ */
......@@ -59,7 +59,7 @@ from the Author.
#ifndef __GLIBC__
/* cbrt() is a GNU extension */
#define cbrt(x) (pow(x, 1.0/3.0))
#define cbrt(x) (pow(x, 1.0/3.0))
#endif
#ifdef GIMP_COMPILATION
......@@ -244,14 +244,14 @@ rgbxyzrgb_init(void)
CMatrix MRC, MRCi;
double C1,C2,C3;
MRC[0][0] = pxr;
MRC[0][1] = pxg;
MRC[0][0] = pxr;
MRC[0][1] = pxg;
MRC[0][2] = pxb;
MRC[1][0] = pyr;
MRC[1][1] = pyg;
MRC[1][0] = pyr;
MRC[1][1] = pyg;
MRC[1][2] = pyb;
MRC[2][0] = 1.0F - (pxr + pyr);
MRC[2][1] = 1.0F - (pxg + pyg);
MRC[2][0] = 1.0F - (pxr + pyr);
MRC[2][1] = 1.0F - (pxg + pyg);
MRC[2][2] = 1.0F - (pxb + pyb);
Minvert (MRC, MRCi);
......@@ -305,15 +305,6 @@ rgb_to_xyz (double *inr_outx,
}
/* call this before using the CPercep function */
void
cpercep_init_conversions(void)
{
rgbxyzrgb_init();
}
static inline double
ffunc(const double t)
{
......@@ -369,7 +360,7 @@ xyz_to_lab (double *inx,
{
g_printerr (" <eek1>%f \007",(float)L);
}
if (L > 100.0F)
{
g_printerr (" <eek2>%f \007",(float)L);
......@@ -384,7 +375,7 @@ xyz_to_lab (double *inx,
ffuncY = ffunc(Y);
a = 500.0F * (ffunc(X/xnn) - ffuncY);
b = 200.0F * (ffuncY - ffunc(Z/znn));
*inx = L;
*iny = a;
*inz = b;
......@@ -446,10 +437,26 @@ lab_to_xyz (double *inl,
/* call this before using the CPercep function */
void
cpercep_init (void)
{
static gboolean initialized = FALSE;
if (! initialized)
{
rgbxyzrgb_init();
initialized = TRUE;
}
}
void
cpercep_rgb_to_space (double inr, double ing, double inb,
double* outr, double* outg, double* outb)
cpercep_rgb_to_space (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb)
{
#ifdef APPROX
#ifdef SANITY
......@@ -525,8 +532,12 @@ cpercep_rgb_to_space (double inr, double ing, double inb,
void
cpercep_space_to_rgb (double inr, double ing, double inb,
double* outr, double* outg, double* outb)
cpercep_space_to_rgb (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb)
{
lab_to_xyz(&inr, &ing, &inb);
......@@ -590,7 +601,7 @@ mix_colours (const double L1, const double a1, const double b1,
double mass1, double mass2)
{
double w1, w2;
#if 0
*rtnL = xscaler (L1, L2, mass1, mass2);
*rtna = xscaler (a1, a2, mass1, mass2);
......@@ -604,7 +615,7 @@ mix_colours (const double L1, const double a1, const double b1,
w1 = mass1 * (L1*L1*L1);
w2 = mass2 * (L2*L2*L2);
#endif
*rtnL = xscaler (L1, L2, mass1, mass2);
if (w1 <= 0.0 &&
......
#ifndef __CPERCEP_H__
#define __CPERCEP_H__
/*
Copyright (C) 1997-2002 Adam D. Moss (the "Author"). All Rights Reserved.
......@@ -33,16 +31,26 @@ from the Author.
TODO: document functions, rename erroneously-named arguments
*/
void
cpercep_init_conversions(void);
#ifndef __CPERCEP_H__
#define __CPERCEP_H__
void cpercep_init (void);
void
cpercep_rgb_to_space (double inr, double ing, double inb,
double* outr, double* outg, double* outb);
void cpercep_rgb_to_space (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb);
void cpercep_space_to_rgb (double inr,
double ing,
double inb,
double *outr,
double *outg,
double *outb);
void
cpercep_space_to_rgb (double inr, double ing, double inb,
double* outr, double* outg, double* outb);
#if 0
/* This is in the header so that it can potentially be inlined. */
......@@ -53,24 +61,10 @@ cpercep_distance_space (const double L1, const double a1, const double b1,
const double Ld = L1 - L2;
const double ad = a1 - a2;
const double bd = b1 - b2;
return (Ld*Ld + ad*ad + bd*bd);
}
#endif
/* EXPERIMENTAL */
#if 0
void
mix_colours (const double L1, const double a1, const double b1,
const double L2, const double a2, const double b2,
double *rtnL, double *rtna, double *rtnb,
double mass1, double mass2);
/* util function */
const double
xscaler(const double start, const double end,
const double me, const double him);
#define MF(L) ((L)<=0.0 ? 0.0 : 1.0)
#endif /* EXPERIMENTAL */
#endif /* __CPERCEP_H__ */
......@@ -850,7 +850,7 @@ gimp_image_convert (GimpImage *gimage,
g_object_set (gimage, "base-type", new_type, NULL);
/* initialize the colour conversion routines */
cpercep_init_conversions ();
cpercep_init ();
/* Convert to indexed? Build histogram if necessary. */
if (new_type == GIMP_INDEXED)
......
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