summaryrefslogtreecommitdiff
path: root/babl
diff options
context:
space:
mode:
authorKevin Cozens <kcozens@cvs.gnome.org>2006-09-11 04:37:43 +0000
committerKevin Cozens <kcozens@src.gnome.org>2006-09-11 04:37:43 +0000
commitddce56797d2d71cc29ded4f609d5ceeba37fb3cd (patch)
treeec7f8a7e426fad17d90c6c123b6e67e2689a300b /babl
parent7c1697dba3703a8fa7e9353414692947625a6ac1 (diff)
babl/babl-classes.h babl/babl-conversion.c babl/babl-fish-path.c
2006-09-10 Kevin Cozens <kcozens@cvs.gnome.org> * babl/babl-classes.h * babl/babl-conversion.c * babl/babl-fish-path.c * babl/babl-fish-stats.c * babl/babl-internal.c: Tick times are in usecs not msecs. Use longs to hold tick values. * babl/babl-util.h: * babl/babl-util.c (babl_ticks): Fixed calculation of time (usecs not msecs). Changed declaration to return a long not unsigned int.
Diffstat (limited to 'babl')
-rw-r--r--babl/babl-classes.h10
-rw-r--r--babl/babl-conversion.c60
-rw-r--r--babl/babl-fish-path.c34
-rw-r--r--babl/babl-fish-stats.c14
-rw-r--r--babl/babl-internal.c6
-rw-r--r--babl/babl-util.c14
-rw-r--r--babl/babl-util.h3
7 files changed, 71 insertions, 70 deletions
diff --git a/babl/babl-classes.h b/babl/babl-classes.h
index 24ca3db..7f83ba9 100644
--- a/babl/babl-classes.h
+++ b/babl/babl-classes.h
@@ -93,7 +93,7 @@ BablConversion {
BablInstance instance;
union Babl *source;
union Babl *destination;
- int cost;
+ long cost;
double error;
union
{
@@ -171,7 +171,7 @@ typedef struct
BablModel *model;
int bytes_per_pixel;
int planar;
- double loss; /*< average relative error when converting
+ double loss; /*< average relative error when converting
from and to RGBA double */
} BablFormat;
@@ -202,7 +202,7 @@ typedef struct
/* instrumentation */
int processings; /* number of times the fish has been used */
long pixels; /* number of pixels translates */
- long msecs; /* msecs spent within this fish */
+ long usecs; /* usecs spent within this fish */
} BablFish;
@@ -242,7 +242,7 @@ typedef struct
BablConversion *conversion[BABL_HARD_MAX_PATH_LENGTH];
} BablFishPath;
-/* BablFishReference
+/* BablFishReference
*
* A BablFishReference is not intended to be fast, thus the algorithm
* encoded can use a multi stage approach, based on the knowledge babl
@@ -264,7 +264,7 @@ typedef struct
{
BablInstance instance; /* path to .so / .dll is stored in instance name */
void *dl_handle;
- void (*destroy) (void);
+ void (*destroy) (void);
} BablExtension;
typedef union
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
index 53721d5..88ebafd 100644
--- a/babl/babl-conversion.c
+++ b/babl/babl-conversion.c
@@ -23,7 +23,7 @@
#include <stdarg.h>
#include <math.h>
-static int
+static int
each_babl_conversion_destroy (Babl *babl,
void *data)
{
@@ -37,7 +37,7 @@ conversion_new (const char *name,
Babl *source,
Babl *destination,
BablFuncLinear linear,
- BablFuncPlane plane,
+ BablFuncPlane plane,
BablFuncPlanar planar)
{
Babl *babl = NULL;
@@ -101,7 +101,7 @@ conversion_new (const char *name,
babl->conversion.source = (union Babl*)source;
babl->conversion.destination = (union Babl*)destination;
babl->conversion.error = -1.0;
- babl->conversion.cost = 69;
+ babl->conversion.cost = 69L;
babl->conversion.pixels = 0;
babl->conversion.processings = 0;
@@ -131,7 +131,7 @@ conversion_new (const char *name,
}
babl_conversion_new (
src_format,
- dst_format,
+ dst_format,
"linear", linear,
NULL);
babl->conversion.error = 0.0;
@@ -194,21 +194,21 @@ babl_conversion_new (void *first_arg,
assert (BABL_IS_BABL(source));
assert (BABL_IS_BABL(destination));
-
-
+
+
while (arg)
{
-
+
if (!strcmp (arg, "id"))
{
id = va_arg (varg, int);
}
-
+
else if (!strcmp (arg, "linear"))
{
if (got_func++)
{
- babl_fatal ("already got a conversion func\n");
+ babl_fatal ("already got a conversion func\n");
}
linear = va_arg (varg, BablFuncLinear);
}
@@ -217,7 +217,7 @@ babl_conversion_new (void *first_arg,
{
if (got_func++)
{
- babl_fatal ("already got a conversion func\n");
+ babl_fatal ("already got a conversion func\n");
}
plane = va_arg (varg, BablFuncPlane);
}
@@ -226,7 +226,7 @@ babl_conversion_new (void *first_arg,
{
if (got_func++)
{
- babl_fatal ("already got a conversion func\n");
+ babl_fatal ("already got a conversion func\n");
}
planar = va_arg (varg, BablFuncPlanar);
}
@@ -238,7 +238,7 @@ babl_conversion_new (void *first_arg,
arg = va_arg (varg, char *);
}
-
+
va_end (varg);
assert (source);
@@ -259,7 +259,7 @@ babl_conversion_new (void *first_arg,
babl = conversion_new (create_name (source, destination, type),
id, source, destination, linear, plane, planar);
- {
+ {
Babl *ret = babl_db_insert (db, babl);
if (ret!=babl)
babl_free (babl);
@@ -301,14 +301,14 @@ babl_conversion_planar_process (BablConversion *conversion,
#ifdef USE_ALLOCA
void **src_data = alloca (sizeof (void*) * source->components);
void **dst_data = alloca (sizeof (void*) * destination->components);
-#else
+#else
void *src_data[BABL_MAX_COMPONENTS];
void *dst_data[BABL_MAX_COMPONENTS];
#endif
memcpy (src_data, source->data, sizeof (void*) * source->components);
memcpy (dst_data, destination->data, sizeof (void*) * destination->components);
-
+
return conversion->function.planar (source->components,
src_data,
source->pitch,
@@ -340,7 +340,7 @@ babl_conversion_process (Babl *babl,
if (BABL_IS_BABL(source))
{
BablImage *img;
-
+
img = (BablImage*)source;
src_data = img->data[0];
src_pitch = img->pitch[0];
@@ -348,7 +348,7 @@ babl_conversion_process (Babl *babl,
if (BABL_IS_BABL(destination))
{
BablImage *img = (BablImage*)destination;
-
+
dst_data = img->data[0];
dst_pitch = img->pitch[0];
}
@@ -373,18 +373,18 @@ babl_conversion_process (Babl *babl,
babl_assert (BABL_IS_BABL (destination));
babl_conversion_planar_process ( conversion,
- (BablImage*) source,
+ (BablImage*) source,
(BablImage*) destination,
n);
break;
case BABL_CONVERSION_LINEAR:
- /* the assertions relied on a babl_malloc structure
+ /* the assertions relied on a babl_malloc structure
*
* babl_assert (!BABL_IS_BABL (source));
babl_assert (!BABL_IS_BABL (destination));*/
babl_conversion_linear_process (conversion,
- source,
+ source,
destination,
n);
break;
@@ -409,7 +409,7 @@ test_create (void)
{
double *test;
int i;
-
+
srandom (20050728);
test = babl_malloc (sizeof (double) * test_pixels * 4);
@@ -423,12 +423,12 @@ long
babl_conversion_cost (BablConversion *conversion)
{
if (!conversion)
- return 100000000.0;
+ return 100000000L;
if (conversion->error==-1.0)
babl_conversion_error (conversion);
return conversion->cost;
}
-
+
double
babl_conversion_error (BablConversion *conversion)
{
@@ -445,10 +445,10 @@ babl_conversion_error (BablConversion *conversion)
NULL);
double error = 0.0;
- unsigned int ticks_start = 0;
- unsigned int ticks_end = 0;
-
- double *test;
+ long ticks_start = 0;
+ long ticks_end = 0;
+
+ double *test;
void *source;
void *destination;
double *destination_rgba_double;
@@ -488,7 +488,7 @@ babl_conversion_error (BablConversion *conversion)
{
return conversion->error;
}
-
+
test=test_create ();
@@ -497,7 +497,7 @@ babl_conversion_error (BablConversion *conversion)
ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
-
+
babl_process (fish_rgba_to_source,
test, source, test_pixels);
@@ -526,7 +526,7 @@ babl_conversion_error (BablConversion *conversion)
fish_reference->fish.pixels -= test_pixels;
fish_destination_to_rgba->fish.pixels -= 2 * test_pixels;
-
+
babl_free (source);
babl_free (destination);
babl_free (destination_rgba_double);
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 092ca6c..d3e4428 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -147,7 +147,7 @@ get_conversion_chain (Babl *from,
format.from)
babl_list_each (
- (void **)
+ (void **)
BABL(temp_chain[temp_conversions-1]->destination)->
format.from,
chain_gen_each,
@@ -185,7 +185,7 @@ chain_gen_each (Babl *babl,
if ((BABL(babl->conversion.destination) == c->to) )
{
/* a candidate path has been found */
-
+
double temp_cost = 0.0;
double temp_error = 1.0;
int i;
@@ -195,11 +195,11 @@ chain_gen_each (Babl *babl,
temp_error *= (1.0+babl_conversion_error (c->temp_chain[i]));
temp_cost += babl_conversion_cost (c->temp_chain[i]);
}
-
+
if (temp_cost < *c->best_cost &&
temp_error - 1.0 <= legal_error() && /* this check before the next; which does a more accurate
measurement of the error */
- (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error()
+ (temp_error=chain_error (c->from, c->to, c->temp_chain, c->temp_conversions+1)) <= legal_error()
)
{
int i;
@@ -292,7 +292,7 @@ babl_fish_path (Babl *source,
babl->fish.processings = 0;
babl->fish.pixels = 0;
- babl->fish.msecs = 0;
+ babl->fish.usecs = 0;
babl->fish.error = 200000;
babl->fish_path.cost = 200000;
@@ -302,7 +302,7 @@ babl_fish_path (Babl *source,
babl_assert (source->class_type == BABL_FORMAT);
babl_assert (destination->class_type == BABL_FORMAT);
-
+
get_conversion_chain (source,
destination,
&babl->fish_path.cost,
@@ -311,7 +311,7 @@ babl_fish_path (Babl *source,
(BablConversion**)(babl->fish_path.conversion),
&babl->fish_path.conversions,
temp_chain,
- 0,
+ 0,
max_path_length ());
if (babl->fish_path.conversions==0)
@@ -319,8 +319,8 @@ babl_fish_path (Babl *source,
babl_free (babl);
return NULL;
}
-
- {
+
+ {
Babl *ret = babl_db_insert (babl_fish_db (), babl);
if (ret!=babl)
babl_free (babl);
@@ -338,15 +338,15 @@ chain_process (BablConversion *chain[],
void *bufA = NULL;
void *bufB = NULL;
int i;
-
+
babl_assert (source);
babl_assert (destination);
-
+
if (conversions > 1)
bufA = babl_malloc (n * sizeof (double) * 5);
if (conversions > 2)
bufB = babl_malloc (n * sizeof (double) * 5);
-
+
for (i=0; i<conversions; i++)
{
if (i==0 && conversions == 1)
@@ -422,7 +422,7 @@ test_create (void)
{
double *test;
int i;
-
+
srandom (20050728);
test = babl_malloc (sizeof (double) * test_pixels * 4);
@@ -449,8 +449,8 @@ chain_error (Babl *fmt_source,
NULL);
double error = 0.0;
-
- double *test;
+
+ double *test;
void *source;
void *destination;
double *destination_rgba_double;
@@ -469,8 +469,8 @@ chain_error (Babl *fmt_source,
ref_destination = babl_calloc (test_pixels, fmt_destination->format.bytes_per_pixel);
destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
ref_destination_rgba_double = babl_calloc (test_pixels, fmt_rgba_double->format.bytes_per_pixel);
-
- /* create sourcebuffer from testbuffer in the correct format */
+
+ /* create sourcebuffer from testbuffer in the correct format */
babl_process (fish_rgba_to_source,
test, source, test_pixels);
diff --git a/babl/babl-fish-stats.c b/babl/babl-fish-stats.c
index e02e6d3..66403a2 100644
--- a/babl/babl-fish-stats.c
+++ b/babl/babl-fish-stats.c
@@ -42,11 +42,11 @@ table_destination_each (Babl *babl,
babl_assert (fish);
-
+
switch (fish->class_type)
{
case BABL_FISH_PATH:
-
+
fprintf (output_file, "<td class='cell'%s><a href='javascript:o()'>%s",
fish->fish.processings > 0 ? " style='background-color: #69f'":"",
utf8_bar[fish->fish_path.conversions]);
@@ -57,7 +57,7 @@ table_destination_each (Babl *babl,
fprintf (output_file, "<h3><span class='g'>path</span> %s <span class='g'>to</span> %s</h3>", source->instance.name, destination->instance.name);
if (fish->fish.processings > 0)
{
- fprintf (output_file, "<span class='g'>msecs:</span>%li<br/>", fish->fish.msecs);
+ fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
}
@@ -96,7 +96,7 @@ table_destination_each (Babl *babl,
if (fish->fish.processings > 0)
{
- fprintf (output_file, "<span class='g'>msecs:</span>%li<br/>", fish->fish.msecs);
+ fprintf (output_file, "<span class='g'>usecs:</span>%li<br/>", fish->fish.usecs);
fprintf (output_file, "<span class='g'>Processings:</span>%i<br/>", fish->fish.processings);
fprintf (output_file, "<span class='g'>Pixels:</span>%li<br/>", fish->fish.pixels);
}
@@ -144,7 +144,7 @@ table_source_each (Babl *babl,
break;
}
}
-
+
fprintf (output_file, "<tr>");
fprintf (output_file, "<td class='format_name'><a href='javascript:o();'>%s", expanded_name);
{
@@ -201,7 +201,7 @@ each_conv (Babl *babl,
fprintf (output_file, "<em>error:</em> %f <em>cost:</em> %4.0f <em>processings:</em> %i <em>pixels:</em> %li", error, cost,
babl->conversion.processings, babl->conversion.pixels);
fprintf (output_file, "</dd>");
-
+
return 0;
}
@@ -218,7 +218,7 @@ babl_fish_stats (FILE *file)
{
output_file = file;
- fprintf (output_file,
+ fprintf (output_file,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
"<html>\n"
diff --git a/babl/babl-internal.c b/babl/babl-internal.c
index 73af012..46bd660 100644
--- a/babl/babl-internal.c
+++ b/babl/babl-internal.c
@@ -91,7 +91,7 @@ babl_process (Babl *babl,
if (babl->class_type >= BABL_CONVERSION &&
babl->class_type <= BABL_CONVERSION_PLANAR)
return babl_conversion_process (babl, source, destination, n);
-
+
if (babl->class_type == BABL_FISH ||
babl->class_type == BABL_FISH_REFERENCE ||
babl->class_type == BABL_FISH_PATH ||
@@ -102,9 +102,9 @@ babl_process (Babl *babl,
ret = babl_fish_process (babl, source, destination, n);
ticks -= babl_ticks();
- ticks *= -1;
+ ticks *= -1L;
- babl->fish.msecs += ticks;
+ babl->fish.usecs += ticks;
babl->fish.processings++;
babl->fish.pixels += ret;
return ret;
diff --git a/babl/babl-util.c b/babl/babl-util.c
index 032ee60..8ba7278 100644
--- a/babl/babl-util.c
+++ b/babl/babl-util.c
@@ -28,7 +28,7 @@ static int list_length (void **list)
{
void **ptr;
int len=0;
-
+
ptr = list;
while (NULL!=*ptr)
{
@@ -43,13 +43,13 @@ babl_add_ptr_to_list (void ***list,
void *new)
{
int orig_len=0;
-
+
if (*list)
{
orig_len = list_length (*list);
}
- *list = babl_realloc ( (*list),
+ *list = babl_realloc ( (*list),
sizeof(void *) * (orig_len + 2));
if (!(*list))
@@ -82,7 +82,7 @@ babl_list_each (void **list,
static struct timeval start_time;
static struct timeval measure_time;
-#define msecs(time) ((time.tv_sec-start_time.tv_sec)*10000000 + time.tv_usec)
+#define usecs(time) ((time.tv_sec-start_time.tv_sec)*1000000 + time.tv_usec)
static void
init_ticks (void)
@@ -94,12 +94,12 @@ init_ticks (void)
gettimeofday (&start_time, NULL);
}
-unsigned int
+long
babl_ticks (void)
{
init_ticks ();
gettimeofday (&measure_time, NULL);
- return msecs(measure_time) - msecs(start_time);
+ return usecs(measure_time) - usecs(start_time);
}
double
@@ -108,7 +108,7 @@ babl_rel_avg_error (double *imgA,
long samples)
{
double error = 0.0;
- int i;
+ long i;
for (i=0; i<samples; i++)
error += fabs (imgA[i] - imgB[i]);
diff --git a/babl/babl-util.h b/babl/babl-util.h
index be6c9bc..b49ca7b 100644
--- a/babl/babl-util.h
+++ b/babl/babl-util.h
@@ -30,7 +30,8 @@ babl_list_each (void **list,
BablEachFunction each_fun,
void *user_data);
-unsigned int babl_ticks (void);
+long
+babl_ticks (void);
double
babl_rel_avg_error (double *imgA,