babl r309 - in trunk: . babl



Author: ok
Date: Wed Apr 16 10:44:54 2008
New Revision: 309
URL: http://svn.gnome.org/viewvc/babl?rev=309&view=rev

Log:
* 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.


Added:
   trunk/babl/babl-component.h
   trunk/babl/babl-conversion.h
   trunk/babl/babl-extension.h
   trunk/babl/babl-fish.h
   trunk/babl/babl-format.h
   trunk/babl/babl-image.h
   trunk/babl/babl-model.h
   trunk/babl/babl-sampling.h
   trunk/babl/babl-type.h
Modified:
   trunk/ChangeLog
   trunk/babl/Makefile.am
   trunk/babl/babl.h

Modified: trunk/babl/Makefile.am
==============================================================================
--- trunk/babl/Makefile.am	(original)
+++ trunk/babl/Makefile.am	Wed Apr 16 10:44:54 2008
@@ -43,7 +43,16 @@
 
 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
 

Added: trunk/babl/babl-component.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-component.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-conversion.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-conversion.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-extension.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-extension.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-fish.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-fish.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-format.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-format.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-image.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-image.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-model.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-model.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-sampling.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-sampling.h	Wed Apr 16 10:44:54 2008
@@ -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;

Added: trunk/babl/babl-type.h
==============================================================================
--- (empty file)
+++ trunk/babl/babl-type.h	Wed Apr 16 10:44:54 2008
@@ -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;

Modified: trunk/babl/babl.h
==============================================================================
--- trunk/babl/babl.h	(original)
+++ trunk/babl/babl.h	Wed Apr 16 10:44:54 2008
@@ -140,381 +140,15 @@
 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 *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]