diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | babl/Makefile.am | 11 | ||||
-rw-r--r-- | babl/babl-component.h | 44 | ||||
-rw-r--r-- | babl/babl-conversion.h | 78 | ||||
-rw-r--r-- | babl/babl-extension.h | 41 | ||||
-rw-r--r-- | babl/babl-fish.h | 107 | ||||
-rw-r--r-- | babl/babl-format.h | 68 | ||||
-rw-r--r-- | babl/babl-image.h | 61 | ||||
-rw-r--r-- | babl/babl-model.h | 50 | ||||
-rw-r--r-- | babl/babl-sampling.h | 39 | ||||
-rw-r--r-- | babl/babl-type.h | 68 | ||||
-rw-r--r-- | babl/babl.h | 384 |
12 files changed, 592 insertions, 376 deletions
@@ -1,3 +1,20 @@ +2008-04-16 Øyvind Kolås <pippin@gimp.org> + + * babl/babl.h: split up into ... + Separate header files. + + * babl/babl-component.h: + * babl/babl-conversion.h: + * babl/babl-extension.h: + * babl/babl-fish.h: + * babl/babl-format.h: + * babl/babl-image.h: + * babl/babl-model.h: + * babl/babl-sampling.h: + * babl/babl-type.h: + + * babl/Makefile.am: install new headers. + 2008-04-15 Øyvind Kolås <pippin@gimp.org> * babl/Makefile.am: removed babl-classes.h diff --git a/babl/Makefile.am b/babl/Makefile.am index 2dcd4fe..36bcdd0 100644 --- a/babl/Makefile.am +++ b/babl/Makefile.am @@ -43,7 +43,16 @@ h_sources = \ library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl library_include_HEADERS = \ - babl.h + babl.h \ + babl-component.h \ + babl-conversion.h \ + babl-extension.h \ + babl-fish.h \ + babl-format.h \ + babl-image.h \ + babl-model.h \ + babl-sampling.h \ + babl-type.h INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/babl/base diff --git a/babl/babl-component.h b/babl/babl-component.h new file mode 100644 index 0000000..fa8090b --- /dev/null +++ b/babl/babl-component.h @@ -0,0 +1,44 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + + +/****************************************************************/ +/* BablComponent */ +BABL_NAMED_CLASS (component); +/* + * Babl * babl_component_new (const char *name, + * NULL); + */ +Babl *babl_component_id (int id); +void babl_component_each (BablEachFunction each_fun, + void *user_data); +Babl * babl_component (const char *name); +Babl * babl_component_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +typedef struct +{ + BablInstance instance; + int luma; + int chroma; + int alpha; +} BablComponent; diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h new file mode 100644 index 0000000..4f697b1 --- /dev/null +++ b/babl/babl-conversion.h @@ -0,0 +1,78 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablConversion */ +BABL_NAMED_CLASS (conversion); +/* + * Babl * babl_conversion_new (<BablFormat *source, BablFormat *destination| + * BablModel *source, BablModel *destination| + * BablType *source, BablType *destination>, + * <"linear"|"planar">, BablConversionFunc conv_func, + * NULL); + */ +Babl *babl_conversion_id (int id); +void babl_conversion_each (BablEachFunction each_fun, + void *user_data); +Babl * babl_conversion (const char *name); +Babl * babl_conversion_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +/* Type and Format */ +typedef long (*BablFuncLinear) (char *src, + char *dst, + long n); + +/* Signature of functions registered for reference type + * conversions, + */ +typedef long (*BablFuncPlane) (char *src, + char *dst, + int src_pitch, + int dst_pitch, + long n); + +/* TypePlanar,ModelPlanar and FormatPlanar */ +typedef long (*BablFuncPlanar) (int src_bands, + char *src[], + int src_pitch[], + int dst_bands, + char *dst[], + int dst_pitch[], + long n); + +typedef struct +BablConversion { + BablInstance instance; + const Babl *source; + const Babl *destination; + long cost; + double error; + union + { + BablFuncLinear linear; + BablFuncPlane plane; + BablFuncPlanar planar; + } function; + int processings; + long pixels; +} BablConversion; diff --git a/babl/babl-extension.h b/babl/babl-extension.h new file mode 100644 index 0000000..152ab7f --- /dev/null +++ b/babl/babl-extension.h @@ -0,0 +1,41 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablExtension */ +BABL_NAMED_CLASS (extension); +/* + * BablExtension objects are only used internally in babl. + */ +Babl *babl_extension_id (int id); +void babl_extension_each (BablEachFunction each_fun, + void *user_data); +Babl * babl_extension (const char *name); +Babl * babl_extension_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +typedef struct +{ + BablInstance instance; /* path to .so / .dll is stored in instance name */ + void *dl_handle; + void (*destroy) (void); +} BablExtension; diff --git a/babl/babl-fish.h b/babl/babl-fish.h new file mode 100644 index 0000000..56b7ab5 --- /dev/null +++ b/babl/babl-fish.h @@ -0,0 +1,107 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablFish */ +BABL_CLASS (fish); +/* Create a babl fish capable of converting from source_format to + * destination_format, source and destination can be + * either strings with the names of the formats or BablFormat objects. + */ +Babl * babl_fish (const void *source_format, + const void *destination_format); + +/** Process n pixels from source to destination using babl_fish, + * returns number of pixels converted. + */ +long babl_process (Babl *babl_fish, + void *source, + void *destination, + long n); + +Babl *babl_fish_id (int id); +void babl_fish_each (BablEachFunction each_fun, + void *user_data); + +/* BablFish, common base class for various fishes. + */ +typedef struct +{ + BablInstance instance; + const Babl *source; + const Babl *destination; + + double error; /* the amount of noise introduced by the fish */ + + /* instrumentation */ + int processings; /* number of times the fish has been used */ + long pixels; /* number of pixels translates */ + long usecs; /* usecs spent within this fish */ +} BablFish; + +/* BablFishSimple is the simplest type of fish, wrapping a single + * conversion function, (note this might not be the optimal chosen + * conversion even if it exists) + * + * TODO: exterminate + */ +typedef struct +{ + BablFish fish; + BablConversion *conversion; +} BablFishSimple; + + +/* BablFishPath is a combination of registered conversions, both + * from the reference types / model conversions, and optimized format to + * format conversion. + * + * This is the most advanced scheduled species of fish, some future + * version of babl might even be evovling path fishes in a background + * thread, based on the fish instrumentation. For this to work in a future + * version transmogrification between the fish classes would be used. + */ +typedef struct +{ + BablFish fish; + double cost; /* number of ticks *10 + chain_length */ + double loss; /* error introduced */ + BablList *conversion_list; +} BablFishPath; + +/* BablFishReference + * + * A BablFishReference is not intended to be fast, thus the algorithm + * encoded can use a multi stage approach, based on the knowledge babl + * has encoded in the pixel formats. + * + * One of the contributions that would be welcome are new fish factories. + * + * TODO: + * * make optimal use of a single allocation containing enough space + * for the maximum amount of memory needed in two adjecant buffers + * at any time. + */ +typedef struct +{ + BablFish fish; +} BablFishReference; diff --git a/babl/babl-format.h b/babl/babl-format.h new file mode 100644 index 0000000..e7b7111 --- /dev/null +++ b/babl/babl-format.h @@ -0,0 +1,68 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablFormat */ +BABL_NAMED_CLASS (format); +/* + * Babl * babl_format_new (["name", const char *name,] + * BablModel *model, + * [BablType *type,] + * [BablSampling, *sampling,] + * BablComponent *component1, + * [[BablType *type,] + * [BablSampling *sampling,] + * BablComponent *componentN, + * ...] + * ["planar",] + * NULL); + * + * Provided BablType and|or BablSampling is valid for the following + * components as well. If no name is provided a (long) descriptive + * name is used. + */ +Babl *babl_format_id (int id); +void babl_format_each (BablEachFunction each_fun, + void *user_data); +Babl * babl_format (const char *name); +Babl * babl_format_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +typedef struct +{ + BablInstance instance; + BablList *from_list; + int components; + BablComponent **component; + BablType **type; + void *image_template; /* image template for use with + linear (non-planer) images */ + + BablSampling **sampling; + BablModel *model; + int bytes_per_pixel; + int planar; + double loss; /*< average relative error when converting + from and to RGBA double */ + int visited; /* for convenience in code while searching + for conversion paths */ +} BablFormat; diff --git a/babl/babl-image.h b/babl/babl-image.h new file mode 100644 index 0000000..353144e --- /dev/null +++ b/babl/babl-image.h @@ -0,0 +1,61 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablImage */ +BABL_CLASS (image); +/* + * Babl images can be used for planar buffers instead of linear buffers for + * babl_process(), BablImages are still experimental, for now BablImages can be + * passed to babl_process, two different babl_process() functions will be + * needed for this since the polymorphism cannot be trusted to work on linear + * buffers that originate outside babl's control. + * + * Babl * babl_image (BablComponent *component1, + * void *data, + * int pitch, + * int stride, + * [BablComponent *component1, + * void *data, + * int pitch, + * int stride, + * ...] + * NULL); + */ +Babl * babl_image (void *first_component, + ...) BABL_ARG_NULL_TERMINATED; +Babl *babl_image_id (int id); +void babl_image_each (BablEachFunction each_fun, + void *user_data); +typedef struct +{ + BablInstance instance; + BablFormat *format; /*< (if known) */ + BablModel *model; /*< (always known) */ + int components; + BablComponent **component; + BablType **type; + BablSampling **sampling; + char **data; + int *pitch; + int *stride; +} BablImage; diff --git a/babl/babl-model.h b/babl/babl-model.h new file mode 100644 index 0000000..8307d0e --- /dev/null +++ b/babl/babl-model.h @@ -0,0 +1,50 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablModel */ +BABL_NAMED_CLASS (model); +/* + * Babl * babl_model_new (["name", const char *name,] + * BablComponent *component1, + * [BablComponent *componentN, ...] + * NULL); + * + * If no name is provided a name is generated by concatenating the + * name of all the involved components. + * + */ +Babl *babl_model_id (int id); +void babl_model_each (BablEachFunction each_fun, + void *user_data); +Babl * babl_model (const char *name); +Babl * babl_model_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +typedef struct +{ + BablInstance instance; + BablList *from_list; + int components; + BablComponent **component; + BablType **type; /*< must be doubles, used here for convenience in code */ +} BablModel; diff --git a/babl/babl-sampling.h b/babl/babl-sampling.h new file mode 100644 index 0000000..6aeee0b --- /dev/null +++ b/babl/babl-sampling.h @@ -0,0 +1,39 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablSampling */ +BABL_CLASS (sampling); +/**/ +Babl * babl_sampling (int horizontal, + int vertical); +Babl *babl_sampling_id (int id); +void babl_sampling_each (BablEachFunction each_fun, + void *user_data); +typedef struct +{ + BablInstance instance; + BablList *from_list; + int horizontal; + int vertical; + char name[4]; +} BablSampling; diff --git a/babl/babl-type.h b/babl/babl-type.h new file mode 100644 index 0000000..ee51eb7 --- /dev/null +++ b/babl/babl-type.h @@ -0,0 +1,68 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * <http://www.gnu.org/licenses/>. + */ + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + +/****************************************************************/ +/* BablType */ +BABL_NAMED_CLASS (type); +/* + * A data type that babl can have in it's buffers, requires + * conversions to and from "double" to be registered before + * passing sanity. + * + * Babl * babl_type_new ( const char *name, + * "bits", int bits, + * ["min_val", double min_val,] + * ["max_val", double max_val,] + * NULL); + */ +Babl *babl_type_id (int id); +void babl_type_each (BablEachFunction each_fun, + void *user_data); +Babl * babl_type (const char *name); +Babl * babl_type_new (void *first_arg, + ...) BABL_ARG_NULL_TERMINATED; + +typedef struct +{ + BablInstance instance; + BablList *from_list; + int bits; /*< number of bits used to represent the data type + (initially restricted to a multiple of 8) */ + double min_val; + double max_val; +} BablType; + +typedef struct +{ + BablType type; + int is_signed; + long max; + long min; +} BablTypeInteger; + +typedef struct +{ + BablType type; + /* sign + * biased_exponent + * mantissa */ +} BablTypeFloat; diff --git a/babl/babl.h b/babl/babl.h index b085cb4..4ea3a3f 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -140,381 +140,15 @@ typedef struct const char *babl_name (const Babl *babl); void babl_introspect (Babl *babl); /* introspect a given BablObject */ -/****************************************************************/ -/* BablType */ -BABL_NAMED_CLASS (type); -/* - * A data type that babl can have in it's buffers, requires - * conversions to and from "double" to be registered before - * passing sanity. - * - * Babl * babl_type_new ( const char *name, - * "bits", int bits, - * ["min_val", double min_val,] - * ["max_val", double max_val,] - * NULL); - */ -Babl *babl_type_id (int id); -void babl_type_each (BablEachFunction each_fun, - void *user_data); -Babl * babl_type (const char *name); -Babl * babl_type_new (void *first_arg, - ...) BABL_ARG_NULL_TERMINATED; - -typedef struct -{ - BablInstance instance; - BablList *from_list; - int bits; /*< number of bits used to represent the data type - (initially restricted to a multiple of 8) */ - double min_val; - double max_val; -} BablType; - -typedef struct -{ - BablType type; - int is_signed; - long max; - long min; -} BablTypeInteger; - -typedef struct -{ - BablType type; - /* sign - * biased_exponent - * mantissa */ -} BablTypeFloat; - - -/****************************************************************/ -/* BablSampling */ -BABL_CLASS (sampling); -/**/ -Babl * babl_sampling (int horizontal, - int vertical); -Babl *babl_sampling_id (int id); -void babl_sampling_each (BablEachFunction each_fun, - void *user_data); -typedef struct -{ - BablInstance instance; - BablList *from_list; - int horizontal; - int vertical; - char name[4]; -} BablSampling; - - -/****************************************************************/ -/* BablComponent */ -BABL_NAMED_CLASS (component); -/* - * Babl * babl_component_new (const char *name, - * NULL); - */ -Babl *babl_component_id (int id); -void babl_component_each (BablEachFunction each_fun, - void *user_data); -Babl * babl_component (const char *name); -Babl * babl_component_new (void *first_arg, - ...) BABL_ARG_NULL_TERMINATED; - -typedef struct -{ - BablInstance instance; - int luma; - int chroma; - int alpha; -} BablComponent; - - -/****************************************************************/ -/* BablModel */ -BABL_NAMED_CLASS (model); -/* - * Babl * babl_model_new (["name", const char *name,] - * BablComponent *component1, - * [BablComponent *componentN, ...] - * NULL); - * - * If no name is provided a name is generated by concatenating the - * name of all the involved components. - * - */ -Babl *babl_model_id (int id); -void babl_model_each (BablEachFunction each_fun, - void *user_data); -Babl * babl_model (const char *name); -Babl * babl_model_new (void *first_arg, - ...) BABL_ARG_NULL_TERMINATED; - -typedef struct -{ - BablInstance instance; - BablList *from_list; - int components; - BablComponent **component; - BablType **type; /*< must be doubles, used here for convenience in code */ -} BablModel; - - -/****************************************************************/ -/* BablFormat */ -BABL_NAMED_CLASS (format); -/* - * Babl * babl_format_new (["name", const char *name,] - * BablModel *model, - * [BablType *type,] - * [BablSampling, *sampling,] - * BablComponent *component1, - * [[BablType *type,] - * [BablSampling *sampling,] - * BablComponent *componentN, - * ...] - * ["planar",] - * NULL); - * - * Provided BablType and|or BablSampling is valid for the following - * components as well. If no name is provided a (long) descriptive - * name is used. - */ -Babl *babl_format_id (int id); -void babl_format_each (BablEachFunction each_fun, - void *user_data); -Babl * babl_format (const char *name); -Babl * babl_format_new (void *first_arg, - ...) BABL_ARG_NULL_TERMINATED; - -typedef struct -{ - BablInstance instance; - BablList *from_list; - int components; - BablComponent **component; - BablType **type; - void *image_template; /* image template for use with - linear (non-planer) images */ - - BablSampling **sampling; - BablModel *model; - int bytes_per_pixel; - int planar; - double loss; /*< average relative error when converting - from and to RGBA double */ - int visited; /* for convenience in code while searching - for conversion paths */ -} BablFormat; - - -/****************************************************************/ -/* BablImage */ -BABL_CLASS (image); -/* - * Babl images can be used for planar buffers instead of linear buffers for - * babl_process(), BablImages are still experimental, for now BablImages can be - * passed to babl_process, two different babl_process() functions will be - * needed for this since the polymorphism cannot be trusted to work on linear - * buffers that originate outside babl's control. - * - * Babl * babl_image (BablComponent *component1, - * void *data, - * int pitch, - * int stride, - * [BablComponent *component1, - * void *data, - * int pitch, - * int stride, - * ...] - * NULL); - */ -Babl * babl_image (void *first_component, - ...) BABL_ARG_NULL_TERMINATED; -Babl *babl_image_id (int id); -void babl_image_each (BablEachFunction each_fun, - void *user_data); -typedef struct -{ - BablInstance instance; - BablFormat *format; /*< (if known) */ - BablModel *model; /*< (always known) */ - int components; - BablComponent **component; - BablType **type; - BablSampling **sampling; - char **data; - int *pitch; - int *stride; -} BablImage; - - -/****************************************************************/ -/* BablConversion */ -BABL_NAMED_CLASS (conversion); -/* - * Babl * babl_conversion_new (<BablFormat *source, BablFormat *destination| - * BablModel *source, BablModel *destination| - * BablType *source, BablType *destination>, - * <"linear"|"planar">, BablConversionFunc conv_func, - * NULL); - */ -Babl *babl_conversion_id (int id); -void babl_conversion_each (BablEachFunction each_fun, - void *user_data); -Babl * babl_conversion (const char *name); -Babl * babl_conversion_new (void *first_arg, - ...) BABL_ARG_NULL_TERMINATED; - -/* Type and Format */ -typedef long (*BablFuncLinear) (char *src, - char *dst, - long n); - -/* Signature of functions registered for reference type - * conversions, - */ -typedef long (*BablFuncPlane) (char *src, - char *dst, - int src_pitch, - int dst_pitch, - long n); - -/* TypePlanar,ModelPlanar and FormatPlanar */ -typedef long (*BablFuncPlanar) (int src_bands, - char *src[], - int src_pitch[], - int dst_bands, - char *dst[], - int dst_pitch[], - long n); - -typedef struct -BablConversion { - BablInstance instance; - const Babl *source; - const Babl *destination; - long cost; - double error; - union - { - BablFuncLinear linear; - BablFuncPlane plane; - BablFuncPlanar planar; - } function; - int processings; - long pixels; -} BablConversion; - - -/****************************************************************/ -/* BablFish */ -BABL_CLASS (fish); -/* Create a babl fish capable of converting from source_format to - * destination_format, source and destination can be - * either strings with the names of the formats or BablFormat objects. - */ -Babl * babl_fish (const void *source_format, - const void *destination_format); - -/** Process n pixels from source to destination using babl_fish, - * returns number of pixels converted. - */ -long babl_process (Babl *babl_fish, - void *source, - void *destination, - long n); - -Babl *babl_fish_id (int id); -void babl_fish_each (BablEachFunction each_fun, - void *user_data); - -/* BablFish, common base class for various fishes. - */ -typedef struct -{ - BablInstance instance; - const Babl *source; - const Babl *destination; - - double error; /* the amount of noise introduced by the fish */ - - /* instrumentation */ - int processings; /* number of times the fish has been used */ - long pixels; /* number of pixels translates */ - long usecs; /* usecs spent within this fish */ -} BablFish; - -/* BablFishSimple is the simplest type of fish, wrapping a single - * conversion function, (note this might not be the optimal chosen - * conversion even if it exists) - * - * TODO: exterminate - */ -typedef struct -{ - BablFish fish; - BablConversion *conversion; -} BablFishSimple; - - -/* BablFishPath is a combination of registered conversions, both - * from the reference types / model conversions, and optimized format to - * format conversion. - * - * This is the most advanced scheduled species of fish, some future - * version of babl might even be evovling path fishes in a background - * thread, based on the fish instrumentation. For this to work in a future - * version transmogrification between the fish classes would be used. - */ -typedef struct -{ - BablFish fish; - double cost; /* number of ticks *10 + chain_length */ - double loss; /* error introduced */ - BablList *conversion_list; -} BablFishPath; - -/* BablFishReference - * - * A BablFishReference is not intended to be fast, thus the algorithm - * encoded can use a multi stage approach, based on the knowledge babl - * has encoded in the pixel formats. - * - * One of the contributions that would be welcome are new fish factories. - * - * TODO: - * * make optimal use of a single allocation containing enough space - * for the maximum amount of memory needed in two adjecant buffers - * at any time. - */ -typedef struct -{ - BablFish fish; -} BablFishReference; - - -/****************************************************************/ -/* BablExtension */ -BABL_NAMED_CLASS (extension); -/* - * BablExtension objects are only used internally in babl. - */ -Babl *babl_extension_id (int id); -void babl_extension_each (BablEachFunction each_fun, - void *user_data); -Babl * babl_extension (const char *name); -Babl * babl_extension_new (void *first_arg, - ...) BABL_ARG_NULL_TERMINATED; - -typedef struct -{ - BablInstance instance; /* path to .so / .dll is stored in instance name */ - void *dl_handle; - void (*destroy) (void); -} BablExtension; - - +#include "babl-type.h" +#include "babl-sampling.h" +#include "babl-component.h" +#include "babl-model.h" +#include "babl-format.h" +#include "babl-image.h" +#include "babl-conversion.h" +#include "babl-fish.h" +#include "babl-extension.h" /* This union can be used for convenient access to any field without the need * to case if the variable already is of the type Babl * |