From anders at brander.dk Sun Mar 8 23:48:09 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 08 Mar 2009 23:48:09 +0100 Subject: [Rawstudio-commit] r2230 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-08 23:48:09 +0100 (Sun, 08 Mar 2009) New Revision: 2230 Modified: trunk/librawstudio/rs-filetypes.c Log: Made filetype_search_traverse() static. Modified: trunk/librawstudio/rs-filetypes.c =================================================================== --- trunk/librawstudio/rs-filetypes.c 2009-02-25 17:21:01 UTC (rev 2229) +++ trunk/librawstudio/rs-filetypes.c 2009-03-08 22:48:09 UTC (rev 2230) @@ -55,7 +55,7 @@ return extension; } -gboolean +static gboolean filetype_search_traverse(gpointer key, gpointer value, gpointer data) { RSFiletype *type = key; From anders at kvistmail.dk Mon Mar 9 00:21:00 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Mon, 09 Mar 2009 00:21:00 +0100 Subject: [Rawstudio-commit] r2231 - in trunk/plugins: . output-flickr Message-ID: Author: akv Date: 2009-03-09 00:21:00 +0100 (Mon, 09 Mar 2009) New Revision: 2231 Added: trunk/plugins/output-flickr/ trunk/plugins/output-flickr/Makefile.am trunk/plugins/output-flickr/output-flickr.c trunk/plugins/output-flickr/output-flickr.h Log: Initial commit of flickr plugin - still disabled. Property changes on: trunk/plugins/output-flickr ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile .deps Added: trunk/plugins/output-flickr/Makefile.am =================================================================== --- trunk/plugins/output-flickr/Makefile.am (rev 0) +++ trunk/plugins/output-flickr/Makefile.am 2009-03-08 23:21:00 UTC (rev 2231) @@ -0,0 +1,21 @@ +plugindir = $(libdir)/rawstudio/plugins + +AM_CFLAGS =\ + -Wall\ + -O4 + +AM_CXXFLAGS = $(AM_CFLAGS) + +INCLUDES = \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + @PACKAGE_CFLAGS@ \ + -I../../librawstudio/ + +lib_LTLIBRARIES = output_flickr.la + +libdir = $(datadir)/rawstudio/plugins/ + +output_flickr_la_LIBADD = @PACKAGE_LIBS@ +output_flickr_la_LDFLAGS = -module -avoid-version -L/usr/lib -lflickcurl +output_flickr_la_SOURCES = output-flickr.c Added: trunk/plugins/output-flickr/output-flickr.c =================================================================== --- trunk/plugins/output-flickr/output-flickr.c (rev 0) +++ trunk/plugins/output-flickr/output-flickr.c 2009-03-08 23:21:00 UTC (rev 2231) @@ -0,0 +1,451 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* Output plugin tmpl version 1 */ + +/* + TODO: + - move rs_conf_* to librawstudio - this needs RS_FILETYPE from application.h. Should/can we move this to rs-filetypes.h? + - decide if rawstudio can be dependent on libflickcurl. Will this plugin be build on dependency satisfiction or --with-output-flickr option. +*/ + +#include +#include +#include "config.h" +#include "output-flickr.h" +#include +#include +#include + +/* Ugly HACK - conf_interface.c|h needs to be ported to librawstudio */ +gchar *rs_conf_get_string (const gchar * name); +gboolean rs_conf_set_string (const gchar * name, const gchar * value); + +#define RS_TYPE_FLICKR (rs_flickr_type) +#define RS_FLICKR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_FLICKR, RSFlickr)) +#define RS_FLICKR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_FLICKR, RSFlickrClass)) +#define RS_IS_FLICKR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_FLICKR)) + +typedef struct _RSFlickr RSFlickr; +typedef struct _RSFlickrClass RSFlickrClass; + +struct _RSFlickr +{ + RSOutput parent; + + gint quality; + gchar *title; + gchar *description; + gchar *tags; + gboolean is_public; + gboolean is_friend; + gboolean is_family; + gint safety_level; + gint content_type; +}; + +struct _RSFlickrClass +{ + RSOutputClass parent_class; +}; + +RS_DEFINE_OUTPUT (rs_flickr, RSFlickr) +enum +{ + PROP_0, + PROP_JPEG_QUALITY, + PROP_TITLE, + PROP_DESCRIPTION, + PROP_TAGS, + PROP_IS_PUBLIC, + PROP_IS_FRIEND, + PROP_IS_FAMILY +}; + +static void get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec); +static void set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec); +static gboolean execute8 (RSOutput * output, GdkPixbuf * pixbuf); + +G_MODULE_EXPORT void rs_plugin_load (RSPlugin * plugin) +{ + rs_flickr_get_type (G_TYPE_MODULE (plugin)); +} + +static void +rs_flickr_class_init (RSFlickrClass * klass) +{ + RSOutputClass *output_class = RS_OUTPUT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = get_property; + object_class->set_property = set_property; + + g_object_class_install_property (object_class, + PROP_JPEG_QUALITY, + g_param_spec_int ("quality", + "JPEG Quality", + _("JPEG Quality"), 10, + 100, 90, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_TITLE, g_param_spec_string ("title", + "title", + "Title", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_DESCRIPTION, + g_param_spec_string ("description", + "description", + "Description", NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_TAGS, g_param_spec_string ("tags", + "tags", + "Tags", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_IS_PUBLIC, + g_param_spec_boolean ("public", "public", + "Public", FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_IS_FRIEND, + g_param_spec_boolean ("friend", "friend", + "Friend", FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_IS_PUBLIC, + g_param_spec_boolean ("family", "family", + "Family", FALSE, + G_PARAM_READWRITE)); + + output_class->execute8 = execute8; + output_class->display_name = _("Upload photo to Flickr"); +} + +static void +rs_flickr_init (RSFlickr * flickr) +{ + flickr->quality = 90; +} + +static void +get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) +{ + RSFlickr *flickr = RS_FLICKR (object); + + switch (property_id) + { + case PROP_JPEG_QUALITY: + g_value_set_int (value, flickr->quality); + break; + case PROP_TITLE: + g_value_set_string (value, flickr->title); + break; + case PROP_DESCRIPTION: + g_value_set_string (value, flickr->description); + break; + case PROP_TAGS: + g_value_set_string (value, flickr->tags); + break; + case PROP_IS_PUBLIC: + g_value_set_boolean (value, flickr->is_public); + break; + case PROP_IS_FRIEND: + g_value_set_boolean (value, flickr->is_friend); + break; + case PROP_IS_FAMILY: + g_value_set_boolean (value, flickr->is_family); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) +{ + RSFlickr *flickr = RS_FLICKR (object); + + switch (property_id) + { + case PROP_JPEG_QUALITY: + flickr->quality = g_value_get_int (value); + break; + case PROP_TITLE: + flickr->title = g_value_dup_string (value); + break; + case PROP_DESCRIPTION: + flickr->description = g_value_dup_string (value); + break; + case PROP_TAGS: + flickr->tags = g_value_dup_string (value); + break; + case PROP_IS_PUBLIC: + flickr->is_public = g_value_get_boolean (value); + break; + case PROP_IS_FRIEND: + flickr->is_friend = g_value_get_boolean (value); + break; + case PROP_IS_FAMILY: + flickr->is_family = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +GtkWidget * +gui_dialog_make_from_widget (const gchar * stock_id, gchar * primary_text, GtkWidget * widget) +{ + GtkWidget *dialog, *image, *hhbox, *vvbox; + GtkWidget *primary_label; + gchar *str; + + image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG); + gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0); + dialog = gtk_dialog_new (); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); + gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14); + gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); + gtk_window_set_title (GTK_WINDOW (dialog), ""); + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); + + primary_label = gtk_label_new (NULL); + gtk_label_set_line_wrap (GTK_LABEL (primary_label), TRUE); + gtk_label_set_use_markup (GTK_LABEL (primary_label), TRUE); + gtk_misc_set_alignment (GTK_MISC (primary_label), 0.0, 0.5); + gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE); + str = g_strconcat ("", primary_text, "", NULL); + gtk_label_set_markup (GTK_LABEL (primary_label), str); + g_free (str); + + hhbox = gtk_hbox_new (FALSE, 12); + gtk_container_set_border_width (GTK_CONTAINER (hhbox), 5); + gtk_box_pack_start (GTK_BOX (hhbox), image, FALSE, FALSE, 0); + vvbox = gtk_vbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (hhbox), vvbox, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vvbox), primary_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vvbox), widget, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hhbox, FALSE, FALSE, 0); + + return (dialog); +} + +GtkWidget * +gui_dialog_make_from_text (const gchar * stock_id, gchar * primary_text, gchar * secondary_text) +{ + GtkWidget *secondary_label; + + secondary_label = gtk_label_new (NULL); + gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE); + gtk_label_set_use_markup (GTK_LABEL (secondary_label), TRUE); + gtk_misc_set_alignment (GTK_MISC (secondary_label), 0.0, 0.5); + gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE); + gtk_label_set_markup (GTK_LABEL (secondary_label), secondary_text); + + return (gui_dialog_make_from_widget(stock_id, primary_text, secondary_label)); +} + +void +flickcurl_print_error (void *user_data, const char *temp) +{ + gchar *message = NULL; + + /* Errors not catched yet - probably due to lack of knowledge about what causes it + Call failed with error 99 - Insufficient permissions. Method requires write privileges; none granted. + */ + + /* DEBUG */ + g_debug ("flickcurl: %s\n", temp); + + /* Catch errors and show our own and more userfriendly errors */ + if (g_ascii_strcasecmp(temp,"Method flickr.auth.getToken failed with error 108 - Invalid frob") == 0) + message = g_strdup("We recieved an error during authentication. You didn't authorize Rawstudio, did you?"); + + else if (g_ascii_strcasecmp(temp, "Call failed with error 98 - Invalid auth token") == 0) + message = g_strdup("Rawstudio were not able to upload the photo cause the authentication has been revoked. Please re-authenticate Rawstudio to upload to Flickr."); + + else if (g_ascii_strcasecmp(temp,"Method flickr.test.login failed with error 98 - Invalid auth token")) + message = g_strdup("It seems like rawstudio lost it's authentication to upload to your account, please re-authenticate."); + + /* Everything else will be shown along with a note */ + else + message = g_strdup_printf("%s\n\nNote: This error isn't catched by Rawstudio. Please let us know that you found it and how to reproduce it so we can make a more useful errormessage. Thanks!", (gchar *) temp); + + GtkWidget *dialog = gui_dialog_make_from_text (GTK_STOCK_DIALOG_ERROR, g_strdup ("Flickr error"), message); + gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); + gdk_threads_enter (); + gtk_widget_show_all (dialog); + gtk_dialog_run (GTK_DIALOG (dialog)); + gdk_threads_leave (); + gtk_widget_destroy (dialog); +} + +static gboolean +execute8 (RSOutput * output, GdkPixbuf * pixbuf) +{ + RSFlickr *flickr = RS_FLICKR (output); + + flickcurl *fc; + + flickcurl_init (); /* optional static initialising of resources */ + fc = flickcurl_new (); + + flickcurl_set_error_handler (fc, flickcurl_print_error, NULL); + + /* Set configuration, or more likely read from a config file */ + flickcurl_set_api_key (fc, FLICKR_API_KEY); + flickcurl_set_shared_secret (fc, FLICKR_SECRET_KEY); + + gchar *flickr_user_token = rs_conf_get_string ("flickr_user_token"); + gchar *flickr_user_name = NULL; + + if (flickr_user_token) + { + flickcurl_set_auth_token (fc, flickr_user_token); + flickr_user_name = flickcurl_test_login (fc); + + /* We need to reset all flickcurl */ + flickcurl_free (fc); + fc = flickcurl_new (); + flickcurl_set_error_handler (fc, flickcurl_print_error, NULL); + + /* Set configuration, or more likely read from a config file */ + flickcurl_set_api_key (fc, FLICKR_API_KEY); + flickcurl_set_shared_secret (fc, FLICKR_SECRET_KEY); + } + + if (!flickr_user_name) + { + char *frob = g_strdup (flickcurl_auth_getFrob (fc)); // FIXME: Returns NULL on failure + char *sign = g_strdup_printf ("%sapi_key%sfrob%spermswrite", FLICKR_SECRET_KEY, FLICKR_API_KEY, frob); + char *sign_md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, sign, strlen (sign)); + char *auth_url = g_strdup_printf("http://flickr.com/services/auth/?api_key=%s&perms=write&frob=%s&api_sig=%s", FLICKR_API_KEY, frob, sign_md5); + + gdk_threads_enter (); + + GtkWidget *flickr_auth_dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (flickr_auth_dialog), "Rawstudio"); + gtk_container_set_border_width (GTK_CONTAINER (flickr_auth_dialog), 4); + gtk_dialog_set_has_separator (GTK_DIALOG (flickr_auth_dialog), FALSE); + + GtkWidget *vbox = GTK_DIALOG (flickr_auth_dialog)->vbox; + + GtkWidget *textlabel = gtk_label_new("Rawstudio needs to be authenticated before it will be able to upload photos to your Flickr account."); + gtk_label_set_line_wrap (GTK_LABEL (textlabel), TRUE); + + gtk_box_pack_start (GTK_BOX (vbox), textlabel, TRUE, TRUE, 4); + + GtkWidget *table = gtk_table_new (2, 2, FALSE); + + GtkWidget *step1label = gtk_label_new ("Step 1:"); + GtkWidget *step2label = gtk_label_new ("Step 2:"); + + GtkWidget *link = gtk_link_button_new_with_label (auth_url, "Authenticate Rawstudio"); + + GtkWidget *hbox = gtk_hbox_new (FALSE, 4); + + GtkWidget *cancelbutton = gtk_button_new_from_stock (GTK_STOCK_CANCEL); + GtkWidget *acceptbutton = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD); + + gtk_box_pack_start (GTK_BOX (hbox), cancelbutton, TRUE, TRUE, 4); + gtk_box_pack_start (GTK_BOX (hbox), acceptbutton, TRUE, TRUE, 4); + + gtk_dialog_add_action_widget (GTK_DIALOG (flickr_auth_dialog), cancelbutton, GTK_RESPONSE_CANCEL); + gtk_dialog_add_action_widget (GTK_DIALOG (flickr_auth_dialog), acceptbutton, GTK_RESPONSE_ACCEPT); + + gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 4); + + gtk_table_attach_defaults (GTK_TABLE (table), step1label, 0, 1, 0, 1); + gtk_table_attach_defaults (GTK_TABLE (table), step2label, 0, 1, 1, 2); + + gtk_table_attach_defaults (GTK_TABLE (table), link, 1, 2, 0, 1); + gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2); + + gtk_widget_show_all (flickr_auth_dialog); + gint response = gtk_dialog_run (GTK_DIALOG (flickr_auth_dialog)); + + gtk_widget_destroy (flickr_auth_dialog); + + gdk_threads_leave (); + + if (response == GTK_RESPONSE_ACCEPT) + { + gchar *token = g_strdup (flickcurl_auth_getToken (fc, frob)); + + if (token) + { + rs_conf_set_string ("flickr_user_token", token); + flickr_user_token = token; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + } + + RSOutput *jpegsave = rs_output_new ("RSJpegfile"); + + gchar *temp_file = g_strdup_printf ("%s%s.rawstudio-tmp-%d.jpg", g_get_tmp_dir (), G_DIR_SEPARATOR_S, (gint) (g_random_double () * 10000.0)); + + g_object_set (jpegsave, "filename", temp_file, "quality", flickr->quality, NULL); + rs_output_execute (jpegsave, pixbuf); + g_object_unref (jpegsave); + + flickcurl_upload_params *upload_params = malloc (sizeof (flickcurl_upload_params)); + + flickcurl_set_auth_token (fc, flickr_user_token); + + upload_params->photo_file = temp_file; + upload_params->title = flickr->title; + upload_params->description = flickr->description; + upload_params->tags = flickr->tags; + upload_params->is_public = flickr->is_public; + upload_params->is_friend = flickr->is_friend; + upload_params->is_family = flickr->is_family; + upload_params->safety_level = 0; /* FIXME: we leave this hardcoded at the moment */ + upload_params->content_type = 0; /* FIXME: same as above */ + + /* Perform upload */ + flickcurl_photos_upload_params (fc, upload_params); + + unlink (temp_file); + g_free (temp_file); + + flickcurl_free (fc); + flickcurl_finish (); /* optional static free of resources */ + + return TRUE; +} Added: trunk/plugins/output-flickr/output-flickr.h =================================================================== --- trunk/plugins/output-flickr/output-flickr.h (rev 0) +++ trunk/plugins/output-flickr/output-flickr.h 2009-03-08 23:21:00 UTC (rev 2231) @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#define FLICKR_API_KEY "0ef831c5ac838c533b300572fa72e58e" +#define FLICKR_SECRET_KEY "ca0bb543187a30d1" From anders at kvistmail.dk Mon Mar 9 23:14:25 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Mon, 09 Mar 2009 23:14:25 +0100 Subject: [Rawstudio-commit] r2232 - trunk/src Message-ID: Author: akv Date: 2009-03-09 23:14:25 +0100 (Mon, 09 Mar 2009) New Revision: 2232 Modified: trunk/src/conf_interface.c trunk/src/conf_interface.h Log: Added rs_conf_unset(). Modified: trunk/src/conf_interface.c =================================================================== --- trunk/src/conf_interface.c 2009-03-08 23:21:00 UTC (rev 2231) +++ trunk/src/conf_interface.c 2009-03-09 22:14:25 UTC (rev 2232) @@ -619,3 +619,26 @@ } return value; } + +gboolean +rs_conf_unset(const gchar *name) +{ + gboolean ret = FALSE; +#ifdef WITH_GCONF + GConfClient *client = gconf_client_get_default(); + GString *fullname = g_string_new(GCONF_PATH); + g_string_append(fullname, name); + if (client) + { + g_static_mutex_lock(&lock); + ret = gconf_client_unset(client, fullname->str, NULL); + g_static_mutex_unlock(&lock); + g_object_unref(client); + } + g_string_free(fullname, TRUE); +#endif +#ifdef WITH_REGISTRY + /* FIXME: windows stub */ +#endif + return ret; +} Modified: trunk/src/conf_interface.h =================================================================== --- trunk/src/conf_interface.h 2009-03-08 23:21:00 UTC (rev 2231) +++ trunk/src/conf_interface.h 2009-03-09 22:14:25 UTC (rev 2232) @@ -128,3 +128,4 @@ gboolean rs_conf_set_list_string(const gchar *name, GSList *list); gboolean rs_conf_add_string_to_list_string(const gchar *name, gchar *value); gchar *rs_conf_get_nth_string_from_list_string(const gchar *name, gint num); +gboolean rs_conf_unset(const gchar *name); From anders at kvistmail.dk Mon Mar 9 23:16:55 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Mon, 09 Mar 2009 23:16:55 +0100 Subject: [Rawstudio-commit] r2233 - trunk/src Message-ID: Author: akv Date: 2009-03-09 23:16:54 +0100 (Mon, 09 Mar 2009) New Revision: 2233 Modified: trunk/src/rs-preview-widget.c Log: Changed strength of lights-out mode. Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-09 22:14:25 UTC (rev 2232) +++ trunk/src/rs-preview-widget.c 2009-03-09 22:16:54 UTC (rev 2233) @@ -540,7 +540,7 @@ gtk_window_get_size(GTK_WINDOW(widget), &width, &height); - cairo_set_source_rgba (cairo_context, 0.0f, 0.0f, 0.0f, 0.9f); + cairo_set_source_rgba (cairo_context, 0.0f, 0.0f, 0.0f, 0.8f); cairo_set_operator (cairo_context, CAIRO_OPERATOR_SOURCE); cairo_paint (cairo_context); From anders at brander.dk Tue Mar 10 01:15:19 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 10 Mar 2009 01:15:19 +0100 Subject: [Rawstudio-commit] r2234 - trunk/src Message-ID: Author: abrander Date: 2009-03-10 01:15:18 +0100 (Tue, 10 Mar 2009) New Revision: 2234 Modified: trunk/src/rs-preview-widget.c Log: Removed stupid GLib-warning from buffer(). Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-09 22:16:54 UTC (rev 2233) +++ trunk/src/rs-preview-widget.c 2009-03-10 00:15:18 UTC (rev 2234) @@ -1124,9 +1124,11 @@ RS_IMAGE16 *source; GdkRectangle clip, image; - g_return_if_fail(preview->photo); g_return_if_fail(VIEW_IS_VALID(view)); + if (!preview->photo) + return; + if (!ISDIRTY(preview->dirty[view], BUFFER)) return; From anders at brander.dk Tue Mar 10 02:21:00 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 10 Mar 2009 02:21:00 +0100 Subject: [Rawstudio-commit] r2235 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-10 02:21:00 +0100 (Tue, 10 Mar 2009) New Revision: 2235 Modified: trunk/librawstudio/rs-utils.c trunk/librawstudio/rs-utils.h Log: Added rs_object_class_property_reset(). Modified: trunk/librawstudio/rs-utils.c =================================================================== --- trunk/librawstudio/rs-utils.c 2009-03-10 00:15:18 UTC (rev 2234) +++ trunk/librawstudio/rs-utils.c 2009-03-10 01:21:00 UTC (rev 2235) @@ -376,6 +376,29 @@ } /** + * Reset a property on a GObject to it's default + * @param object A GObject + * @param property_name A name of a property installed in object's class + */ +void +rs_object_class_property_reset(GObject *object, const gchar *property_name) +{ + GObjectClass *klass = G_OBJECT_GET_CLASS(object); + GParamSpec *spec; + GValue value = {0}; + + spec = g_object_class_find_property(klass, property_name); + g_assert(spec != NULL); + + g_value_init(&value, spec->value_type); + + g_param_value_set_default(spec, &value); + g_object_set_property(object, spec->name, &value); + + g_value_unset(&value); +} + +/** * Check (and complain if needed) the Rawstudio install */ void Modified: trunk/librawstudio/rs-utils.h =================================================================== --- trunk/librawstudio/rs-utils.h 2009-03-10 00:15:18 UTC (rev 2234) +++ trunk/librawstudio/rs-utils.h 2009-03-10 01:21:00 UTC (rev 2235) @@ -127,6 +127,13 @@ extern void rs_rect_rotate(RS_RECT *in, RS_RECT *out, gint w, gint h, gint quarterturns); +/** + * Reset a property on a GObject to it's default + * @param object A GObject + * @param property_name A name of a property installed in object's class + */ +void +rs_object_class_property_reset(GObject *object, const gchar *property_name); /** * Check (and complain if needed) the Rawstudio install From anders at brander.dk Tue Mar 10 02:43:41 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 10 Mar 2009 02:43:41 +0100 Subject: [Rawstudio-commit] r2236 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-10 02:43:40 +0100 (Tue, 10 Mar 2009) New Revision: 2236 Modified: trunk/librawstudio/rs-output.c Log: Stop rs_output_get_parameter_widget() from leaking. Modified: trunk/librawstudio/rs-output.c =================================================================== --- trunk/librawstudio/rs-output.c 2009-03-10 01:21:00 UTC (rev 2235) +++ trunk/librawstudio/rs-output.c 2009-03-10 01:43:40 UTC (rev 2236) @@ -301,7 +301,7 @@ g_object_get(output, specs[i]->name, &str, NULL); if (str) gtk_entry_set_text(GTK_ENTRY(entry), str); - /* Are we leaking? */ + g_free(str); g_object_set_data(G_OBJECT(entry), "spec-name", specs[i]->name); g_object_set_data_full(G_OBJECT(entry), "conf-path", confpath, g_free); From anders at brander.dk Tue Mar 10 02:57:23 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 10 Mar 2009 02:57:23 +0100 Subject: [Rawstudio-commit] r2237 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-10 02:57:23 +0100 (Tue, 10 Mar 2009) New Revision: 2237 Modified: trunk/librawstudio/rs-output.c Log: Stop rs_output_get_parameter_widget() from crashing. Modified: trunk/librawstudio/rs-output.c =================================================================== --- trunk/librawstudio/rs-output.c 2009-03-10 01:43:40 UTC (rev 2236) +++ trunk/librawstudio/rs-output.c 2009-03-10 01:57:23 UTC (rev 2237) @@ -300,8 +300,10 @@ g_object_get(output, specs[i]->name, &str, NULL); if (str) + { gtk_entry_set_text(GTK_ENTRY(entry), str); - g_free(str); + g_free(str); + } g_object_set_data(G_OBJECT(entry), "spec-name", specs[i]->name); g_object_set_data_full(G_OBJECT(entry), "conf-path", confpath, g_free); From anders at brander.dk Tue Mar 10 03:27:34 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 10 Mar 2009 03:27:34 +0100 Subject: [Rawstudio-commit] r2238 - in trunk: librawstudio src Message-ID: Author: abrander Date: 2009-03-10 03:27:34 +0100 (Tue, 10 Mar 2009) New Revision: 2238 Modified: trunk/librawstudio/rs-color-transform.c trunk/librawstudio/rs-settings.c trunk/librawstudio/rs-settings.h trunk/src/toolbox.c Log: Ported all scalar properties of RSSettings to "real" GObject properties. Modified: trunk/librawstudio/rs-color-transform.c =================================================================== --- trunk/librawstudio/rs-color-transform.c 2009-03-10 01:57:23 UTC (rev 2237) +++ trunk/librawstudio/rs-color-transform.c 2009-03-10 02:27:34 UTC (rev 2238) @@ -206,21 +206,28 @@ if (mask & (MASK_EXPOSURE|MASK_SATURATION|MASK_HUE)) { + gfloat exposure; + gfloat saturation; + gfloat hue; + g_object_get(settings, "exposure", &exposure, "saturation", &saturation, "hue", &hue, NULL); + /* FIXME: this is broken, we should cache the results */ if (rct->cms_transform) matrix4_identity(&rct->color_matrix); else rct->color_matrix = rct->adobe_matrix; - matrix4_color_exposure(&rct->color_matrix, rs_settings_get_exposure(settings)); - matrix4_color_saturate(&rct->color_matrix, rs_settings_get_saturation(settings)); - matrix4_color_hue(&rct->color_matrix, rs_settings_get_hue(settings)); + matrix4_color_exposure(&rct->color_matrix, exposure); + matrix4_color_saturate(&rct->color_matrix, saturation); + matrix4_color_hue(&rct->color_matrix, hue); } if (mask & MASK_WB) { - const gfloat warmth = rs_settings_get_warmth(settings); - const gfloat tint = rs_settings_get_tint(settings); + const gfloat warmth; + const gfloat tint; + g_object_get(settings, "warmth", &warmth, "tint", &tint, NULL); + rct->pre_mul[R] = (1.0+warmth)*(2.0-tint); rct->pre_mul[G] = 1.0; rct->pre_mul[B] = (1.0-warmth)*(2.0-tint); @@ -229,10 +236,13 @@ if (mask & MASK_CONTRAST) { - if (rct->contrast != rs_settings_get_contrast(settings)) + gfloat contrast; + g_object_get(settings, "contrast", &contrast, NULL); + + if (rct->contrast != contrast) { update_tables = TRUE; - rct->contrast = rs_settings_get_contrast(settings); + rct->contrast = contrast; } } Modified: trunk/librawstudio/rs-settings.c =================================================================== --- trunk/librawstudio/rs-settings.c 2009-03-10 01:57:23 UTC (rev 2237) +++ trunk/librawstudio/rs-settings.c 2009-03-10 02:27:34 UTC (rev 2238) @@ -18,6 +18,8 @@ */ #include "rs-settings.h" +#include +#include "gettext.h" #include /* memcmp() */ G_DEFINE_TYPE (RSSettings, rs_settings, G_TYPE_OBJECT) @@ -29,6 +31,9 @@ static guint signals[LAST_SIGNAL] = { 0 }; +static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); +static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); + static void rs_settings_finalize (GObject *object) { @@ -36,12 +41,61 @@ G_OBJECT_CLASS (rs_settings_parent_class)->finalize (object); } +enum { + PROP_0, + PROP_EXPOSURE, + PROP_SATURATION, + PROP_HUE, + PROP_CONTRAST, + PROP_WARMTH, + PROP_TINT, + PROP_SHARPEN, +}; + static void rs_settings_class_init (RSSettingsClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); object_class->finalize = rs_settings_finalize; + object_class->get_property = get_property; + object_class->set_property = set_property; + g_object_class_install_property(object_class, + PROP_EXPOSURE, g_param_spec_float( + "exposure", _("Exposure"), _("Exposure Compensation"), + -3.0, 3.0, 0.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_SATURATION, g_param_spec_float( + "saturation", _("Saturation"), _("Saturation"), + 0.0, 3.0, 1.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_HUE, g_param_spec_float( + "hue", _("Hue"), _("Hue Rotation"), + -180.0, 180.0, 0.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_CONTRAST, g_param_spec_float( + "contrast", _("Contrast"), _("Contrast"), + 0.0, 3.0, 1.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_WARMTH, g_param_spec_float( + "warmth", _("Warmth"), _("Warmth"), + -2.0, 2.0, 0.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_TINT, g_param_spec_float( + "tint", _("Tint"), _("Tint"), + -2.0, 2.0, 0.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_SHARPEN, g_param_spec_float( + "sharpen", _("Sharpen"), _("Sharpen"), + 0.0, 10.0, 0.0, G_PARAM_READWRITE) + ); + signals[SETTINGS_CHANGED] = g_signal_new ("settings-changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, @@ -67,6 +121,67 @@ return g_object_new (RS_TYPE_SETTINGS, NULL); } +static void +get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + RSSettings *settings = RS_SETTINGS(object); + +#define CASE(upper, lower) \ + case PROP_##upper: \ + g_value_set_float(value, settings->lower); \ + break + switch (property_id) + { + CASE(EXPOSURE, exposure); + CASE(SATURATION, saturation); + CASE(HUE, hue); + CASE(CONTRAST, contrast); + CASE(WARMTH, warmth); + CASE(TINT, tint); + CASE(SHARPEN, sharpen); + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +#undef CASE +} + +static void +set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + RSSettings *settings = RS_SETTINGS(object); + RSSettingsMask changed_mask = 0; + +#define CASE(upper, lower) \ + case PROP_##upper: \ + if (settings->lower != g_value_get_float(value)) \ + { \ + settings->lower = g_value_get_float(value); \ + changed_mask |= MASK_##upper; \ + } \ + break + switch (property_id) + { + CASE(EXPOSURE, exposure); + CASE(SATURATION, saturation); + CASE(HUE, hue); + CASE(CONTRAST, contrast); + CASE(WARMTH, warmth); + CASE(TINT, tint); + CASE(SHARPEN, sharpen); + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +#undef CASE + + if (changed_mask > 0) + { + if (settings->commit > 0) + settings->commit_todo |= changed_mask; + else + g_signal_emit(settings, signals[SETTINGS_CHANGED], 0, changed_mask); + } +} + /** * Reset a RSSettings * @param settings A RSSettings @@ -77,26 +192,28 @@ { g_assert(RS_IS_SETTINGS(settings)); + rs_settings_commit_start(settings); + if (mask & MASK_EXPOSURE) - settings->exposure = 0; + rs_object_class_property_reset(settings, "exposure"); if (mask & MASK_SATURATION) - settings->saturation = 1.0; + rs_object_class_property_reset(settings, "saturation"); if (mask & MASK_HUE) - settings->hue = 0.0; + rs_object_class_property_reset(settings, "hue"); if (mask & MASK_CONTRAST) - settings->contrast = 1.0; + rs_object_class_property_reset(settings, "contrast"); if (mask & MASK_WARMTH) - settings->warmth = 0.0; + rs_object_class_property_reset(settings, "warmth"); if (mask & MASK_TINT) - settings->tint = 0.0; + rs_object_class_property_reset(settings, "tint"); if (mask & MASK_SHARPEN) - settings->sharpen = 0.0; + rs_object_class_property_reset(settings, "sharpen"); if (mask && MASK_CURVE) { @@ -110,8 +227,7 @@ settings->curve_nknots = 2; } - if (mask > 0) - g_signal_emit(settings, signals[SETTINGS_CHANGED], 0, mask); + rs_settings_commit_stop(settings); } /** @@ -215,40 +331,6 @@ return changed_mask; } -/* Macro to create functions for changing single parameters, programmers are lazy */ -#define RS_SETTINGS_SET(upper, lower) \ -gfloat \ -rs_settings_set_##lower(RSSettings *settings, const gfloat lower) \ -{ \ - gfloat previous; \ - g_assert(RS_IS_SETTINGS(settings)); \ -\ - previous = settings->lower; \ -\ - if (settings->lower != lower) \ - { \ - settings->lower = lower; \ -\ - if (settings->commit > 0) \ - { \ - settings->commit_todo |= MASK_##upper; \ - } \ - else \ - g_signal_emit(settings, signals[SETTINGS_CHANGED], 0, MASK_##upper); \ - } \ - return previous; \ -} - -RS_SETTINGS_SET(EXPOSURE, exposure) -RS_SETTINGS_SET(SATURATION, saturation) -RS_SETTINGS_SET(HUE, hue) -RS_SETTINGS_SET(CONTRAST, contrast) -RS_SETTINGS_SET(WARMTH, warmth) -RS_SETTINGS_SET(TINT, tint) -RS_SETTINGS_SET(SHARPEN, sharpen) - -#undef RS_SETTINGS_SET - /** * Set curve knots * @param settings A RSSettings @@ -281,30 +363,10 @@ g_assert(RS_IS_SETTINGS(settings)); rs_settings_commit_start(settings); - rs_settings_set_warmth(settings, warmth); - rs_settings_set_tint(settings, tint); + g_object_set(settings, "warmth", warmth, "tint", tint, NULL); rs_settings_commit_stop(settings); } -/* Programmers write programs to write programs */ -#define RS_SETTINGS_GET(lower) \ -gfloat \ -rs_settings_get_##lower(RSSettings *settings) \ -{ \ - g_assert(RS_IS_SETTINGS(settings)); \ - return settings->lower; \ -} - -RS_SETTINGS_GET(exposure); -RS_SETTINGS_GET(saturation); -RS_SETTINGS_GET(hue); -RS_SETTINGS_GET(contrast); -RS_SETTINGS_GET(warmth); -RS_SETTINGS_GET(tint); -RS_SETTINGS_GET(sharpen); - -#undef RS_SETTINGS_GET - /** * Get the knots from the curve * @param settings A RSSettings Modified: trunk/librawstudio/rs-settings.h =================================================================== --- trunk/librawstudio/rs-settings.h 2009-03-10 01:57:23 UTC (rev 2237) +++ trunk/librawstudio/rs-settings.h 2009-03-10 02:27:34 UTC (rev 2238) @@ -97,62 +97,6 @@ extern RSSettingsMask rs_settings_copy(RSSettings *source, const RSSettingsMask mask, RSSettings *target); /** - * Set the exposure value of a RSSettings - * @param settings A RSSettings - * @param exposure New value - * @return Old value - */ -extern gfloat rs_settings_set_exposure(RSSettings *settings, const gfloat exposure); - -/** - * Set the saturation value of a RSSettings - * @param settings A RSSettings - * @param saturation New value - * @return Old value - */ -extern gfloat rs_settings_set_saturation(RSSettings *settings, const gfloat saturation); - -/** - * Set the hue value of a RSSettings - * @param settings A RSSettings - * @param hue New value - * @return Old value - */ -extern gfloat rs_settings_set_hue(RSSettings *settings, const gfloat hue); - -/** - * Set the contrast value of a RSSettings - * @param settings A RSSettings - * @param contrast New value - * @return Old value - */ -extern gfloat rs_settings_set_contrast(RSSettings *settings, const gfloat contrast); - -/** - * Set the warmth value of a RSSettings - * @param settings A RSSettings - * @param warmth New value - * @return Old value - */ -extern gfloat rs_settings_set_warmth(RSSettings *settings, const gfloat warmth); - -/** - * Set the tint value of a RSSettings - * @param settings A RSSettings - * @param tint New value - * @return Old value - */ -extern gfloat rs_settings_set_tint(RSSettings *settings, const gfloat tint); - -/** - * Set the sharpen value of a RSSettings - * @param settings A RSSettings - * @param sharpen New value - * @return Old value - */ -extern gfloat rs_settings_set_sharpen(RSSettings *settings, const gfloat sharpen); - -/** * Set curve knots * @param settings A RSSettings * @param knots Knots for curve @@ -167,14 +111,6 @@ */ extern void rs_settings_set_wb(RSSettings *settings, const gfloat warmth, const gfloat tint); -extern gfloat rs_settings_get_exposure(RSSettings *settings); -extern gfloat rs_settings_get_saturation(RSSettings *settings); -extern gfloat rs_settings_get_hue(RSSettings *settings); -extern gfloat rs_settings_get_contrast(RSSettings *settings); -extern gfloat rs_settings_get_warmth(RSSettings *settings); -extern gfloat rs_settings_get_tint(RSSettings *settings); -extern gfloat rs_settings_get_sharpen(RSSettings *settings); - /** * Get the knots from the curve * @param settings A RSSettings Modified: trunk/src/toolbox.c =================================================================== --- trunk/src/toolbox.c 2009-03-10 01:57:23 UTC (rev 2237) +++ trunk/src/toolbox.c 2009-03-10 02:27:34 UTC (rev 2238) @@ -175,7 +175,7 @@ #define APPLY(lower, upper) \ do { \ if (rc->mask & MASK_##upper) \ - rs_settings_set_##lower(rc->settings, gtk_adjustment_get_value(adj)); \ + g_object_set(rc->settings, #lower, gtk_adjustment_get_value(adj), NULL); \ } while(0) APPLY(exposure, EXPOSURE); APPLY(saturation, SATURATION); @@ -423,8 +423,10 @@ #define APPLY(lower, upper) do { \ if (mask & MASK_##upper) \ {\ + gfloat value = 0.0; \ g_signal_handlers_block_matched(adjusters->lower, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, gui_adj_value_callback, NULL); \ - gtk_adjustment_set_value(adjusters->lower, rs_settings_get_##lower(settings)); \ + g_object_get(settings, #lower, &value, NULL); \ + gtk_adjustment_set_value(adjusters->lower, value); \ g_signal_handlers_unblock_matched(adjusters->lower, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, gui_adj_value_callback, NULL); \ } \ } while(0) @@ -480,6 +482,9 @@ for(n = 0; n < 3; n++) { GtkWidget *embed; gulong settings_signal_id; + GObjectClass *klass = G_OBJECT_GET_CLASS(rs->settings[n]); + GParamSpec *spec; + GParamSpecFloat *specf; tbox[n] = gtk_vbox_new (FALSE, 0); gtk_widget_show (tbox[n]); @@ -487,42 +492,54 @@ settings_signal_id = g_signal_connect(rs->settings[n], "settings-changed", G_CALLBACK(toolbox_settings_changed_cb), adjusters); -#define SLIDER(lower, upper, label, floor, ceiling, step, page) \ - adjusters->lower = GTK_ADJUSTMENT(gtk_adjustment_new(rs_settings_get_##lower(rs->settings[n]), floor, ceiling, step, page, 0.0)); \ +#define SLIDER(lower, upper, page) \ + spec = g_object_class_find_property(klass, #lower); \ + specf = (GParamSpecFloat *) spec; \ + g_assert(spec != NULL); \ + g_assert(G_PARAM_SPEC_VALUE_TYPE(spec) == G_TYPE_FLOAT); \ + adjusters->lower = GTK_ADJUSTMENT(gtk_adjustment_new(specf->default_value, specf->minimum, specf->maximum, 0.1, page, 0.0)); \ rs_conf_get_boolean_with_default(CONF_SHOW_TOOLBOX_##upper, &show, DEFAULT_CONF_SHOW_TOOLBOX_##upper); \ embed = gui_make_scale_from_adj(rs->settings[n], settings_signal_id, G_CALLBACK(gui_adj_value_callback), adjusters->lower, MASK_##upper); \ - toolbox_##lower[n] = gui_box(label, embed, show); \ + toolbox_##lower[n] = gui_box(g_param_spec_get_nick(spec), embed, show); \ gtk_box_pack_start (GTK_BOX (tbox[n]), toolbox_##lower[n], FALSE, FALSE, 0); \ g_signal_connect_after(toolbox_##lower[n], "activate", G_CALLBACK(gui_expander_toggle_callback), toolbox_##lower); \ g_signal_connect_after(toolbox_##lower[n], "activate", G_CALLBACK(gui_expander_save_status_callback), CONF_SHOW_TOOLBOX_##upper) \ - SLIDER(exposure, EXPOSURE, _("Exposure"), -3.0, 3.0, 0.1, 0.5); - SLIDER(saturation, SATURATION, _("Saturation"), 0.0, 3.0, 0.1, 0.5); - SLIDER(hue, HUE, _("Hue"), -180.0, 180.0, 0.1, 30.0); - SLIDER(contrast, CONTRAST, _("Contrast"), 0.0, 3.0, 0.1, 0.5); + SLIDER(exposure, EXPOSURE, 0.5); + SLIDER(saturation, SATURATION, 0.5); + SLIDER(hue, HUE, 30.0); + SLIDER(contrast, CONTRAST, 0.5); /* White balance */ + GParamSpec *warmth_spec, *tint_spec; + gfloat warmth, tint; GtkWidget *box = gtk_vbox_new (FALSE, 0); + gchar *label; rs_conf_get_boolean_with_default(CONF_SHOW_TOOLBOX_WARMTH, &show, DEFAULT_CONF_SHOW_TOOLBOX_WARMTH); + g_object_get(rs->settings[n], "warmth", &warmth, "tint", &tint, NULL); /* Warmth slider */ - adjusters->warmth = GTK_ADJUSTMENT(gtk_adjustment_new(rs_settings_get_warmth(rs->settings[n]), -2.0, 2.0, 0.1, 0.5, 0.0)); + specf = (GParamSpecFloat *) (warmth_spec = g_object_class_find_property(klass, "warmth")); + adjusters->warmth = GTK_ADJUSTMENT(gtk_adjustment_new(warmth, specf->minimum, specf->maximum, 0.1, 0.5, 0.0)); embed = gui_make_scale_from_adj(rs->settings[n], settings_signal_id, G_CALLBACK(gui_adj_value_callback), adjusters->warmth, MASK_WARMTH); \ gtk_box_pack_start (GTK_BOX (box), embed, FALSE, FALSE, 0); /* Tint slider */ - adjusters->tint = GTK_ADJUSTMENT(gtk_adjustment_new(rs_settings_get_tint(rs->settings[n]), -2.0, 2.0, 0.1, 0.5, 0.0)); + specf = (GParamSpecFloat *) (tint_spec = g_object_class_find_property(klass, "tint")); + adjusters->tint = GTK_ADJUSTMENT(gtk_adjustment_new(tint, specf->minimum, specf->maximum, 0.1, 0.5, 0.0)); embed = gui_make_scale_from_adj(rs->settings[n], settings_signal_id, G_CALLBACK(gui_adj_value_callback), adjusters->tint, MASK_TINT); gtk_box_pack_start (GTK_BOX (box), embed, FALSE, FALSE, 0); /* Box it! */ - toolbox_warmth[n] = gui_box(_("Warmth/tint"), box, show); + label = g_strdup_printf("%s/%s", g_param_spec_get_nick(warmth_spec), g_param_spec_get_nick(tint_spec)); + toolbox_warmth[n] = gui_box(label, box, show); + g_free(label); gtk_box_pack_start (GTK_BOX (tbox[n]), toolbox_warmth[n], FALSE, FALSE, 0); \ g_signal_connect_after(toolbox_warmth[n], "activate", G_CALLBACK(gui_expander_toggle_callback), toolbox_warmth); g_signal_connect_after(toolbox_warmth[n], "activate", G_CALLBACK(gui_expander_save_status_callback), CONF_SHOW_TOOLBOX_WARMTH); - SLIDER(sharpen, SHARPEN, _("Sharpen"), 0.0, 10.0, 0.1, 0.5); + SLIDER(sharpen, SHARPEN, 0.5); /* Curve */ gfloat *knots; From klauspost at gmail.com Thu Mar 12 22:56:42 2009 From: klauspost at gmail.com (Klaus Post) Date: Thu, 12 Mar 2009 22:56:42 +0100 Subject: [Rawstudio-commit] rawspeed r64 - / RawSpeed include include/libxml lib Message-ID: Author: post Date: 2009-03-12 22:56:41 +0100 (Thu, 12 Mar 2009) New Revision: 64 Added: RawSpeed/BlackArea.cpp RawSpeed/BlackArea.h RawSpeed/Camera.cpp RawSpeed/Camera.h RawSpeed/CameraMetaData.cpp RawSpeed/CameraMetaData.h RawSpeed/CameraMetadataException.cpp RawSpeed/CameraMetadataException.h RawSpeed/PlanarRawImage.cpp RawSpeed/PlanarRawImage.h cameras.xml include/iconv.h include/libxml/ include/libxml/DOCBparser.h include/libxml/HTMLparser.h include/libxml/HTMLtree.h include/libxml/SAX.h include/libxml/SAX2.h include/libxml/c14n.h include/libxml/catalog.h include/libxml/chvalid.h include/libxml/debugXML.h include/libxml/dict.h include/libxml/encoding.h include/libxml/entities.h include/libxml/globals.h include/libxml/hash.h include/libxml/list.h include/libxml/nanoftp.h include/libxml/nanohttp.h include/libxml/parser.h include/libxml/parserInternals.h include/libxml/pattern.h include/libxml/relaxng.h include/libxml/schemasInternals.h include/libxml/schematron.h include/libxml/threads.h include/libxml/tree.h include/libxml/uri.h include/libxml/valid.h include/libxml/xinclude.h include/libxml/xlink.h include/libxml/xmlIO.h include/libxml/xmlautomata.h include/libxml/xmlerror.h include/libxml/xmlexports.h include/libxml/xmlmemory.h include/libxml/xmlmodule.h include/libxml/xmlreader.h include/libxml/xmlregexp.h include/libxml/xmlsave.h include/libxml/xmlschemas.h include/libxml/xmlschemastypes.h include/libxml/xmlstring.h include/libxml/xmlunicode.h include/libxml/xmlversion.h include/libxml/xmlwin32version.h include/libxml/xmlwriter.h include/libxml/xpath.h include/libxml/xpathInternals.h include/libxml/xpointer.h lib/iconv.lib lib/libxml2.lib Modified: / RawSpeed/ArwDecoder.cpp RawSpeed/ArwDecoder.h RawSpeed/BitPumpJPEG.cpp RawSpeed/ColorFilterArray.cpp RawSpeed/ColorFilterArray.h RawSpeed/Cr2Decoder.cpp RawSpeed/Cr2Decoder.h RawSpeed/DngDecoder.cpp RawSpeed/DngDecoder.h RawSpeed/LJpegDecompressor.cpp RawSpeed/LJpegDecompressor.h RawSpeed/LJpegPlain.cpp RawSpeed/LJpegPlain.h RawSpeed/NefDecoder.cpp RawSpeed/NefDecoder.h RawSpeed/OrfDecoder.cpp RawSpeed/OrfDecoder.h RawSpeed/PefDecoder.cpp RawSpeed/PefDecoder.h RawSpeed/RawDecoder.cpp RawSpeed/RawDecoder.h RawSpeed/RawImage.cpp RawSpeed/RawImage.h RawSpeed/RawSpeed.cpp RawSpeed/RawSpeed.vcproj RawSpeed/Rw2Decoder.cpp RawSpeed/Rw2Decoder.h RawSpeed/rawstudio-plugin-api.cpp Log: - Added external Camera meta data loader. - Windows only - not ported to Linux yet. - Added JPEG Copyright notice (Thanks Hubert) - Now depending on libxml2, ixonv and zlib. Property changes on: ___________________________________________________________________ Name: svn:ignore - debug RawSpeed.ncb RawSpeed.suo release testimg dcraw(4).c + debug RawSpeed.ncb RawSpeed.suo release testimg dcraw(4).c _cfa-patterns.txt cameras.dtd dcraw(5).c Modified: RawSpeed/ArwDecoder.cpp =================================================================== --- RawSpeed/ArwDecoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/ArwDecoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -158,16 +158,17 @@ ThrowRDE("Unsupported bit depth"); } -void ArwDecoder::decodeMetaData() +void ArwDecoder::decodeMetaData(CameraMetaData *meta) { - mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); + //Default + mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); vector data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) - ThrowRDE("CR2 Decoder: Model name found"); + ThrowRDE("ARW Meta Decoder: Model name found"); + string make = data[0]->getEntry(MAKE)->getString(); string model = data[0]->getEntry(MODEL)->getString(); -// printf("Model:\"%s\"\n",model.c_str()); - + setMetaData(meta, make, model); } \ No newline at end of file Modified: RawSpeed/ArwDecoder.h =================================================================== --- RawSpeed/ArwDecoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/ArwDecoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -32,7 +32,7 @@ ArwDecoder(TiffIFD *rootIFD, FileMap* file); virtual ~ArwDecoder(void); virtual RawImage decodeRaw(); - virtual void decodeMetaData(); + virtual void decodeMetaData(CameraMetaData *meta); protected: void DecodeARW(ByteStream &input, guint w, guint h); void DecodeARW2(ByteStream &input, guint w, guint h, guint bpp); Modified: RawSpeed/BitPumpJPEG.cpp =================================================================== --- RawSpeed/BitPumpJPEG.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/BitPumpJPEG.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA http://www.klauspost.com + + This is based on code by Hubert Figuiere. + Copyright (C) 2007 Hubert Figuiere, released under LGPL */ Added: RawSpeed/BlackArea.cpp =================================================================== --- RawSpeed/BlackArea.cpp (rev 0) +++ RawSpeed/BlackArea.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,12 @@ +#include "StdAfx.h" +#include "BlackArea.h" + +BlackArea::BlackArea( int _offset, int _size, gboolean _isVertical ) : +offset(_offset), size(_size), isVertical(isVertical) +{ + +} + +BlackArea::~BlackArea(void) +{ +} Added: RawSpeed/BlackArea.h =================================================================== --- RawSpeed/BlackArea.h (rev 0) +++ RawSpeed/BlackArea.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,11 @@ +#pragma once + +class BlackArea +{ +public: + BlackArea(int offset, int size, gboolean isVertical); + virtual ~BlackArea(void); + gboolean isVertical; // Otherwise horizontal + guint size; // Size in bayer pixels. + guint offset; // Offset in bayer pixels. +}; Added: RawSpeed/Camera.cpp =================================================================== --- RawSpeed/Camera.cpp (rev 0) +++ RawSpeed/Camera.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,152 @@ +#include "StdAfx.h" +#include "Camera.h" + +Camera::Camera(xmlDocPtr doc, xmlNodePtr cur) { + xmlChar *key; + key = xmlGetProp(cur,(const xmlChar *)"make"); + if (!key) + ThrowCME("Camera XML Parser: \"make\" attribute not found."); + make = string((const char*)key); + xmlFree(key); + + key = xmlGetProp(cur,(const xmlChar *)"model"); + if (!key) + ThrowCME("Camera XML Parser: \"model\" attribute not found."); + model = string((const char*)key); + xmlFree(key); + + cur = cur->xmlChildrenNode; + while (cur != NULL) { + parseCameraChild(doc, cur); + cur = cur->next; + } +} + +Camera::~Camera(void) { +} + +void Camera::parseCameraChild( xmlDocPtr doc, xmlNodePtr cur ) +{ + if (!xmlStrcmp(cur->name, (const xmlChar *) "CFA")) { + if( 2 != getAttributeAsInt(cur,cur->name,"width")) + ThrowCME("Unsupported CFA size in camera %s %s", make.c_str(), model.c_str()); + if( 2 != getAttributeAsInt(cur,cur->name,"height")) + ThrowCME("Unsupported CFA size in camera %s %s", make.c_str(), model.c_str()); + + cur = cur->xmlChildrenNode; + while (cur != NULL) { + parseCFA(doc, cur); + cur = cur->next; + } + + return; + } + + if (!xmlStrcmp(cur->name, (const xmlChar *) "Crop")) { + cropPos.x = getAttributeAsInt(cur,cur->name,"x"); + cropPos.y = getAttributeAsInt(cur,cur->name,"y"); + + cropSize.x = getAttributeAsInt(cur,cur->name,"width"); + cropSize.y = getAttributeAsInt(cur,cur->name,"height"); + return; + } + + if (!xmlStrcmp(cur->name, (const xmlChar *) "Sensor")) { + black = getAttributeAsInt(cur,cur->name,"black"); + white = getAttributeAsInt(cur,cur->name,"white"); + return; + } + + if (!xmlStrcmp(cur->name, (const xmlChar *) "BlackAreas")) { + cur = cur->xmlChildrenNode; + while (cur != NULL) { + parseBlackAreas(doc, cur); + cur = cur->next; + } + return; + } +} + +void Camera::parseCFA( xmlDocPtr doc, xmlNodePtr cur ) +{ + xmlChar *key; + if (!xmlStrcmp(cur->name, (const xmlChar *) "Color")) { + int x = getAttributeAsInt(cur,cur->name,"x"); + if (x<0 || x>1) { + ThrowCME("Invalid x coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str()); + } + + int y = getAttributeAsInt(cur,cur->name,"y"); + if (y<0 || y>1) { + ThrowCME("Invalid y coordinate in CFA array of in camera %s %s", make.c_str(), model.c_str()); + } + + key = xmlNodeListGetString(doc, cur->children, 1); + if (!xmlStrcmp(key, (const xmlChar *) "GREEN")) + cfa.setColorAt(iPoint2D(x,y),CFA_GREEN); + else if (!xmlStrcmp(key, (const xmlChar *) "RED")) + cfa.setColorAt(iPoint2D(x,y),CFA_RED); + else if (!xmlStrcmp(key, (const xmlChar *) "BLUE")) + cfa.setColorAt(iPoint2D(x,y),CFA_BLUE); + + xmlFree(key); + + } +} + +void Camera::parseBlackAreas( xmlDocPtr doc, xmlNodePtr cur ) +{ + if (!xmlStrcmp(cur->name, (const xmlChar *) "Vertical")) { + + int x = getAttributeAsInt(cur,cur->name,"x"); + if (x<0) { + ThrowCME("Invalid x coordinate in vertical BlackArea of in camera %s %s", make.c_str(), model.c_str()); + } + + int w = getAttributeAsInt(cur,cur->name,"width"); + if (w<0) { + ThrowCME("Invalid width in vertical BlackArea of in camera %s %s", make.c_str(), model.c_str()); + } + + blackAreas.push_back(BlackArea(x,w,true)); + + } else if (!xmlStrcmp(cur->name, (const xmlChar *) "Horizontal")) { + + int y = getAttributeAsInt(cur,cur->name,"y"); + if (y<0) { + ThrowCME("Invalid y coordinate in horizontal BlackArea of in camera %s %s", make.c_str(), model.c_str()); + } + + int h = getAttributeAsInt(cur,cur->name,"height"); + if (h<0) { + ThrowCME("Invalid width in horizontal BlackArea of in camera %s %s", make.c_str(), model.c_str()); + } + + blackAreas.push_back(BlackArea(y,h,false)); + + } +} + +int Camera::StringToInt( const xmlChar *in, const xmlChar *tag, const char* attribute ) +{ + int i; + + if (EOF == sscanf_s((const char*)in, "%d", &i)) + ThrowCME("Error parsing attribute %s in tag %s, in camera %s %s.", attribute, tag, make.c_str(), model.c_str()); + + return i; +} + + +int Camera::getAttributeAsInt( xmlNodePtr cur , const xmlChar *tag, const char* attribute) +{ + xmlChar *key = xmlGetProp(cur,(const xmlChar *)attribute); + + if (!key) + ThrowCME("Could not find attribute %s in tag %s, in camera %s %s.", attribute, tag, make.c_str(), model.c_str()); + + int i = StringToInt(key,tag,attribute); + + return i; +} + Added: RawSpeed/Camera.h =================================================================== --- RawSpeed/Camera.h (rev 0) +++ RawSpeed/Camera.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,27 @@ +#pragma once +#include "ColorFilterArray.h" +#include +#include "BlackArea.h" +#include "CameraMetadataException.h" + +class Camera +{ +public: + Camera(xmlDocPtr doc, xmlNodePtr cur); + void parseCameraChild(xmlDocPtr doc, xmlNodePtr cur); + virtual ~Camera(void); + string make; + string model; + ColorFilterArray cfa; + guint black; + guint white; + iPoint2D cropSize; + iPoint2D cropPos; + vector blackAreas; + void parseCFA( xmlDocPtr doc, xmlNodePtr cur ); + void parseBlackAreas( xmlDocPtr doc, xmlNodePtr cur ); + +private: + int StringToInt(const xmlChar *in, const xmlChar *tag, const char* attribute); + int getAttributeAsInt( xmlNodePtr cur , const xmlChar *tag, const char* attribute); +}; Added: RawSpeed/CameraMetaData.cpp =================================================================== --- RawSpeed/CameraMetaData.cpp (rev 0) +++ RawSpeed/CameraMetaData.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,93 @@ +#include "StdAfx.h" +#include "CameraMetaData.h" +#include + +CameraMetaData::CameraMetaData(char *docname) +{ + ctxt = xmlNewParserCtxt(); + doc = xmlCtxtReadFile(ctxt, docname, NULL, XML_PARSE_DTDVALID); + + if (doc == NULL ) { + ThrowCME("CameraMetaData: XML Document could not be parsed successfully. Error was: %s", ctxt->lastError.message); + } + + if (ctxt->valid == 0) { + if (ctxt->lastError.code ==0x5e) { + printf("CameraMetaData: Unable to locate DTD, attempting to ignore."); + } else { + ThrowCME("CameraMetaData: XML file does not validate. DTD Error was: %s", ctxt->lastError.message); + } + } + + xmlNodePtr cur; + cur = xmlDocGetRootElement(doc); + if (xmlStrcmp(cur->name, (const xmlChar *) "Cameras")) { + ThrowCME("CameraMetaData: XML document of the wrong type, root node is not cameras."); + return; + } + + cur = cur->xmlChildrenNode; + while (cur != NULL) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"Camera"))){ + Camera *camera = new Camera(doc, cur); + string id = string(camera->make).append(camera->model); + if (cameras.end() !=cameras.find(id)) + printf("CameraMetaData: Duplicate entry found for camera: %s %s, Skipping!\n",camera->make.c_str(), camera->model.c_str()); + else + cameras[id] = camera; + } + cur = cur->next; + } +} + +CameraMetaData::~CameraMetaData(void) { + if (doc) + xmlFreeDoc(doc); + doc = 0; + if (ctxt) + xmlFreeParserCtxt(ctxt); + ctxt = 0; +} + +void CameraMetaData::dumpXML() +{ + map::iterator i = cameras.begin(); + for ( ; i != cameras.end(); i++) { + dumpCameraXML((*i).second); + } +} + +void CameraMetaData::dumpCameraXML( Camera* cam ) +{ + cout << "make << "\" model = \"" << cam->model << "\">" << endl; + cout << "" << endl; + cout << "" << ColorFilterArray::colorToString(cam->cfa.getColorAt(0,0)) << ""; + cout << "" << ColorFilterArray::colorToString(cam->cfa.getColorAt(1,0)) << "" << endl; + cout << "" << ColorFilterArray::colorToString(cam->cfa.getColorAt(0,1)) << ""; + cout << "" << ColorFilterArray::colorToString(cam->cfa.getColorAt(1,1)) << "" << endl; + cout << "" << endl; + cout << "cropPos.x << "\" y=\"" << cam->cropPos.y << "\" "; + cout << "width=\"" << cam->cropSize.x << "\" height=\"" << cam->cropSize.y << "\"/>" << endl; + cout << "black << "\" white=\"" << cam->white << "\"/>" << endl; + if (!cam->blackAreas.empty()) { + cout << "" << endl; + for (guint i = 0; i < cam->blackAreas.size(); i++) { + BlackArea b = cam->blackAreas[i]; + if (b.isVertical) { + cout << ""<< endl; + } else { + cout << ""<< endl; + } + } + cout << "" << endl; + } + cout << "" < +#include +#include +#include "Camera.h" + +class CameraMetaData +{ +public: + CameraMetaData(char *docname); + virtual ~CameraMetaData(void); + xmlDocPtr doc; + xmlParserCtxtPtr ctxt; /* the parser context */ + map cameras; + void dumpXML(); + Camera* getCamera(string make, string model); +protected: + void dumpCameraXML(Camera* cam); +}; Added: RawSpeed/CameraMetadataException.cpp =================================================================== --- RawSpeed/CameraMetadataException.cpp (rev 0) +++ RawSpeed/CameraMetadataException.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,21 @@ +#include "StdAfx.h" +#include "CameraMetadataException.h" + +void ThrowCME(const char* fmt, ...) { + va_list val; + va_start(val, fmt); + char buf[8192]; + vsprintf_s(buf, 8192, fmt, val); + va_end(val); + _RPT1(0, "EXCEPTION: %s\n",buf); + throw CameraMetadataException(buf); +} + +CameraMetadataException::CameraMetadataException(const string _msg): runtime_error(_msg) +{ + _RPT1(0, "CameraMetadata Exception: %s\n", _msg.c_str()); +} + +CameraMetadataException::~CameraMetadataException(void) +{ +} Added: RawSpeed/CameraMetadataException.h =================================================================== --- RawSpeed/CameraMetadataException.h (rev 0) +++ RawSpeed/CameraMetadataException.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,12 @@ +#pragma once + +void ThrowCME(const char* fmt, ...); + +class CameraMetadataException : + public std::runtime_error +{ +public: + CameraMetadataException(const string _msg); +public: + ~CameraMetadataException(void); +}; Modified: RawSpeed/ColorFilterArray.cpp =================================================================== --- RawSpeed/ColorFilterArray.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/ColorFilterArray.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -86,5 +86,25 @@ if (pos.y > 1 || pos.y < 0) ThrowRDE("ColorFilterArray::SetColor: position out of CFA pattern"); cfa[pos.x+pos.y*2] = c; - _RPT2(0, "cfa[%u] = %u\n",pos.x+pos.y*2, c); +// _RPT2(0, "cfa[%u] = %u\n",pos.x+pos.y*2, c); +} + +void ColorFilterArray::shiftLeft() +{ + CFAColor tmp1 = cfa[0]; + CFAColor tmp2 = cfa[2]; + cfa[0] = cfa[1]; + cfa[2] = cfa[3]; + cfa[1] = tmp1; + cfa[3] = tmp2; +} + +void ColorFilterArray::shiftDown() +{ + CFAColor tmp1 = cfa[0]; + CFAColor tmp2 = cfa[1]; + cfa[0] = cfa[2]; + cfa[1] = cfa[3]; + cfa[2] = tmp1; + cfa[3] = tmp2; } \ No newline at end of file Modified: RawSpeed/ColorFilterArray.h =================================================================== --- RawSpeed/ColorFilterArray.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/ColorFilterArray.h 2009-03-12 21:56:41 UTC (rev 64) @@ -34,8 +34,10 @@ __inline CFAColor getColorAt(guint x, guint y) {return cfa[(x&1)+((y&1)<<1)];} guint toDcrawColor(CFAColor c); guint getDcrawFilter(); + void shiftLeft(); + void shiftDown(); std::string asString(); + static std::string colorToString(CFAColor c); private: - std::string colorToString(CFAColor c); CFAColor cfa[4]; }; Modified: RawSpeed/Cr2Decoder.cpp =================================================================== --- RawSpeed/Cr2Decoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/Cr2Decoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -110,17 +110,16 @@ return mRaw; } -void Cr2Decoder::decodeMetaData() { +void Cr2Decoder::decodeMetaData(CameraMetaData *meta) { mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); vector data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) - ThrowRDE("CR2 Decoder: Model name found"); + ThrowRDE("ARW Meta Decoder: Model name found"); + string make = data[0]->getEntry(MAKE)->getString(); string model = data[0]->getEntry(MODEL)->getString(); - if (!model.compare("Canon EOS-1Ds Mark II") || - !model.compare("Canon EOS 5D Mark II") ) { - mRaw->cfa.setCFA(CFA_GREEN2, CFA_BLUE, CFA_RED, CFA_GREEN); - } + setMetaData(meta, make, model); + } \ No newline at end of file Modified: RawSpeed/Cr2Decoder.h =================================================================== --- RawSpeed/Cr2Decoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/Cr2Decoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -30,7 +30,7 @@ public: Cr2Decoder(TiffIFD *rootIFD, FileMap* file); virtual RawImage decodeRaw(); - virtual void decodeMetaData(); + virtual void decodeMetaData(CameraMetaData *meta); virtual ~Cr2Decoder(void); protected: TiffIFD *mRootIFD; Modified: RawSpeed/DngDecoder.cpp =================================================================== --- RawSpeed/DngDecoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/DngDecoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -1,5 +1,7 @@ #include "StdAfx.h" #include "DngDecoder.h" +#include + /* RawSpeed - RAW file decoder. @@ -22,6 +24,8 @@ http://www.klauspost.com */ +//#define PRINT_INFO + DngDecoder::DngDecoder(TiffIFD *rootIFD, FileMap* file) : RawDecoder(file), mRootIFD(rootIFD) { vector data = mRootIFD->getIFDsWithTag(DNGVERSION); @@ -99,11 +103,11 @@ if (raw->hasEntry(CFAPLANECOLOR)) { TiffEntry* e = raw->getEntry(CFAPLANECOLOR); const unsigned char* cPlaneOrder = e->getData(); // Map from the order in the image, to the position in the CFA - printf("Planecolor: "); +/* printf("Planecolor: "); for (guint i = 0; i < e->count; i++) { printf("%u,",cPlaneOrder[i]); } - printf("\n"); + printf("\n"); */ } iPoint2D cfaSize(pDim[1],pDim[0]); @@ -242,7 +246,7 @@ } catch (TiffParserException) { ThrowRDE("DNG Decoder: Image could not be read."); } - +#ifndef PRINT_INFO // Crop if (raw->hasEntry(ACTIVEAREA)) { const guint *corners = raw->getEntry(ACTIVEAREA)->getIntArray(); @@ -250,6 +254,7 @@ iPoint2D new_size(corners[3]-corners[1], corners[2]-corners[0]); mRaw->subFrame(top_left,new_size); } +#endif // Linearization if (raw->hasEntry(LINEARIZATIONTABLE)) { @@ -262,7 +267,7 @@ else table[i] = intable[len-1]; } - for (guint y = 0; y < mRaw->dim.y; y++) { + for (gint y = 0; y < mRaw->dim.y; y++) { guint cw = mRaw->dim.x*mRaw->getCpp(); gushort* pixels = (gushort*)mRaw->getData(0,y); for (guint x = 0; x < cw; x++) { @@ -270,11 +275,71 @@ } } } + mRaw->whitePoint = raw->getEntry(WHITELEVEL)->getInt(); + return mRaw; } -void DngDecoder::decodeMetaData() +void DngDecoder::decodeMetaData(CameraMetaData *meta) { +#ifdef PRINT_INFO + if (mRaw->isCFA) + printMetaData(); +#endif +} +void DngDecoder::printMetaData() +{ + vector data = mRootIFD->getIFDsWithTag(MODEL); + if (data.empty()) + ThrowRDE("Model name found"); + TiffIFD* raw = data[0]; + + string model = raw->getEntry(MODEL)->getString(); + string make = raw->getEntry(MAKE)->getString(); + TrimSpaces(model); + TrimSpaces(make); + + data = mRootIFD->getIFDsWithTag(ACTIVEAREA); + if (data.empty()) + ThrowRDE("Model name found"); + raw = data[0]; + + ColorFilterArray cfa(mRaw->cfa); + const guint *corners = raw->getEntry(ACTIVEAREA)->getIntArray(); + iPoint2D top_left(corners[1], corners[0]); + iPoint2D new_size(corners[3]-corners[1], corners[2]-corners[0]); + + if (top_left.x & 1) + cfa.shiftLeft(); + if (top_left.y & 1) + cfa.shiftDown(); + + cout << "" << endl; + cout << "" << endl; + cout << "" << ColorFilterArray::colorToString(cfa.getColorAt(0,0)) << ""; + cout << "" << ColorFilterArray::colorToString(cfa.getColorAt(1,0)) << "" << endl; + cout << "" << ColorFilterArray::colorToString(cfa.getColorAt(0,1)) << ""; + cout << "" << ColorFilterArray::colorToString(cfa.getColorAt(1,1)) << "" << endl; + cout << "" << endl; + cout << "" << endl; + int white = raw->getEntry(WHITELEVEL)->getInt(); + int b = 65536; + for(int row=10;rowdim.y-10;row++) + { + gushort *pixel = (gushort*)&mRaw->getData()[row*mRaw->pitch+10*mRaw->bpp]; + for(int col=10;col<(mRaw->dim.x-20);col++) + { + b = MIN(*pixel, b); + pixel++; + } + } + + cout << "" << endl; + + cout << "" <1 && skipX)); // Check if this is a valid state + guint comps = frame.cps; // Components + HuffmanTable *dctbl[4]; // Tables for up to 4 components + gushort *predict[4]; // Prediction pointers for each of the four components + guint samplesH[4]; + guint samplesV[4]; + guint skipEveryH[4]; + guint skipEveryV[4]; + + guchar *draw = mRaw->getData(); + guint maxSuperH = 1; + guint maxSuperV = 1; + for (guint i = 0; i < comps; i++) { + dctbl[i] = &huff[frame.compInfo[i].dcTblNo]; + samplesH[i] = frame.compInfo[i].superH; + maxSuperH = max(samplesH[i], maxSuperH); + samplesV[i] = frame.compInfo[i].superV; + maxSuperV = max(samplesV[i], maxSuperV); + } + for (guint i = 0; i < comps; i++) { + skipEveryH[i] = maxSuperH / samplesH[i] - 1; // Mask for determining if we should skip + skipEveryV[i] = maxSuperV / samplesV[i] - 1; // 0 = skip no lines, 1 = skip odd, 3 = skip 1-2-3 + } + + //Prepare slices (for CR2) + guint slices = (guint)slicesW.size()*(frame.h-skipY); + offset = new guint[slices+1]; + + guint t_y = 0; + guint t_x = 0; + guint t_s = 0; + guint slice = 0; + for (slice = 0; slice< slices; slice++) { + offset[slice] = ((t_x+offX)*mRaw->bpp+((offY+t_y)*mRaw->pitch)) | (t_s<<28); + _ASSERTE((offset[slice]&0x0fffffff)pitch*mRaw->dim.y); + t_y++; + if (t_y == (frame.h-skipY)) { + t_y = 0; + t_x += slicesW[t_s++]; + } + } + offset[slices] = offset[slices-1]; // Extra offset to avoid branch in loop. + + if (skipX) + slicesW[slicesW.size()-1] -= skipX*frame.cps; + + // First pixels are obviously not predicted + gint p[4]; + gushort *dest = (gushort*)&draw[offset[0]&0x0fffffff]; + + // First pixels + for (guint i = 0; i < comps; i++) { + predict[i] = dest; + *dest++ = p[i] = (1<<(frame.prec-Pt-1)) + HuffDecode(dctbl[i]); + for (guint j = 0; j < samplesH[i]; j++) { + p[i] += HuffDecode(dctbl[i]); + *dest++ = p[i]; + } + } + + slices = (guint)slicesW.size(); + slice = 1; + guint pixInSlice = slicesW[0]/comps-1; // This is divided by comps, since comps pixels are processed at the time + + guint cw = (frame.w-skipX); + guint x = 1; // Skip first pixels on first line. + + for (guint y=0;y<(frame.h-skipY);y++) { + for (; x < cw ; x++) { + for (guint i = 0; i < comps; i++) { + if (((y&skipEveryV[i])==0) && ((x&skipEveryH[i])==0)) { // Should this component be decoded? + p[i] += HuffDecode(dctbl[i]); + _ASSERTE(p[i]>=0 && p[i]<65536); + *dest++ = p[i]; + } + } + + if (0 == --pixInSlice) { // Next slice + guint o = offset[slice++]; + dest = (gushort*)&draw[o&0x0fffffff]; // Adjust destination for next pixel + _ASSERTE((o&0x0fffffff)pitch*mRaw->dim.y); + pixInSlice = slicesW[o>>28]/comps; + } + bits->checkPos(); + } + if (skipX) { + for (guint i = 0; i < skipX; i++) { + for (guint i = 0; i < comps; i++) + if ((y&skipEveryV[i])==0 && (x&skipEveryV[i])==0) + HuffDecode(dctbl[i]); + } + } + for (guint i = 0; i < comps; i++) { + if ((y&skipEveryV[i])==0) { + p[i] = *predict[i]; + predict[i] = dest; + } + } + x = 0; + } +} + #define COMPS 2 void LJpegPlain::decodeScanLeft2Comps() { _ASSERTE(slicesW.size()<16); // We only have 4 bits for slice number. Modified: RawSpeed/LJpegPlain.h =================================================================== --- RawSpeed/LJpegPlain.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/LJpegPlain.h 2009-03-12 21:56:41 UTC (rev 64) @@ -39,5 +39,6 @@ void decodeScanLeft4Comps(); void decodeScanLeft2Comps(); void decodeScanLeft3Comps(); + void decodeScanLeftGeneric(); guint *offset; }; Modified: RawSpeed/NefDecoder.cpp =================================================================== --- RawSpeed/NefDecoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/NefDecoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -211,12 +211,23 @@ }*/ } -void NefDecoder::decodeMetaData() +void NefDecoder::decodeMetaData(CameraMetaData *meta) { mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); + vector data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) + ThrowRDE("ARW Meta Decoder: Model name found"); + + string make = data[0]->getEntry(MAKE)->getString(); + string model = data[0]->getEntry(MODEL)->getString(); + + setMetaData(meta, make, model); + +/* vector data = mRootIFD->getIFDsWithTag(MODEL); + + if (data.empty()) ThrowRDE("CR2 Decoder: Model name found"); string model(data[0]->getEntry(MODEL)->getString()); @@ -245,5 +256,5 @@ { mRaw->cfa.setCFA(CFA_BLUE, CFA_GREEN, CFA_GREEN2, CFA_RED); } - +*/ } \ No newline at end of file Modified: RawSpeed/NefDecoder.h =================================================================== --- RawSpeed/NefDecoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/NefDecoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -34,7 +34,7 @@ NefDecoder(TiffIFD *rootIFD, FileMap* file); virtual ~NefDecoder(void); virtual RawImage decodeRaw(); - virtual void decodeMetaData(); + virtual void decodeMetaData(CameraMetaData *meta); TiffIFD *mRootIFD; private: gboolean D100IsCompressed(guint offset); Modified: RawSpeed/OrfDecoder.cpp =================================================================== --- RawSpeed/OrfDecoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/OrfDecoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -139,8 +139,17 @@ } } -void OrfDecoder::decodeMetaData() +void OrfDecoder::decodeMetaData(CameraMetaData *meta) { mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); + vector data = mRootIFD->getIFDsWithTag(MODEL); + if (data.empty()) + ThrowRDE("ARW Meta Decoder: Model name found"); + + string make = data[0]->getEntry(MAKE)->getString(); + string model = data[0]->getEntry(MODEL)->getString(); + + setMetaData(meta, make, model); + } Modified: RawSpeed/OrfDecoder.h =================================================================== --- RawSpeed/OrfDecoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/OrfDecoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -33,7 +33,7 @@ OrfDecoder(TiffIFD *rootIFD, FileMap* file); virtual ~OrfDecoder(void); virtual RawImage decodeRaw(); - virtual void decodeMetaData(); + virtual void decodeMetaData(CameraMetaData *meta); private: void decodeCompressed(ByteStream& s,guint w, guint h); TiffIFD *mRootIFD; Modified: RawSpeed/PefDecoder.cpp =================================================================== --- RawSpeed/PefDecoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/PefDecoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -69,12 +69,22 @@ return mRaw; } -void PefDecoder::decodeMetaData() +void PefDecoder::decodeMetaData(CameraMetaData *meta) { mRaw->cfa.setCFA(CFA_RED, CFA_GREEN, CFA_GREEN2, CFA_BLUE); vector data = mRootIFD->getIFDsWithTag(MODEL); if (data.empty()) + ThrowRDE("ARW Meta Decoder: Model name found"); + + string make = data[0]->getEntry(MAKE)->getString(); + string model = data[0]->getEntry(MODEL)->getString(); + + setMetaData(meta, make, model); + +/* vector data = mRootIFD->getIFDsWithTag(MODEL); + + if (data.empty()) ThrowRDE("PEF Decoder: Model name found"); string model(data[0]->getEntry(MODEL)->getString()); @@ -84,4 +94,5 @@ { mRaw->cfa.setCFA(CFA_BLUE, CFA_GREEN, CFA_GREEN2, CFA_RED); } +*/ } \ No newline at end of file Modified: RawSpeed/PefDecoder.h =================================================================== --- RawSpeed/PefDecoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/PefDecoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -31,7 +31,7 @@ PefDecoder(TiffIFD *rootIFD, FileMap* file); virtual ~PefDecoder(void); virtual RawImage decodeRaw(); - virtual void decodeMetaData(); + virtual void decodeMetaData(CameraMetaData *meta); TiffIFD *mRootIFD; }; Added: RawSpeed/PlanarRawImage.cpp =================================================================== --- RawSpeed/PlanarRawImage.cpp (rev 0) +++ RawSpeed/PlanarRawImage.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,33 @@ +#include "StdAfx.h" +/* +RawSpeed - RAW file decoder. + +Copyright (C) 2009 Klaus Post + +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 2 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, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +http://www.klauspost.com +*/ + + +#include "PlanarRawImage.h" + +PlanarRawImage::PlanarRawImage(void) +{ +} + +PlanarRawImage::~PlanarRawImage(void) +{ +} Added: RawSpeed/PlanarRawImage.h =================================================================== --- RawSpeed/PlanarRawImage.h (rev 0) +++ RawSpeed/PlanarRawImage.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,48 @@ +#pragma once +/* +RawSpeed - RAW file decoder. + +Copyright (C) 2009 Klaus Post + +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 2 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, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +http://www.klauspost.com +*/ + +#include "RawImage.h" + +/**** +* Conventions: +* +* The dimensions of an image is determined by the largest plane. +* Each plane size is defined as the largest plane divided by a power of two. +* Each plane can only hold one component. +* Each planar image can only hold up to four planes. +****/ +class PlanarPlane { +public: + PlanarPlane() : data(0), subfactor(0) {}; + guchar* data; + guint subfactor; +}; + +class PlanarRawImage : + public RawImage +{ +public: + PlanarRawImage(void); + virtual ~PlanarRawImage(void); + PlanarPlane p[4]; +}; Modified: RawSpeed/RawDecoder.cpp =================================================================== --- RawSpeed/RawDecoder.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/RawDecoder.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -107,6 +107,38 @@ } } -void RawDecoder::decodeMetaData() { -} \ No newline at end of file +void RawDecoder::setMetaData( CameraMetaData *meta, string make, string model ) +{ + TrimSpaces(make); + TrimSpaces(model); + Camera *cam = meta->getCamera(make, model); + if (!cam) { + printf("Unable to find camera in database: %s %s\n", make.c_str(), model.c_str()); + return; + } + mRaw->subFrame(cam->cropPos, cam->cropSize); + mRaw->cfa = cam->cfa; + if (cam->cropPos.x & 1) + mRaw->cfa.shiftLeft(); + if (cam->cropPos.y & 1) + mRaw->cfa.shiftDown(); + + mRaw->blackLevel = cam->black; + mRaw->whitePoint = cam->white; +} +void RawDecoder::TrimSpaces( string& str) +{ + // Trim Both leading and trailing spaces + size_t startpos = str.find_first_not_of(" \t"); // Find the first character position after excluding leading blank spaces + size_t endpos = str.find_last_not_of(" \t"); // Find the first character position from reverse af + + // if all spaces or empty return an empty string + if(( string::npos == startpos ) || ( string::npos == endpos)) + { + str = ""; + } + else + str = str.substr( startpos, endpos-startpos+1 ); + +} Modified: RawSpeed/RawDecoder.h =================================================================== --- RawSpeed/RawDecoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/RawDecoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -5,6 +5,7 @@ #include "RawImage.h" #include "BitPumpMSB.h" #include "BitPumpPlain.h" +#include "CameraMetaData.h" class RawDecoder { @@ -12,13 +13,15 @@ RawDecoder(FileMap* file); virtual ~RawDecoder(void); virtual RawImage decodeRaw() = 0; - virtual void decodeMetaData(); + virtual void decodeMetaData(CameraMetaData *meta) = 0; FileMap *mFile; void readUncompressedRaw(ByteStream &input, iPoint2D& size, iPoint2D& offset, int inputPitch, int bitPerPixel, gboolean MSBOrder); RawImage mRaw; vector errors; protected: + virtual void setMetaData(CameraMetaData *meta, string make, string model); void Decode12BitRaw(ByteStream &input, guint w, guint h); + void TrimSpaces( string& str); }; Modified: RawSpeed/RawImage.cpp =================================================================== --- RawSpeed/RawImage.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/RawImage.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -24,13 +24,16 @@ */ RawImageData::RawImageData(void): -dim(0,0), bpp(0), isCFA(true), dataRefCount(0),data(0), cpp(1) +dim(0,0), bpp(0), isCFA(true), dataRefCount(0),data(0), cpp(1), +blackLevel(-1), whitePoint(65536) { pthread_mutex_init(&mymutex, NULL); } RawImageData::RawImageData(iPoint2D _dim, guint _bpc, guint cpp) : -dim(_dim), bpp(_bpc), dataRefCount(0),data(0) { +dim(_dim), bpp(_bpc), dataRefCount(0),data(0), +blackLevel(-1), whitePoint(65536) +{ createData(); pthread_mutex_init(&mymutex, NULL); } @@ -93,6 +96,36 @@ dim = new_size; } +void RawImageData::scaleBlackWhite() +{ + gint gw = (dim.x-20)*cpp; + if (blackLevel < 0 || whitePoint == 65536) { // Estimate + int b = 65536; + int m = 0; + for(int row=10;row>14,16); + } + } +} + RawImage::RawImage( RawImageData* p ) : p_(p) { pthread_mutex_lock(&p_->mymutex); @@ -106,6 +139,7 @@ ++p_->dataRefCount; pthread_mutex_unlock(&p_->mymutex); } + RawImage::~RawImage() { pthread_mutex_lock(&p_->mymutex); Modified: RawSpeed/RawImage.h =================================================================== --- RawSpeed/RawImage.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/RawImage.h 2009-03-12 21:56:41 UTC (rev 64) @@ -34,13 +34,16 @@ guint getCpp() const { return cpp; } void setCpp(guint val); guint pitch; - void createData(); + virtual void createData(); guchar* getData(); guchar* getData(guint x, guint y); // Not super fast, but safe. Don't use per pixel. + virtual void subFrame( iPoint2D offset, iPoint2D new_size ); + void scaleBlackWhite(); gboolean isCFA; ColorFilterArray cfa; - void subFrame( iPoint2D offset, iPoint2D new_size ); -private: + int blackLevel; + int whitePoint; +protected: RawImageData(void); RawImageData(iPoint2D dim, guint bpp, guint cpp=1); guint dataRefCount; Modified: RawSpeed/RawSpeed.cpp =================================================================== --- RawSpeed/RawSpeed.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/RawSpeed.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -23,6 +23,8 @@ #include "FileReader.h" #include "TiffParser.h" #include "RawDecoder.h" +#include "CameraMetaData.h" + #define _USE_GFL_ #ifdef _USE_GFL_ #include "libgfl.h" @@ -33,7 +35,7 @@ int startTime; -void OpenFile(FileReader f) { +void OpenFile(FileReader f, CameraMetaData *meta) { RawDecoder *d = 0; FileMap* m = 0; try { @@ -46,19 +48,20 @@ startTime = GetTickCount(); try { d->decodeRaw(); - d->decodeMetaData(); + d->decodeMetaData(meta); RawImage r = d->mRaw; guint time = GetTickCount()-startTime; float mpps = (float)r->dim.x * (float)r->dim.y * (float)r->getCpp() / (1000.0f * (float)time); wprintf(L"Decoding %s took: %u ms, %4.2f Mpixel/s\n", f.Filename(), time, mpps); + r->scaleBlackWhite(); for (guint i = 0; i < d->errors.size(); i++) { printf("Error Encoutered:%s", d->errors[i]); } if (r->isCFA) { - printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); - printf(r->cfa.asString().c_str()); +// printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); +// printf(r->cfa.asString().c_str()); } #ifdef _USE_GFL_ @@ -112,238 +115,240 @@ return 1; } #endif -/* -// OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_LX3(300109).dng")); - //OpenFile(FileReader(L"..\\testimg\\Panasonic_LX3.rw2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk2.cr2")); - OpenFile(FileReader(L"..\\testimg\\5d.CR2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk3-2.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_20D-demosaic.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_30D.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_450D.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_350d.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_40D.cr2")); -// OpenFile(FileReader(L"..\\testimg\\Canon_EOS_50D.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_450D-2.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_G10.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_PowerShot_G9.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1D_Mk2.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1000D.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1D_Mk3.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk3.cr2")); - OpenFile(FileReader(L"..\\testimg\\Canon_EOS_400D.cr2")); + CameraMetaData meta("..\\cameras.xml"); + //meta.dumpXML(); +// OpenFile(FileReader(L"..\\testimg\\dng\\Panasonic_LX3(300109).dng"),&meta); + //OpenFile(FileReader(L"..\\testimg\\Panasonic_LX3.rw2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_50D.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\kp.CR2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk2.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\5d.CR2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk3-2.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_20D-demosaic.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_30D.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_450D.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_350d.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_40D.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_450D-2.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_Powershot_G10.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_PowerShot_G9.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1D_Mk2.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1000D.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1D_Mk3.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_1Ds_Mk3.cr2"),&meta); + OpenFile(FileReader(L"..\\testimg\\Canon_EOS_400D.cr2"),&meta); - OpenFile(FileReader(L"..\\testimg\\Pentax_K10D-2.dng")); - OpenFile(FileReader(L"..\\testimg\\Pentax_K10D.pef")); - OpenFile(FileReader(L"..\\testimg\\Pentax_K100D.pef")); - OpenFile(FileReader(L"..\\testimg\\Pentax_K10D.pef")); - OpenFile(FileReader(L"..\\testimg\\Pentax_K20D.pef")); - OpenFile(FileReader(L"..\\testimg\\Pentax_optio_33wr.pef")); + OpenFile(FileReader(L"..\\testimg\\Pentax_K10D-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\Pentax_K10D.pef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Pentax_K100D.pef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Pentax_K10D.pef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Pentax_K20D.pef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Pentax_optio_33wr.pef"),&meta); - OpenFile(FileReader(L"..\\testimg\\SONY-DSLR-A700.arw")); - OpenFile(FileReader(L"..\\testimg\\SONY_A200.ARW")); - OpenFile(FileReader(L"..\\testimg\\Sony_A300.arw")); - OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A100-1.arw")); - OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A350.arw")); - OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900-2.arw")); - OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900.arw")); + OpenFile(FileReader(L"..\\testimg\\SONY-DSLR-A700.arw"),&meta); + OpenFile(FileReader(L"..\\testimg\\SONY_A200.ARW"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_A300.arw"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A100-1.arw"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A350.arw"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900-2.arw"),&meta); + OpenFile(FileReader(L"..\\testimg\\Sony_DSLR-A900.arw"),&meta); - OpenFile(FileReader(L"..\\testimg\\Nikon_D1.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D100-backhigh.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D200_compressed-1.nef")); - OpenFile(FileReader(L"..\\testimg\\NikonCoolPix8800.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D1H.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D1X.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D2H.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D2X_sRGB.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D100-1.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D200-1.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D3.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D300.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D40X.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D40_(sRGB).nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D60-2.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D60.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D70.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D700.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D70s-3.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D80_(sRGB).nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_D90.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_E5400.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_E5700.nef")); - OpenFile(FileReader(L"..\\testimg\\Nikon_E5700_(sRGB).nef")); + OpenFile(FileReader(L"..\\testimg\\Nikon_D1.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D100-backhigh.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D200_compressed-1.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\NikonCoolPix8800.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D1H.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D1X.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D2H.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D2X_sRGB.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D100-1.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D200-1.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D3.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D300.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D40X.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D40_(sRGB).nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D60-2.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D60.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D70.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D700.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D70s-3.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D80_(sRGB).nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_D90.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_E5400.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_E5700.nef"),&meta); + OpenFile(FileReader(L"..\\testimg\\Nikon_E5700_(sRGB).nef"),&meta); - OpenFile(FileReader(L"..\\testimg\\Olympus_500UZ.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_C7070WZ.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_C8080.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E1.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E10.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E20.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E3-2.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E3-3.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E3-4.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E3.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E300.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E330.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E400.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E410-2.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E410.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E420.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E500.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E510-2.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E510.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E520-2.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E520-3.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E520-4.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E520-5.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_E520.orf")); - OpenFile(FileReader(L"..\\testimg\\Olympus_SP350.orf")); -*/ - OpenFile(FileReader(L"..\\testimg\\dng\\5d-raw.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\5d.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS10-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS10.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS20D-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS20D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS300D-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS300D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-POWERSHOTPRO1-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\CANON-POWERSHOTPRO1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1000D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1Ds_Mk2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1Ds_Mk3-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1Ds_Mk3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1D_Mk2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1D_Mk2_N.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1D_Mk3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_20D-demosaic.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_20d.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_30D-uga1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_30D-uga2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_30D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_350d-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_350D-3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_350d.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_400D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_40D-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_40D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-4.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-5.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D_Mk2-ISO100_sRAW1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D_Mk2-ISO12800_sRAW1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D_Mk2-ISO12800_sRAW2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_Mk2-ISO100_sRAW2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_Powershot_G10.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_Powershot_G9-1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_Powershot_G9-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Canon_PowerShot_G9.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\FUJI-FINEPIXS2PRO-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\FUJI-FINEPIXS2PRO.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\KODAK-DCSPRO-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\KODAK-DCSPRO.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\M8-1-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\M8-1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE5-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE5.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE7HI-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE7HI.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGEA1-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGEA1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-01-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-01.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-02-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-02.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-03-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-03.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-04-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-04.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-05-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-05.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-COOLPIX5700-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-COOLPIX5700.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D100-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D100.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-01-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-01.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-02-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-02.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\NikonCoolPix8800.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D100-1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D1H.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D1X.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D200-1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D200_compressed-1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D2H.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D2X_sRGB.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D300.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D40X.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D40_(sRGB).dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D60-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D60.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D70.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D700.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D70s-3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D80_(sRGB).dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D90.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_E5400.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_E5700.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_E5700_(sRGB).dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-C5050Z-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-C5050Z.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-E10-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-E10.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_500UZ.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_C7070WZ.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_C8080.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E10.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E20.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3-3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3-4.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E300.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E330.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E400.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E410-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E410.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E420.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E500.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E510-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E510.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-3.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-4.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-5.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_SP350.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\PENTAX-ISD-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\PENTAX-ISD.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K100D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K10D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K20D.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\SIGMA-SD10-linear.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\SIGMA-SD10.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\SONY-DSLR-A700.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\SONY_A200.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Sony_A300.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A100-1.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A350.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A900-2.dng")); - OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A900.dng")); -OpenFile(FileReader(L"..\\testimg\\dng\\uncompressed.dng")); -OpenFile(FileReader(L"..\\testimg\\dng\\uncompressed2.dng")); -OpenFile(FileReader(L"..\\testimg\\dng\\uncompressed3.dng")); + OpenFile(FileReader(L"..\\testimg\\Olympus_500UZ.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_C7070WZ.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_C8080.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E1.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E10.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E20.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E3-2.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E3-3.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E3-4.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E3.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E300.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E330.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E400.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E410-2.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E410.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E420.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E500.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E510-2.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E510.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E520-2.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E520-3.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E520-4.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E520-5.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_E520.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\Olympus_SP350.orf"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\5d-raw.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\5d.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS10-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS10.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS20D-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS20D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS300D-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-EOS300D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-POWERSHOTPRO1-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\CANON-POWERSHOTPRO1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1000D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1Ds_Mk2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1Ds_Mk3-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1Ds_Mk3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1D_Mk2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1D_Mk2_N.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_1D_Mk3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_20D-demosaic.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_20d.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_30D-uga1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_30D-uga2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_30D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_350d-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_350D-3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_350d.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_400D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_40D-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_40D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-4.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D-5.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_450D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D_Mk2-ISO100_sRAW1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D_Mk2-ISO12800_sRAW1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_5D_Mk2-ISO12800_sRAW2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_EOS_Mk2-ISO100_sRAW2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_Powershot_G10.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_Powershot_G9-1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_Powershot_G9-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Canon_PowerShot_G9.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\FUJI-FINEPIXS2PRO-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\FUJI-FINEPIXS2PRO.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\KODAK-DCSPRO-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\KODAK-DCSPRO.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\M8-1-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\M8-1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE5-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE5.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE7HI-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGE7HI.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGEA1-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DIMAGEA1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-01-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-01.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-02-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-02.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-03-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-03.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-04-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-04.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-05-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\MINOLTA-DYNAX7D-05.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-COOLPIX5700-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-COOLPIX5700.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D100-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D100.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-01-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-01.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-02-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NIKON-D70-02.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\NikonCoolPix8800.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D100-1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D1H.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D1X.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D200-1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D200_compressed-1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D2H.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D2X_sRGB.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D300.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D40X.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D40_(sRGB).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D60-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D60.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D70.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D700.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D70s-3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D80_(sRGB).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_D90.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_E5400.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_E5700.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Nikon_E5700_(sRGB).dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-C5050Z-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-C5050Z.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-E10-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\OLYMPUS-E10.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_500UZ.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_C7070WZ.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_C8080.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E10.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E20.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3-3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3-4.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E300.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E330.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E400.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E410-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E410.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E420.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E500.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E510-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E510.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-3.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-4.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520-5.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_E520.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Olympus_SP350.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\PENTAX-ISD-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\PENTAX-ISD.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K100D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K10D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Pentax_K20D.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\SIGMA-SD10-linear.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\SIGMA-SD10.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\SONY-DSLR-A700.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\SONY_A200.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Sony_A300.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A100-1.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A350.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A900-2.dng"),&meta); + OpenFile(FileReader(L"..\\testimg\\dng\\Sony_DSLR-A900.dng"),&meta); +OpenFile(FileReader(L"..\\testimg\\dng\\uncompressed.dng"),&meta); +OpenFile(FileReader(L"..\\testimg\\dng\\uncompressed2.dng"),&meta); +OpenFile(FileReader(L"..\\testimg\\dng\\uncompressed3.dng"),&meta); + MessageBox(0,L"Finished", L"Finished",0); #ifdef _USE_GFL_ gflLibraryExit(); Modified: RawSpeed/RawSpeed.vcproj =================================================================== --- RawSpeed/RawSpeed.vcproj 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/RawSpeed.vcproj 2009-03-12 21:56:41 UTC (rev 64) @@ -61,9 +61,10 @@ /> - - @@ -321,10 +318,6 @@ RelativePath=".\PentaxDecompressor.cpp" > - - + + + + + + + + + + + + + + - - @@ -512,10 +529,6 @@ > - - @@ -552,10 +565,38 @@ > + + + + + + + + + + + + + + getEntry((TiffTag)3)->getInt(); guint bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt(); return mRaw; +} + +void Rw2Decoder::decodeMetaData( CameraMetaData *meta ) +{ + } \ No newline at end of file Modified: RawSpeed/Rw2Decoder.h =================================================================== --- RawSpeed/Rw2Decoder.h 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/Rw2Decoder.h 2009-03-12 21:56:41 UTC (rev 64) @@ -32,5 +32,6 @@ Rw2Decoder(TiffIFD *rootIFD, FileMap* file); virtual ~Rw2Decoder(void); RawImage decodeRaw(); + virtual void decodeMetaData(CameraMetaData *meta); TiffIFD *mRootIFD; }; Modified: RawSpeed/rawstudio-plugin-api.cpp =================================================================== --- RawSpeed/rawstudio-plugin-api.cpp 2009-02-12 19:53:56 UTC (rev 63) +++ RawSpeed/rawstudio-plugin-api.cpp 2009-03-12 21:56:41 UTC (rev 64) @@ -29,9 +29,13 @@ extern "C" { +CameraMetaData c* = 0; + RS_IMAGE16 * load_rawspeed(const gchar *filename) { + if (!c) + c = new CameraMetaData("~/.rawstudio/cameras.xml"); RS_IMAGE16 *image = NULL; FileReader f((char *) filename); RawDecoder *d = 0; @@ -54,7 +58,7 @@ GTimer *gt = g_timer_new(); d->decodeRaw(); - d->decodeMetaData(); + d->decodeMetaData(c); printf("%s: %.03f\n", filename, g_timer_elapsed(gt, NULL)); g_timer_destroy(gt); @@ -62,12 +66,13 @@ printf("Error Encountered:%s\n", d->errors[i]); RawImage r = d->mRaw; + r->scaleBlackWhite(); cpp = r->getCpp(); if (cpp == 1) image = rs_image16_new(r->dim.x, r->dim.y, cpp, cpp); else if (cpp == 3) - image = rs_image16_new(r->dim.x, r->dim.y, 3, 4); + image = rs_image16_new(r->dim.x, r->dim.y, 3, 3); else { printf("Unsupported component per pixel count"); return NULL; @@ -81,48 +86,25 @@ printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); printf(r->cfa.asString().c_str()); } - - /* Calculate black and white point */ - for(row=100;rowh-100;row++) - { - gushort *pixel = (gushort*)&r->getData()[row*r->pitch+100*r->bpp]; - for(col=100*cpp;col<(image->w-200)*cpp;col++) - { - max = MAX(*pixel, max); - black = MIN(*pixel, black); - pixel++; - } - } - - shift = (gint) (16.0-log((gdouble) max)/log(2.0)); - - /* Apply black and whitepoint */ - if ( cpp == 1 ) - { - for(row=0;rowh;row++) - { - gushort *inpixel = (gushort*)&r->getData()[row*r->pitch]; - gushort *outpixel = GET_PIXEL(image, 0, row); - for(col=0;colw;col++) - { - *outpixel++ = clampbits(((gint)(*inpixel++)-black)<h;row++) - { - gushort *inpixel = (gushort*)&r->getData()[row*r->pitch]; - gushort *outpixel = GET_PIXEL(image, 0, row); - for(col=0;colw;col++) - { - *outpixel++ = clampbits(((gint)(*inpixel++)-black)<pitch/2, + r->getData(0,0), r->pitch, r->bpp*r->dim.x,r->pitch, r->dim.y); + } else + { + for(row=0;rowh;row++) + { + gushort *inpixel = (gushort*)&r->getData()[row*r->pitch]; + gushort *outpixel = GET_PIXEL(image, 0, row); + for(col=0;colw;col++) + { + *outpixel++ = *inpixel++; + *outpixel++ = *inpixel++; + *outpixel++ = *inpixel++; + outpixel++; + } + } + } } catch (RawDecoderException e) { Added: cameras.xml =================================================================== --- cameras.xml (rev 0) +++ cameras.xml 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,616 @@ + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + RED + BLUE + GREEN + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + GREEN + UNKNOWN + UNKNOWN + UNKNOWN + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + GREEN + RED + BLUE + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + RED + BLUE + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + GREEN + BLUE + RED + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + BLUE + GREEN + GREEN + RED + + + + + + + GREEN + RED + BLUE + GREEN + + + + + + + GREEN + RED + BLUE + GREEN + + + + + + + GREEN + RED + BLUE + GREEN + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + RED + GREEN + GREEN + BLUE + + + + + + + Added: include/iconv.h =================================================================== --- include/iconv.h (rev 0) +++ include/iconv.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,134 @@ +/* Copyright (C) 1999-2003 Free Software Foundation, Inc. + This file is part of the GNU LIBICONV Library. + + The GNU LIBICONV Library is free software; you can redistribute it + and/or modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + The GNU LIBICONV 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU LIBICONV Library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, Inc., 59 Temple Place - + Suite 330, Boston, MA 02111-1307, USA. */ + +/* When installed, this file is called "iconv.h". */ + +#ifndef _LIBICONV_H +#define _LIBICONV_H + +#define _LIBICONV_VERSION 0x0109 /* version number: (major<<8) + minor */ +extern int _libiconv_version; /* Likewise */ + +/* We would like to #include any system header file which could define + iconv_t, 1. in order to eliminate the risk that the user gets compilation + errors because some other system header file includes /usr/include/iconv.h + which defines iconv_t or declares iconv after this file, 2. when compiling + for LIBICONV_PLUG, we need the proper iconv_t type in order to produce + binary compatible code. + But gcc's #include_next is not portable. Thus, once libiconv's iconv.h + has been installed in /usr/local/include, there is no way any more to + include the original /usr/include/iconv.h. We simply have to get away + without it. + Ad 1. The risk that a system header file does + #include "iconv.h" or #include_next "iconv.h" + is small. They all do #include . + Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It + has to be a scalar type because (iconv_t)(-1) is a possible return value + from iconv_open().) */ + +/* Define iconv_t ourselves. */ +#undef iconv_t +#define iconv_t libiconv_t +typedef void* iconv_t; + +/* Get size_t declaration. */ +#include + +/* Get errno declaration and values. */ +#include +/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, + have EILSEQ in a different header. On these systems, define EILSEQ + ourselves. */ +#ifndef EILSEQ +/* Igor: called upon EILSEQ from glibc, since autogeneration of this header + on Windows didn't do the job. */ +/* #define EILSEQ @EILSEQ@ */ +#define EILSEQ 84 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Allocates descriptor for code conversion from encoding `fromcode' to + encoding `tocode'. */ +#ifndef LIBICONV_PLUG +#define iconv_open libiconv_open +#endif +extern iconv_t iconv_open (const char* tocode, const char* fromcode); + +/* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes + starting at `*inbuf', writing at most `*outbytesleft' bytes starting at + `*outbuf'. + Decrements `*inbytesleft' and increments `*inbuf' by the same amount. + Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */ +#ifndef LIBICONV_PLUG +#define iconv libiconv +#endif +extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); + +/* Frees resources allocated for conversion descriptor `cd'. */ +#ifndef LIBICONV_PLUG +#define iconv_close libiconv_close +#endif +extern int iconv_close (iconv_t cd); + + +#ifndef LIBICONV_PLUG + +/* Nonstandard extensions. */ + +/* Control of attributes. */ +#define iconvctl libiconvctl +extern int iconvctl (iconv_t cd, int request, void* argument); + +/* Requests for iconvctl. */ +#define ICONV_TRIVIALP 0 /* int *argument */ +#define ICONV_GET_TRANSLITERATE 1 /* int *argument */ +#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ +#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ +#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ + +/* Listing of locale independent encodings. */ +#define iconvlist libiconvlist +extern void iconvlist (int (*do_one) (unsigned int namescount, + const char * const * names, + void* data), + void* data); + +/* Support for relocatable packages. */ + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +extern void libiconv_set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LIBICONV_H */ Added: include/libxml/DOCBparser.h =================================================================== --- include/libxml/DOCBparser.h (rev 0) +++ include/libxml/DOCBparser.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,96 @@ +/* + * Summary: old DocBook SGML parser + * Description: interface for a DocBook SGML non-verifying parser + * This code is DEPRECATED, and should not be used anymore. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DOCB_PARSER_H__ +#define __DOCB_PARSER_H__ +#include + +#ifdef LIBXML_DOCB_ENABLED + +#include +#include + +#ifndef IN_LIBXML +#ifdef __GNUC__ +#warning "The DOCBparser module has been deprecated in libxml2-2.6.0" +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most of the back-end structures from XML and SGML are shared. + */ +typedef xmlParserCtxt docbParserCtxt; +typedef xmlParserCtxtPtr docbParserCtxtPtr; +typedef xmlSAXHandler docbSAXHandler; +typedef xmlSAXHandlerPtr docbSAXHandlerPtr; +typedef xmlParserInput docbParserInput; +typedef xmlParserInputPtr docbParserInputPtr; +typedef xmlDocPtr docbDocPtr; + +/* + * There is only few public functions. + */ +XMLPUBFUN int XMLCALL + docbEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); + +XMLPUBFUN docbDocPtr XMLCALL + docbSAXParseDoc (xmlChar *cur, + const char *encoding, + docbSAXHandlerPtr sax, + void *userData); +XMLPUBFUN docbDocPtr XMLCALL + docbParseDoc (xmlChar *cur, + const char *encoding); +XMLPUBFUN docbDocPtr XMLCALL + docbSAXParseFile (const char *filename, + const char *encoding, + docbSAXHandlerPtr sax, + void *userData); +XMLPUBFUN docbDocPtr XMLCALL + docbParseFile (const char *filename, + const char *encoding); + +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN void XMLCALL + docbFreeParserCtxt (docbParserCtxtPtr ctxt); +XMLPUBFUN docbParserCtxtPtr XMLCALL + docbCreatePushParserCtxt(docbSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + docbParseChunk (docbParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +XMLPUBFUN docbParserCtxtPtr XMLCALL + docbCreateFileParserCtxt(const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + docbParseDocument (docbParserCtxtPtr ctxt); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DOCB_ENABLED */ + +#endif /* __DOCB_PARSER_H__ */ Added: include/libxml/HTMLparser.h =================================================================== --- include/libxml/HTMLparser.h (rev 0) +++ include/libxml/HTMLparser.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,303 @@ +/* + * Summary: interface for an HTML 4.0 non-verifying parser + * Description: this module implements an HTML 4.0 non-verifying parser + * with API compatible with the XML parser ones. It should + * be able to parse "real world" HTML, even if severely + * broken from a specification point of view. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_PARSER_H__ +#define __HTML_PARSER_H__ +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Most of the back-end structures from XML and HTML are shared. + */ +typedef xmlParserCtxt htmlParserCtxt; +typedef xmlParserCtxtPtr htmlParserCtxtPtr; +typedef xmlParserNodeInfo htmlParserNodeInfo; +typedef xmlSAXHandler htmlSAXHandler; +typedef xmlSAXHandlerPtr htmlSAXHandlerPtr; +typedef xmlParserInput htmlParserInput; +typedef xmlParserInputPtr htmlParserInputPtr; +typedef xmlDocPtr htmlDocPtr; +typedef xmlNodePtr htmlNodePtr; + +/* + * Internal description of an HTML element, representing HTML 4.01 + * and XHTML 1.0 (which share the same structure). + */ +typedef struct _htmlElemDesc htmlElemDesc; +typedef htmlElemDesc *htmlElemDescPtr; +struct _htmlElemDesc { + const char *name; /* The tag name */ + char startTag; /* Whether the start tag can be implied */ + char endTag; /* Whether the end tag can be implied */ + char saveEndTag; /* Whether the end tag should be saved */ + char empty; /* Is this an empty element ? */ + char depr; /* Is this a deprecated element ? */ + char dtd; /* 1: only in Loose DTD, 2: only Frameset one */ + char isinline; /* is this a block 0 or inline 1 element */ + const char *desc; /* the description */ + +/* NRK Jan.2003 + * New fields encapsulating HTML structure + * + * Bugs: + * This is a very limited representation. It fails to tell us when + * an element *requires* subelements (we only have whether they're + * allowed or not), and it doesn't tell us where CDATA and PCDATA + * are allowed. Some element relationships are not fully represented: + * these are flagged with the word MODIFIER + */ + const char** subelts; /* allowed sub-elements of this element */ + const char* defaultsubelt; /* subelement for suggested auto-repair + if necessary or NULL */ + const char** attrs_opt; /* Optional Attributes */ + const char** attrs_depr; /* Additional deprecated attributes */ + const char** attrs_req; /* Required attributes */ +}; + +/* + * Internal description of an HTML entity. + */ +typedef struct _htmlEntityDesc htmlEntityDesc; +typedef htmlEntityDesc *htmlEntityDescPtr; +struct _htmlEntityDesc { + unsigned int value; /* the UNICODE value for the character */ + const char *name; /* The entity name */ + const char *desc; /* the description */ +}; + +/* + * There is only few public functions. + */ +XMLPUBFUN const htmlElemDesc * XMLCALL + htmlTagLookup (const xmlChar *tag); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlEntityLookup(const xmlChar *name); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlEntityValueLookup(unsigned int value); + +XMLPUBFUN int XMLCALL + htmlIsAutoClosed(htmlDocPtr doc, + htmlNodePtr elem); +XMLPUBFUN int XMLCALL + htmlAutoCloseTag(htmlDocPtr doc, + const xmlChar *name, + htmlNodePtr elem); +XMLPUBFUN const htmlEntityDesc * XMLCALL + htmlParseEntityRef(htmlParserCtxtPtr ctxt, + const xmlChar **str); +XMLPUBFUN int XMLCALL + htmlParseCharRef(htmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + htmlParseElement(htmlParserCtxtPtr ctxt); + +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlNewParserCtxt(void); + +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlCreateMemoryParserCtxt(const char *buffer, + int size); + +XMLPUBFUN int XMLCALL + htmlParseDocument(htmlParserCtxtPtr ctxt); +XMLPUBFUN htmlDocPtr XMLCALL + htmlSAXParseDoc (xmlChar *cur, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr XMLCALL + htmlParseDoc (xmlChar *cur, + const char *encoding); +XMLPUBFUN htmlDocPtr XMLCALL + htmlSAXParseFile(const char *filename, + const char *encoding, + htmlSAXHandlerPtr sax, + void *userData); +XMLPUBFUN htmlDocPtr XMLCALL + htmlParseFile (const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + UTF8ToHtml (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +XMLPUBFUN int XMLCALL + htmlEncodeEntities(unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen, int quoteChar); +XMLPUBFUN int XMLCALL + htmlIsScriptAttribute(const xmlChar *name); +XMLPUBFUN int XMLCALL + htmlHandleOmittedElem(int val); + +#ifdef LIBXML_PUSH_ENABLED +/** + * Interfaces for the Push mode. + */ +XMLPUBFUN htmlParserCtxtPtr XMLCALL + htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + htmlParseChunk (htmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +XMLPUBFUN void XMLCALL + htmlFreeParserCtxt (htmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + HTML_PARSE_RECOVER = 1<<0, /* Relaxed parsing */ + HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */ + HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + HTML_PARSE_NONET = 1<<11,/* Forbid network access */ + HTML_PARSE_COMPACT = 1<<16 /* compact small text nodes */ +} htmlParserOption; + +XMLPUBFUN void XMLCALL + htmlCtxtReset (htmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + htmlCtxtUseOptions (htmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN htmlDocPtr XMLCALL + htmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/* NRK/Jan2003: further knowledge of HTML structure + */ +typedef enum { + HTML_NA = 0 , /* something we don't check at all */ + HTML_INVALID = 0x1 , + HTML_DEPRECATED = 0x2 , + HTML_VALID = 0x4 , + HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */ +} htmlStatus ; + +/* Using htmlElemDesc rather than name here, to emphasise the fact + that otherwise there's a lookup overhead +*/ +XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ; +XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ; +XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ; +XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ; +/** + * htmlDefaultSubelement: + * @elt: HTML element + * + * Returns the default subelement for this element + */ +#define htmlDefaultSubelement(elt) elt->defaultsubelt +/** + * htmlElementAllowedHereDesc: + * @parent: HTML parent element + * @elt: HTML element + * + * Checks whether an HTML element description may be a + * direct child of the specified element. + * + * Returns 1 if allowed; 0 otherwise. + */ +#define htmlElementAllowedHereDesc(parent,elt) \ + htmlElementAllowedHere((parent), (elt)->name) +/** + * htmlRequiredAttrs: + * @elt: HTML element + * + * Returns the attributes required for the specified element. + */ +#define htmlRequiredAttrs(elt) (elt)->attrs_req + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ +#endif /* __HTML_PARSER_H__ */ Added: include/libxml/HTMLtree.h =================================================================== --- include/libxml/HTMLtree.h (rev 0) +++ include/libxml/HTMLtree.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,147 @@ +/* + * Summary: specific APIs to process HTML tree, especially serialization + * Description: this module implements a few function needed to process + * tree in an HTML specific way. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __HTML_TREE_H__ +#define __HTML_TREE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_HTML_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * HTML_TEXT_NODE: + * + * Macro. A text node in a HTML document is really implemented + * the same way as a text node in an XML document. + */ +#define HTML_TEXT_NODE XML_TEXT_NODE +/** + * HTML_ENTITY_REF_NODE: + * + * Macro. An entity reference in a HTML document is really implemented + * the same way as an entity reference in an XML document. + */ +#define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE +/** + * HTML_COMMENT_NODE: + * + * Macro. A comment in a HTML document is really implemented + * the same way as a comment in an XML document. + */ +#define HTML_COMMENT_NODE XML_COMMENT_NODE +/** + * HTML_PRESERVE_NODE: + * + * Macro. A preserved node in a HTML document is really implemented + * the same way as a CDATA section in an XML document. + */ +#define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE +/** + * HTML_PI_NODE: + * + * Macro. A processing instruction in a HTML document is really implemented + * the same way as a processing instruction in an XML document. + */ +#define HTML_PI_NODE XML_PI_NODE + +XMLPUBFUN htmlDocPtr XMLCALL + htmlNewDoc (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN htmlDocPtr XMLCALL + htmlNewDocNoDtD (const xmlChar *URI, + const xmlChar *ExternalID); +XMLPUBFUN const xmlChar * XMLCALL + htmlGetMetaEncoding (htmlDocPtr doc); +XMLPUBFUN int XMLCALL + htmlSetMetaEncoding (htmlDocPtr doc, + const xmlChar *encoding); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + htmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void XMLCALL + htmlDocDumpMemoryFormat (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN int XMLCALL + htmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + htmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + htmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN void XMLCALL + htmlNodeDumpFile (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int XMLCALL + htmlNodeDumpFileFormat (FILE *out, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN int XMLCALL + htmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int XMLCALL + htmlSaveFileFormat (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN void XMLCALL + htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + htmlDocContentDumpOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN void XMLCALL + htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + htmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XMLPUBFUN int XMLCALL + htmlIsBooleanAttr (const xmlChar *name); + + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTML_ENABLED */ + +#endif /* __HTML_TREE_H__ */ + Added: include/libxml/SAX.h =================================================================== --- include/libxml/SAX.h (rev 0) +++ include/libxml/SAX.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,173 @@ +/* + * Summary: Old SAX version 1 handler, deprecated + * Description: DEPRECATED set of SAX version 1 interfaces used to + * build the DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX_H__ +#define __XML_SAX_H__ + +#include +#include +#include +#include +#include + +#ifdef LIBXML_LEGACY_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * XMLCALL + getPublicId (void *ctx); +XMLPUBFUN const xmlChar * XMLCALL + getSystemId (void *ctx); +XMLPUBFUN void XMLCALL + setDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int XMLCALL + getLineNumber (void *ctx); +XMLPUBFUN int XMLCALL + getColumnNumber (void *ctx); + +XMLPUBFUN int XMLCALL + isStandalone (void *ctx); +XMLPUBFUN int XMLCALL + hasInternalSubset (void *ctx); +XMLPUBFUN int XMLCALL + hasExternalSubset (void *ctx); + +XMLPUBFUN void XMLCALL + internalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void XMLCALL + externalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr XMLCALL + getEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + getParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr XMLCALL + resolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void XMLCALL + entityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void XMLCALL + attributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void XMLCALL + elementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + notationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void XMLCALL + unparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void XMLCALL + startDocument (void *ctx); +XMLPUBFUN void XMLCALL + endDocument (void *ctx); +XMLPUBFUN void XMLCALL + attribute (void *ctx, + const xmlChar *fullname, + const xmlChar *value); +XMLPUBFUN void XMLCALL + startElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XMLPUBFUN void XMLCALL + endElement (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + ignorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + processingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void XMLCALL + globalNamespace (void *ctx, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + setNamespace (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlNsPtr XMLCALL + getNamespace (void *ctx); +XMLPUBFUN int XMLCALL + checkNamespace (void *ctx, + xmlChar *nameSpace); +XMLPUBFUN void XMLCALL + namespaceDecl (void *ctx, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void XMLCALL + cdataBlock (void *ctx, + const xmlChar *value, + int len); + +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN void XMLCALL + initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void XMLCALL + inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); +#endif +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN void XMLCALL + initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); +#endif +#endif /* LIBXML_SAX1_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_LEGACY_ENABLED */ + +#endif /* __XML_SAX_H__ */ Added: include/libxml/SAX2.h =================================================================== --- include/libxml/SAX2.h (rev 0) +++ include/libxml/SAX2.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,176 @@ +/* + * Summary: SAX2 parser interface used to build the DOM tree + * Description: those are the default SAX2 interfaces used by + * the library when building DOM tree. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SAX2_H__ +#define __XML_SAX2_H__ + +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN const xmlChar * XMLCALL + xmlSAX2GetPublicId (void *ctx); +XMLPUBFUN const xmlChar * XMLCALL + xmlSAX2GetSystemId (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2SetDocumentLocator (void *ctx, + xmlSAXLocatorPtr loc); + +XMLPUBFUN int XMLCALL + xmlSAX2GetLineNumber (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2GetColumnNumber (void *ctx); + +XMLPUBFUN int XMLCALL + xmlSAX2IsStandalone (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2HasInternalSubset (void *ctx); +XMLPUBFUN int XMLCALL + xmlSAX2HasExternalSubset (void *ctx); + +XMLPUBFUN void XMLCALL + xmlSAX2InternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN void XMLCALL + xmlSAX2ExternalSubset (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlSAX2GetEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlSAX2GetParameterEntity (void *ctx, + const xmlChar *name); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlSAX2ResolveEntity (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); + +XMLPUBFUN void XMLCALL + xmlSAX2EntityDecl (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +XMLPUBFUN void XMLCALL + xmlSAX2AttributeDecl (void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +XMLPUBFUN void XMLCALL + xmlSAX2ElementDecl (void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlSAX2NotationDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +XMLPUBFUN void XMLCALL + xmlSAX2UnparsedEntityDecl (void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); + +XMLPUBFUN void XMLCALL + xmlSAX2StartDocument (void *ctx); +XMLPUBFUN void XMLCALL + xmlSAX2EndDocument (void *ctx); +#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) +XMLPUBFUN void XMLCALL + xmlSAX2StartElement (void *ctx, + const xmlChar *fullname, + const xmlChar **atts); +XMLPUBFUN void XMLCALL + xmlSAX2EndElement (void *ctx, + const xmlChar *name); +#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED */ +XMLPUBFUN void XMLCALL + xmlSAX2StartElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); +XMLPUBFUN void XMLCALL + xmlSAX2EndElementNs (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); +XMLPUBFUN void XMLCALL + xmlSAX2Reference (void *ctx, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSAX2Characters (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + xmlSAX2IgnorableWhitespace (void *ctx, + const xmlChar *ch, + int len); +XMLPUBFUN void XMLCALL + xmlSAX2ProcessingInstruction (void *ctx, + const xmlChar *target, + const xmlChar *data); +XMLPUBFUN void XMLCALL + xmlSAX2Comment (void *ctx, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlSAX2CDataBlock (void *ctx, + const xmlChar *value, + int len); + +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlSAXDefaultVersion (int version); +#endif /* LIBXML_SAX1_ENABLED */ + +XMLPUBFUN int XMLCALL + xmlSAXVersion (xmlSAXHandler *hdlr, + int version); +XMLPUBFUN void XMLCALL + xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, + int warning); +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN void XMLCALL + xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr); +XMLPUBFUN void XMLCALL + htmlDefaultSAXHandlerInit (void); +#endif +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN void XMLCALL + xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr); +XMLPUBFUN void XMLCALL + docbDefaultSAXHandlerInit (void); +#endif +XMLPUBFUN void XMLCALL + xmlDefaultSAXHandlerInit (void); +#ifdef __cplusplus +} +#endif +#endif /* __XML_SAX2_H__ */ Added: include/libxml/c14n.h =================================================================== --- include/libxml/c14n.h (rev 0) +++ include/libxml/c14n.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,115 @@ +/* + * Summary: Provide Canonical XML and Exclusive XML Canonicalization + * Description: the c14n modules provides a + * + * "Canonical XML" implementation + * http://www.w3.org/TR/xml-c14n + * + * and an + * + * "Exclusive XML Canonicalization" implementation + * http://www.w3.org/TR/xml-exc-c14n + + * Copy: See Copyright for the status of this software. + * + * Author: Aleksey Sanin + */ +#ifndef __XML_C14N_H__ +#define __XML_C14N_H__ +#ifdef LIBXML_C14N_ENABLED +#ifdef LIBXML_OUTPUT_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include +#include + +/* + * XML Canonicazation + * http://www.w3.org/TR/xml-c14n + * + * Exclusive XML Canonicazation + * http://www.w3.org/TR/xml-exc-c14n + * + * Canonical form of an XML document could be created if and only if + * a) default attributes (if any) are added to all nodes + * b) all character and parsed entity references are resolved + * In order to achive this in libxml2 the document MUST be loaded with + * following global setings: + * + * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + * xmlSubstituteEntitiesDefault(1); + * + * or corresponding parser context setting: + * xmlParserCtxtPtr ctxt; + * + * ... + * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS; + * ctxt->replaceEntities = 1; + * ... + */ + + +XMLPUBFUN int XMLCALL + xmlC14NDocSaveTo (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +XMLPUBFUN int XMLCALL + xmlC14NDocDumpMemory (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlChar **doc_txt_ptr); + +XMLPUBFUN int XMLCALL + xmlC14NDocSave (xmlDocPtr doc, + xmlNodeSetPtr nodes, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + const char* filename, + int compression); + + +/** + * This is the core C14N function + */ +/** + * xmlC14NIsVisibleCallback: + * @user_data: user data + * @node: the curent node + * @parent: the parent node + * + * Signature for a C14N callback on visible nodes + * + * Returns 1 if the node should be included + */ +typedef int (*xmlC14NIsVisibleCallback) (void* user_data, + xmlNodePtr node, + xmlNodePtr parent); + +XMLPUBFUN int XMLCALL + xmlC14NExecute (xmlDocPtr doc, + xmlC14NIsVisibleCallback is_visible_callback, + void* user_data, + int exclusive, + xmlChar **inclusive_ns_prefixes, + int with_comments, + xmlOutputBufferPtr buf); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* LIBXML_C14N_ENABLED */ +#endif /* __XML_C14N_H__ */ + Added: include/libxml/catalog.h =================================================================== --- include/libxml/catalog.h (rev 0) +++ include/libxml/catalog.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,182 @@ +/** + * Summary: interfaces to the Catalog handling system + * Description: the catalog module implements the support for + * XML Catalogs and SGML catalogs + * + * SGML Open Technical Resolution TR9401:1997. + * http://www.jclark.com/sp/catalog.htm + * + * XML Catalogs Working Draft 06 August 2001 + * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CATALOG_H__ +#define __XML_CATALOG_H__ + +#include + +#include +#include +#include + +#ifdef LIBXML_CATALOG_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_CATALOGS_NAMESPACE: + * + * The namespace for the XML Catalogs elements. + */ +#define XML_CATALOGS_NAMESPACE \ + (const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog" +/** + * XML_CATALOG_PI: + * + * The specific XML Catalog Processing Instuction name. + */ +#define XML_CATALOG_PI \ + (const xmlChar *) "oasis-xml-catalog" + +/* + * The API is voluntarily limited to general cataloging. + */ +typedef enum { + XML_CATA_PREFER_NONE = 0, + XML_CATA_PREFER_PUBLIC = 1, + XML_CATA_PREFER_SYSTEM +} xmlCatalogPrefer; + +typedef enum { + XML_CATA_ALLOW_NONE = 0, + XML_CATA_ALLOW_GLOBAL = 1, + XML_CATA_ALLOW_DOCUMENT = 2, + XML_CATA_ALLOW_ALL = 3 +} xmlCatalogAllow; + +typedef struct _xmlCatalog xmlCatalog; +typedef xmlCatalog *xmlCatalogPtr; + +/* + * Operations on a given catalog. + */ +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlNewCatalog (int sgml); +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlLoadACatalog (const char *filename); +XMLPUBFUN xmlCatalogPtr XMLCALL + xmlLoadSGMLSuperCatalog (const char *filename); +XMLPUBFUN int XMLCALL + xmlConvertSGMLCatalog (xmlCatalogPtr catal); +XMLPUBFUN int XMLCALL + xmlACatalogAdd (xmlCatalogPtr catal, + const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int XMLCALL + xmlACatalogRemove (xmlCatalogPtr catal, + const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolve (xmlCatalogPtr catal, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolveSystem(xmlCatalogPtr catal, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolvePublic(xmlCatalogPtr catal, + const xmlChar *pubID); +XMLPUBFUN xmlChar * XMLCALL + xmlACatalogResolveURI (xmlCatalogPtr catal, + const xmlChar *URI); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlACatalogDump (xmlCatalogPtr catal, + FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeCatalog (xmlCatalogPtr catal); +XMLPUBFUN int XMLCALL + xmlCatalogIsEmpty (xmlCatalogPtr catal); + +/* + * Global operations. + */ +XMLPUBFUN void XMLCALL + xmlInitializeCatalog (void); +XMLPUBFUN int XMLCALL + xmlLoadCatalog (const char *filename); +XMLPUBFUN void XMLCALL + xmlLoadCatalogs (const char *paths); +XMLPUBFUN void XMLCALL + xmlCatalogCleanup (void); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlCatalogDump (FILE *out); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolve (const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolveSystem (const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolvePublic (const xmlChar *pubID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogResolveURI (const xmlChar *URI); +XMLPUBFUN int XMLCALL + xmlCatalogAdd (const xmlChar *type, + const xmlChar *orig, + const xmlChar *replace); +XMLPUBFUN int XMLCALL + xmlCatalogRemove (const xmlChar *value); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseCatalogFile (const char *filename); +XMLPUBFUN int XMLCALL + xmlCatalogConvert (void); + +/* + * Strictly minimal interfaces for per-document catalogs used + * by the parser. + */ +XMLPUBFUN void XMLCALL + xmlCatalogFreeLocal (void *catalogs); +XMLPUBFUN void * XMLCALL + xmlCatalogAddLocal (void *catalogs, + const xmlChar *URL); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogLocalResolve (void *catalogs, + const xmlChar *pubID, + const xmlChar *sysID); +XMLPUBFUN xmlChar * XMLCALL + xmlCatalogLocalResolveURI(void *catalogs, + const xmlChar *URI); +/* + * Preference settings. + */ +XMLPUBFUN int XMLCALL + xmlCatalogSetDebug (int level); +XMLPUBFUN xmlCatalogPrefer XMLCALL + xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer); +XMLPUBFUN void XMLCALL + xmlCatalogSetDefaults (xmlCatalogAllow allow); +XMLPUBFUN xmlCatalogAllow XMLCALL + xmlCatalogGetDefaults (void); + + +/* DEPRECATED interfaces */ +XMLPUBFUN const xmlChar * XMLCALL + xmlCatalogGetSystem (const xmlChar *sysID); +XMLPUBFUN const xmlChar * XMLCALL + xmlCatalogGetPublic (const xmlChar *pubID); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_CATALOG_ENABLED */ +#endif /* __XML_CATALOG_H__ */ Added: include/libxml/chvalid.h =================================================================== --- include/libxml/chvalid.h (rev 0) +++ include/libxml/chvalid.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,230 @@ +/* + * Summary: Unicode character range checking + * Description: this module exports interfaces for the character + * range validation APIs + * + * This file is automatically generated from the cvs source + * definition files using the genChRanges.py Python script + * + * Generation date: Mon Mar 27 11:09:48 2006 + * Sources: chvalid.def + * Author: William Brack + */ + +#ifndef __XML_CHVALID_H__ +#define __XML_CHVALID_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Define our typedefs and structures + * + */ +typedef struct _xmlChSRange xmlChSRange; +typedef xmlChSRange *xmlChSRangePtr; +struct _xmlChSRange { + unsigned short low; + unsigned short high; +}; + +typedef struct _xmlChLRange xmlChLRange; +typedef xmlChLRange *xmlChLRangePtr; +struct _xmlChLRange { + unsigned int low; + unsigned int high; +}; + +typedef struct _xmlChRangeGroup xmlChRangeGroup; +typedef xmlChRangeGroup *xmlChRangeGroupPtr; +struct _xmlChRangeGroup { + int nbShortRange; + int nbLongRange; + const xmlChSRange *shortRange; /* points to an array of ranges */ + const xmlChLRange *longRange; +}; + +/** + * Range checking routine + */ +XMLPUBFUN int XMLCALL + xmlCharInRange(unsigned int val, const xmlChRangeGroup *group); + + +/** + * xmlIsBaseChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseChar_ch(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ + ((0x61 <= (c)) && ((c) <= 0x7a)) || \ + ((0xc0 <= (c)) && ((c) <= 0xd6)) || \ + ((0xd8 <= (c)) && ((c) <= 0xf6)) || \ + (0xf8 <= (c))) + +/** + * xmlIsBaseCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBaseCharQ(c) (((c) < 0x100) ? \ + xmlIsBaseChar_ch((c)) : \ + xmlCharInRange((c), &xmlIsBaseCharGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup; + +/** + * xmlIsBlank_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlank_ch(c) (((c) == 0x20) || \ + ((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd)) + +/** + * xmlIsBlankQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsBlankQ(c) (((c) < 0x100) ? \ + xmlIsBlank_ch((c)) : 0) + + +/** + * xmlIsChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsChar_ch(c) (((0x9 <= (c)) && ((c) <= 0xa)) || \ + ((c) == 0xd) || \ + (0x20 <= (c))) + +/** + * xmlIsCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCharQ(c) (((c) < 0x100) ? \ + xmlIsChar_ch((c)) :\ + (((0x100 <= (c)) && ((c) <= 0xd7ff)) || \ + ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \ + ((0x10000 <= (c)) && ((c) <= 0x10ffff)))) + +XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup; + +/** + * xmlIsCombiningQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsCombiningQ(c) (((c) < 0x100) ? \ + 0 : \ + xmlCharInRange((c), &xmlIsCombiningGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup; + +/** + * xmlIsDigit_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigit_ch(c) (((0x30 <= (c)) && ((c) <= 0x39))) + +/** + * xmlIsDigitQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsDigitQ(c) (((c) < 0x100) ? \ + xmlIsDigit_ch((c)) : \ + xmlCharInRange((c), &xmlIsDigitGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup; + +/** + * xmlIsExtender_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtender_ch(c) (((c) == 0xb7)) + +/** + * xmlIsExtenderQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsExtenderQ(c) (((c) < 0x100) ? \ + xmlIsExtender_ch((c)) : \ + xmlCharInRange((c), &xmlIsExtenderGroup)) + +XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup; + +/** + * xmlIsIdeographicQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsIdeographicQ(c) (((c) < 0x100) ? \ + 0 :\ + (((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \ + ((c) == 0x3007) || \ + ((0x3021 <= (c)) && ((c) <= 0x3029)))) + +XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup; +XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256]; + +/** + * xmlIsPubidChar_ch: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)]) + +/** + * xmlIsPubidCharQ: + * @c: char to validate + * + * Automatically generated by genChRanges.py + */ +#define xmlIsPubidCharQ(c) (((c) < 0x100) ? \ + xmlIsPubidChar_ch((c)) : 0) + +XMLPUBFUN int XMLCALL + xmlIsBaseChar(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsBlank(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsChar(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsCombining(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsDigit(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsExtender(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsIdeographic(unsigned int ch); +XMLPUBFUN int XMLCALL + xmlIsPubidChar(unsigned int ch); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_CHVALID_H__ */ Added: include/libxml/debugXML.h =================================================================== --- include/libxml/debugXML.h (rev 0) +++ include/libxml/debugXML.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,217 @@ +/* + * Summary: Tree debugging APIs + * Description: Interfaces to a set of routines used for debugging the tree + * produced by the XML parser. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __DEBUG_XML__ +#define __DEBUG_XML__ +#include +#include +#include + +#ifdef LIBXML_DEBUG_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The standard Dump routines. + */ +XMLPUBFUN void XMLCALL + xmlDebugDumpString (FILE *output, + const xmlChar *str); +XMLPUBFUN void XMLCALL + xmlDebugDumpAttr (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpAttrList (FILE *output, + xmlAttrPtr attr, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpOneNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpNode (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpNodeList (FILE *output, + xmlNodePtr node, + int depth); +XMLPUBFUN void XMLCALL + xmlDebugDumpDocumentHead(FILE *output, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlDebugDumpDocument (FILE *output, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlDebugDumpDTD (FILE *output, + xmlDtdPtr dtd); +XMLPUBFUN void XMLCALL + xmlDebugDumpEntities (FILE *output, + xmlDocPtr doc); + +/**************************************************************** + * * + * Checking routines * + * * + ****************************************************************/ + +XMLPUBFUN int XMLCALL + xmlDebugCheckDocument (FILE * output, + xmlDocPtr doc); + +/**************************************************************** + * * + * XML shell helpers * + * * + ****************************************************************/ + +XMLPUBFUN void XMLCALL + xmlLsOneNode (FILE *output, xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlLsCountNode (xmlNodePtr node); + +XMLPUBFUN const char * XMLCALL + xmlBoolToText (int boolval); + +/**************************************************************** + * * + * The XML shell related structures and functions * + * * + ****************************************************************/ + +#ifdef LIBXML_XPATH_ENABLED +/** + * xmlShellReadlineFunc: + * @prompt: a string prompt + * + * This is a generic signature for the XML shell input function. + * + * Returns a string which will be freed by the Shell. + */ +typedef char * (* xmlShellReadlineFunc)(char *prompt); + +/** + * xmlShellCtxt: + * + * A debugging shell context. + * TODO: add the defined function tables. + */ +typedef struct _xmlShellCtxt xmlShellCtxt; +typedef xmlShellCtxt *xmlShellCtxtPtr; +struct _xmlShellCtxt { + char *filename; + xmlDocPtr doc; + xmlNodePtr node; + xmlXPathContextPtr pctxt; + int loaded; + FILE *output; + xmlShellReadlineFunc input; +}; + +/** + * xmlShellCmd: + * @ctxt: a shell context + * @arg: a string argument + * @node: a first node + * @node2: a second node + * + * This is a generic signature for the XML shell functions. + * + * Returns an int, negative returns indicating errors. + */ +typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); + +XMLPUBFUN void XMLCALL + xmlShellPrintXPathError (int errorType, + const char *arg); +XMLPUBFUN void XMLCALL + xmlShellPrintXPathResult(xmlXPathObjectPtr list); +XMLPUBFUN int XMLCALL + xmlShellList (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellBase (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellDir (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellLoad (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlShellPrintNode (xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlShellCat (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellWrite (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellSave (xmlShellCtxtPtr ctxt, + char *filename, + xmlNodePtr node, + xmlNodePtr node2); +#endif /* LIBXML_OUTPUT_ENABLED */ +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN int XMLCALL + xmlShellValidate (xmlShellCtxtPtr ctxt, + char *dtd, + xmlNodePtr node, + xmlNodePtr node2); +#endif /* LIBXML_VALID_ENABLED */ +XMLPUBFUN int XMLCALL + xmlShellDu (xmlShellCtxtPtr ctxt, + char *arg, + xmlNodePtr tree, + xmlNodePtr node2); +XMLPUBFUN int XMLCALL + xmlShellPwd (xmlShellCtxtPtr ctxt, + char *buffer, + xmlNodePtr node, + xmlNodePtr node2); + +/* + * The Shell interface. + */ +XMLPUBFUN void XMLCALL + xmlShell (xmlDocPtr doc, + char *filename, + xmlShellReadlineFunc input, + FILE *output); + +#endif /* LIBXML_XPATH_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_DEBUG_ENABLED */ +#endif /* __DEBUG_XML__ */ Added: include/libxml/dict.h =================================================================== --- include/libxml/dict.h (rev 0) +++ include/libxml/dict.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,69 @@ +/* + * Summary: string dictionnary + * Description: dictionary of reusable strings, just used to avoid allocation + * and freeing operations. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_DICT_H__ +#define __XML_DICT_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The dictionnary. + */ +typedef struct _xmlDict xmlDict; +typedef xmlDict *xmlDictPtr; + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreate (void); +XMLPUBFUN xmlDictPtr XMLCALL + xmlDictCreateSub(xmlDictPtr sub); +XMLPUBFUN int XMLCALL + xmlDictReference(xmlDictPtr dict); +XMLPUBFUN void XMLCALL + xmlDictFree (xmlDictPtr dict); + +/* + * Lookup of entry in the dictionnary. + */ +XMLPUBFUN const xmlChar * XMLCALL + xmlDictLookup (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlDictExists (xmlDictPtr dict, + const xmlChar *name, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlDictQLookup (xmlDictPtr dict, + const xmlChar *prefix, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlDictOwns (xmlDictPtr dict, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlDictSize (xmlDictPtr dict); + +/* + * Cleanup function + */ +XMLPUBFUN void XMLCALL + xmlDictCleanup (void); + +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_DICT_H__ */ Added: include/libxml/encoding.h =================================================================== --- include/libxml/encoding.h (rev 0) +++ include/libxml/encoding.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,226 @@ +/* + * Summary: interface for the encoding conversion functions + * Description: interface for the encoding conversion functions needed for + * XML basic encoding and iconv() support. + * + * Related specs are + * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies + * [ISO-10646] UTF-8 and UTF-16 in Annexes + * [ISO-8859-1] ISO Latin-1 characters codes. + * [UNICODE] The Unicode Consortium, "The Unicode Standard -- + * Worldwide Character Encoding -- Version 1.0", Addison- + * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is + * described in Unicode Technical Report #4. + * [US-ASCII] Coded Character Set--7-bit American Standard Code for + * Information Interchange, ANSI X3.4-1986. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_CHAR_ENCODING_H__ +#define __XML_CHAR_ENCODING_H__ + +#include + +#ifdef LIBXML_ICONV_ENABLED +#include +#endif +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlCharEncoding: + * + * Predefined values for some standard encodings. + * Libxml does not do beforehand translation on UTF8 and ISOLatinX. + * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default. + * + * Anything else would have to be translated to UTF8 before being + * given to the parser itself. The BOM for UTF16 and the encoding + * declaration are looked at and a converter is looked for at that + * point. If not found the parser stops here as asked by the XML REC. A + * converter can be registered by the user using xmlRegisterCharEncodingHandler + * but the current form doesn't allow stateful transcoding (a serious + * problem agreed !). If iconv has been found it will be used + * automatically and allow stateful transcoding, the simplest is then + * to be sure to enable iconv and to provide iconv libs for the encoding + * support needed. + * + * Note that the generic "UTF-16" is not a predefined value. Instead, only + * the specific UTF-16LE and UTF-16BE are present. + */ +typedef enum { + XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */ + XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */ + XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */ + XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */ + XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */ + XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */ + XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */ + XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */ + XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */ + XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */ + XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */ + XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */ + XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */ + XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */ + XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */ + XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */ + XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */ + XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */ + XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */ + XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */ + XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */ + XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */ + XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */ +} xmlCharEncoding; + +/** + * xmlCharEncodingInputFunc: + * @out: a pointer to an array of bytes to store the UTF-8 result + * @outlen: the length of @out + * @in: a pointer to an array of chars in the original encoding + * @inlen: the length of @in + * + * Take a block of chars in the original encoding and try to convert + * it to an UTF-8 block of chars out. + * + * Returns the number of bytes written, -1 if lack of space, or -2 + * if the transcoding failed. + * The value of @inlen after return is the number of octets consumed + * if the return value is positive, else unpredictiable. + * The value of @outlen after return is the number of octets consumed. + */ +typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/** + * xmlCharEncodingOutputFunc: + * @out: a pointer to an array of bytes to store the result + * @outlen: the length of @out + * @in: a pointer to an array of UTF-8 chars + * @inlen: the length of @in + * + * Take a block of UTF-8 chars in and try to convert it to another + * encoding. + * Note: a first call designed to produce heading info is called with + * in = NULL. If stateful this should also initialize the encoder state. + * + * Returns the number of bytes written, -1 if lack of space, or -2 + * if the transcoding failed. + * The value of @inlen after return is the number of octets consumed + * if the return value is positive, else unpredictiable. + * The value of @outlen after return is the number of octets produced. + */ +typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, + const unsigned char *in, int *inlen); + + +/* + * Block defining the handlers for non UTF-8 encodings. + * If iconv is supported, there are two extra fields. + */ + +typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler; +typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr; +struct _xmlCharEncodingHandler { + char *name; + xmlCharEncodingInputFunc input; + xmlCharEncodingOutputFunc output; +#ifdef LIBXML_ICONV_ENABLED + iconv_t iconv_in; + iconv_t iconv_out; +#endif /* LIBXML_ICONV_ENABLED */ +}; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Interfaces for encoding handlers. + */ +XMLPUBFUN void XMLCALL + xmlInitCharEncodingHandlers (void); +XMLPUBFUN void XMLCALL + xmlCleanupCharEncodingHandlers (void); +XMLPUBFUN void XMLCALL + xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlGetCharEncodingHandler (xmlCharEncoding enc); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlFindCharEncodingHandler (const char *name); +XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL + xmlNewCharEncodingHandler (const char *name, + xmlCharEncodingInputFunc input, + xmlCharEncodingOutputFunc output); + +/* + * Interfaces for encoding names and aliases. + */ +XMLPUBFUN int XMLCALL + xmlAddEncodingAlias (const char *name, + const char *alias); +XMLPUBFUN int XMLCALL + xmlDelEncodingAlias (const char *alias); +XMLPUBFUN const char * XMLCALL + xmlGetEncodingAlias (const char *alias); +XMLPUBFUN void XMLCALL + xmlCleanupEncodingAliases (void); +XMLPUBFUN xmlCharEncoding XMLCALL + xmlParseCharEncoding (const char *name); +XMLPUBFUN const char * XMLCALL + xmlGetCharEncodingName (xmlCharEncoding enc); + +/* + * Interfaces directly used by the parsers. + */ +XMLPUBFUN xmlCharEncoding XMLCALL + xmlDetectCharEncoding (const unsigned char *in, + int len); + +XMLPUBFUN int XMLCALL + xmlCharEncOutFunc (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); + +XMLPUBFUN int XMLCALL + xmlCharEncInFunc (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); +XMLPUBFUN int XMLCALL + xmlCharEncFirstLine (xmlCharEncodingHandler *handler, + xmlBufferPtr out, + xmlBufferPtr in); +XMLPUBFUN int XMLCALL + xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); + +/* + * Export a few useful functions + */ +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int XMLCALL + UTF8Toisolat1 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN int XMLCALL + isolat1ToUTF8 (unsigned char *out, + int *outlen, + const unsigned char *in, + int *inlen); +#ifdef __cplusplus +} +#endif + +#endif /* __XML_CHAR_ENCODING_H__ */ Added: include/libxml/entities.h =================================================================== --- include/libxml/entities.h (rev 0) +++ include/libxml/entities.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,150 @@ +/* + * Summary: interface for the XML entities handling + * Description: this module provides some of the entity API needed + * for the parser and applications. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_ENTITIES_H__ +#define __XML_ENTITIES_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The different valid entity types. + */ +typedef enum { + XML_INTERNAL_GENERAL_ENTITY = 1, + XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, + XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, + XML_INTERNAL_PARAMETER_ENTITY = 4, + XML_EXTERNAL_PARAMETER_ENTITY = 5, + XML_INTERNAL_PREDEFINED_ENTITY = 6 +} xmlEntityType; + +/* + * An unit of storage for an entity, contains the string, the value + * and the linkind data needed for the linking in the hash table. + */ + +struct _xmlEntity { + void *_private; /* application data */ + xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ + const xmlChar *name; /* Entity name */ + struct _xmlNode *children; /* First child link */ + struct _xmlNode *last; /* Last child link */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlChar *orig; /* content without ref substitution */ + xmlChar *content; /* content or ndata if unparsed */ + int length; /* the content length */ + xmlEntityType etype; /* The entity type */ + const xmlChar *ExternalID; /* External identifier for PUBLIC */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ + + struct _xmlEntity *nexte; /* unused */ + const xmlChar *URI; /* the full URI as computed */ + int owner; /* does the entity own the childrens */ + int checked; /* was the entity content checked */ + /* this is also used to count entites + * references done from that entity */ +}; + +/* + * All entities are stored in an hash table. + * There is 2 separate hash tables for global and parameter entities. + */ + +typedef struct _xmlHashTable xmlEntitiesTable; +typedef xmlEntitiesTable *xmlEntitiesTablePtr; + +/* + * External functions: + */ + +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN void XMLCALL + xmlInitializePredefinedEntities (void); +#endif /* LIBXML_LEGACY_ENABLED */ + +XMLPUBFUN xmlEntityPtr XMLCALL + xmlNewEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlAddDocEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlAddDtdEntity (xmlDocPtr doc, + const xmlChar *name, + int type, + const xmlChar *ExternalID, + const xmlChar *SystemID, + const xmlChar *content); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetPredefinedEntity (const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetDocEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetDtdEntity (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlGetParameterEntity (xmlDocPtr doc, + const xmlChar *name); +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN const xmlChar * XMLCALL + xmlEncodeEntities (xmlDocPtr doc, + const xmlChar *input); +#endif /* LIBXML_LEGACY_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlEncodeEntitiesReentrant(xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlChar * XMLCALL + xmlEncodeSpecialChars (xmlDocPtr doc, + const xmlChar *input); +XMLPUBFUN xmlEntitiesTablePtr XMLCALL + xmlCreateEntitiesTable (void); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlEntitiesTablePtr XMLCALL + xmlCopyEntitiesTable (xmlEntitiesTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeEntitiesTable (xmlEntitiesTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpEntitiesTable (xmlBufferPtr buf, + xmlEntitiesTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpEntityDecl (xmlBufferPtr buf, + xmlEntityPtr ent); +#endif /* LIBXML_OUTPUT_ENABLED */ +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN void XMLCALL + xmlCleanupPredefinedEntities(void); +#endif /* LIBXML_LEGACY_ENABLED */ + + +#ifdef __cplusplus +} +#endif + +# endif /* __XML_ENTITIES_H__ */ Added: include/libxml/globals.h =================================================================== --- include/libxml/globals.h (rev 0) +++ include/libxml/globals.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,491 @@ +/* + * Summary: interface for all global variables of the library + * Description: all the global variables and thread handling for + * those variables is handled by this module. + * + * The bottom of this file is automatically generated by build_glob.py + * based on the description file global.data + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington , Daniel Veillard + */ + +#ifndef __XML_GLOBALS_H +#define __XML_GLOBALS_H + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL xmlInitGlobals(void); +XMLPUBFUN void XMLCALL xmlCleanupGlobals(void); + +/** + * xmlParserInputBufferCreateFilenameFunc: + * @URI: the URI to read from + * @enc: the requested source encoding + * + * Signature for the function doing the lookup for a suitable input method + * corresponding to an URI. + * + * Returns the new xmlParserInputBufferPtr in case of success or NULL if no + * method was found. + */ +typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc); + +/** + * xmlOutputBufferCreateFilenameFunc: + * @URI: the URI to write to + * @enc: the requested target encoding + * + * Signature for the function doing the lookup for a suitable output method + * corresponding to an URI. + * + * Returns the new xmlOutputBufferPtr in case of success or NULL if no + * method was found. + */ +typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression); + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc +XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func); +XMLPUBFUN xmlOutputBufferCreateFilenameFunc +XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); + +/* + * Externally global symbols which need to be protected for backwards + * compatibility support. + */ + +#undef docbDefaultSAXHandler +#undef htmlDefaultSAXHandler +#undef oldXMLWDcompatibility +#undef xmlBufferAllocScheme +#undef xmlDefaultBufferSize +#undef xmlDefaultSAXHandler +#undef xmlDefaultSAXLocator +#undef xmlDoValidityCheckingDefaultValue +#undef xmlFree +#undef xmlGenericError +#undef xmlStructuredError +#undef xmlGenericErrorContext +#undef xmlGetWarningsDefaultValue +#undef xmlIndentTreeOutput +#undef xmlTreeIndentString +#undef xmlKeepBlanksDefaultValue +#undef xmlLineNumbersDefaultValue +#undef xmlLoadExtDtdDefaultValue +#undef xmlMalloc +#undef xmlMallocAtomic +#undef xmlMemStrdup +#undef xmlParserDebugEntities +#undef xmlParserVersion +#undef xmlPedanticParserDefaultValue +#undef xmlRealloc +#undef xmlSaveNoEmptyTags +#undef xmlSubstituteEntitiesDefaultValue +#undef xmlRegisterNodeDefaultValue +#undef xmlDeregisterNodeDefaultValue +#undef xmlLastError +#undef xmlParserInputBufferCreateFilenameValue +#undef xmlOutputBufferCreateFilenameValue + +/** + * xmlRegisterNodeFunc: + * @node: the current node + * + * Signature for the registration callback of a created node + */ +typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node); +/** + * xmlDeregisterNodeFunc: + * @node: the current node + * + * Signature for the deregistration callback of a discarded node + */ +typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); + +typedef struct _xmlGlobalState xmlGlobalState; +typedef xmlGlobalState *xmlGlobalStatePtr; +struct _xmlGlobalState +{ + const char *xmlParserVersion; + + xmlSAXLocator xmlDefaultSAXLocator; + xmlSAXHandlerV1 xmlDefaultSAXHandler; + xmlSAXHandlerV1 docbDefaultSAXHandler; + xmlSAXHandlerV1 htmlDefaultSAXHandler; + + xmlFreeFunc xmlFree; + xmlMallocFunc xmlMalloc; + xmlStrdupFunc xmlMemStrdup; + xmlReallocFunc xmlRealloc; + + xmlGenericErrorFunc xmlGenericError; + xmlStructuredErrorFunc xmlStructuredError; + void *xmlGenericErrorContext; + + int oldXMLWDcompatibility; + + xmlBufferAllocationScheme xmlBufferAllocScheme; + int xmlDefaultBufferSize; + + int xmlSubstituteEntitiesDefaultValue; + int xmlDoValidityCheckingDefaultValue; + int xmlGetWarningsDefaultValue; + int xmlKeepBlanksDefaultValue; + int xmlLineNumbersDefaultValue; + int xmlLoadExtDtdDefaultValue; + int xmlParserDebugEntities; + int xmlPedanticParserDefaultValue; + + int xmlSaveNoEmptyTags; + int xmlIndentTreeOutput; + const char *xmlTreeIndentString; + + xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; + xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; + + xmlMallocFunc xmlMallocAtomic; + xmlError xmlLastError; + + xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; + xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; +}; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs); + +XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler); + +XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler); + +XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func); +XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func); +XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func); +XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func); + +XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL + xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func); +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL + xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func); + +/** DOC_DISABLE */ +/* + * In general the memory allocation entry points are not kept + * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED + * - xmlMalloc + * - xmlMallocAtomic + * - xmlRealloc + * - xmlMemStrdup + * - xmlFree + */ + +#ifdef LIBXML_THREAD_ALLOC_ENABLED +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void); +#define xmlMalloc \ +(*(__xmlMalloc())) +#else +XMLPUBVAR xmlMallocFunc xmlMalloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void); +#define xmlMallocAtomic \ +(*(__xmlMallocAtomic())) +#else +XMLPUBVAR xmlMallocFunc xmlMallocAtomic; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void); +#define xmlRealloc \ +(*(__xmlRealloc())) +#else +XMLPUBVAR xmlReallocFunc xmlRealloc; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void); +#define xmlFree \ +(*(__xmlFree())) +#else +XMLPUBVAR xmlFreeFunc xmlFree; +#endif + +#ifdef LIBXML_THREAD_ENABLED +XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void); +#define xmlMemStrdup \ +(*(__xmlMemStrdup())) +#else +XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif + +#else /* !LIBXML_THREAD_ALLOC_ENABLED */ +XMLPUBVAR xmlMallocFunc xmlMalloc; +XMLPUBVAR xmlMallocFunc xmlMallocAtomic; +XMLPUBVAR xmlReallocFunc xmlRealloc; +XMLPUBVAR xmlFreeFunc xmlFree; +XMLPUBVAR xmlStrdupFunc xmlMemStrdup; +#endif /* LIBXML_THREAD_ALLOC_ENABLED */ + +#ifdef LIBXML_DOCB_ENABLED +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define docbDefaultSAXHandler \ +(*(__docbDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler; +#endif +#endif + +#ifdef LIBXML_HTML_ENABLED +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define htmlDefaultSAXHandler \ +(*(__htmlDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler; +#endif +#endif + +XMLPUBFUN xmlError * XMLCALL __xmlLastError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLastError \ +(*(__xmlLastError())) +#else +XMLPUBVAR xmlError xmlLastError; +#endif + +/* + * Everything starting from the line below is + * Automatically generated by build_glob.py. + * Do not modify the previous line. + */ + + +XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void); +#ifdef LIBXML_THREAD_ENABLED +#define oldXMLWDcompatibility \ +(*(__oldXMLWDcompatibility())) +#else +XMLPUBVAR int oldXMLWDcompatibility; +#endif + +XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlBufferAllocScheme \ +(*(__xmlBufferAllocScheme())) +#else +XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme; +#endif +XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v); + +XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultBufferSize \ +(*(__xmlDefaultBufferSize())) +#else +XMLPUBVAR int xmlDefaultBufferSize; +#endif +XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v); + +XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultSAXHandler \ +(*(__xmlDefaultSAXHandler())) +#else +XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler; +#endif + +XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDefaultSAXLocator \ +(*(__xmlDefaultSAXLocator())) +#else +XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator; +#endif + +XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDoValidityCheckingDefaultValue \ +(*(__xmlDoValidityCheckingDefaultValue())) +#else +XMLPUBVAR int xmlDoValidityCheckingDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v); + +XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGenericError \ +(*(__xmlGenericError())) +#else +XMLPUBVAR xmlGenericErrorFunc xmlGenericError; +#endif + +XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlStructuredError \ +(*(__xmlStructuredError())) +#else +XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError; +#endif + +XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGenericErrorContext \ +(*(__xmlGenericErrorContext())) +#else +XMLPUBVAR void * xmlGenericErrorContext; +#endif + +XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlGetWarningsDefaultValue \ +(*(__xmlGetWarningsDefaultValue())) +#else +XMLPUBVAR int xmlGetWarningsDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlIndentTreeOutput \ +(*(__xmlIndentTreeOutput())) +#else +XMLPUBVAR int xmlIndentTreeOutput; +#endif +XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v); + +XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlTreeIndentString \ +(*(__xmlTreeIndentString())) +#else +XMLPUBVAR const char * xmlTreeIndentString; +#endif +XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v); + +XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlKeepBlanksDefaultValue \ +(*(__xmlKeepBlanksDefaultValue())) +#else +XMLPUBVAR int xmlKeepBlanksDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLineNumbersDefaultValue \ +(*(__xmlLineNumbersDefaultValue())) +#else +XMLPUBVAR int xmlLineNumbersDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlLoadExtDtdDefaultValue \ +(*(__xmlLoadExtDtdDefaultValue())) +#else +XMLPUBVAR int xmlLoadExtDtdDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserDebugEntities \ +(*(__xmlParserDebugEntities())) +#else +XMLPUBVAR int xmlParserDebugEntities; +#endif +XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v); + +XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserVersion \ +(*(__xmlParserVersion())) +#else +XMLPUBVAR const char * xmlParserVersion; +#endif + +XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlPedanticParserDefaultValue \ +(*(__xmlPedanticParserDefaultValue())) +#else +XMLPUBVAR int xmlPedanticParserDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v); + +XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlSaveNoEmptyTags \ +(*(__xmlSaveNoEmptyTags())) +#else +XMLPUBVAR int xmlSaveNoEmptyTags; +#endif +XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v); + +XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlSubstituteEntitiesDefaultValue \ +(*(__xmlSubstituteEntitiesDefaultValue())) +#else +XMLPUBVAR int xmlSubstituteEntitiesDefaultValue; +#endif +XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v); + +XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlRegisterNodeDefaultValue \ +(*(__xmlRegisterNodeDefaultValue())) +#else +XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; +#endif + +XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlDeregisterNodeDefaultValue \ +(*(__xmlDeregisterNodeDefaultValue())) +#else +XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; +#endif + +XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlParserInputBufferCreateFilenameValue \ +(*(__xmlParserInputBufferCreateFilenameValue())) +#else +XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; +#endif + +XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void); +#ifdef LIBXML_THREAD_ENABLED +#define xmlOutputBufferCreateFilenameValue \ +(*(__xmlOutputBufferCreateFilenameValue())) +#else +XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_GLOBALS_H */ Added: include/libxml/hash.h =================================================================== --- include/libxml/hash.h (rev 0) +++ include/libxml/hash.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,233 @@ +/* + * Summary: Chained hash tables + * Description: This module implements the hash table support used in + * various places in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Bjorn Reese + */ + +#ifndef __XML_HASH_H__ +#define __XML_HASH_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The hash table. + */ +typedef struct _xmlHashTable xmlHashTable; +typedef xmlHashTable *xmlHashTablePtr; + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Recent version of gcc produce a warning when a function pointer is assigned + * to an object pointer, or vice versa. The following macro is a dirty hack + * to allow suppression of the warning. If your architecture has function + * pointers which are a different size than a void pointer, there may be some + * serious trouble within the library. + */ +/** + * XML_CAST_FPTR: + * @fptr: pointer to a function + * + * Macro to do a casting from an object pointer to a + * function pointer without encountering a warning from + * gcc + * + * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr)) + * This macro violated ISO C aliasing rules (gcc4 on s390 broke) + * so it is disabled now + */ + +#define XML_CAST_FPTR(fptr) fptr + + +/* + * function types: + */ +/** + * xmlHashDeallocator: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to free data from a hash. + */ +typedef void (*xmlHashDeallocator)(void *payload, xmlChar *name); +/** + * xmlHashCopier: + * @payload: the data in the hash + * @name: the name associated + * + * Callback to copy data from a hash. + * + * Returns a copy of the data or NULL in case of error. + */ +typedef void *(*xmlHashCopier)(void *payload, xmlChar *name); +/** + * xmlHashScanner: + * @payload: the data in the hash + * @data: extra scannner data + * @name: the name associated + * + * Callback when scanning data in a hash with the simple scanner. + */ +typedef void (*xmlHashScanner)(void *payload, void *data, xmlChar *name); +/** + * xmlHashScannerFull: + * @payload: the data in the hash + * @data: extra scannner data + * @name: the name associated + * @name2: the second name associated + * @name3: the third name associated + * + * Callback when scanning data in a hash with the full scanner. + */ +typedef void (*xmlHashScannerFull)(void *payload, void *data, + const xmlChar *name, const xmlChar *name2, + const xmlChar *name3); + +/* + * Constructor and destructor. + */ +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCreate (int size); +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCreateDict(int size, + xmlDictPtr dict); +XMLPUBFUN void XMLCALL + xmlHashFree (xmlHashTablePtr table, + xmlHashDeallocator f); + +/* + * Add a new entry to the hash table. + */ +XMLPUBFUN int XMLCALL + xmlHashAddEntry (xmlHashTablePtr table, + const xmlChar *name, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry(xmlHashTablePtr table, + const xmlChar *name, + void *userdata, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashAddEntry2(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry2(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + void *userdata, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashAddEntry3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata); +XMLPUBFUN int XMLCALL + xmlHashUpdateEntry3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + void *userdata, + xmlHashDeallocator f); + +/* + * Remove an entry from the hash table. + */ +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, + xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, xmlHashDeallocator f); +XMLPUBFUN int XMLCALL + xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name, + const xmlChar *name2, const xmlChar *name3, + xmlHashDeallocator f); + +/* + * Retrieve the userdata. + */ +XMLPUBFUN void * XMLCALL + xmlHashLookup (xmlHashTablePtr table, + const xmlChar *name); +XMLPUBFUN void * XMLCALL + xmlHashLookup2 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2); +XMLPUBFUN void * XMLCALL + xmlHashLookup3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3); +XMLPUBFUN void * XMLCALL + xmlHashQLookup (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN void * XMLCALL + xmlHashQLookup2 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix, + const xmlChar *name2, + const xmlChar *prefix2); +XMLPUBFUN void * XMLCALL + xmlHashQLookup3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *prefix, + const xmlChar *name2, + const xmlChar *prefix2, + const xmlChar *name3, + const xmlChar *prefix3); + +/* + * Helpers. + */ +XMLPUBFUN xmlHashTablePtr XMLCALL + xmlHashCopy (xmlHashTablePtr table, + xmlHashCopier f); +XMLPUBFUN int XMLCALL + xmlHashSize (xmlHashTablePtr table); +XMLPUBFUN void XMLCALL + xmlHashScan (xmlHashTablePtr table, + xmlHashScanner f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScan3 (xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScanner f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScanFull (xmlHashTablePtr table, + xmlHashScannerFull f, + void *data); +XMLPUBFUN void XMLCALL + xmlHashScanFull3(xmlHashTablePtr table, + const xmlChar *name, + const xmlChar *name2, + const xmlChar *name3, + xmlHashScannerFull f, + void *data); +#ifdef __cplusplus +} +#endif +#endif /* ! __XML_HASH_H__ */ Added: include/libxml/list.h =================================================================== --- include/libxml/list.h (rev 0) +++ include/libxml/list.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,137 @@ +/* + * Summary: lists interfaces + * Description: this module implement the list support used in + * various place in the library. + * + * Copy: See Copyright for the status of this software. + * + * Author: Gary Pennington + */ + +#ifndef __XML_LINK_INCLUDE__ +#define __XML_LINK_INCLUDE__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlLink xmlLink; +typedef xmlLink *xmlLinkPtr; + +typedef struct _xmlList xmlList; +typedef xmlList *xmlListPtr; + +/** + * xmlListDeallocator: + * @lk: the data to deallocate + * + * Callback function used to free data from a list. + */ +typedef void (*xmlListDeallocator) (xmlLinkPtr lk); +/** + * xmlListDataCompare: + * @data0: the first data + * @data1: the second data + * + * Callback function used to compare 2 data. + * + * Returns 0 is equality, -1 or 1 otherwise depending on the ordering. + */ +typedef int (*xmlListDataCompare) (const void *data0, const void *data1); +/** + * xmlListWalker: + * @data: the data found in the list + * @user: extra user provided data to the walker + * + * Callback function used when walking a list with xmlListWalk(). + * + * Returns 0 to stop walking the list, 1 otherwise. + */ +typedef int (*xmlListWalker) (const void *data, const void *user); + +/* Creation/Deletion */ +XMLPUBFUN xmlListPtr XMLCALL + xmlListCreate (xmlListDeallocator deallocator, + xmlListDataCompare compare); +XMLPUBFUN void XMLCALL + xmlListDelete (xmlListPtr l); + +/* Basic Operators */ +XMLPUBFUN void * XMLCALL + xmlListSearch (xmlListPtr l, + void *data); +XMLPUBFUN void * XMLCALL + xmlListReverseSearch (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListInsert (xmlListPtr l, + void *data) ; +XMLPUBFUN int XMLCALL + xmlListAppend (xmlListPtr l, + void *data) ; +XMLPUBFUN int XMLCALL + xmlListRemoveFirst (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListRemoveLast (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListRemoveAll (xmlListPtr l, + void *data); +XMLPUBFUN void XMLCALL + xmlListClear (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListEmpty (xmlListPtr l); +XMLPUBFUN xmlLinkPtr XMLCALL + xmlListFront (xmlListPtr l); +XMLPUBFUN xmlLinkPtr XMLCALL + xmlListEnd (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListSize (xmlListPtr l); + +XMLPUBFUN void XMLCALL + xmlListPopFront (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListPopBack (xmlListPtr l); +XMLPUBFUN int XMLCALL + xmlListPushFront (xmlListPtr l, + void *data); +XMLPUBFUN int XMLCALL + xmlListPushBack (xmlListPtr l, + void *data); + +/* Advanced Operators */ +XMLPUBFUN void XMLCALL + xmlListReverse (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListSort (xmlListPtr l); +XMLPUBFUN void XMLCALL + xmlListWalk (xmlListPtr l, + xmlListWalker walker, + const void *user); +XMLPUBFUN void XMLCALL + xmlListReverseWalk (xmlListPtr l, + xmlListWalker walker, + const void *user); +XMLPUBFUN void XMLCALL + xmlListMerge (xmlListPtr l1, + xmlListPtr l2); +XMLPUBFUN xmlListPtr XMLCALL + xmlListDup (const xmlListPtr old); +XMLPUBFUN int XMLCALL + xmlListCopy (xmlListPtr cur, + const xmlListPtr old); +/* Link operators */ +XMLPUBFUN void * XMLCALL + xmlLinkGetData (xmlLinkPtr lk); + +/* xmlListUnique() */ +/* xmlListSwap */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_LINK_INCLUDE__ */ Added: include/libxml/nanoftp.h =================================================================== --- include/libxml/nanoftp.h (rev 0) +++ include/libxml/nanoftp.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,143 @@ +/* + * Summary: minimal FTP implementation + * Description: minimal FTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_FTP_H__ +#define __NANO_FTP_H__ + +#include + +#ifdef LIBXML_FTP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * ftpListCallback: + * @userData: user provided data for the callback + * @filename: the file name (including "->" when links are shown) + * @attrib: the attribute string + * @owner: the owner string + * @group: the group string + * @size: the file size + * @links: the link count + * @year: the year + * @month: the month + * @day: the day + * @hour: the hour + * @minute: the minute + * + * A callback for the xmlNanoFTPList command. + * Note that only one of year and day:minute are specified. + */ +typedef void (*ftpListCallback) (void *userData, + const char *filename, const char *attrib, + const char *owner, const char *group, + unsigned long size, int links, int year, + const char *month, int day, int hour, + int minute); +/** + * ftpDataCallback: + * @userData: the user provided context + * @data: the data received + * @len: its size in bytes + * + * A callback for the xmlNanoFTPGet command. + */ +typedef void (*ftpDataCallback) (void *userData, + const char *data, + int len); + +/* + * Init + */ +XMLPUBFUN void XMLCALL + xmlNanoFTPInit (void); +XMLPUBFUN void XMLCALL + xmlNanoFTPCleanup (void); + +/* + * Creating/freeing contexts. + */ +XMLPUBFUN void * XMLCALL + xmlNanoFTPNewCtxt (const char *URL); +XMLPUBFUN void XMLCALL + xmlNanoFTPFreeCtxt (void * ctx); +XMLPUBFUN void * XMLCALL + xmlNanoFTPConnectTo (const char *server, + int port); +/* + * Opening/closing session connections. + */ +XMLPUBFUN void * XMLCALL + xmlNanoFTPOpen (const char *URL); +XMLPUBFUN int XMLCALL + xmlNanoFTPConnect (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPClose (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPQuit (void *ctx); +XMLPUBFUN void XMLCALL + xmlNanoFTPScanProxy (const char *URL); +XMLPUBFUN void XMLCALL + xmlNanoFTPProxy (const char *host, + int port, + const char *user, + const char *passwd, + int type); +XMLPUBFUN int XMLCALL + xmlNanoFTPUpdateURL (void *ctx, + const char *URL); + +/* + * Rather internal commands. + */ +XMLPUBFUN int XMLCALL + xmlNanoFTPGetResponse (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPCheckResponse (void *ctx); + +/* + * CD/DIR/GET handlers. + */ +XMLPUBFUN int XMLCALL + xmlNanoFTPCwd (void *ctx, + const char *directory); +XMLPUBFUN int XMLCALL + xmlNanoFTPDele (void *ctx, + const char *file); + +XMLPUBFUN int XMLCALL + xmlNanoFTPGetConnection (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPCloseConnection(void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoFTPList (void *ctx, + ftpListCallback callback, + void *userData, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPGetSocket (void *ctx, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPGet (void *ctx, + ftpDataCallback callback, + void *userData, + const char *filename); +XMLPUBFUN int XMLCALL + xmlNanoFTPRead (void *ctx, + void *dest, + int len); + +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_FTP_ENABLED */ +#endif /* __NANO_FTP_H__ */ Added: include/libxml/nanohttp.h =================================================================== --- include/libxml/nanohttp.h (rev 0) +++ include/libxml/nanohttp.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,81 @@ +/* + * Summary: minimal HTTP implementation + * Description: minimal HTTP implementation allowing to fetch resources + * like external subset. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __NANO_HTTP_H__ +#define __NANO_HTTP_H__ + +#include + +#ifdef LIBXML_HTTP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN void XMLCALL + xmlNanoHTTPInit (void); +XMLPUBFUN void XMLCALL + xmlNanoHTTPCleanup (void); +XMLPUBFUN void XMLCALL + xmlNanoHTTPScanProxy (const char *URL); +XMLPUBFUN int XMLCALL + xmlNanoHTTPFetch (const char *URL, + const char *filename, + char **contentType); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPMethod (const char *URL, + const char *method, + const char *input, + char **contentType, + const char *headers, + int ilen); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPMethodRedir (const char *URL, + const char *method, + const char *input, + char **contentType, + char **redir, + const char *headers, + int ilen); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPOpen (const char *URL, + char **contentType); +XMLPUBFUN void * XMLCALL + xmlNanoHTTPOpenRedir (const char *URL, + char **contentType, + char **redir); +XMLPUBFUN int XMLCALL + xmlNanoHTTPReturnCode (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPAuthHeader (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPRedir (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoHTTPContentLength( void * ctx ); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPEncoding (void *ctx); +XMLPUBFUN const char * XMLCALL + xmlNanoHTTPMimeType (void *ctx); +XMLPUBFUN int XMLCALL + xmlNanoHTTPRead (void *ctx, + void *dest, + int len); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN int XMLCALL + xmlNanoHTTPSave (void *ctxt, + const char *filename); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNanoHTTPClose (void *ctx); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_HTTP_ENABLED */ +#endif /* __NANO_HTTP_H__ */ Added: include/libxml/parser.h =================================================================== --- include/libxml/parser.h (rev 0) +++ include/libxml/parser.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,1226 @@ +/* + * Summary: the core parser module + * Description: Interfaces, constants and types related to the XML parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_H__ +#define __XML_PARSER_H__ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XML_DEFAULT_VERSION: + * + * The default version of XML used: 1.0 + */ +#define XML_DEFAULT_VERSION "1.0" + +/** + * xmlParserInput: + * + * An xmlParserInput is an input flow for the XML processor. + * Each entity parsed is associated an xmlParserInput (except the + * few predefined ones). This is the case both for internal entities + * - in which case the flow is already completely in memory - or + * external entities - in which case we use the buf structure for + * progressive reading and I18N conversions to the internal UTF-8 format. + */ + +/** + * xmlParserInputDeallocate: + * @str: the string to deallocate + * + * Callback for freeing some parser input allocations. + */ +typedef void (* xmlParserInputDeallocate)(xmlChar *str); + +struct _xmlParserInput { + /* Input buffer */ + xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ + + const char *filename; /* The file analyzed, if any */ + const char *directory; /* the directory/base of the file */ + const xmlChar *base; /* Base of the array to parse */ + const xmlChar *cur; /* Current char being parsed */ + const xmlChar *end; /* end of the array to parse */ + int length; /* length if known */ + int line; /* Current line */ + int col; /* Current column */ + /* + * NOTE: consumed is only tested for equality in the parser code, + * so even if there is an overflow this should not give troubles + * for parsing very large instances. + */ + unsigned long consumed; /* How many xmlChars already consumed */ + xmlParserInputDeallocate free; /* function to deallocate the base */ + const xmlChar *encoding; /* the encoding string for entity */ + const xmlChar *version; /* the version string for entity */ + int standalone; /* Was that entity marked standalone */ + int id; /* an unique identifier for the entity */ +}; + +/** + * xmlParserNodeInfo: + * + * The parser can be asked to collect Node informations, i.e. at what + * place in the file they were detected. + * NOTE: This is off by default and not very well tested. + */ +typedef struct _xmlParserNodeInfo xmlParserNodeInfo; +typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; + +struct _xmlParserNodeInfo { + const struct _xmlNode* node; + /* Position & line # that text that created the node begins & ends on */ + unsigned long begin_pos; + unsigned long begin_line; + unsigned long end_pos; + unsigned long end_line; +}; + +typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; +typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; +struct _xmlParserNodeInfoSeq { + unsigned long maximum; + unsigned long length; + xmlParserNodeInfo* buffer; +}; + +/** + * xmlParserInputState: + * + * The parser is now working also as a state based parser. + * The recursive one use the state info for entities processing. + */ +typedef enum { + XML_PARSER_EOF = -1, /* nothing is to be parsed */ + XML_PARSER_START = 0, /* nothing has been parsed */ + XML_PARSER_MISC, /* Misc* before int subset */ + XML_PARSER_PI, /* Within a processing instruction */ + XML_PARSER_DTD, /* within some DTD content */ + XML_PARSER_PROLOG, /* Misc* after internal subset */ + XML_PARSER_COMMENT, /* within a comment */ + XML_PARSER_START_TAG, /* within a start tag */ + XML_PARSER_CONTENT, /* within the content */ + XML_PARSER_CDATA_SECTION, /* within a CDATA section */ + XML_PARSER_END_TAG, /* within a closing tag */ + XML_PARSER_ENTITY_DECL, /* within an entity declaration */ + XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ + XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ + XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ + XML_PARSER_EPILOG, /* the Misc* after the last end tag */ + XML_PARSER_IGNORE, /* within an IGNORED section */ + XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */ +} xmlParserInputState; + +/** + * XML_DETECT_IDS: + * + * Bit in the loadsubset context field to tell to do ID/REFs lookups. + * Use it to initialize xmlLoadExtDtdDefaultValue. + */ +#define XML_DETECT_IDS 2 + +/** + * XML_COMPLETE_ATTRS: + * + * Bit in the loadsubset context field to tell to do complete the + * elements attributes lists with the ones defaulted from the DTDs. + * Use it to initialize xmlLoadExtDtdDefaultValue. + */ +#define XML_COMPLETE_ATTRS 4 + +/** + * XML_SKIP_IDS: + * + * Bit in the loadsubset context field to tell to not do ID/REFs registration. + * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. + */ +#define XML_SKIP_IDS 8 + +/** + * xmlParserMode: + * + * A parser can operate in various modes + */ +typedef enum { + XML_PARSE_UNKNOWN = 0, + XML_PARSE_DOM = 1, + XML_PARSE_SAX = 2, + XML_PARSE_PUSH_DOM = 3, + XML_PARSE_PUSH_SAX = 4, + XML_PARSE_READER = 5 +} xmlParserMode; + +/** + * xmlParserCtxt: + * + * The parser context. + * NOTE This doesn't completely define the parser state, the (current ?) + * design of the parser uses recursive function calls since this allow + * and easy mapping from the production rules of the specification + * to the actual code. The drawback is that the actual function call + * also reflect the parser state. However most of the parsing routines + * takes as the only argument the parser context pointer, so migrating + * to a state based parser for progressive parsing shouldn't be too hard. + */ +struct _xmlParserCtxt { + struct _xmlSAXHandler *sax; /* The SAX handler */ + void *userData; /* For SAX interface only, used by DOM build */ + xmlDocPtr myDoc; /* the document being built */ + int wellFormed; /* is the document well formed */ + int replaceEntities; /* shall we replace entities ? */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* the declared encoding, if any */ + int standalone; /* standalone document */ + int html; /* an HTML(1)/Docbook(2) document */ + + /* Input stream stack */ + xmlParserInputPtr input; /* Current input stream */ + int inputNr; /* Number of current input streams */ + int inputMax; /* Max number of input streams */ + xmlParserInputPtr *inputTab; /* stack of inputs */ + + /* Node analysis stack only used for DOM building */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + int record_info; /* Whether node info should be kept */ + xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ + + int errNo; /* error code */ + + int hasExternalSubset; /* reference and external subset */ + int hasPErefs; /* the internal subset has PE refs */ + int external; /* are we parsing an external entity */ + + int valid; /* is the document valid */ + int validate; /* shall we try to validate ? */ + xmlValidCtxt vctxt; /* The validity context */ + + xmlParserInputState instate; /* current type of input */ + int token; /* next char look-ahead */ + + char *directory; /* the data directory */ + + /* Node name stack */ + const xmlChar *name; /* Current parsed Node */ + int nameNr; /* Depth of the parsing stack */ + int nameMax; /* Max depth of the parsing stack */ + const xmlChar * *nameTab; /* array of nodes */ + + long nbChars; /* number of xmlChar processed */ + long checkIndex; /* used by progressive parsing lookup */ + int keepBlanks; /* ugly but ... */ + int disableSAX; /* SAX callbacks are disabled */ + int inSubset; /* Parsing is in int 1/ext 2 subset */ + const xmlChar * intSubName; /* name of subset */ + xmlChar * extSubURI; /* URI of external subset */ + xmlChar * extSubSystem; /* SYSTEM ID of external subset */ + + /* xml:space values */ + int * space; /* Should the parser preserve spaces */ + int spaceNr; /* Depth of the parsing stack */ + int spaceMax; /* Max depth of the parsing stack */ + int * spaceTab; /* array of space infos */ + + int depth; /* to prevent entity substitution loops */ + xmlParserInputPtr entity; /* used to check entities boundaries */ + int charset; /* encoding of the in-memory content + actually an xmlCharEncoding */ + int nodelen; /* Those two fields are there to */ + int nodemem; /* Speed up large node parsing */ + int pedantic; /* signal pedantic warnings */ + void *_private; /* For user data, libxml won't touch it */ + + int loadsubset; /* should the external subset be loaded */ + int linenumbers; /* set line number in element content */ + void *catalogs; /* document's own catalog */ + int recovery; /* run in recovery mode */ + int progressive; /* is this a progressive parsing */ + xmlDictPtr dict; /* dictionnary for the parser */ + const xmlChar * *atts; /* array for the attributes callbacks */ + int maxatts; /* the size of the array */ + int docdict; /* use strings from dict to build tree */ + + /* + * pre-interned strings + */ + const xmlChar *str_xml; + const xmlChar *str_xmlns; + const xmlChar *str_xml_ns; + + /* + * Everything below is used only by the new SAX mode + */ + int sax2; /* operating in the new SAX mode */ + int nsNr; /* the number of inherited namespaces */ + int nsMax; /* the size of the arrays */ + const xmlChar * *nsTab; /* the array of prefix/namespace name */ + int *attallocs; /* which attribute were allocated */ + void * *pushTab; /* array of data for push */ + xmlHashTablePtr attsDefault; /* defaulted attributes if any */ + xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ + int nsWellFormed; /* is the document XML Nanespace okay */ + int options; /* Extra options */ + + /* + * Those fields are needed only for treaming parsing so far + */ + int dictNames; /* Use dictionary names for the tree */ + int freeElemsNr; /* number of freed element nodes */ + xmlNodePtr freeElems; /* List of freed element nodes */ + int freeAttrsNr; /* number of freed attributes nodes */ + xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ + + /* + * the complete error informations for the last error. + */ + xmlError lastError; + xmlParserMode parseMode; /* the parser mode */ + unsigned long nbentities; /* number of entities references */ + unsigned long sizeentities; /* size of parsed entities */ +}; + +/** + * xmlSAXLocator: + * + * A SAX Locator. + */ +struct _xmlSAXLocator { + const xmlChar *(*getPublicId)(void *ctx); + const xmlChar *(*getSystemId)(void *ctx); + int (*getLineNumber)(void *ctx); + int (*getColumnNumber)(void *ctx); +}; + +/** + * xmlSAXHandler: + * + * A SAX handler is bunch of callbacks called by the parser when processing + * of the input generate data or structure informations. + */ + +/** + * resolveEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * Callback: + * The entity loader, to control the loading of external entities, + * the application can either: + * - override this resolveEntity() callback in the SAX block + * - or better use the xmlSetExternalEntityLoader() function to + * set up it's own entity resolution routine + * + * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. + */ +typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * internalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on internal subset declaration. + */ +typedef void (*internalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * externalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the root element name + * @ExternalID: the external ID + * @SystemID: the SYSTEM ID (e.g. filename or URL) + * + * Callback on external subset declaration. + */ +typedef void (*externalSubsetSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * getEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get an entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * getParameterEntitySAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Get a parameter entity by name. + * + * Returns the xmlEntityPtr if found. + */ +typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, + const xmlChar *name); +/** + * entityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the entity name + * @type: the entity type + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @content: the entity value (without processing). + * + * An entity definition has been parsed. + */ +typedef void (*entityDeclSAXFunc) (void *ctx, + const xmlChar *name, + int type, + const xmlChar *publicId, + const xmlChar *systemId, + xmlChar *content); +/** + * notationDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the notation + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * + * What to do when a notation declaration has been parsed. + */ +typedef void (*notationDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId); +/** + * attributeDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @elem: the name of the element + * @fullname: the attribute name + * @type: the attribute type + * @def: the type of default value + * @defaultValue: the attribute default value + * @tree: the tree of enumerated value set + * + * An attribute definition has been parsed. + */ +typedef void (*attributeDeclSAXFunc)(void *ctx, + const xmlChar *elem, + const xmlChar *fullname, + int type, + int def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +/** + * elementDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: the element name + * @type: the element type + * @content: the element value tree + * + * An element definition has been parsed. + */ +typedef void (*elementDeclSAXFunc)(void *ctx, + const xmlChar *name, + int type, + xmlElementContentPtr content); +/** + * unparsedEntityDeclSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The name of the entity + * @publicId: The public ID of the entity + * @systemId: The system ID of the entity + * @notationName: the name of the notation + * + * What to do when an unparsed entity declaration is parsed. + */ +typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, + const xmlChar *name, + const xmlChar *publicId, + const xmlChar *systemId, + const xmlChar *notationName); +/** + * setDocumentLocatorSAXFunc: + * @ctx: the user data (XML parser context) + * @loc: A SAX Locator + * + * Receive the document locator at startup, actually xmlDefaultSAXLocator. + * Everything is available on the context, so this is useless in our case. + */ +typedef void (*setDocumentLocatorSAXFunc) (void *ctx, + xmlSAXLocatorPtr loc); +/** + * startDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document start being processed. + */ +typedef void (*startDocumentSAXFunc) (void *ctx); +/** + * endDocumentSAXFunc: + * @ctx: the user data (XML parser context) + * + * Called when the document end has been detected. + */ +typedef void (*endDocumentSAXFunc) (void *ctx); +/** + * startElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name, including namespace prefix + * @atts: An array of name/value attributes pairs, NULL terminated + * + * Called when an opening tag has been processed. + */ +typedef void (*startElementSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar **atts); +/** + * endElementSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The element name + * + * Called when the end of an element has been detected. + */ +typedef void (*endElementSAXFunc) (void *ctx, + const xmlChar *name); +/** + * attributeSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The attribute name, including namespace prefix + * @value: The attribute value + * + * Handle an attribute that has been read by the parser. + * The default handling is to convert the attribute into an + * DOM subtree and past it in a new xmlAttr element added to + * the element. + */ +typedef void (*attributeSAXFunc) (void *ctx, + const xmlChar *name, + const xmlChar *value); +/** + * referenceSAXFunc: + * @ctx: the user data (XML parser context) + * @name: The entity name + * + * Called when an entity reference is detected. + */ +typedef void (*referenceSAXFunc) (void *ctx, + const xmlChar *name); +/** + * charactersSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some chars from the parser. + */ +typedef void (*charactersSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * ignorableWhitespaceSAXFunc: + * @ctx: the user data (XML parser context) + * @ch: a xmlChar string + * @len: the number of xmlChar + * + * Receiving some ignorable whitespaces from the parser. + * UNUSED: by default the DOM building will use characters. + */ +typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, + const xmlChar *ch, + int len); +/** + * processingInstructionSAXFunc: + * @ctx: the user data (XML parser context) + * @target: the target name + * @data: the PI data's + * + * A processing instruction has been parsed. + */ +typedef void (*processingInstructionSAXFunc) (void *ctx, + const xmlChar *target, + const xmlChar *data); +/** + * commentSAXFunc: + * @ctx: the user data (XML parser context) + * @value: the comment content + * + * A comment has been parsed. + */ +typedef void (*commentSAXFunc) (void *ctx, + const xmlChar *value); +/** + * cdataBlockSAXFunc: + * @ctx: the user data (XML parser context) + * @value: The pcdata content + * @len: the block length + * + * Called when a pcdata block has been parsed. + */ +typedef void (*cdataBlockSAXFunc) ( + void *ctx, + const xmlChar *value, + int len); +/** + * warningSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format a warning messages, callback. + */ +typedef void (XMLCDECL *warningSAXFunc) (void *ctx, + const char *msg, ...) ATTRIBUTE_PRINTF(2,3); +/** + * errorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format an error messages, callback. + */ +typedef void (XMLCDECL *errorSAXFunc) (void *ctx, + const char *msg, ...) ATTRIBUTE_PRINTF(2,3); +/** + * fatalErrorSAXFunc: + * @ctx: an XML parser context + * @msg: the message to display/transmit + * @...: extra parameters for the message display + * + * Display and format fatal error messages, callback. + * Note: so far fatalError() SAX callbacks are not used, error() + * get all the callbacks for errors. + */ +typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx, + const char *msg, ...) ATTRIBUTE_PRINTF(2,3); +/** + * isStandaloneSAXFunc: + * @ctx: the user data (XML parser context) + * + * Is this document tagged standalone? + * + * Returns 1 if true + */ +typedef int (*isStandaloneSAXFunc) (void *ctx); +/** + * hasInternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an internal subset. + * + * Returns 1 if true + */ +typedef int (*hasInternalSubsetSAXFunc) (void *ctx); + +/** + * hasExternalSubsetSAXFunc: + * @ctx: the user data (XML parser context) + * + * Does this document has an external subset? + * + * Returns 1 if true + */ +typedef int (*hasExternalSubsetSAXFunc) (void *ctx); + +/************************************************************************ + * * + * The SAX version 2 API extensions * + * * + ************************************************************************/ +/** + * XML_SAX2_MAGIC: + * + * Special constant found in SAX2 blocks initialized fields + */ +#define XML_SAX2_MAGIC 0xDEEDBEAF + +/** + * startElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * @nb_namespaces: number of namespace definitions on that node + * @namespaces: pointer to the array of prefix/URI pairs namespace definitions + * @nb_attributes: the number of attributes on that node + * @nb_defaulted: the number of defaulted attributes. The defaulted + * ones are at the end of the array + * @attributes: pointer to the array of (localname/prefix/URI/value/end) + * attribute values. + * + * SAX2 callback when an element start has been detected by the parser. + * It provides the namespace informations for the element, as well as + * the new namespace declarations on the element. + */ + +typedef void (*startElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI, + int nb_namespaces, + const xmlChar **namespaces, + int nb_attributes, + int nb_defaulted, + const xmlChar **attributes); + +/** + * endElementNsSAX2Func: + * @ctx: the user data (XML parser context) + * @localname: the local name of the element + * @prefix: the element namespace prefix if available + * @URI: the element namespace name if available + * + * SAX2 callback when an element end has been detected by the parser. + * It provides the namespace informations for the element. + */ + +typedef void (*endElementNsSAX2Func) (void *ctx, + const xmlChar *localname, + const xmlChar *prefix, + const xmlChar *URI); + + +struct _xmlSAXHandler { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; + /* The following fields are extensions available only on version 2 */ + void *_private; + startElementNsSAX2Func startElementNs; + endElementNsSAX2Func endElementNs; + xmlStructuredErrorFunc serror; +}; + +/* + * SAX Version 1 + */ +typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; +typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; +struct _xmlSAXHandlerV1 { + internalSubsetSAXFunc internalSubset; + isStandaloneSAXFunc isStandalone; + hasInternalSubsetSAXFunc hasInternalSubset; + hasExternalSubsetSAXFunc hasExternalSubset; + resolveEntitySAXFunc resolveEntity; + getEntitySAXFunc getEntity; + entityDeclSAXFunc entityDecl; + notationDeclSAXFunc notationDecl; + attributeDeclSAXFunc attributeDecl; + elementDeclSAXFunc elementDecl; + unparsedEntityDeclSAXFunc unparsedEntityDecl; + setDocumentLocatorSAXFunc setDocumentLocator; + startDocumentSAXFunc startDocument; + endDocumentSAXFunc endDocument; + startElementSAXFunc startElement; + endElementSAXFunc endElement; + referenceSAXFunc reference; + charactersSAXFunc characters; + ignorableWhitespaceSAXFunc ignorableWhitespace; + processingInstructionSAXFunc processingInstruction; + commentSAXFunc comment; + warningSAXFunc warning; + errorSAXFunc error; + fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ + getParameterEntitySAXFunc getParameterEntity; + cdataBlockSAXFunc cdataBlock; + externalSubsetSAXFunc externalSubset; + unsigned int initialized; +}; + + +/** + * xmlExternalEntityLoader: + * @URL: The System ID of the resource requested + * @ID: The Public ID of the resource requested + * @context: the XML parser context + * + * External entity loaders types. + * + * Returns the entity input parser. + */ +typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, + const char *ID, + xmlParserCtxtPtr context); + +#ifdef __cplusplus +} +#endif + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Init/Cleanup + */ +XMLPUBFUN void XMLCALL + xmlInitParser (void); +XMLPUBFUN void XMLCALL + xmlCleanupParser (void); + +/* + * Input functions + */ +XMLPUBFUN int XMLCALL + xmlParserInputRead (xmlParserInputPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputGrow (xmlParserInputPtr in, + int len); + +/* + * Basic parsing Interfaces + */ +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseDoc (const xmlChar *cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseFile (const char *filename); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseMemory (const char *buffer, + int size); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN int XMLCALL + xmlSubstituteEntitiesDefault(int val); +XMLPUBFUN int XMLCALL + xmlKeepBlanksDefault (int val); +XMLPUBFUN void XMLCALL + xmlStopParser (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlPedanticParserDefault(int val); +XMLPUBFUN int XMLCALL + xmlLineNumbersDefault (int val); + +#ifdef LIBXML_SAX1_ENABLED +/* + * Recovery mode + */ +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverDoc (xmlChar *cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverMemory (const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlRecoverFile (const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ + +/* + * Less common routines and SAX interfaces + */ +XMLPUBFUN int XMLCALL + xmlParseDocument (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlSAXUserParseFile (xmlSAXHandlerPtr sax, + void *user_data, + const char *filename); +XMLPUBFUN int XMLCALL + xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, + void *user_data, + const char *buffer, + int size); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseDoc (xmlSAXHandlerPtr sax, + const xmlChar *cur, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseMemory (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, + const char *buffer, + int size, + int recovery, + void *data); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseFile (xmlSAXHandlerPtr sax, + const char *filename, + int recovery); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, + const char *filename, + int recovery, + void *data); +XMLPUBFUN xmlDocPtr XMLCALL + xmlSAXParseEntity (xmlSAXHandlerPtr sax, + const char *filename); +XMLPUBFUN xmlDocPtr XMLCALL + xmlParseEntity (const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ + +#ifdef LIBXML_VALID_ENABLED +XMLPUBFUN xmlDtdPtr XMLCALL + xmlSAXParseDTD (xmlSAXHandlerPtr sax, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlParseDTD (const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlIOParseDTD (xmlSAXHandlerPtr sax, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); +#endif /* LIBXML_VALID_ENABLE */ +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlParseBalancedChunkMemory(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN xmlParserErrors XMLCALL + xmlParseInNodeContext (xmlNodePtr node, + const char *data, + int datalen, + int options, + xmlNodePtr *lst); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN int XMLCALL + xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *string, + xmlNodePtr *lst, + int recover); +XMLPUBFUN int XMLCALL + xmlParseExternalEntity (xmlDocPtr doc, + xmlSAXHandlerPtr sax, + void *user_data, + int depth, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN int XMLCALL + xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, + const xmlChar *URL, + const xmlChar *ID, + xmlNodePtr *lst); + +/* + * Parser contexts handling. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlNewParserCtxt (void); +XMLPUBFUN int XMLCALL + xmlInitParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlClearParserCtxt (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN void XMLCALL + xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, + const xmlChar* buffer, + const char *filename); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateDocParserCtxt (const xmlChar *cur); + +#ifdef LIBXML_LEGACY_ENABLED +/* + * Reading/setting optional parsing features. + */ +XMLPUBFUN int XMLCALL + xmlGetFeaturesList (int *len, + const char **result); +XMLPUBFUN int XMLCALL + xmlGetFeature (xmlParserCtxtPtr ctxt, + const char *name, + void *result); +XMLPUBFUN int XMLCALL + xmlSetFeature (xmlParserCtxtPtr ctxt, + const char *name, + void *value); +#endif /* LIBXML_LEGACY_ENABLED */ + +#ifdef LIBXML_PUSH_ENABLED +/* + * Interfaces for the Push mode. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, + void *user_data, + const char *chunk, + int size, + const char *filename); +XMLPUBFUN int XMLCALL + xmlParseChunk (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + int terminate); +#endif /* LIBXML_PUSH_ENABLED */ + +/* + * Special I/O mode. + */ + +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, + void *user_data, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewIOInputStream (xmlParserCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc); + +/* + * Node infos. + */ +XMLPUBFUN const xmlParserNodeInfo* XMLCALL + xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, + const xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XMLPUBFUN void XMLCALL + xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); +XMLPUBFUN unsigned long XMLCALL + xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, + const xmlNodePtr node); +XMLPUBFUN void XMLCALL + xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, + const xmlParserNodeInfoPtr info); + +/* + * External entities handling actually implemented in xmlIO. + */ + +XMLPUBFUN void XMLCALL + xmlSetExternalEntityLoader(xmlExternalEntityLoader f); +XMLPUBFUN xmlExternalEntityLoader XMLCALL + xmlGetExternalEntityLoader(void); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlLoadExternalEntity (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +/* + * Index lookup, actually implemented in the encoding module + */ +XMLPUBFUN long XMLCALL + xmlByteConsumed (xmlParserCtxtPtr ctxt); + +/* + * New set of simpler/more flexible APIs + */ +/** + * xmlParserOption: + * + * This is the set of XML parser options that can be passed down + * to the xmlReadDoc() and similar calls. + */ +typedef enum { + XML_PARSE_RECOVER = 1<<0, /* recover on errors */ + XML_PARSE_NOENT = 1<<1, /* substitute entities */ + XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ + XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ + XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ + XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ + XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ + XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ + XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ + XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ + XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */ + XML_PARSE_NONET = 1<<11,/* Forbid network access */ + XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */ + XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ + XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ + XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ + XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of + the tree allowed afterwards (will possibly + crash if you try to modify the tree) */ + XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */ + XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */ + XML_PARSE_HUGE = 1<<19, /* relax any hardcoded limit from the parser */ + XML_PARSE_OLDSAX = 1<<20 /* parse using SAX2 interface from before 2.7.0 */ +} xmlParserOption; + +XMLPUBFUN void XMLCALL + xmlCtxtReset (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlCtxtResetPush (xmlParserCtxtPtr ctxt, + const char *chunk, + int size, + const char *filename, + const char *encoding); +XMLPUBFUN int XMLCALL + xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadDoc (const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadFile (const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlReadIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadFile (xmlParserCtxtPtr ctxt, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadFd (xmlParserCtxtPtr ctxt, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlDocPtr XMLCALL + xmlCtxtReadIO (xmlParserCtxtPtr ctxt, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +/* + * Library wide options + */ +/** + * xmlFeature: + * + * Used to examine the existance of features that can be enabled + * or disabled at compile-time. + * They used to be called XML_FEATURE_xxx but this clashed with Expat + */ +typedef enum { + XML_WITH_THREAD = 1, + XML_WITH_TREE = 2, + XML_WITH_OUTPUT = 3, + XML_WITH_PUSH = 4, + XML_WITH_READER = 5, + XML_WITH_PATTERN = 6, + XML_WITH_WRITER = 7, + XML_WITH_SAX1 = 8, + XML_WITH_FTP = 9, + XML_WITH_HTTP = 10, + XML_WITH_VALID = 11, + XML_WITH_HTML = 12, + XML_WITH_LEGACY = 13, + XML_WITH_C14N = 14, + XML_WITH_CATALOG = 15, + XML_WITH_XPATH = 16, + XML_WITH_XPTR = 17, + XML_WITH_XINCLUDE = 18, + XML_WITH_ICONV = 19, + XML_WITH_ISO8859X = 20, + XML_WITH_UNICODE = 21, + XML_WITH_REGEXP = 22, + XML_WITH_AUTOMATA = 23, + XML_WITH_EXPR = 24, + XML_WITH_SCHEMAS = 25, + XML_WITH_SCHEMATRON = 26, + XML_WITH_MODULES = 27, + XML_WITH_DEBUG = 28, + XML_WITH_DEBUG_MEM = 29, + XML_WITH_DEBUG_RUN = 30, + XML_WITH_ZLIB = 31, + XML_WITH_NONE = 99999 /* just to be sure of allocation size */ +} xmlFeature; + +XMLPUBFUN int XMLCALL + xmlHasFeature (xmlFeature feature); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_H__ */ + Added: include/libxml/parserInternals.h =================================================================== --- include/libxml/parserInternals.h (rev 0) +++ include/libxml/parserInternals.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,611 @@ +/* + * Summary: internals routines exported by the parser. + * Description: this module exports a number of internal parsing routines + * they are not really all intended for applications but + * can prove useful doing low level processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PARSER_INTERNALS_H__ +#define __XML_PARSER_INTERNALS_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlParserMaxDepth: + * + * arbitrary depth limit for the XML documents that we allow to + * process. This is not a limitation of the parser but a safety + * boundary feature, use XML_PARSE_HUGE option to override it. + */ +XMLPUBVAR unsigned int xmlParserMaxDepth; + +/** + * XML_MAX_TEXT_LENGTH: + * + * Maximum size allowed for a single text node when building a tree. + * This is not a limitation of the parser but a safety boundary feature, + * use XML_PARSE_HUGE option to override it. + */ +#define XML_MAX_TEXT_LENGTH 10000000 + +/** + * XML_MAX_NAMELEN: + * + * Identifiers can be longer, but this will be more costly + * at runtime. + */ +#define XML_MAX_NAMELEN 100 + +/** + * INPUT_CHUNK: + * + * The parser tries to always have that amount of input ready. + * One of the point is providing context when reporting errors. + */ +#define INPUT_CHUNK 250 + +/************************************************************************ + * * + * UNICODE version of the macros. * + * * + ************************************************************************/ +/** + * IS_BYTE_CHAR: + * @c: an byte value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20...] + * any byte character in the accepted range + */ +#define IS_BYTE_CHAR(c) xmlIsChar_ch(c) + +/** + * IS_CHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + * | [#x10000-#x10FFFF] + * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. + */ +#define IS_CHAR(c) xmlIsCharQ(c) + +/** + * IS_CHAR_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Behaves like IS_CHAR on single-byte value + */ +#define IS_CHAR_CH(c) xmlIsChar_ch(c) + +/** + * IS_BLANK: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [3] S ::= (#x20 | #x9 | #xD | #xA)+ + */ +#define IS_BLANK(c) xmlIsBlankQ(c) + +/** + * IS_BLANK_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Behaviour same as IS_BLANK + */ +#define IS_BLANK_CH(c) xmlIsBlank_ch(c) + +/** + * IS_BASECHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [85] BaseChar ::= ... long list see REC ... + */ +#define IS_BASECHAR(c) xmlIsBaseCharQ(c) + +/** + * IS_DIGIT: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [88] Digit ::= ... long list see REC ... + */ +#define IS_DIGIT(c) xmlIsDigitQ(c) + +/** + * IS_DIGIT_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_DIGIT but with a single byte argument + */ +#define IS_DIGIT_CH(c) xmlIsDigit_ch(c) + +/** + * IS_COMBINING: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * [87] CombiningChar ::= ... long list see REC ... + */ +#define IS_COMBINING(c) xmlIsCombiningQ(c) + +/** + * IS_COMBINING_CH: + * @c: an xmlChar (usually an unsigned char) + * + * Always false (all combining chars > 0xff) + */ +#define IS_COMBINING_CH(c) 0 + +/** + * IS_EXTENDER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | + * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | + * [#x309D-#x309E] | [#x30FC-#x30FE] + */ +#define IS_EXTENDER(c) xmlIsExtenderQ(c) + +/** + * IS_EXTENDER_CH: + * @c: an xmlChar value (usually an unsigned char) + * + * Behaves like IS_EXTENDER but with a single-byte argument + */ +#define IS_EXTENDER_CH(c) xmlIsExtender_ch(c) + +/** + * IS_IDEOGRAPHIC: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029] + */ +#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c) + +/** + * IS_LETTER: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [84] Letter ::= BaseChar | Ideographic + */ +#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c)) + +/** + * IS_LETTER_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Macro behaves like IS_LETTER, but only check base chars + * + */ +#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c) + +/** + * IS_ASCII_LETTER: + * @c: an xmlChar value + * + * Macro to check [a-zA-Z] + * + */ +#define IS_ASCII_LETTER(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ + ((0x61 <= (c)) && ((c) <= 0x7a))) + +/** + * IS_ASCII_DIGIT: + * @c: an xmlChar value + * + * Macro to check [0-9] + * + */ +#define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39)) + +/** + * IS_PUBIDCHAR: + * @c: an UNICODE value (int) + * + * Macro to check the following production in the XML spec: + * + * + * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] + */ +#define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c) + +/** + * IS_PUBIDCHAR_CH: + * @c: an xmlChar value (normally unsigned char) + * + * Same as IS_PUBIDCHAR but for single-byte value + */ +#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c) + +/** + * SKIP_EOL: + * @p: and UTF8 string pointer + * + * Skips the end of line chars. + */ +#define SKIP_EOL(p) \ + if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \ + if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; } + +/** + * MOVETO_ENDTAG: + * @p: and UTF8 string pointer + * + * Skips to the next '>' char. + */ +#define MOVETO_ENDTAG(p) \ + while ((*p) && (*(p) != '>')) (p)++ + +/** + * MOVETO_STARTTAG: + * @p: and UTF8 string pointer + * + * Skips to the next '<' char. + */ +#define MOVETO_STARTTAG(p) \ + while ((*p) && (*(p) != '<')) (p)++ + +/** + * Global variables used for predefined strings. + */ +XMLPUBVAR const xmlChar xmlStringText[]; +XMLPUBVAR const xmlChar xmlStringTextNoenc[]; +XMLPUBVAR const xmlChar xmlStringComment[]; + +/* + * Function to finish the work of the macros where needed. + */ +XMLPUBFUN int XMLCALL xmlIsLetter (int c); + +/** + * Parser context. + */ +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateFileParserCtxt (const char *filename); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateURLParserCtxt (const char *filename, + int options); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateMemoryParserCtxt(const char *buffer, + int size); +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlCreateEntityParserCtxt(const xmlChar *URL, + const xmlChar *ID, + const xmlChar *base); +XMLPUBFUN int XMLCALL + xmlSwitchEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, + xmlCharEncodingHandlerPtr handler); +XMLPUBFUN int XMLCALL + xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input, + xmlCharEncodingHandlerPtr handler); + +#ifdef IN_LIBXML +/* internal error reporting */ +XMLPUBFUN void XMLCALL + __xmlErrEncoding (xmlParserCtxtPtr ctxt, + xmlParserErrors xmlerr, + const char *msg, + const xmlChar * str1, + const xmlChar * str2); +#endif + +/** + * Input Streams. + */ +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewStringInputStream (xmlParserCtxtPtr ctxt, + const xmlChar *buffer); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); +XMLPUBFUN int XMLCALL + xmlPushInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr input); +XMLPUBFUN xmlChar XMLCALL + xmlPopInput (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlFreeInputStream (xmlParserInputPtr input); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewInputFromFile (xmlParserCtxtPtr ctxt, + const char *filename); +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNewInputStream (xmlParserCtxtPtr ctxt); + +/** + * Namespaces. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlSplitQName (xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlChar **prefix); + +/** + * Generic production rules. + */ +XMLPUBFUN const xmlChar * XMLCALL + xmlParseName (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseNmtoken (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseEntityValue (xmlParserCtxtPtr ctxt, + xmlChar **orig); +XMLPUBFUN xmlChar * XMLCALL + xmlParseAttValue (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseSystemLiteral (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParsePubidLiteral (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseCharData (xmlParserCtxtPtr ctxt, + int cdata); +XMLPUBFUN xmlChar * XMLCALL + xmlParseExternalID (xmlParserCtxtPtr ctxt, + xmlChar **publicID, + int strict); +XMLPUBFUN void XMLCALL + xmlParseComment (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParsePITarget (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParsePI (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseNotationDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseEntityDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, + xmlChar **value); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlParseNotationType (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlParseEnumerationType (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XMLPUBFUN int XMLCALL + xmlParseAttributeType (xmlParserCtxtPtr ctxt, + xmlEnumerationPtr *tree); +XMLPUBFUN void XMLCALL + xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlParseElementMixedContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlParseElementChildrenContentDecl + (xmlParserCtxtPtr ctxt, + int inputchk); +XMLPUBFUN int XMLCALL + xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, + const xmlChar *name, + xmlElementContentPtr *result); +XMLPUBFUN int XMLCALL + xmlParseElementDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseMarkupDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseCharRef (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlEntityPtr XMLCALL + xmlParseEntityRef (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseReference (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParsePEReference (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt); +#ifdef LIBXML_SAX1_ENABLED +XMLPUBFUN const xmlChar * XMLCALL + xmlParseAttribute (xmlParserCtxtPtr ctxt, + xmlChar **value); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseStartTag (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseEndTag (xmlParserCtxtPtr ctxt); +#endif /* LIBXML_SAX1_ENABLED */ +XMLPUBFUN void XMLCALL + xmlParseCDSect (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseContent (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseElement (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseVersionNum (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseVersionInfo (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlParseEncName (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL + xmlParseEncodingDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlParseSDDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseXMLDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseTextDecl (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseMisc (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseExternalSubset (xmlParserCtxtPtr ctxt, + const xmlChar *ExternalID, + const xmlChar *SystemID); +/** + * XML_SUBSTITUTE_NONE: + * + * If no entities need to be substituted. + */ +#define XML_SUBSTITUTE_NONE 0 +/** + * XML_SUBSTITUTE_REF: + * + * Whether general entities need to be substituted. + */ +#define XML_SUBSTITUTE_REF 1 +/** + * XML_SUBSTITUTE_PEREF: + * + * Whether parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_PEREF 2 +/** + * XML_SUBSTITUTE_BOTH: + * + * Both general and parameter entities need to be substituted. + */ +#define XML_SUBSTITUTE_BOTH 3 + +XMLPUBFUN xmlChar * XMLCALL + xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XMLPUBFUN xmlChar * XMLCALL + xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, + const xmlChar *str, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); + +/* + * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP. + */ +XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, + xmlNodePtr value); +XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, + xmlParserInputPtr value); +XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt); +XMLPUBFUN const xmlChar * XMLCALL namePop (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, + const xmlChar *value); + +/* + * other commodities shared between parser.c and parserInternals. + */ +XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, + const xmlChar *cur, + int *len); +XMLPUBFUN void XMLCALL xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); +XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang); + +/* + * Really core function shared with HTML parser. + */ +XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, + int *len); +XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, + int val); +XMLPUBFUN int XMLCALL xmlCopyChar (int len, + xmlChar *out, + int val); +XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in); + +#ifdef LIBXML_HTML_ENABLED +/* + * Actually comes from the HTML parser but launched from the init stuff. + */ +XMLPUBFUN void XMLCALL htmlInitAutoClose (void); +XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename, + const char *encoding); +#endif + +/* + * Specific function to keep track of entities references + * and used by the XSLT debugger. + */ +#ifdef LIBXML_LEGACY_ENABLED +/** + * xmlEntityReferenceFunc: + * @ent: the entity + * @firstNode: the fist node in the chunk + * @lastNode: the last nod in the chunk + * + * Callback function used when one needs to be able to track back the + * provenance of a chunk of nodes inherited from an entity replacement. + */ +typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent, + xmlNodePtr firstNode, + xmlNodePtr lastNode); + +XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func); + +XMLPUBFUN xmlChar * XMLCALL + xmlParseQuotedString (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlParseNamespace (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlScanName (xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlNamespaceParseQName (xmlParserCtxtPtr ctxt, + xmlChar **prefix); +/** + * Entities + */ +XMLPUBFUN xmlChar * XMLCALL + xmlDecodeEntities (xmlParserCtxtPtr ctxt, + int len, + int what, + xmlChar end, + xmlChar end2, + xmlChar end3); +XMLPUBFUN void XMLCALL + xmlHandleEntity (xmlParserCtxtPtr ctxt, + xmlEntityPtr entity); + +#endif /* LIBXML_LEGACY_ENABLED */ + +#ifdef IN_LIBXML +/* + * internal only + */ +XMLPUBFUN void XMLCALL + xmlErrMemory (xmlParserCtxtPtr ctxt, + const char *extra); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* __XML_PARSER_INTERNALS_H__ */ Added: include/libxml/pattern.h =================================================================== --- include/libxml/pattern.h (rev 0) +++ include/libxml/pattern.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,100 @@ +/* + * Summary: pattern expression handling + * Description: allows to compile and test pattern expressions for nodes + * either in a tree or based on a parser state. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_PATTERN_H__ +#define __XML_PATTERN_H__ + +#include +#include +#include + +#ifdef LIBXML_PATTERN_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlPattern: + * + * A compiled (XPath based) pattern to select nodes + */ +typedef struct _xmlPattern xmlPattern; +typedef xmlPattern *xmlPatternPtr; + +/** + * xmlPatternFlags: + * + * This is the set of options affecting the behaviour of pattern + * matching with this module + * + */ +typedef enum { + XML_PATTERN_DEFAULT = 0, /* simple pattern match */ + XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */ + XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */ + XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */ +} xmlPatternFlags; + +XMLPUBFUN void XMLCALL + xmlFreePattern (xmlPatternPtr comp); + +XMLPUBFUN void XMLCALL + xmlFreePatternList (xmlPatternPtr comp); + +XMLPUBFUN xmlPatternPtr XMLCALL + xmlPatterncompile (const xmlChar *pattern, + xmlDict *dict, + int flags, + const xmlChar **namespaces); +XMLPUBFUN int XMLCALL + xmlPatternMatch (xmlPatternPtr comp, + xmlNodePtr node); + +/* streaming interfaces */ +typedef struct _xmlStreamCtxt xmlStreamCtxt; +typedef xmlStreamCtxt *xmlStreamCtxtPtr; + +XMLPUBFUN int XMLCALL + xmlPatternStreamable (xmlPatternPtr comp); +XMLPUBFUN int XMLCALL + xmlPatternMaxDepth (xmlPatternPtr comp); +XMLPUBFUN int XMLCALL + xmlPatternMinDepth (xmlPatternPtr comp); +XMLPUBFUN int XMLCALL + xmlPatternFromRoot (xmlPatternPtr comp); +XMLPUBFUN xmlStreamCtxtPtr XMLCALL + xmlPatternGetStreamCtxt (xmlPatternPtr comp); +XMLPUBFUN void XMLCALL + xmlFreeStreamCtxt (xmlStreamCtxtPtr stream); +XMLPUBFUN int XMLCALL + xmlStreamPushNode (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns, + int nodeType); +XMLPUBFUN int XMLCALL + xmlStreamPush (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlStreamPushAttr (xmlStreamCtxtPtr stream, + const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlStreamPop (xmlStreamCtxtPtr stream); +XMLPUBFUN int XMLCALL + xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_PATTERN_ENABLED */ + +#endif /* __XML_PATTERN_H__ */ Added: include/libxml/relaxng.h =================================================================== --- include/libxml/relaxng.h (rev 0) +++ include/libxml/relaxng.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,213 @@ +/* + * Summary: implementation of the Relax-NG validation + * Description: implementation of the Relax-NG validation + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_RELAX_NG__ +#define __XML_RELAX_NG__ + +#include +#include +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xmlRelaxNG xmlRelaxNG; +typedef xmlRelaxNG *xmlRelaxNGPtr; + + +/** + * xmlRelaxNGValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from a Relax-NG validation + */ +typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3); + +/** + * xmlRelaxNGValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from a Relax-NG validation + */ +typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3); + +/** + * A schemas validation context + */ +typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; +typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; + +typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; +typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; + +/* + * xmlRelaxNGValidErr: + * + * List of possible Relax NG validation errors + */ +typedef enum { + XML_RELAXNG_OK = 0, + XML_RELAXNG_ERR_MEMORY, + XML_RELAXNG_ERR_TYPE, + XML_RELAXNG_ERR_TYPEVAL, + XML_RELAXNG_ERR_DUPID, + XML_RELAXNG_ERR_TYPECMP, + XML_RELAXNG_ERR_NOSTATE, + XML_RELAXNG_ERR_NODEFINE, + XML_RELAXNG_ERR_LISTEXTRA, + XML_RELAXNG_ERR_LISTEMPTY, + XML_RELAXNG_ERR_INTERNODATA, + XML_RELAXNG_ERR_INTERSEQ, + XML_RELAXNG_ERR_INTEREXTRA, + XML_RELAXNG_ERR_ELEMNAME, + XML_RELAXNG_ERR_ATTRNAME, + XML_RELAXNG_ERR_ELEMNONS, + XML_RELAXNG_ERR_ATTRNONS, + XML_RELAXNG_ERR_ELEMWRONGNS, + XML_RELAXNG_ERR_ATTRWRONGNS, + XML_RELAXNG_ERR_ELEMEXTRANS, + XML_RELAXNG_ERR_ATTREXTRANS, + XML_RELAXNG_ERR_ELEMNOTEMPTY, + XML_RELAXNG_ERR_NOELEM, + XML_RELAXNG_ERR_NOTELEM, + XML_RELAXNG_ERR_ATTRVALID, + XML_RELAXNG_ERR_CONTENTVALID, + XML_RELAXNG_ERR_EXTRACONTENT, + XML_RELAXNG_ERR_INVALIDATTR, + XML_RELAXNG_ERR_DATAELEM, + XML_RELAXNG_ERR_VALELEM, + XML_RELAXNG_ERR_LISTELEM, + XML_RELAXNG_ERR_DATATYPE, + XML_RELAXNG_ERR_VALUE, + XML_RELAXNG_ERR_LIST, + XML_RELAXNG_ERR_NOGRAMMAR, + XML_RELAXNG_ERR_EXTRADATA, + XML_RELAXNG_ERR_LACKDATA, + XML_RELAXNG_ERR_INTERNAL, + XML_RELAXNG_ERR_ELEMWRONG, + XML_RELAXNG_ERR_TEXTWRONG +} xmlRelaxNGValidErr; + +/* + * xmlRelaxNGParserFlags: + * + * List of possible Relax NG Parser flags + */ +typedef enum { + XML_RELAXNGP_NONE = 0, + XML_RELAXNGP_FREE_DOC = 1, + XML_RELAXNGP_CRNG = 2 +} xmlRelaxNGParserFlag; + +XMLPUBFUN int XMLCALL + xmlRelaxNGInitTypes (void); +XMLPUBFUN void XMLCALL + xmlRelaxNGCleanupTypes (void); + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewParserCtxt (const char *URL); +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL + xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); + +XMLPUBFUN int XMLCALL + xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, + int flag); + +XMLPUBFUN void XMLCALL + xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetParserStructuredErrors( + xmlRelaxNGParserCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN xmlRelaxNGPtr XMLCALL + xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlRelaxNGFree (xmlRelaxNGPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlRelaxNGDump (FILE *output, + xmlRelaxNGPtr schema); +XMLPUBFUN void XMLCALL + xmlRelaxNGDumpTree (FILE * output, + xmlRelaxNGPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc err, + xmlRelaxNGValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlRelaxNGValidityErrorFunc *err, + xmlRelaxNGValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN void XMLCALL + xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, void *ctx); +XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL + xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); +XMLPUBFUN void XMLCALL + xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc); +/* + * Interfaces for progressive validation when possible + */ +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ + +#endif /* __XML_RELAX_NG__ */ Added: include/libxml/schemasInternals.h =================================================================== --- include/libxml/schemasInternals.h (rev 0) +++ include/libxml/schemasInternals.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,958 @@ +/* + * Summary: internal interfaces for XML Schemas + * Description: internal interfaces for the XML Schemas handling + * and schema validity checking + * The Schemas development is a Work In Progress. + * Some of those interfaces are not garanteed to be API or ABI stable ! + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_INTERNALS_H__ +#define __XML_SCHEMA_INTERNALS_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMAS_UNKNOWN = 0, + XML_SCHEMAS_STRING, + XML_SCHEMAS_NORMSTRING, + XML_SCHEMAS_DECIMAL, + XML_SCHEMAS_TIME, + XML_SCHEMAS_GDAY, + XML_SCHEMAS_GMONTH, + XML_SCHEMAS_GMONTHDAY, + XML_SCHEMAS_GYEAR, + XML_SCHEMAS_GYEARMONTH, + XML_SCHEMAS_DATE, + XML_SCHEMAS_DATETIME, + XML_SCHEMAS_DURATION, + XML_SCHEMAS_FLOAT, + XML_SCHEMAS_DOUBLE, + XML_SCHEMAS_BOOLEAN, + XML_SCHEMAS_TOKEN, + XML_SCHEMAS_LANGUAGE, + XML_SCHEMAS_NMTOKEN, + XML_SCHEMAS_NMTOKENS, + XML_SCHEMAS_NAME, + XML_SCHEMAS_QNAME, + XML_SCHEMAS_NCNAME, + XML_SCHEMAS_ID, + XML_SCHEMAS_IDREF, + XML_SCHEMAS_IDREFS, + XML_SCHEMAS_ENTITY, + XML_SCHEMAS_ENTITIES, + XML_SCHEMAS_NOTATION, + XML_SCHEMAS_ANYURI, + XML_SCHEMAS_INTEGER, + XML_SCHEMAS_NPINTEGER, + XML_SCHEMAS_NINTEGER, + XML_SCHEMAS_NNINTEGER, + XML_SCHEMAS_PINTEGER, + XML_SCHEMAS_INT, + XML_SCHEMAS_UINT, + XML_SCHEMAS_LONG, + XML_SCHEMAS_ULONG, + XML_SCHEMAS_SHORT, + XML_SCHEMAS_USHORT, + XML_SCHEMAS_BYTE, + XML_SCHEMAS_UBYTE, + XML_SCHEMAS_HEXBINARY, + XML_SCHEMAS_BASE64BINARY, + XML_SCHEMAS_ANYTYPE, + XML_SCHEMAS_ANYSIMPLETYPE +} xmlSchemaValType; + +/* + * XML Schemas defines multiple type of types. + */ +typedef enum { + XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */ + XML_SCHEMA_TYPE_ANY, + XML_SCHEMA_TYPE_FACET, + XML_SCHEMA_TYPE_SIMPLE, + XML_SCHEMA_TYPE_COMPLEX, + XML_SCHEMA_TYPE_SEQUENCE = 6, + XML_SCHEMA_TYPE_CHOICE, + XML_SCHEMA_TYPE_ALL, + XML_SCHEMA_TYPE_SIMPLE_CONTENT, + XML_SCHEMA_TYPE_COMPLEX_CONTENT, + XML_SCHEMA_TYPE_UR, + XML_SCHEMA_TYPE_RESTRICTION, + XML_SCHEMA_TYPE_EXTENSION, + XML_SCHEMA_TYPE_ELEMENT, + XML_SCHEMA_TYPE_ATTRIBUTE, + XML_SCHEMA_TYPE_ATTRIBUTEGROUP, + XML_SCHEMA_TYPE_GROUP, + XML_SCHEMA_TYPE_NOTATION, + XML_SCHEMA_TYPE_LIST, + XML_SCHEMA_TYPE_UNION, + XML_SCHEMA_TYPE_ANY_ATTRIBUTE, + XML_SCHEMA_TYPE_IDC_UNIQUE, + XML_SCHEMA_TYPE_IDC_KEY, + XML_SCHEMA_TYPE_IDC_KEYREF, + XML_SCHEMA_TYPE_PARTICLE = 25, + XML_SCHEMA_TYPE_ATTRIBUTE_USE, + XML_SCHEMA_FACET_MININCLUSIVE = 1000, + XML_SCHEMA_FACET_MINEXCLUSIVE, + XML_SCHEMA_FACET_MAXINCLUSIVE, + XML_SCHEMA_FACET_MAXEXCLUSIVE, + XML_SCHEMA_FACET_TOTALDIGITS, + XML_SCHEMA_FACET_FRACTIONDIGITS, + XML_SCHEMA_FACET_PATTERN, + XML_SCHEMA_FACET_ENUMERATION, + XML_SCHEMA_FACET_WHITESPACE, + XML_SCHEMA_FACET_LENGTH, + XML_SCHEMA_FACET_MAXLENGTH, + XML_SCHEMA_FACET_MINLENGTH, + XML_SCHEMA_EXTRA_QNAMEREF = 2000, + XML_SCHEMA_EXTRA_ATTR_USE_PROHIB +} xmlSchemaTypeType; + +typedef enum { + XML_SCHEMA_CONTENT_UNKNOWN = 0, + XML_SCHEMA_CONTENT_EMPTY = 1, + XML_SCHEMA_CONTENT_ELEMENTS, + XML_SCHEMA_CONTENT_MIXED, + XML_SCHEMA_CONTENT_SIMPLE, + XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */ + XML_SCHEMA_CONTENT_BASIC, + XML_SCHEMA_CONTENT_ANY +} xmlSchemaContentType; + +typedef struct _xmlSchemaVal xmlSchemaVal; +typedef xmlSchemaVal *xmlSchemaValPtr; + +typedef struct _xmlSchemaType xmlSchemaType; +typedef xmlSchemaType *xmlSchemaTypePtr; + +typedef struct _xmlSchemaFacet xmlSchemaFacet; +typedef xmlSchemaFacet *xmlSchemaFacetPtr; + +/** + * Annotation + */ +typedef struct _xmlSchemaAnnot xmlSchemaAnnot; +typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; +struct _xmlSchemaAnnot { + struct _xmlSchemaAnnot *next; + xmlNodePtr content; /* the annotation */ +}; + +/** + * XML_SCHEMAS_ANYATTR_SKIP: + * + * Skip unknown attribute from validation + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_SKIP 1 +/** + * XML_SCHEMAS_ANYATTR_LAX: + * + * Ignore validation non definition on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_LAX 2 +/** + * XML_SCHEMAS_ANYATTR_STRICT: + * + * Apply strict validation rules on attributes + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ANYATTR_STRICT 3 +/** + * XML_SCHEMAS_ANY_SKIP: + * + * Skip unknown attribute from validation + */ +#define XML_SCHEMAS_ANY_SKIP 1 +/** + * XML_SCHEMAS_ANY_LAX: + * + * Used by wildcards. + * Validate if type found, don't worry if not found + */ +#define XML_SCHEMAS_ANY_LAX 2 +/** + * XML_SCHEMAS_ANY_STRICT: + * + * Used by wildcards. + * Apply strict validation rules + */ +#define XML_SCHEMAS_ANY_STRICT 3 +/** + * XML_SCHEMAS_ATTR_USE_PROHIBITED: + * + * Used by wildcards. + * The attribute is prohibited. + */ +#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0 +/** + * XML_SCHEMAS_ATTR_USE_REQUIRED: + * + * The attribute is required. + */ +#define XML_SCHEMAS_ATTR_USE_REQUIRED 1 +/** + * XML_SCHEMAS_ATTR_USE_OPTIONAL: + * + * The attribute is optional. + */ +#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2 +/** + * XML_SCHEMAS_ATTR_GLOBAL: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_GLOBAL 1 << 0 +/** + * XML_SCHEMAS_ATTR_NSDEFAULT: + * + * allow elements in no namespace + */ +#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED: + * + * this is set when the "type" and "ref" references + * have been resolved. + */ +#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8 +/** + * XML_SCHEMAS_ATTR_FIXED: + * + * the attribute has a fixed value + */ +#define XML_SCHEMAS_ATTR_FIXED 1 << 9 + +/** + * xmlSchemaAttribute: + * An attribute definition. + */ + +typedef struct _xmlSchemaAttribute xmlSchemaAttribute; +typedef xmlSchemaAttribute *xmlSchemaAttributePtr; +struct _xmlSchemaAttribute { + xmlSchemaTypeType type; + struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */ + const xmlChar *name; /* the name of the declaration */ + const xmlChar *id; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + const xmlChar *typeName; /* the local name of the type definition */ + const xmlChar *typeNs; /* the ns URI of the type definition */ + xmlSchemaAnnotPtr annot; + + xmlSchemaTypePtr base; /* Deprecated; not used */ + int occurs; /* Deprecated; not used */ + const xmlChar *defValue; /* The initial value of the value constraint */ + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlNodePtr node; + const xmlChar *targetNamespace; + int flags; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaValPtr defVal; /* The compiled value constraint */ + xmlSchemaAttributePtr refDecl; /* Deprecated; not used */ +}; + +/** + * xmlSchemaAttributeLink: + * Used to build a list of attribute uses on complexType definitions. + * WARNING: Deprecated; not used. + */ +typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink; +typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr; +struct _xmlSchemaAttributeLink { + struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */ + struct _xmlSchemaAttribute *attr;/* the linked attribute */ +}; + +/** + * XML_SCHEMAS_WILDCARD_COMPLETE: + * + * If the wildcard is complete. + */ +#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0 + +/** + * xmlSchemaCharValueLink: + * Used to build a list of namespaces on wildcards. + */ +typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs; +typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr; +struct _xmlSchemaWildcardNs { + struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */ + const xmlChar *value;/* the value */ +}; + +/** + * xmlSchemaWildcard. + * A wildcard. + */ +typedef struct _xmlSchemaWildcard xmlSchemaWildcard; +typedef xmlSchemaWildcard *xmlSchemaWildcardPtr; +struct _xmlSchemaWildcard { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *id; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + int processContents; + int any; /* Indicates if the ns constraint is of ##any */ + xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */ + xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */ + int flags; +}; + +/** + * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED: + * + * The attribute wildcard has been already builded. + */ +#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0 +/** + * XML_SCHEMAS_ATTRGROUP_GLOBAL: + * + * The attribute wildcard has been already builded. + */ +#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ATTRGROUP_MARKED: + * + * Marks the attr group as marked; used for circular checks. + */ +#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2 + +/** + * XML_SCHEMAS_ATTRGROUP_REDEFINED: + * + * The attr group was redefined. + */ +#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3 +/** + * XML_SCHEMAS_ATTRGROUP_HAS_REFS: + * + * Whether this attr. group contains attr. group references. + */ +#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4 + +/** + * An attribute group definition. + * + * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures + * must be kept similar + */ +typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; +typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; +struct _xmlSchemaAttributeGroup { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ + const xmlChar *name; + const xmlChar *id; + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + + xmlSchemaAttributePtr attributes; /* Deprecated; not used */ + xmlNodePtr node; + int flags; + xmlSchemaWildcardPtr attributeWildcard; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */ + const xmlChar *targetNamespace; + void *attrUses; +}; + +/** + * xmlSchemaTypeLink: + * Used to build a list of types (e.g. member types of + * simpleType with variety "union"). + */ +typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink; +typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr; +struct _xmlSchemaTypeLink { + struct _xmlSchemaTypeLink *next;/* the next type link ... */ + xmlSchemaTypePtr type;/* the linked type */ +}; + +/** + * xmlSchemaFacetLink: + * Used to build a list of facets. + */ +typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink; +typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr; +struct _xmlSchemaFacetLink { + struct _xmlSchemaFacetLink *next;/* the next facet link ... */ + xmlSchemaFacetPtr facet;/* the linked facet */ +}; + +/** + * XML_SCHEMAS_TYPE_MIXED: + * + * the element content type is mixed + */ +#define XML_SCHEMAS_TYPE_MIXED 1 << 0 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION: + * + * the simple or complex type has a derivation method of "extension". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1 +/** + * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION: + * + * the simple or complex type has a derivation method of "restriction". + */ +#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2 +/** + * XML_SCHEMAS_TYPE_GLOBAL: + * + * the type is global + */ +#define XML_SCHEMAS_TYPE_GLOBAL 1 << 3 +/** + * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD: + * + * the complexType owns an attribute wildcard, i.e. + * it can be freed by the complexType + */ +#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */ +/** + * XML_SCHEMAS_TYPE_VARIETY_ABSENT: + * + * the simpleType has a variety of "absent". + * TODO: Actually not necessary :-/, since if + * none of the variety flags occur then it's + * automatically absent. + */ +#define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5 +/** + * XML_SCHEMAS_TYPE_VARIETY_LIST: + * + * the simpleType has a variety of "list". + */ +#define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6 +/** + * XML_SCHEMAS_TYPE_VARIETY_UNION: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7 +/** + * XML_SCHEMAS_TYPE_VARIETY_ATOMIC: + * + * the simpleType has a variety of "union". + */ +#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8 +/** + * XML_SCHEMAS_TYPE_FINAL_EXTENSION: + * + * the complexType has a final of "extension". + */ +#define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9 +/** + * XML_SCHEMAS_TYPE_FINAL_RESTRICTION: + * + * the simpleType/complexType has a final of "restriction". + */ +#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10 +/** + * XML_SCHEMAS_TYPE_FINAL_LIST: + * + * the simpleType has a final of "list". + */ +#define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11 +/** + * XML_SCHEMAS_TYPE_FINAL_UNION: + * + * the simpleType has a final of "union". + */ +#define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12 +/** + * XML_SCHEMAS_TYPE_FINAL_DEFAULT: + * + * the simpleType has a final of "default". + */ +#define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13 +/** + * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE: + * + * Marks the item as a builtin primitive. + */ +#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14 +/** + * XML_SCHEMAS_TYPE_MARKED: + * + * Marks the item as marked; used for circular checks. + */ +#define XML_SCHEMAS_TYPE_MARKED 1 << 16 +/** + * XML_SCHEMAS_TYPE_BLOCK_DEFAULT: + * + * the complexType did not specify 'block' so use the default of the + * item. + */ +#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17 +/** + * XML_SCHEMAS_TYPE_BLOCK_EXTENSION: + * + * the complexType has a 'block' of "extension". + */ +#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18 +/** + * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION: + * + * the complexType has a 'block' of "restriction". + */ +#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19 +/** + * XML_SCHEMAS_TYPE_ABSTRACT: + * + * the simple/complexType is abstract. + */ +#define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20 +/** + * XML_SCHEMAS_TYPE_FACETSNEEDVALUE: + * + * indicates if the facets need a computed value + */ +#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21 +/** + * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED: + * + * indicates that the type was typefixed + */ +#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22 +/** + * XML_SCHEMAS_TYPE_INTERNAL_INVALID: + * + * indicates that the type is invalid + */ +#define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE: + * + * a whitespace-facet value of "preserve" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE: + * + * a whitespace-facet value of "replace" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25 +/** + * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE: + * + * a whitespace-facet value of "collapse" + */ +#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26 +/** + * XML_SCHEMAS_TYPE_HAS_FACETS: + * + * has facets + */ +#define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27 +/** + * XML_SCHEMAS_TYPE_NORMVALUENEEDED: + * + * indicates if the facets (pattern) need a normalized value + */ +#define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28 + +/** + * XML_SCHEMAS_TYPE_FIXUP_1: + * + * First stage of fixup was done. + */ +#define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29 + +/** + * XML_SCHEMAS_TYPE_REDEFINED: + * + * The type was redefined. + */ +#define XML_SCHEMAS_TYPE_REDEFINED 1 << 30 +/** + * XML_SCHEMAS_TYPE_REDEFINING: + * + * The type redefines an other type. + */ +/* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */ + +/** + * _xmlSchemaType: + * + * Schemas type definition. + */ +struct _xmlSchemaType { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next; /* the next type if in a sequence ... */ + const xmlChar *name; + const xmlChar *id ; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; + xmlSchemaAttributePtr attributes; /* Deprecated; not used */ + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + + int flags; + xmlSchemaContentType contentType; + const xmlChar *base; /* Base type's local name */ + const xmlChar *baseNs; /* Base type's target namespace */ + xmlSchemaTypePtr baseType; /* The base type component */ + xmlSchemaFacetPtr facets; /* Local facets */ + struct _xmlSchemaType *redef; /* Deprecated; not used */ + int recurse; /* Obsolete */ + xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */ + xmlSchemaWildcardPtr attributeWildcard; + int builtInType; /* Type of built-in types. */ + xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */ + xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */ + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types. + Could we use @subtypes for this? */ + xmlRegexpPtr contModel; /* Holds the automaton of the content model */ + const xmlChar *targetNamespace; + void *attrUses; +}; + +/* + * xmlSchemaElement: + * An element definition. + * + * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of + * structures must be kept similar + */ +/** + * XML_SCHEMAS_ELEM_NILLABLE: + * + * the element is nillable + */ +#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 +/** + * XML_SCHEMAS_ELEM_GLOBAL: + * + * the element is global + */ +#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 +/** + * XML_SCHEMAS_ELEM_DEFAULT: + * + * the element has a default value + */ +#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 +/** + * XML_SCHEMAS_ELEM_FIXED: + * + * the element has a fixed value + */ +#define XML_SCHEMAS_ELEM_FIXED 1 << 3 +/** + * XML_SCHEMAS_ELEM_ABSTRACT: + * + * the element is abstract + */ +#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 +/** + * XML_SCHEMAS_ELEM_TOPLEVEL: + * + * the element is top level + * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead + */ +#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 +/** + * XML_SCHEMAS_ELEM_REF: + * + * the element is a reference to a type + */ +#define XML_SCHEMAS_ELEM_REF 1 << 6 +/** + * XML_SCHEMAS_ELEM_NSDEFAULT: + * + * allow elements in no namespace + * Obsolete, not used anymore. + */ +#define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7 +/** + * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED: + * + * this is set when "type", "ref", "substitutionGroup" + * references have been resolved. + */ +#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8 + /** + * XML_SCHEMAS_ELEM_CIRCULAR: + * + * a helper flag for the search of circular references. + */ +#define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9 +/** + * XML_SCHEMAS_ELEM_BLOCK_ABSENT: + * + * the "block" attribute is absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10 +/** + * XML_SCHEMAS_ELEM_BLOCK_EXTENSION: + * + * disallowed substitutions are absent + */ +#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11 +/** + * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: + * + * disallowed substitutions: "restriction" + */ +#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12 +/** + * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION: + * + * disallowed substitutions: "substituion" + */ +#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13 +/** + * XML_SCHEMAS_ELEM_FINAL_ABSENT: + * + * substitution group exclusions are absent + */ +#define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14 +/** + * XML_SCHEMAS_ELEM_FINAL_EXTENSION: + * + * substitution group exclusions: "extension" + */ +#define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15 +/** + * XML_SCHEMAS_ELEM_FINAL_RESTRICTION: + * + * substitution group exclusions: "restriction" + */ +#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16 +/** + * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD: + * + * the declaration is a substitution group head + */ +#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17 +/** + * XML_SCHEMAS_ELEM_INTERNAL_CHECKED: + * + * this is set when the elem decl has been checked against + * all constraints + */ +#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18 + +typedef struct _xmlSchemaElement xmlSchemaElement; +typedef xmlSchemaElement *xmlSchemaElementPtr; +struct _xmlSchemaElement { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaType *next; /* Not used? */ + const xmlChar *name; + const xmlChar *id; /* Deprecated; not used */ + const xmlChar *ref; /* Deprecated; not used */ + const xmlChar *refNs; /* Deprecated; not used */ + xmlSchemaAnnotPtr annot; + xmlSchemaTypePtr subtypes; /* the type definition */ + xmlSchemaAttributePtr attributes; + xmlNodePtr node; + int minOccurs; /* Deprecated; not used */ + int maxOccurs; /* Deprecated; not used */ + + int flags; + const xmlChar *targetNamespace; + const xmlChar *namedType; + const xmlChar *namedTypeNs; + const xmlChar *substGroup; + const xmlChar *substGroupNs; + const xmlChar *scope; + const xmlChar *value; /* The original value of the value constraint. */ + struct _xmlSchemaElement *refDecl; /* This will now be used for the + substitution group affiliation */ + xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */ + xmlSchemaContentType contentType; + const xmlChar *refPrefix; /* Deprecated; not used */ + xmlSchemaValPtr defVal; /* The compiled value contraint. */ + void *idcs; /* The identity-constraint defs */ +}; + +/* + * XML_SCHEMAS_FACET_UNKNOWN: + * + * unknown facet handling + */ +#define XML_SCHEMAS_FACET_UNKNOWN 0 +/* + * XML_SCHEMAS_FACET_PRESERVE: + * + * preserve the type of the facet + */ +#define XML_SCHEMAS_FACET_PRESERVE 1 +/* + * XML_SCHEMAS_FACET_REPLACE: + * + * replace the type of the facet + */ +#define XML_SCHEMAS_FACET_REPLACE 2 +/* + * XML_SCHEMAS_FACET_COLLAPSE: + * + * collapse the types of the facet + */ +#define XML_SCHEMAS_FACET_COLLAPSE 3 +/** + * A facet definition. + */ +struct _xmlSchemaFacet { + xmlSchemaTypeType type; /* The kind of type */ + struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */ + const xmlChar *value; /* The original value */ + const xmlChar *id; /* Obsolete */ + xmlSchemaAnnotPtr annot; + xmlNodePtr node; + int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */ + int whitespace; + xmlSchemaValPtr val; /* The compiled value */ + xmlRegexpPtr regexp; /* The regex for patterns */ +}; + +/** + * A notation definition. + */ +typedef struct _xmlSchemaNotation xmlSchemaNotation; +typedef xmlSchemaNotation *xmlSchemaNotationPtr; +struct _xmlSchemaNotation { + xmlSchemaTypeType type; /* The kind of type */ + const xmlChar *name; + xmlSchemaAnnotPtr annot; + const xmlChar *identifier; + const xmlChar *targetNamespace; +}; + +/* +* TODO: Actually all those flags used for the schema should sit +* on the schema parser context, since they are used only +* during parsing an XML schema document, and not available +* on the component level as per spec. +*/ +/** + * XML_SCHEMAS_QUALIF_ELEM: + * + * Reflects elementFormDefault == qualified in + * an XML schema document. + */ +#define XML_SCHEMAS_QUALIF_ELEM 1 << 0 +/** + * XML_SCHEMAS_QUALIF_ATTR: + * + * Reflects attributeFormDefault == qualified in + * an XML schema document. + */ +#define XML_SCHEMAS_QUALIF_ATTR 1 << 1 +/** + * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2 +/** + * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3 +/** + * XML_SCHEMAS_FINAL_DEFAULT_LIST: + * + * the cshema has "list" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4 +/** + * XML_SCHEMAS_FINAL_DEFAULT_UNION: + * + * the schema has "union" in the set of finalDefault. + */ +#define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION: + * + * the schema has "extension" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION: + * + * the schema has "restriction" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7 +/** + * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION: + * + * the schema has "substitution" in the set of blockDefault. + */ +#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8 +/** + * XML_SCHEMAS_INCLUDING_CONVERT_NS: + * + * the schema is currently including an other schema with + * no target namespace. + */ +#define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9 +/** + * _xmlSchema: + * + * A Schemas definition + */ +struct _xmlSchema { + const xmlChar *name; /* schema name */ + const xmlChar *targetNamespace; /* the target namespace */ + const xmlChar *version; + const xmlChar *id; /* Obsolete */ + xmlDocPtr doc; + xmlSchemaAnnotPtr annot; + int flags; + + xmlHashTablePtr typeDecl; + xmlHashTablePtr attrDecl; + xmlHashTablePtr attrgrpDecl; + xmlHashTablePtr elemDecl; + xmlHashTablePtr notaDecl; + + xmlHashTablePtr schemasImports; + + void *_private; /* unused by the library for users or bindings */ + xmlHashTablePtr groupDecl; + xmlDictPtr dict; + void *includes; /* the includes, this is opaque for now */ + int preserve; /* whether to free the document */ + int counter; /* used to give ononymous components unique names */ + xmlHashTablePtr idcDef; /* All identity-constraint defs. */ + void *volatiles; /* Obsolete */ +}; + +XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type); +XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_INTERNALS_H__ */ Added: include/libxml/schematron.h =================================================================== --- include/libxml/schematron.h (rev 0) +++ include/libxml/schematron.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,142 @@ +/* + * Summary: XML Schemastron implementation + * Description: interface to the XML Schematron validity checking. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMATRON_H__ +#define __XML_SCHEMATRON_H__ + +#include + +#ifdef LIBXML_SCHEMATRON_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ + XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ + XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ + XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */ + XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */ + XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */ + XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */ +} xmlSchematronValidOptions; + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchematron xmlSchematron; +typedef xmlSchematron *xmlSchematronPtr; + +/** + * xmlSchematronValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from a Schematron validation + */ +typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); + +/** + * xmlSchematronValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from a Schematron validation + */ +typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); + +/** + * A schemas validation context + */ +typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; +typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; + +typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; +typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL + xmlSchematronNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL + xmlSchematronNewMemParserCtxt(const char *buffer, + int size); +XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL + xmlSchematronNewDocParserCtxt(xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); +/***** +XMLPUBFUN void XMLCALL + xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, + xmlSchematronValidityErrorFunc err, + xmlSchematronValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, + xmlSchematronValidityErrorFunc * err, + xmlSchematronValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); + *****/ +XMLPUBFUN xmlSchematronPtr XMLCALL + xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchematronFree (xmlSchematronPtr schema); +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlSchematronSetValidStructuredErrors( + xmlSchematronValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +/****** +XMLPUBFUN void XMLCALL + xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, + xmlSchematronValidityErrorFunc err, + xmlSchematronValidityWarningFunc warn, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, + xmlSchematronValidityErrorFunc *err, + xmlSchematronValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, + int options); +XMLPUBFUN int XMLCALL + xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, + xmlNodePtr elem); + *******/ + +XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL + xmlSchematronNewValidCtxt (xmlSchematronPtr schema, + int options); +XMLPUBFUN void XMLCALL + xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, + xmlDocPtr instance); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMATRON_ENABLED */ +#endif /* __XML_SCHEMATRON_H__ */ Added: include/libxml/threads.h =================================================================== --- include/libxml/threads.h (rev 0) +++ include/libxml/threads.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,84 @@ +/** + * Summary: interfaces for thread handling + * Description: set of generic threading related routines + * should work with pthreads, Windows native or TLS threads + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_THREADS_H__ +#define __XML_THREADS_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * xmlMutex are a simple mutual exception locks. + */ +typedef struct _xmlMutex xmlMutex; +typedef xmlMutex *xmlMutexPtr; + +/* + * xmlRMutex are reentrant mutual exception locks. + */ +typedef struct _xmlRMutex xmlRMutex; +typedef xmlRMutex *xmlRMutexPtr; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif +XMLPUBFUN xmlMutexPtr XMLCALL + xmlNewMutex (void); +XMLPUBFUN void XMLCALL + xmlMutexLock (xmlMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlMutexUnlock (xmlMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlFreeMutex (xmlMutexPtr tok); + +XMLPUBFUN xmlRMutexPtr XMLCALL + xmlNewRMutex (void); +XMLPUBFUN void XMLCALL + xmlRMutexLock (xmlRMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlRMutexUnlock (xmlRMutexPtr tok); +XMLPUBFUN void XMLCALL + xmlFreeRMutex (xmlRMutexPtr tok); + +/* + * Library wide APIs. + */ +XMLPUBFUN void XMLCALL + xmlInitThreads (void); +XMLPUBFUN void XMLCALL + xmlLockLibrary (void); +XMLPUBFUN void XMLCALL + xmlUnlockLibrary(void); +XMLPUBFUN int XMLCALL + xmlGetThreadId (void); +XMLPUBFUN int XMLCALL + xmlIsMainThread (void); +XMLPUBFUN void XMLCALL + xmlCleanupThreads(void); +XMLPUBFUN xmlGlobalStatePtr XMLCALL + xmlGetGlobalState(void); + +#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL) +int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved); +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* __XML_THREADS_H__ */ Added: include/libxml/tree.h =================================================================== --- include/libxml/tree.h (rev 0) +++ include/libxml/tree.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,1252 @@ +/* + * Summary: interfaces for tree manipulation + * Description: this module describes the structures found in an tree resulting + * from an XML or HTML parsing, as well as the API provided for + * various processing on that tree + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_TREE_H__ +#define __XML_TREE_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Some of the basic types pointer to structures: + */ +/* xmlIO.h */ +typedef struct _xmlParserInputBuffer xmlParserInputBuffer; +typedef xmlParserInputBuffer *xmlParserInputBufferPtr; + +typedef struct _xmlOutputBuffer xmlOutputBuffer; +typedef xmlOutputBuffer *xmlOutputBufferPtr; + +/* parser.h */ +typedef struct _xmlParserInput xmlParserInput; +typedef xmlParserInput *xmlParserInputPtr; + +typedef struct _xmlParserCtxt xmlParserCtxt; +typedef xmlParserCtxt *xmlParserCtxtPtr; + +typedef struct _xmlSAXLocator xmlSAXLocator; +typedef xmlSAXLocator *xmlSAXLocatorPtr; + +typedef struct _xmlSAXHandler xmlSAXHandler; +typedef xmlSAXHandler *xmlSAXHandlerPtr; + +/* entities.h */ +typedef struct _xmlEntity xmlEntity; +typedef xmlEntity *xmlEntityPtr; + +/** + * BASE_BUFFER_SIZE: + * + * default buffer size 4000. + */ +#define BASE_BUFFER_SIZE 4096 + +/** + * LIBXML_NAMESPACE_DICT: + * + * Defines experimental behaviour: + * 1) xmlNs gets an additional field @context (a xmlDoc) + * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc. + */ +/* #define LIBXML_NAMESPACE_DICT */ + +/** + * xmlBufferAllocationScheme: + * + * A buffer allocation scheme can be defined to either match exactly the + * need or double it's allocated size each time it is found too small. + */ + +typedef enum { + XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */ + XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */ + XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */ + XML_BUFFER_ALLOC_IO /* special allocation scheme used for I/O */ +} xmlBufferAllocationScheme; + +/** + * xmlBuffer: + * + * A buffer structure. + */ +typedef struct _xmlBuffer xmlBuffer; +typedef xmlBuffer *xmlBufferPtr; +struct _xmlBuffer { + xmlChar *content; /* The buffer content UTF8 */ + unsigned int use; /* The buffer size used */ + unsigned int size; /* The buffer size */ + xmlBufferAllocationScheme alloc; /* The realloc method */ + xmlChar *contentIO; /* in IO mode we may have a different base */ +}; + +/** + * XML_XML_NAMESPACE: + * + * This is the namespace for the special xml: prefix predefined in the + * XML Namespace specification. + */ +#define XML_XML_NAMESPACE \ + (const xmlChar *) "http://www.w3.org/XML/1998/namespace" + +/** + * XML_XML_ID: + * + * This is the name for the special xml:id attribute + */ +#define XML_XML_ID (const xmlChar *) "xml:id" + +/* + * The different element types carried by an XML tree. + * + * NOTE: This is synchronized with DOM Level1 values + * See http://www.w3.org/TR/REC-DOM-Level-1/ + * + * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should + * be deprecated to use an XML_DTD_NODE. + */ +typedef enum { + XML_ELEMENT_NODE= 1, + XML_ATTRIBUTE_NODE= 2, + XML_TEXT_NODE= 3, + XML_CDATA_SECTION_NODE= 4, + XML_ENTITY_REF_NODE= 5, + XML_ENTITY_NODE= 6, + XML_PI_NODE= 7, + XML_COMMENT_NODE= 8, + XML_DOCUMENT_NODE= 9, + XML_DOCUMENT_TYPE_NODE= 10, + XML_DOCUMENT_FRAG_NODE= 11, + XML_NOTATION_NODE= 12, + XML_HTML_DOCUMENT_NODE= 13, + XML_DTD_NODE= 14, + XML_ELEMENT_DECL= 15, + XML_ATTRIBUTE_DECL= 16, + XML_ENTITY_DECL= 17, + XML_NAMESPACE_DECL= 18, + XML_XINCLUDE_START= 19, + XML_XINCLUDE_END= 20 +#ifdef LIBXML_DOCB_ENABLED + ,XML_DOCB_DOCUMENT_NODE= 21 +#endif +} xmlElementType; + + +/** + * xmlNotation: + * + * A DTD Notation definition. + */ + +typedef struct _xmlNotation xmlNotation; +typedef xmlNotation *xmlNotationPtr; +struct _xmlNotation { + const xmlChar *name; /* Notation name */ + const xmlChar *PublicID; /* Public identifier, if any */ + const xmlChar *SystemID; /* System identifier, if any */ +}; + +/** + * xmlAttributeType: + * + * A DTD Attribute type definition. + */ + +typedef enum { + XML_ATTRIBUTE_CDATA = 1, + XML_ATTRIBUTE_ID, + XML_ATTRIBUTE_IDREF , + XML_ATTRIBUTE_IDREFS, + XML_ATTRIBUTE_ENTITY, + XML_ATTRIBUTE_ENTITIES, + XML_ATTRIBUTE_NMTOKEN, + XML_ATTRIBUTE_NMTOKENS, + XML_ATTRIBUTE_ENUMERATION, + XML_ATTRIBUTE_NOTATION +} xmlAttributeType; + +/** + * xmlAttributeDefault: + * + * A DTD Attribute default definition. + */ + +typedef enum { + XML_ATTRIBUTE_NONE = 1, + XML_ATTRIBUTE_REQUIRED, + XML_ATTRIBUTE_IMPLIED, + XML_ATTRIBUTE_FIXED +} xmlAttributeDefault; + +/** + * xmlEnumeration: + * + * List structure used when there is an enumeration in DTDs. + */ + +typedef struct _xmlEnumeration xmlEnumeration; +typedef xmlEnumeration *xmlEnumerationPtr; +struct _xmlEnumeration { + struct _xmlEnumeration *next; /* next one */ + const xmlChar *name; /* Enumeration name */ +}; + +/** + * xmlAttribute: + * + * An Attribute declaration in a DTD. + */ + +typedef struct _xmlAttribute xmlAttribute; +typedef xmlAttribute *xmlAttributePtr; +struct _xmlAttribute { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ + const xmlChar *name; /* Attribute name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + struct _xmlAttribute *nexth; /* next in hash table */ + xmlAttributeType atype; /* The attribute type */ + xmlAttributeDefault def; /* the default */ + const xmlChar *defaultValue; /* or the default value */ + xmlEnumerationPtr tree; /* or the enumeration tree if any */ + const xmlChar *prefix; /* the namespace prefix if any */ + const xmlChar *elem; /* Element holding the attribute */ +}; + +/** + * xmlElementContentType: + * + * Possible definitions of element content types. + */ +typedef enum { + XML_ELEMENT_CONTENT_PCDATA = 1, + XML_ELEMENT_CONTENT_ELEMENT, + XML_ELEMENT_CONTENT_SEQ, + XML_ELEMENT_CONTENT_OR +} xmlElementContentType; + +/** + * xmlElementContentOccur: + * + * Possible definitions of element content occurrences. + */ +typedef enum { + XML_ELEMENT_CONTENT_ONCE = 1, + XML_ELEMENT_CONTENT_OPT, + XML_ELEMENT_CONTENT_MULT, + XML_ELEMENT_CONTENT_PLUS +} xmlElementContentOccur; + +/** + * xmlElementContent: + * + * An XML Element content as stored after parsing an element definition + * in a DTD. + */ + +typedef struct _xmlElementContent xmlElementContent; +typedef xmlElementContent *xmlElementContentPtr; +struct _xmlElementContent { + xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ + xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ + const xmlChar *name; /* Element name */ + struct _xmlElementContent *c1; /* first child */ + struct _xmlElementContent *c2; /* second child */ + struct _xmlElementContent *parent; /* parent */ + const xmlChar *prefix; /* Namespace prefix */ +}; + +/** + * xmlElementTypeVal: + * + * The different possibilities for an element content type. + */ + +typedef enum { + XML_ELEMENT_TYPE_UNDEFINED = 0, + XML_ELEMENT_TYPE_EMPTY = 1, + XML_ELEMENT_TYPE_ANY, + XML_ELEMENT_TYPE_MIXED, + XML_ELEMENT_TYPE_ELEMENT +} xmlElementTypeVal; + +#ifdef __cplusplus +} +#endif +#include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlElement: + * + * An XML Element declaration from a DTD. + */ + +typedef struct _xmlElement xmlElement; +typedef xmlElement *xmlElementPtr; +struct _xmlElement { + void *_private; /* application data */ + xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ + const xmlChar *name; /* Element name */ + struct _xmlNode *children; /* NULL */ + struct _xmlNode *last; /* NULL */ + struct _xmlDtd *parent; /* -> DTD */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + xmlElementTypeVal etype; /* The type */ + xmlElementContentPtr content; /* the allowed element content */ + xmlAttributePtr attributes; /* List of the declared attributes */ + const xmlChar *prefix; /* the namespace prefix if any */ +#ifdef LIBXML_REGEXP_ENABLED + xmlRegexpPtr contModel; /* the validating regexp */ +#else + void *contModel; +#endif +}; + + +/** + * XML_LOCAL_NAMESPACE: + * + * A namespace declaration node. + */ +#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL +typedef xmlElementType xmlNsType; + +/** + * xmlNs: + * + * An XML namespace. + * Note that prefix == NULL is valid, it defines the default namespace + * within the subtree (until overridden). + * + * xmlNsType is unified with xmlElementType. + */ + +typedef struct _xmlNs xmlNs; +typedef xmlNs *xmlNsPtr; +struct _xmlNs { + struct _xmlNs *next; /* next Ns link for this node */ + xmlNsType type; /* global or local */ + const xmlChar *href; /* URL for the namespace */ + const xmlChar *prefix; /* prefix for the namespace */ + void *_private; /* application data */ + struct _xmlDoc *context; /* normally an xmlDoc */ +}; + +/** + * xmlDtd: + * + * An XML DTD, as defined by parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + void *notations; /* Hash table for notations if any */ + void *elements; /* Hash table for elements if any */ + void *attributes; /* Hash table for attributes if any */ + void *entities; /* Hash table for entities if any */ + const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ + const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ + void *pentities; /* Hash table for param entities if any */ +}; + +/** + * xmlAttr: + * + * An attribute on an XML node. + */ +typedef struct _xmlAttr xmlAttr; +typedef xmlAttr *xmlAttrPtr; +struct _xmlAttr { + void *_private; /* application data */ + xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ + const xmlChar *name; /* the name of the property */ + struct _xmlNode *children; /* the value of the property */ + struct _xmlNode *last; /* NULL */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlAttr *next; /* next sibling link */ + struct _xmlAttr *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlAttributeType atype; /* the attribute type if validating */ + void *psvi; /* for type/PSVI informations */ +}; + +/** + * xmlID: + * + * An XML ID instance. + */ + +typedef struct _xmlID xmlID; +typedef xmlID *xmlIDPtr; +struct _xmlID { + struct _xmlID *next; /* next ID */ + const xmlChar *value; /* The ID name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ + struct _xmlDoc *doc; /* The document holding the ID */ +}; + +/** + * xmlRef: + * + * An XML IDREF instance. + */ + +typedef struct _xmlRef xmlRef; +typedef xmlRef *xmlRefPtr; +struct _xmlRef { + struct _xmlRef *next; /* next Ref */ + const xmlChar *value; /* The Ref name */ + xmlAttrPtr attr; /* The attribute holding it */ + const xmlChar *name; /* The attribute if attr is not available */ + int lineno; /* The line number if attr is not available */ +}; + +/** + * xmlNode: + * + * A node in an XML tree. + */ +typedef struct _xmlNode xmlNode; +typedef xmlNode *xmlNodePtr; +struct _xmlNode { + void *_private; /* application data */ + xmlElementType type; /* type number, must be second ! */ + const xmlChar *name; /* the name of the node, or the entity */ + struct _xmlNode *children; /* parent->childs link */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* the containing document */ + + /* End of common part */ + xmlNs *ns; /* pointer to the associated namespace */ + xmlChar *content; /* the content */ + struct _xmlAttr *properties;/* properties list */ + xmlNs *nsDef; /* namespace definitions on this node */ + void *psvi; /* for type/PSVI informations */ + unsigned short line; /* line number */ + unsigned short extra; /* extra data for XPath/XSLT */ +}; + +/** + * XML_GET_CONTENT: + * + * Macro to extract the content pointer of a node. + */ +#define XML_GET_CONTENT(n) \ + ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content) + +/** + * XML_GET_LINE: + * + * Macro to extract the line number of an element node. + */ +#define XML_GET_LINE(n) \ + (xmlGetLineNo(n)) + +/** + * xmlDocProperty + * + * Set of properties of the document as found by the parser + * Some of them are linked to similary named xmlParserOption + */ +typedef enum { + XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */ + XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */ + XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */ + XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */ + XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */ + XML_DOC_USERBUILT = 1<<5, /* Document was built using the API + and not by parsing an instance */ + XML_DOC_INTERNAL = 1<<6, /* built for internal processing */ + XML_DOC_HTML = 1<<7 /* parsed or built HTML document */ +} xmlDocProperties; + +/** + * xmlDoc: + * + * An XML document. + */ +typedef struct _xmlDoc xmlDoc; +typedef xmlDoc *xmlDocPtr; +struct _xmlDoc { + void *_private; /* application data */ + xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ + char *name; /* name/filename/URI of the document */ + struct _xmlNode *children; /* the document tree */ + struct _xmlNode *last; /* last child link */ + struct _xmlNode *parent; /* child->parent link */ + struct _xmlNode *next; /* next sibling link */ + struct _xmlNode *prev; /* previous sibling link */ + struct _xmlDoc *doc; /* autoreference to itself */ + + /* End of common part */ + int compression;/* level of zlib compression */ + int standalone; /* standalone document (no external refs) + 1 if standalone="yes" + 0 if standalone="no" + -1 if there is no XML declaration + -2 if there is an XML declaration, but no + standalone attribute was specified */ + struct _xmlDtd *intSubset; /* the document internal subset */ + struct _xmlDtd *extSubset; /* the document external subset */ + struct _xmlNs *oldNs; /* Global namespace, the old way */ + const xmlChar *version; /* the XML version string */ + const xmlChar *encoding; /* external initial encoding, if any */ + void *ids; /* Hash table for ID attributes if any */ + void *refs; /* Hash table for IDREFs attributes if any */ + const xmlChar *URL; /* The URI for that document */ + int charset; /* encoding of the in-memory content + actually an xmlCharEncoding */ + struct _xmlDict *dict; /* dict used to allocate names or NULL */ + void *psvi; /* for type/PSVI informations */ + int parseFlags; /* set of xmlParserOption used to parse the + document */ + int properties; /* set of xmlDocProperties for this document + set at the end of parsing */ +}; + + +typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt; +typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr; + +/** + * xmlDOMWrapAcquireNsFunction: + * @ctxt: a DOM wrapper context + * @node: the context node (element or attribute) + * @nsName: the requested namespace name + * @nsPrefix: the requested namespace prefix + * + * A function called to acquire namespaces (xmlNs) from the wrapper. + * + * Returns an xmlNsPtr or NULL in case of an error. + */ +typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr node, + const xmlChar *nsName, + const xmlChar *nsPrefix); + +/** + * xmlDOMWrapCtxt: + * + * Context for DOM wrapper-operations. + */ +struct _xmlDOMWrapCtxt { + void * _private; + /* + * The type of this context, just in case we need specialized + * contexts in the future. + */ + int type; + /* + * Internal namespace map used for various operations. + */ + void * namespaceMap; + /* + * Use this one to acquire an xmlNsPtr intended for node->ns. + * (Note that this is not intended for elem->nsDef). + */ + xmlDOMWrapAcquireNsFunction getNsForNodeFunc; +}; + +/** + * xmlChildrenNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children." + */ +#ifndef xmlChildrenNode +#define xmlChildrenNode children +#endif + +/** + * xmlRootNode: + * + * Macro for compatibility naming layer with libxml1. Maps + * to "children". + */ +#ifndef xmlRootNode +#define xmlRootNode children +#endif + +/* + * Variables. + */ + +/* + * Some helper functions + */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) +XMLPUBFUN int XMLCALL + xmlValidateNCName (const xmlChar *value, + int space); +#endif + +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN int XMLCALL + xmlValidateQName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateName (const xmlChar *value, + int space); +XMLPUBFUN int XMLCALL + xmlValidateNMToken (const xmlChar *value, + int space); +#endif + +XMLPUBFUN xmlChar * XMLCALL + xmlBuildQName (const xmlChar *ncname, + const xmlChar *prefix, + xmlChar *memory, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlSplitQName2 (const xmlChar *name, + xmlChar **prefix); +XMLPUBFUN const xmlChar * XMLCALL + xmlSplitQName3 (const xmlChar *name, + int *len); + +/* + * Handling Buffers. + */ + +XMLPUBFUN void XMLCALL + xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); +XMLPUBFUN xmlBufferAllocationScheme XMLCALL + xmlGetBufferAllocationScheme(void); + +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreate (void); +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreateSize (size_t size); +XMLPUBFUN xmlBufferPtr XMLCALL + xmlBufferCreateStatic (void *mem, + size_t size); +XMLPUBFUN int XMLCALL + xmlBufferResize (xmlBufferPtr buf, + unsigned int size); +XMLPUBFUN void XMLCALL + xmlBufferFree (xmlBufferPtr buf); +XMLPUBFUN int XMLCALL + xmlBufferDump (FILE *file, + xmlBufferPtr buf); +XMLPUBFUN int XMLCALL + xmlBufferAdd (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int XMLCALL + xmlBufferAddHead (xmlBufferPtr buf, + const xmlChar *str, + int len); +XMLPUBFUN int XMLCALL + xmlBufferCat (xmlBufferPtr buf, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlBufferCCat (xmlBufferPtr buf, + const char *str); +XMLPUBFUN int XMLCALL + xmlBufferShrink (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN int XMLCALL + xmlBufferGrow (xmlBufferPtr buf, + unsigned int len); +XMLPUBFUN void XMLCALL + xmlBufferEmpty (xmlBufferPtr buf); +XMLPUBFUN const xmlChar* XMLCALL + xmlBufferContent (const xmlBufferPtr buf); +XMLPUBFUN void XMLCALL + xmlBufferSetAllocationScheme(xmlBufferPtr buf, + xmlBufferAllocationScheme scheme); +XMLPUBFUN int XMLCALL + xmlBufferLength (const xmlBufferPtr buf); + +/* + * Creating/freeing new structures. + */ +XMLPUBFUN xmlDtdPtr XMLCALL + xmlCreateIntSubset (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlNewDtd (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *ExternalID, + const xmlChar *SystemID); +XMLPUBFUN xmlDtdPtr XMLCALL + xmlGetIntSubset (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlFreeDtd (xmlDtdPtr cur); +#ifdef LIBXML_LEGACY_ENABLED +XMLPUBFUN xmlNsPtr XMLCALL + xmlNewGlobalNs (xmlDocPtr doc, + const xmlChar *href, + const xmlChar *prefix); +#endif /* LIBXML_LEGACY_ENABLED */ +XMLPUBFUN xmlNsPtr XMLCALL + xmlNewNs (xmlNodePtr node, + const xmlChar *href, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + xmlFreeNs (xmlNsPtr cur); +XMLPUBFUN void XMLCALL + xmlFreeNsList (xmlNsPtr cur); +XMLPUBFUN xmlDocPtr XMLCALL + xmlNewDoc (const xmlChar *version); +XMLPUBFUN void XMLCALL + xmlFreeDoc (xmlDocPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewDocProp (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *value); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +#endif +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlNewNsPropEatName (xmlNodePtr node, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlFreePropList (xmlAttrPtr cur); +XMLPUBFUN void XMLCALL + xmlFreeProp (xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlCopyProp (xmlNodePtr target, + xmlAttrPtr cur); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlCopyPropList (xmlNodePtr target, + xmlAttrPtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlDtdPtr XMLCALL + xmlCopyDtd (xmlDtdPtr dtd); +#endif /* LIBXML_TREE_ENABLED */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlDocPtr XMLCALL + xmlCopyDoc (xmlDocPtr doc, + int recursive); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ +/* + * Creating new nodes. + */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocNodeEatName (xmlDocPtr doc, + xmlNsPtr ns, + xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewNode (xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewNodeEatName (xmlNsPtr ns, + xmlChar *name); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +#endif +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocText (xmlDocPtr doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewText (const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocPI (xmlDocPtr doc, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewPI (const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocTextLen (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewTextLen (const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocComment (xmlDocPtr doc, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewComment (const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewCDataBlock (xmlDocPtr doc, + const xmlChar *content, + int len); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewCharRef (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewReference (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlNodePtr XMLCALL + xmlCopyNode (const xmlNodePtr node, + int recursive); +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocCopyNode (const xmlNodePtr node, + xmlDocPtr doc, + int recursive); +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocCopyNodeList (xmlDocPtr doc, + const xmlNodePtr node); +XMLPUBFUN xmlNodePtr XMLCALL + xmlCopyNodeList (const xmlNodePtr node); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewTextChild (xmlNodePtr parent, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocRawNode (xmlDocPtr doc, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *content); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNewDocFragment (xmlDocPtr doc); +#endif /* LIBXML_TREE_ENABLED */ + +/* + * Navigating. + */ +XMLPUBFUN long XMLCALL + xmlGetLineNo (xmlNodePtr node); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) +XMLPUBFUN xmlChar * XMLCALL + xmlGetNodePath (xmlNodePtr node); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocGetRootElement (xmlDocPtr doc); +XMLPUBFUN xmlNodePtr XMLCALL + xmlGetLastChild (xmlNodePtr parent); +XMLPUBFUN int XMLCALL + xmlNodeIsText (xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlIsBlankNode (xmlNodePtr node); + +/* + * Changing the structure. + */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddChild (xmlNodePtr parent, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddChildList (xmlNodePtr parent, + xmlNodePtr cur); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ + defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */ +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN xmlNodePtr XMLCALL + xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); +XMLPUBFUN void XMLCALL + xmlUnlinkNode (xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextMerge (xmlNodePtr first, + xmlNodePtr second); +XMLPUBFUN int XMLCALL + xmlTextConcat (xmlNodePtr node, + const xmlChar *content, + int len); +XMLPUBFUN void XMLCALL + xmlFreeNodeList (xmlNodePtr cur); +XMLPUBFUN void XMLCALL + xmlFreeNode (xmlNodePtr cur); +XMLPUBFUN void XMLCALL + xmlSetTreeDoc (xmlNodePtr tree, + xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSetListDoc (xmlNodePtr list, + xmlDocPtr doc); +/* + * Namespaces. + */ +XMLPUBFUN xmlNsPtr XMLCALL + xmlSearchNs (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *nameSpace); +XMLPUBFUN xmlNsPtr XMLCALL + xmlSearchNsByHref (xmlDocPtr doc, + xmlNodePtr node, + const xmlChar *href); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN xmlNsPtr * XMLCALL + xmlGetNsList (xmlDocPtr doc, + xmlNodePtr node); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */ + +XMLPUBFUN void XMLCALL + xmlSetNs (xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN xmlNsPtr XMLCALL + xmlCopyNamespace (xmlNsPtr cur); +XMLPUBFUN xmlNsPtr XMLCALL + xmlCopyNamespaceList (xmlNsPtr cur); + +/* + * Changing the content. + */ +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) +XMLPUBFUN xmlAttrPtr XMLCALL + xmlSetProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */ +XMLPUBFUN xmlChar * XMLCALL + xmlGetNoNsProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN xmlChar * XMLCALL + xmlGetProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlHasProp (xmlNodePtr node, + const xmlChar *name); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlHasNsProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlChar * XMLCALL + xmlGetNsProp (xmlNodePtr node, + const xmlChar *name, + const xmlChar *nameSpace); +XMLPUBFUN xmlNodePtr XMLCALL + xmlStringGetNodeList (xmlDocPtr doc, + const xmlChar *value); +XMLPUBFUN xmlNodePtr XMLCALL + xmlStringLenGetNodeList (xmlDocPtr doc, + const xmlChar *value, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeListGetString (xmlDocPtr doc, + xmlNodePtr list, + int inLine); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlChar * XMLCALL + xmlNodeListGetRawString (xmlDocPtr doc, + xmlNodePtr list, + int inLine); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNodeSetContent (xmlNodePtr cur, + const xmlChar *content); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlNodeAddContent (xmlNodePtr cur, + const xmlChar *content); +XMLPUBFUN void XMLCALL + xmlNodeAddContentLen (xmlNodePtr cur, + const xmlChar *content, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetContent (xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlNodeBufGetContent (xmlBufferPtr buffer, + xmlNodePtr cur); +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetLang (xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlNodeGetSpacePreserve (xmlNodePtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN void XMLCALL + xmlNodeSetLang (xmlNodePtr cur, + const xmlChar *lang); +XMLPUBFUN void XMLCALL + xmlNodeSetSpacePreserve (xmlNodePtr cur, + int val); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN xmlChar * XMLCALL + xmlNodeGetBase (xmlDocPtr doc, + xmlNodePtr cur); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) +XMLPUBFUN void XMLCALL + xmlNodeSetBase (xmlNodePtr cur, + const xmlChar *uri); +#endif + +/* + * Removing content. + */ +XMLPUBFUN int XMLCALL + xmlRemoveProp (xmlAttrPtr cur); +#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN int XMLCALL + xmlUnsetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlUnsetProp (xmlNodePtr node, + const xmlChar *name); +#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ + +/* + * Internal, don't use. + */ +XMLPUBFUN void XMLCALL + xmlBufferWriteCHAR (xmlBufferPtr buf, + const xmlChar *string); +XMLPUBFUN void XMLCALL + xmlBufferWriteChar (xmlBufferPtr buf, + const char *string); +XMLPUBFUN void XMLCALL + xmlBufferWriteQuotedString(xmlBufferPtr buf, + const xmlChar *string); + +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf, + xmlDocPtr doc, + xmlAttrPtr attr, + const xmlChar *string); +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef LIBXML_TREE_ENABLED +/* + * Namespace handling. + */ +XMLPUBFUN int XMLCALL + xmlReconciliateNs (xmlDocPtr doc, + xmlNodePtr tree); +#endif + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Saving. + */ +XMLPUBFUN void XMLCALL + xmlDocDumpFormatMemory (xmlDocPtr cur, + xmlChar **mem, + int *size, + int format); +XMLPUBFUN void XMLCALL + xmlDocDumpMemory (xmlDocPtr cur, + xmlChar **mem, + int *size); +XMLPUBFUN void XMLCALL + xmlDocDumpMemoryEnc (xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding); +XMLPUBFUN void XMLCALL + xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, + xmlChar **doc_txt_ptr, + int * doc_txt_len, + const char *txt_encoding, + int format); +XMLPUBFUN int XMLCALL + xmlDocFormatDump (FILE *f, + xmlDocPtr cur, + int format); +XMLPUBFUN int XMLCALL + xmlDocDump (FILE *f, + xmlDocPtr cur); +XMLPUBFUN void XMLCALL + xmlElemDump (FILE *f, + xmlDocPtr doc, + xmlNodePtr cur); +XMLPUBFUN int XMLCALL + xmlSaveFile (const char *filename, + xmlDocPtr cur); +XMLPUBFUN int XMLCALL + xmlSaveFormatFile (const char *filename, + xmlDocPtr cur, + int format); +XMLPUBFUN int XMLCALL + xmlNodeDump (xmlBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format); + +XMLPUBFUN int XMLCALL + xmlSaveFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding); +XMLPUBFUN int XMLCALL + xmlSaveFormatFileTo (xmlOutputBufferPtr buf, + xmlDocPtr cur, + const char *encoding, + int format); +XMLPUBFUN void XMLCALL + xmlNodeDumpOutput (xmlOutputBufferPtr buf, + xmlDocPtr doc, + xmlNodePtr cur, + int level, + int format, + const char *encoding); + +XMLPUBFUN int XMLCALL + xmlSaveFormatFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding, + int format); + +XMLPUBFUN int XMLCALL + xmlSaveFileEnc (const char *filename, + xmlDocPtr cur, + const char *encoding); + +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * XHTML + */ +XMLPUBFUN int XMLCALL + xmlIsXHTML (const xmlChar *systemID, + const xmlChar *publicID); + +/* + * Compression. + */ +XMLPUBFUN int XMLCALL + xmlGetDocCompressMode (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSetDocCompressMode (xmlDocPtr doc, + int mode); +XMLPUBFUN int XMLCALL + xmlGetCompressMode (void); +XMLPUBFUN void XMLCALL + xmlSetCompressMode (int mode); + +/* +* DOM-wrapper helper functions. +*/ +XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL + xmlDOMWrapNewCtxt (void); +XMLPUBFUN void XMLCALL + xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt, + xmlNodePtr elem, + int options); +XMLPUBFUN int XMLCALL + xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int options); +XMLPUBFUN int XMLCALL + xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr node, + int options); +XMLPUBFUN int XMLCALL + xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt, + xmlDocPtr sourceDoc, + xmlNodePtr node, + xmlNodePtr *clonedNode, + xmlDocPtr destDoc, + xmlNodePtr destParent, + int deep, + int options); + +#ifdef LIBXML_TREE_ENABLED +/* + * 5 interfaces from DOM ElementTraversal, but different in entities + * traversal. + */ +XMLPUBFUN unsigned long XMLCALL + xmlChildElementCount (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr XMLCALL + xmlNextElementSibling (xmlNodePtr node); +XMLPUBFUN xmlNodePtr XMLCALL + xmlFirstElementChild (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr XMLCALL + xmlLastElementChild (xmlNodePtr parent); +XMLPUBFUN xmlNodePtr XMLCALL + xmlPreviousElementSibling (xmlNodePtr node); +#endif +#ifdef __cplusplus +} +#endif +#ifndef __XML_PARSER_H__ +#include +#endif + +#endif /* __XML_TREE_H__ */ + Added: include/libxml/uri.h =================================================================== --- include/libxml/uri.h (rev 0) +++ include/libxml/uri.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,94 @@ +/** + * Summary: library of generic URI related routines + * Description: library of generic URI related routines + * Implements RFC 2396 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_URI_H__ +#define __XML_URI_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlURI: + * + * A parsed URI reference. This is a struct containing the various fields + * as described in RFC 2396 but separated for further processing. + * + * Note: query is a deprecated field which is incorrectly unescaped. + * query_raw takes precedence over query if the former is set. + * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127 + */ +typedef struct _xmlURI xmlURI; +typedef xmlURI *xmlURIPtr; +struct _xmlURI { + char *scheme; /* the URI scheme */ + char *opaque; /* opaque part */ + char *authority; /* the authority part */ + char *server; /* the server part */ + char *user; /* the user part */ + int port; /* the port number */ + char *path; /* the path string */ + char *query; /* the query string (deprecated - use with caution) */ + char *fragment; /* the fragment identifier */ + int cleanup; /* parsing potentially unclean URI */ + char *query_raw; /* the query string (as it appears in the URI) */ +}; + +/* + * This function is in tree.h: + * xmlChar * xmlNodeGetBase (xmlDocPtr doc, + * xmlNodePtr cur); + */ +XMLPUBFUN xmlURIPtr XMLCALL + xmlCreateURI (void); +XMLPUBFUN xmlChar * XMLCALL + xmlBuildURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlChar * XMLCALL + xmlBuildRelativeURI (const xmlChar *URI, + const xmlChar *base); +XMLPUBFUN xmlURIPtr XMLCALL + xmlParseURI (const char *str); +XMLPUBFUN xmlURIPtr XMLCALL + xmlParseURIRaw (const char *str, + int raw); +XMLPUBFUN int XMLCALL + xmlParseURIReference (xmlURIPtr uri, + const char *str); +XMLPUBFUN xmlChar * XMLCALL + xmlSaveUri (xmlURIPtr uri); +XMLPUBFUN void XMLCALL + xmlPrintURI (FILE *stream, + xmlURIPtr uri); +XMLPUBFUN xmlChar * XMLCALL + xmlURIEscapeStr (const xmlChar *str, + const xmlChar *list); +XMLPUBFUN char * XMLCALL + xmlURIUnescapeString (const char *str, + int len, + char *target); +XMLPUBFUN int XMLCALL + xmlNormalizeURIPath (char *path); +XMLPUBFUN xmlChar * XMLCALL + xmlURIEscape (const xmlChar *str); +XMLPUBFUN void XMLCALL + xmlFreeURI (xmlURIPtr uri); +XMLPUBFUN xmlChar* XMLCALL + xmlCanonicPath (const xmlChar *path); +XMLPUBFUN xmlChar* XMLCALL + xmlPathToURI (const xmlChar *path); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_URI_H__ */ Added: include/libxml/valid.h =================================================================== --- include/libxml/valid.h (rev 0) +++ include/libxml/valid.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,458 @@ +/* + * Summary: The DTD validation + * Description: API for the DTD handling and the validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_VALID_H__ +#define __XML_VALID_H__ + +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Validation state added for non-determinist content model. + */ +typedef struct _xmlValidState xmlValidState; +typedef xmlValidState *xmlValidStatePtr; + +/** + * xmlValidityErrorFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity error is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); + +/** + * xmlValidityWarningFunc: + * @ctx: usually an xmlValidCtxtPtr to a validity error context, + * but comes from ctxt->userData (which normally contains such + * a pointer); ctxt->userData can be changed by the user. + * @msg: the string to format *printf like vararg + * @...: remaining arguments to the format + * + * Callback called when a validity warning is found. This is a message + * oriented function similar to an *printf function. + */ +typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); + +#ifdef IN_LIBXML +/** + * XML_CTXT_FINISH_DTD_0: + * + * Special value for finishDtd field when embedded in an xmlParserCtxt + */ +#define XML_CTXT_FINISH_DTD_0 0xabcd1234 +/** + * XML_CTXT_FINISH_DTD_1: + * + * Special value for finishDtd field when embedded in an xmlParserCtxt + */ +#define XML_CTXT_FINISH_DTD_1 0xabcd1235 +#endif + +/* + * xmlValidCtxt: + * An xmlValidCtxt is used for error reporting when validating. + */ +typedef struct _xmlValidCtxt xmlValidCtxt; +typedef xmlValidCtxt *xmlValidCtxtPtr; +struct _xmlValidCtxt { + void *userData; /* user specific data block */ + xmlValidityErrorFunc error; /* the callback in case of errors */ + xmlValidityWarningFunc warning; /* the callback in case of warning */ + + /* Node analysis stack used when validating within entities */ + xmlNodePtr node; /* Current parsed Node */ + int nodeNr; /* Depth of the parsing stack */ + int nodeMax; /* Max depth of the parsing stack */ + xmlNodePtr *nodeTab; /* array of nodes */ + + unsigned int finishDtd; /* finished validating the Dtd ? */ + xmlDocPtr doc; /* the document */ + int valid; /* temporary validity check result */ + + /* state state used for non-determinist content validation */ + xmlValidState *vstate; /* current state */ + int vstateNr; /* Depth of the validation stack */ + int vstateMax; /* Max depth of the validation stack */ + xmlValidState *vstateTab; /* array of validation states */ + +#ifdef LIBXML_REGEXP_ENABLED + xmlAutomataPtr am; /* the automata */ + xmlAutomataStatePtr state; /* used to build the automata */ +#else + void *am; + void *state; +#endif +}; + +/* + * ALL notation declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlNotationTable; +typedef xmlNotationTable *xmlNotationTablePtr; + +/* + * ALL element declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlElementTable; +typedef xmlElementTable *xmlElementTablePtr; + +/* + * ALL attribute declarations are stored in a table. + * There is one table per DTD. + */ + +typedef struct _xmlHashTable xmlAttributeTable; +typedef xmlAttributeTable *xmlAttributeTablePtr; + +/* + * ALL IDs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlIDTable; +typedef xmlIDTable *xmlIDTablePtr; + +/* + * ALL Refs attributes are stored in a table. + * There is one table per document. + */ + +typedef struct _xmlHashTable xmlRefTable; +typedef xmlRefTable *xmlRefTablePtr; + +/* Notation */ +XMLPUBFUN xmlNotationPtr XMLCALL + xmlAddNotationDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *PublicID, + const xmlChar *SystemID); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlNotationTablePtr XMLCALL + xmlCopyNotationTable (xmlNotationTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeNotationTable (xmlNotationTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpNotationDecl (xmlBufferPtr buf, + xmlNotationPtr nota); +XMLPUBFUN void XMLCALL + xmlDumpNotationTable (xmlBufferPtr buf, + xmlNotationTablePtr table); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Element Content */ +/* the non Doc version are being deprecated */ +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlNewElementContent (const xmlChar *name, + xmlElementContentType type); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlCopyElementContent (xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlFreeElementContent (xmlElementContentPtr cur); +/* the new versions with doc argument */ +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlNewDocElementContent (xmlDocPtr doc, + const xmlChar *name, + xmlElementContentType type); +XMLPUBFUN xmlElementContentPtr XMLCALL + xmlCopyDocElementContent(xmlDocPtr doc, + xmlElementContentPtr content); +XMLPUBFUN void XMLCALL + xmlFreeDocElementContent(xmlDocPtr doc, + xmlElementContentPtr cur); +XMLPUBFUN void XMLCALL + xmlSnprintfElementContent(char *buf, + int size, + xmlElementContentPtr content, + int englob); +#ifdef LIBXML_OUTPUT_ENABLED +/* DEPRECATED */ +XMLPUBFUN void XMLCALL + xmlSprintfElementContent(char *buf, + xmlElementContentPtr content, + int englob); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* DEPRECATED */ + +/* Element */ +XMLPUBFUN xmlElementPtr XMLCALL + xmlAddElementDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *name, + xmlElementTypeVal type, + xmlElementContentPtr content); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlElementTablePtr XMLCALL + xmlCopyElementTable (xmlElementTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeElementTable (xmlElementTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpElementTable (xmlBufferPtr buf, + xmlElementTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpElementDecl (xmlBufferPtr buf, + xmlElementPtr elem); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* Enumeration */ +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlCreateEnumeration (const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlFreeEnumeration (xmlEnumerationPtr cur); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlEnumerationPtr XMLCALL + xmlCopyEnumeration (xmlEnumerationPtr cur); +#endif /* LIBXML_TREE_ENABLED */ + +/* Attribute */ +XMLPUBFUN xmlAttributePtr XMLCALL + xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, + xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *ns, + xmlAttributeType type, + xmlAttributeDefault def, + const xmlChar *defaultValue, + xmlEnumerationPtr tree); +#ifdef LIBXML_TREE_ENABLED +XMLPUBFUN xmlAttributeTablePtr XMLCALL + xmlCopyAttributeTable (xmlAttributeTablePtr table); +#endif /* LIBXML_TREE_ENABLED */ +XMLPUBFUN void XMLCALL + xmlFreeAttributeTable (xmlAttributeTablePtr table); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlDumpAttributeTable (xmlBufferPtr buf, + xmlAttributeTablePtr table); +XMLPUBFUN void XMLCALL + xmlDumpAttributeDecl (xmlBufferPtr buf, + xmlAttributePtr attr); +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* IDs */ +XMLPUBFUN xmlIDPtr XMLCALL + xmlAddID (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void XMLCALL + xmlFreeIDTable (xmlIDTablePtr table); +XMLPUBFUN xmlAttrPtr XMLCALL + xmlGetID (xmlDocPtr doc, + const xmlChar *ID); +XMLPUBFUN int XMLCALL + xmlIsID (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int XMLCALL + xmlRemoveID (xmlDocPtr doc, + xmlAttrPtr attr); + +/* IDREFs */ +XMLPUBFUN xmlRefPtr XMLCALL + xmlAddRef (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *value, + xmlAttrPtr attr); +XMLPUBFUN void XMLCALL + xmlFreeRefTable (xmlRefTablePtr table); +XMLPUBFUN int XMLCALL + xmlIsRef (xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr); +XMLPUBFUN int XMLCALL + xmlRemoveRef (xmlDocPtr doc, + xmlAttrPtr attr); +XMLPUBFUN xmlListPtr XMLCALL + xmlGetRefs (xmlDocPtr doc, + const xmlChar *ID); + +/** + * The public function calls related to validity checking. + */ +#ifdef LIBXML_VALID_ENABLED +/* Allocate/Release Validation Contexts */ +XMLPUBFUN xmlValidCtxtPtr XMLCALL + xmlNewValidCtxt(void); +XMLPUBFUN void XMLCALL + xmlFreeValidCtxt(xmlValidCtxtPtr); + +XMLPUBFUN int XMLCALL + xmlValidateRoot (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateElementDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlElementPtr elem); +XMLPUBFUN xmlChar * XMLCALL + xmlValidNormalizeAttributeValue(xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *name, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlAttributePtr attr); +XMLPUBFUN int XMLCALL + xmlValidateAttributeValue(xmlAttributeType type, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNotationPtr nota); +XMLPUBFUN int XMLCALL + xmlValidateDtd (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlDtdPtr dtd); +XMLPUBFUN int XMLCALL + xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateDocument (xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlValidateElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlValidateOneElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + xmlAttrPtr attr, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *prefix, + xmlNsPtr ns, + const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, + xmlDocPtr doc); +#endif /* LIBXML_VALID_ENABLED */ + +#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN int XMLCALL + xmlValidateNotationUse (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + const xmlChar *notationName); +#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */ + +XMLPUBFUN int XMLCALL + xmlIsMixedElement (xmlDocPtr doc, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr XMLCALL + xmlGetDtdAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name); +XMLPUBFUN xmlAttributePtr XMLCALL + xmlGetDtdQAttrDesc (xmlDtdPtr dtd, + const xmlChar *elem, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlNotationPtr XMLCALL + xmlGetDtdNotationDesc (xmlDtdPtr dtd, + const xmlChar *name); +XMLPUBFUN xmlElementPtr XMLCALL + xmlGetDtdQElementDesc (xmlDtdPtr dtd, + const xmlChar *name, + const xmlChar *prefix); +XMLPUBFUN xmlElementPtr XMLCALL + xmlGetDtdElementDesc (xmlDtdPtr dtd, + const xmlChar *name); + +#ifdef LIBXML_VALID_ENABLED + +XMLPUBFUN int XMLCALL + xmlValidGetPotentialChildren(xmlElementContent *ctree, + const xmlChar **names, + int *len, + int max); + +XMLPUBFUN int XMLCALL + xmlValidGetValidElements(xmlNode *prev, + xmlNode *next, + const xmlChar **names, + int max); +XMLPUBFUN int XMLCALL + xmlValidateNameValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNamesValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNmtokenValue (const xmlChar *value); +XMLPUBFUN int XMLCALL + xmlValidateNmtokensValue(const xmlChar *value); + +#ifdef LIBXML_REGEXP_ENABLED +/* + * Validation based on the regexp support + */ +XMLPUBFUN int XMLCALL + xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, + xmlElementPtr elem); + +XMLPUBFUN int XMLCALL + xmlValidatePushElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +XMLPUBFUN int XMLCALL + xmlValidatePushCData (xmlValidCtxtPtr ctxt, + const xmlChar *data, + int len); +XMLPUBFUN int XMLCALL + xmlValidatePopElement (xmlValidCtxtPtr ctxt, + xmlDocPtr doc, + xmlNodePtr elem, + const xmlChar *qname); +#endif /* LIBXML_REGEXP_ENABLED */ +#endif /* LIBXML_VALID_ENABLED */ +#ifdef __cplusplus +} +#endif +#endif /* __XML_VALID_H__ */ Added: include/libxml/xinclude.h =================================================================== --- include/libxml/xinclude.h (rev 0) +++ include/libxml/xinclude.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,125 @@ +/* + * Summary: implementation of XInclude + * Description: API to handle XInclude processing, + * implements the + * World Wide Web Consortium Last Call Working Draft 10 November 2003 + * http://www.w3.org/TR/2003/WD-xinclude-20031110 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XINCLUDE_H__ +#define __XML_XINCLUDE_H__ + +#include +#include + +#ifdef LIBXML_XINCLUDE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * XINCLUDE_NS: + * + * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude + */ +#define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2003/XInclude" +/** + * XINCLUDE_OLD_NS: + * + * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude + */ +#define XINCLUDE_OLD_NS (const xmlChar *) "http://www.w3.org/2001/XInclude" +/** + * XINCLUDE_NODE: + * + * Macro defining "include" + */ +#define XINCLUDE_NODE (const xmlChar *) "include" +/** + * XINCLUDE_FALLBACK: + * + * Macro defining "fallback" + */ +#define XINCLUDE_FALLBACK (const xmlChar *) "fallback" +/** + * XINCLUDE_HREF: + * + * Macro defining "href" + */ +#define XINCLUDE_HREF (const xmlChar *) "href" +/** + * XINCLUDE_PARSE: + * + * Macro defining "parse" + */ +#define XINCLUDE_PARSE (const xmlChar *) "parse" +/** + * XINCLUDE_PARSE_XML: + * + * Macro defining "xml" + */ +#define XINCLUDE_PARSE_XML (const xmlChar *) "xml" +/** + * XINCLUDE_PARSE_TEXT: + * + * Macro defining "text" + */ +#define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" +/** + * XINCLUDE_PARSE_ENCODING: + * + * Macro defining "encoding" + */ +#define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding" +/** + * XINCLUDE_PARSE_XPOINTER: + * + * Macro defining "xpointer" + */ +#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) "xpointer" + +typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt; +typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr; + +/* + * standalone processing + */ +XMLPUBFUN int XMLCALL + xmlXIncludeProcess (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessFlags (xmlDocPtr doc, + int flags); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessFlagsData(xmlDocPtr doc, + int flags, + void *data); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTree (xmlNodePtr tree); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessTreeFlags(xmlNodePtr tree, + int flags); +/* + * contextual processing + */ +XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL + xmlXIncludeNewContext (xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt, + int flags); +XMLPUBFUN void XMLCALL + xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt, + xmlNodePtr tree); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XINCLUDE_ENABLED */ + +#endif /* __XML_XINCLUDE_H__ */ Added: include/libxml/xlink.h =================================================================== --- include/libxml/xlink.h (rev 0) +++ include/libxml/xlink.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,189 @@ +/* + * Summary: unfinished XLink detection module + * Description: unfinished XLink detection module + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XLINK_H__ +#define __XML_XLINK_H__ + +#include +#include + +#ifdef LIBXML_XPTR_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Various defines for the various Link properties. + * + * NOTE: the link detection layer will try to resolve QName expansion + * of namespaces. If "foo" is the prefix for "http://foo.com/" + * then the link detection layer will expand role="foo:myrole" + * to "http://foo.com/:myrole". + * NOTE: the link detection layer will expand URI-Refences found on + * href attributes by using the base mechanism if found. + */ +typedef xmlChar *xlinkHRef; +typedef xmlChar *xlinkRole; +typedef xmlChar *xlinkTitle; + +typedef enum { + XLINK_TYPE_NONE = 0, + XLINK_TYPE_SIMPLE, + XLINK_TYPE_EXTENDED, + XLINK_TYPE_EXTENDED_SET +} xlinkType; + +typedef enum { + XLINK_SHOW_NONE = 0, + XLINK_SHOW_NEW, + XLINK_SHOW_EMBED, + XLINK_SHOW_REPLACE +} xlinkShow; + +typedef enum { + XLINK_ACTUATE_NONE = 0, + XLINK_ACTUATE_AUTO, + XLINK_ACTUATE_ONREQUEST +} xlinkActuate; + +/** + * xlinkNodeDetectFunc: + * @ctx: user data pointer + * @node: the node to check + * + * This is the prototype for the link detection routine. + * It calls the default link detection callbacks upon link detection. + */ +typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node); + +/* + * The link detection module interact with the upper layers using + * a set of callback registered at parsing time. + */ + +/** + * xlinkSimpleLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @href: the target of the link + * @role: the role string + * @title: the link title + * + * This is the prototype for a simple link detection callback. + */ +typedef void +(*xlinkSimpleLinkFunk) (void *ctx, + xmlNodePtr node, + const xlinkHRef href, + const xlinkRole role, + const xlinkTitle title); + +/** + * xlinkExtendedLinkFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbArcs: the number of arcs detected on the link + * @from: pointer to the array of source roles found on the arcs + * @to: pointer to the array of target roles found on the arcs + * @show: array of values for the show attributes found on the arcs + * @actuate: array of values for the actuate attributes found on the arcs + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link detection callback. + */ +typedef void +(*xlinkExtendedLinkFunk)(void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbArcs, + const xlinkRole *from, + const xlinkRole *to, + xlinkShow *show, + xlinkActuate *actuate, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * xlinkExtendedLinkSetFunk: + * @ctx: user data pointer + * @node: the node carrying the link + * @nbLocators: the number of locators detected on the link + * @hrefs: pointer to the array of locator hrefs + * @roles: pointer to the array of locator roles + * @nbTitles: the number of titles detected on the link + * @title: array of titles detected on the link + * @langs: array of xml:lang values for the titles + * + * This is the prototype for a extended link set detection callback. + */ +typedef void +(*xlinkExtendedLinkSetFunk) (void *ctx, + xmlNodePtr node, + int nbLocators, + const xlinkHRef *hrefs, + const xlinkRole *roles, + int nbTitles, + const xlinkTitle *titles, + const xmlChar **langs); + +/** + * This is the structure containing a set of Links detection callbacks. + * + * There is no default xlink callbacks, if one want to get link + * recognition activated, those call backs must be provided before parsing. + */ +typedef struct _xlinkHandler xlinkHandler; +typedef xlinkHandler *xlinkHandlerPtr; +struct _xlinkHandler { + xlinkSimpleLinkFunk simple; + xlinkExtendedLinkFunk extended; + xlinkExtendedLinkSetFunk set; +}; + +/* + * The default detection routine, can be overridden, they call the default + * detection callbacks. + */ + +XMLPUBFUN xlinkNodeDetectFunc XMLCALL + xlinkGetDefaultDetect (void); +XMLPUBFUN void XMLCALL + xlinkSetDefaultDetect (xlinkNodeDetectFunc func); + +/* + * Routines to set/get the default handlers. + */ +XMLPUBFUN xlinkHandlerPtr XMLCALL + xlinkGetDefaultHandler (void); +XMLPUBFUN void XMLCALL + xlinkSetDefaultHandler (xlinkHandlerPtr handler); + +/* + * Link detection module itself. + */ +XMLPUBFUN xlinkType XMLCALL + xlinkIsLink (xmlDocPtr doc, + xmlNodePtr node); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ + +#endif /* __XML_XLINK_H__ */ Added: include/libxml/xmlIO.h =================================================================== --- include/libxml/xmlIO.h (rev 0) +++ include/libxml/xmlIO.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,360 @@ +/* + * Summary: interface for the I/O interfaces used by the parser + * Description: interface for the I/O interfaces used by the parser + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_IO_H__ +#define __XML_IO_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Those are the functions and datatypes for the parser input + * I/O structures. + */ + +/** + * xmlInputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to detect if the current handler + * can provide input fonctionnalities for this resource. + * + * Returns 1 if yes and 0 if another Input module should be used + */ +typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename); +/** + * xmlInputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Input API to open the resource + * + * Returns an Input context or NULL in case or error + */ +typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename); +/** + * xmlInputReadCallback: + * @context: an Input context + * @buffer: the buffer to store data read + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Input API to read the resource + * + * Returns the number of bytes read or -1 in case of error + */ +typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len); +/** + * xmlInputCloseCallback: + * @context: an Input context + * + * Callback used in the I/O Input API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (XMLCALL *xmlInputCloseCallback) (void * context); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Those are the functions and datatypes for the library output + * I/O structures. + */ + +/** + * xmlOutputMatchCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to detect if the current handler + * can provide output fonctionnalities for this resource. + * + * Returns 1 if yes and 0 if another Output module should be used + */ +typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename); +/** + * xmlOutputOpenCallback: + * @filename: the filename or URI + * + * Callback used in the I/O Output API to open the resource + * + * Returns an Output context or NULL in case or error + */ +typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename); +/** + * xmlOutputWriteCallback: + * @context: an Output context + * @buffer: the buffer of data to write + * @len: the length of the buffer in bytes + * + * Callback used in the I/O Output API to write to the resource + * + * Returns the number of bytes written or -1 in case of error + */ +typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer, + int len); +/** + * xmlOutputCloseCallback: + * @context: an Output context + * + * Callback used in the I/O Output API to close the resource + * + * Returns 0 or -1 in case of error + */ +typedef int (XMLCALL *xmlOutputCloseCallback) (void * context); +#endif /* LIBXML_OUTPUT_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +struct _xmlParserInputBuffer { + void* context; + xmlInputReadCallback readcallback; + xmlInputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */ + xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */ + int compressed; /* -1=unknown, 0=not compressed, 1=compressed */ + int error; + unsigned long rawconsumed;/* amount consumed from raw */ +}; + + +#ifdef LIBXML_OUTPUT_ENABLED +struct _xmlOutputBuffer { + void* context; + xmlOutputWriteCallback writecallback; + xmlOutputCloseCallback closecallback; + + xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ + + xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ + xmlBufferPtr conv; /* if encoder != NULL buffer for output */ + int written; /* total number of byte written */ + int error; +}; +#endif /* LIBXML_OUTPUT_ENABLED */ + +/* + * Interfaces for input + */ +XMLPUBFUN void XMLCALL + xmlCleanupInputCallbacks (void); + +XMLPUBFUN int XMLCALL + xmlPopInputCallbacks (void); + +XMLPUBFUN void XMLCALL + xmlRegisterDefaultInputCallbacks (void); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlAllocParserInputBuffer (xmlCharEncoding enc); + +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFilename (const char *URI, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFile (FILE *file, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateFd (int fd, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateMem (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateStatic (const char *mem, int size, + xmlCharEncoding enc); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + xmlCharEncoding enc); +XMLPUBFUN int XMLCALL + xmlParserInputBufferRead (xmlParserInputBufferPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputBufferGrow (xmlParserInputBufferPtr in, + int len); +XMLPUBFUN int XMLCALL + xmlParserInputBufferPush (xmlParserInputBufferPtr in, + int len, + const char *buf); +XMLPUBFUN void XMLCALL + xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); +XMLPUBFUN char * XMLCALL + xmlParserGetDirectory (const char *filename); + +XMLPUBFUN int XMLCALL + xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, + xmlInputOpenCallback openFunc, + xmlInputReadCallback readFunc, + xmlInputCloseCallback closeFunc); + +xmlParserInputBufferPtr + __xmlParserInputBufferCreateFilename(const char *URI, + xmlCharEncoding enc); + +#ifdef LIBXML_OUTPUT_ENABLED +/* + * Interfaces for output + */ +XMLPUBFUN void XMLCALL + xmlCleanupOutputCallbacks (void); +XMLPUBFUN void XMLCALL + xmlRegisterDefaultOutputCallbacks(void); +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFilename (const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFile (FILE *file, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateBuffer (xmlBufferPtr buffer, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateFd (int fd, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN xmlOutputBufferPtr XMLCALL + xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + xmlCharEncodingHandlerPtr encoder); + +XMLPUBFUN int XMLCALL + xmlOutputBufferWrite (xmlOutputBufferPtr out, + int len, + const char *buf); +XMLPUBFUN int XMLCALL + xmlOutputBufferWriteString (xmlOutputBufferPtr out, + const char *str); +XMLPUBFUN int XMLCALL + xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, + const xmlChar *str, + xmlCharEncodingOutputFunc escaping); + +XMLPUBFUN int XMLCALL + xmlOutputBufferFlush (xmlOutputBufferPtr out); +XMLPUBFUN int XMLCALL + xmlOutputBufferClose (xmlOutputBufferPtr out); + +XMLPUBFUN int XMLCALL + xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, + xmlOutputOpenCallback openFunc, + xmlOutputWriteCallback writeFunc, + xmlOutputCloseCallback closeFunc); + +xmlOutputBufferPtr + __xmlOutputBufferCreateFilename(const char *URI, + xmlCharEncodingHandlerPtr encoder, + int compression); + +#ifdef LIBXML_HTTP_ENABLED +/* This function only exists if HTTP support built into the library */ +XMLPUBFUN void XMLCALL + xmlRegisterHTTPPostCallbacks (void ); +#endif /* LIBXML_HTTP_ENABLED */ + +#endif /* LIBXML_OUTPUT_ENABLED */ + +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, + xmlParserInputPtr ret); + +/* + * A predefined entity loader disabling network accesses + */ +XMLPUBFUN xmlParserInputPtr XMLCALL + xmlNoNetExternalEntityLoader (const char *URL, + const char *ID, + xmlParserCtxtPtr ctxt); + +/* + * xmlNormalizeWindowsPath is obsolete, don't use it. + * Check xmlCanonicPath in uri.h for a better alternative. + */ +XMLPUBFUN xmlChar * XMLCALL + xmlNormalizeWindowsPath (const xmlChar *path); + +XMLPUBFUN int XMLCALL + xmlCheckFilename (const char *path); +/** + * Default 'file://' protocol callbacks + */ +XMLPUBFUN int XMLCALL + xmlFileMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlFileOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlFileRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlFileClose (void * context); + +/** + * Default 'http://' protocol callbacks + */ +#ifdef LIBXML_HTTP_ENABLED +XMLPUBFUN int XMLCALL + xmlIOHTTPMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlIOHTTPOpen (const char *filename); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void * XMLCALL + xmlIOHTTPOpenW (const char * post_uri, + int compression ); +#endif /* LIBXML_OUTPUT_ENABLED */ +XMLPUBFUN int XMLCALL + xmlIOHTTPRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlIOHTTPClose (void * context); +#endif /* LIBXML_HTTP_ENABLED */ + +/** + * Default 'ftp://' protocol callbacks + */ +#ifdef LIBXML_FTP_ENABLED +XMLPUBFUN int XMLCALL + xmlIOFTPMatch (const char *filename); +XMLPUBFUN void * XMLCALL + xmlIOFTPOpen (const char *filename); +XMLPUBFUN int XMLCALL + xmlIOFTPRead (void * context, + char * buffer, + int len); +XMLPUBFUN int XMLCALL + xmlIOFTPClose (void * context); +#endif /* LIBXML_FTP_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_IO_H__ */ Added: include/libxml/xmlautomata.h =================================================================== --- include/libxml/xmlautomata.h (rev 0) +++ include/libxml/xmlautomata.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,146 @@ +/* + * Summary: API to build regexp automata + * Description: the API to build regexp automata + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_AUTOMATA_H__ +#define __XML_AUTOMATA_H__ + +#include +#include + +#ifdef LIBXML_REGEXP_ENABLED +#ifdef LIBXML_AUTOMATA_ENABLED +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlAutomataPtr: + * + * A libxml automata description, It can be compiled into a regexp + */ +typedef struct _xmlAutomata xmlAutomata; +typedef xmlAutomata *xmlAutomataPtr; + +/** + * xmlAutomataStatePtr: + * + * A state int the automata description, + */ +typedef struct _xmlAutomataState xmlAutomataState; +typedef xmlAutomataState *xmlAutomataStatePtr; + +/* + * Building API + */ +XMLPUBFUN xmlAutomataPtr XMLCALL + xmlNewAutomata (void); +XMLPUBFUN void XMLCALL + xmlFreeAutomata (xmlAutomataPtr am); + +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataGetInitState (xmlAutomataPtr am); +XMLPUBFUN int XMLCALL + xmlAutomataSetFinalState (xmlAutomataPtr am, + xmlAutomataStatePtr state); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewState (xmlAutomataPtr am); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewTransition (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewTransition2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewNegTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + void *data); + +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewOnceTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewOnceTrans2 (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + const xmlChar *token, + const xmlChar *token2, + int min, + int max, + void *data); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewAllTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int lax); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewEpsilon (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCountedTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XMLPUBFUN xmlAutomataStatePtr XMLCALL + xmlAutomataNewCounterTrans (xmlAutomataPtr am, + xmlAutomataStatePtr from, + xmlAutomataStatePtr to, + int counter); +XMLPUBFUN int XMLCALL + xmlAutomataNewCounter (xmlAutomataPtr am, + int min, + int max); + +XMLPUBFUN xmlRegexpPtr XMLCALL + xmlAutomataCompile (xmlAutomataPtr am); +XMLPUBFUN int XMLCALL + xmlAutomataIsDeterminist (xmlAutomataPtr am); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_AUTOMATA_ENABLED */ +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /* __XML_AUTOMATA_H__ */ Added: include/libxml/xmlerror.h =================================================================== --- include/libxml/xmlerror.h (rev 0) +++ include/libxml/xmlerror.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,944 @@ +/* + * Summary: error handling + * Description: the API used to report errors + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#include + +#ifndef __XML_ERROR_H__ +#define __XML_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlErrorLevel: + * + * Indicates the level of an error + */ +typedef enum { + XML_ERR_NONE = 0, + XML_ERR_WARNING = 1, /* A simple warning */ + XML_ERR_ERROR = 2, /* A recoverable error */ + XML_ERR_FATAL = 3 /* A fatal error */ +} xmlErrorLevel; + +/** + * xmlErrorDomain: + * + * Indicates where an error may have come from + */ +typedef enum { + XML_FROM_NONE = 0, + XML_FROM_PARSER, /* The XML parser */ + XML_FROM_TREE, /* The tree module */ + XML_FROM_NAMESPACE, /* The XML Namespace module */ + XML_FROM_DTD, /* The XML DTD validation with parser context*/ + XML_FROM_HTML, /* The HTML parser */ + XML_FROM_MEMORY, /* The memory allocator */ + XML_FROM_OUTPUT, /* The serialization code */ + XML_FROM_IO, /* The Input/Output stack */ + XML_FROM_FTP, /* The FTP module */ + XML_FROM_HTTP, /* The HTTP module */ + XML_FROM_XINCLUDE, /* The XInclude processing */ + XML_FROM_XPATH, /* The XPath module */ + XML_FROM_XPOINTER, /* The XPointer module */ + XML_FROM_REGEXP, /* The regular expressions module */ + XML_FROM_DATATYPE, /* The W3C XML Schemas Datatype module */ + XML_FROM_SCHEMASP, /* The W3C XML Schemas parser module */ + XML_FROM_SCHEMASV, /* The W3C XML Schemas validation module */ + XML_FROM_RELAXNGP, /* The Relax-NG parser module */ + XML_FROM_RELAXNGV, /* The Relax-NG validator module */ + XML_FROM_CATALOG, /* The Catalog module */ + XML_FROM_C14N, /* The Canonicalization module */ + XML_FROM_XSLT, /* The XSLT engine from libxslt */ + XML_FROM_VALID, /* The XML DTD validation with valid context */ + XML_FROM_CHECK, /* The error checking module */ + XML_FROM_WRITER, /* The xmlwriter module */ + XML_FROM_MODULE, /* The dynamically loaded module module*/ + XML_FROM_I18N, /* The module handling character conversion */ + XML_FROM_SCHEMATRONV /* The Schematron validator module */ +} xmlErrorDomain; + +/** + * xmlError: + * + * An XML Error instance. + */ + +typedef struct _xmlError xmlError; +typedef xmlError *xmlErrorPtr; +struct _xmlError { + int domain; /* What part of the library raised this error */ + int code; /* The error code, e.g. an xmlParserError */ + char *message;/* human-readable informative error message */ + xmlErrorLevel level;/* how consequent is the error */ + char *file; /* the filename */ + int line; /* the line number if available */ + char *str1; /* extra string information */ + char *str2; /* extra string information */ + char *str3; /* extra string information */ + int int1; /* extra number information */ + int int2; /* column number of the error or 0 if N/A (todo: rename this field when we would break ABI) */ + void *ctxt; /* the parser context if available */ + void *node; /* the node in the tree */ +}; + +/** + * xmlParserError: + * + * This is an error that the XML (or HTML) parser can generate + */ +typedef enum { + XML_ERR_OK = 0, + XML_ERR_INTERNAL_ERROR, /* 1 */ + XML_ERR_NO_MEMORY, /* 2 */ + XML_ERR_DOCUMENT_START, /* 3 */ + XML_ERR_DOCUMENT_EMPTY, /* 4 */ + XML_ERR_DOCUMENT_END, /* 5 */ + XML_ERR_INVALID_HEX_CHARREF, /* 6 */ + XML_ERR_INVALID_DEC_CHARREF, /* 7 */ + XML_ERR_INVALID_CHARREF, /* 8 */ + XML_ERR_INVALID_CHAR, /* 9 */ + XML_ERR_CHARREF_AT_EOF, /* 10 */ + XML_ERR_CHARREF_IN_PROLOG, /* 11 */ + XML_ERR_CHARREF_IN_EPILOG, /* 12 */ + XML_ERR_CHARREF_IN_DTD, /* 13 */ + XML_ERR_ENTITYREF_AT_EOF, /* 14 */ + XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */ + XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */ + XML_ERR_ENTITYREF_IN_DTD, /* 17 */ + XML_ERR_PEREF_AT_EOF, /* 18 */ + XML_ERR_PEREF_IN_PROLOG, /* 19 */ + XML_ERR_PEREF_IN_EPILOG, /* 20 */ + XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */ + XML_ERR_ENTITYREF_NO_NAME, /* 22 */ + XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */ + XML_ERR_PEREF_NO_NAME, /* 24 */ + XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */ + XML_ERR_UNDECLARED_ENTITY, /* 26 */ + XML_WAR_UNDECLARED_ENTITY, /* 27 */ + XML_ERR_UNPARSED_ENTITY, /* 28 */ + XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */ + XML_ERR_ENTITY_IS_PARAMETER, /* 30 */ + XML_ERR_UNKNOWN_ENCODING, /* 31 */ + XML_ERR_UNSUPPORTED_ENCODING, /* 32 */ + XML_ERR_STRING_NOT_STARTED, /* 33 */ + XML_ERR_STRING_NOT_CLOSED, /* 34 */ + XML_ERR_NS_DECL_ERROR, /* 35 */ + XML_ERR_ENTITY_NOT_STARTED, /* 36 */ + XML_ERR_ENTITY_NOT_FINISHED, /* 37 */ + XML_ERR_LT_IN_ATTRIBUTE, /* 38 */ + XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */ + XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */ + XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */ + XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */ + XML_ERR_LITERAL_NOT_STARTED, /* 43 */ + XML_ERR_LITERAL_NOT_FINISHED, /* 44 */ + XML_ERR_COMMENT_NOT_FINISHED, /* 45 */ + XML_ERR_PI_NOT_STARTED, /* 46 */ + XML_ERR_PI_NOT_FINISHED, /* 47 */ + XML_ERR_NOTATION_NOT_STARTED, /* 48 */ + XML_ERR_NOTATION_NOT_FINISHED, /* 49 */ + XML_ERR_ATTLIST_NOT_STARTED, /* 50 */ + XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */ + XML_ERR_MIXED_NOT_STARTED, /* 52 */ + XML_ERR_MIXED_NOT_FINISHED, /* 53 */ + XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */ + XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */ + XML_ERR_XMLDECL_NOT_STARTED, /* 56 */ + XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */ + XML_ERR_CONDSEC_NOT_STARTED, /* 58 */ + XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */ + XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */ + XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */ + XML_ERR_MISPLACED_CDATA_END, /* 62 */ + XML_ERR_CDATA_NOT_FINISHED, /* 63 */ + XML_ERR_RESERVED_XML_NAME, /* 64 */ + XML_ERR_SPACE_REQUIRED, /* 65 */ + XML_ERR_SEPARATOR_REQUIRED, /* 66 */ + XML_ERR_NMTOKEN_REQUIRED, /* 67 */ + XML_ERR_NAME_REQUIRED, /* 68 */ + XML_ERR_PCDATA_REQUIRED, /* 69 */ + XML_ERR_URI_REQUIRED, /* 70 */ + XML_ERR_PUBID_REQUIRED, /* 71 */ + XML_ERR_LT_REQUIRED, /* 72 */ + XML_ERR_GT_REQUIRED, /* 73 */ + XML_ERR_LTSLASH_REQUIRED, /* 74 */ + XML_ERR_EQUAL_REQUIRED, /* 75 */ + XML_ERR_TAG_NAME_MISMATCH, /* 76 */ + XML_ERR_TAG_NOT_FINISHED, /* 77 */ + XML_ERR_STANDALONE_VALUE, /* 78 */ + XML_ERR_ENCODING_NAME, /* 79 */ + XML_ERR_HYPHEN_IN_COMMENT, /* 80 */ + XML_ERR_INVALID_ENCODING, /* 81 */ + XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */ + XML_ERR_CONDSEC_INVALID, /* 83 */ + XML_ERR_VALUE_REQUIRED, /* 84 */ + XML_ERR_NOT_WELL_BALANCED, /* 85 */ + XML_ERR_EXTRA_CONTENT, /* 86 */ + XML_ERR_ENTITY_CHAR_ERROR, /* 87 */ + XML_ERR_ENTITY_PE_INTERNAL, /* 88 */ + XML_ERR_ENTITY_LOOP, /* 89 */ + XML_ERR_ENTITY_BOUNDARY, /* 90 */ + XML_ERR_INVALID_URI, /* 91 */ + XML_ERR_URI_FRAGMENT, /* 92 */ + XML_WAR_CATALOG_PI, /* 93 */ + XML_ERR_NO_DTD, /* 94 */ + XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */ + XML_ERR_VERSION_MISSING, /* 96 */ + XML_WAR_UNKNOWN_VERSION, /* 97 */ + XML_WAR_LANG_VALUE, /* 98 */ + XML_WAR_NS_URI, /* 99 */ + XML_WAR_NS_URI_RELATIVE, /* 100 */ + XML_ERR_MISSING_ENCODING, /* 101 */ + XML_WAR_SPACE_VALUE, /* 102 */ + XML_ERR_NOT_STANDALONE, /* 103 */ + XML_ERR_ENTITY_PROCESSING, /* 104 */ + XML_ERR_NOTATION_PROCESSING, /* 105 */ + XML_WAR_NS_COLUMN, /* 106 */ + XML_WAR_ENTITY_REDEFINED, /* 107 */ + XML_ERR_UNKNOWN_VERSION, /* 108 */ + XML_ERR_VERSION_MISMATCH, /* 109 */ + XML_NS_ERR_XML_NAMESPACE = 200, + XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */ + XML_NS_ERR_QNAME, /* 202 */ + XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */ + XML_NS_ERR_EMPTY, /* 204 */ + XML_NS_ERR_COLON, /* 205 */ + XML_DTD_ATTRIBUTE_DEFAULT = 500, + XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */ + XML_DTD_ATTRIBUTE_VALUE, /* 502 */ + XML_DTD_CONTENT_ERROR, /* 503 */ + XML_DTD_CONTENT_MODEL, /* 504 */ + XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */ + XML_DTD_DIFFERENT_PREFIX, /* 506 */ + XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */ + XML_DTD_ELEM_NAMESPACE, /* 508 */ + XML_DTD_ELEM_REDEFINED, /* 509 */ + XML_DTD_EMPTY_NOTATION, /* 510 */ + XML_DTD_ENTITY_TYPE, /* 511 */ + XML_DTD_ID_FIXED, /* 512 */ + XML_DTD_ID_REDEFINED, /* 513 */ + XML_DTD_ID_SUBSET, /* 514 */ + XML_DTD_INVALID_CHILD, /* 515 */ + XML_DTD_INVALID_DEFAULT, /* 516 */ + XML_DTD_LOAD_ERROR, /* 517 */ + XML_DTD_MISSING_ATTRIBUTE, /* 518 */ + XML_DTD_MIXED_CORRUPT, /* 519 */ + XML_DTD_MULTIPLE_ID, /* 520 */ + XML_DTD_NO_DOC, /* 521 */ + XML_DTD_NO_DTD, /* 522 */ + XML_DTD_NO_ELEM_NAME, /* 523 */ + XML_DTD_NO_PREFIX, /* 524 */ + XML_DTD_NO_ROOT, /* 525 */ + XML_DTD_NOTATION_REDEFINED, /* 526 */ + XML_DTD_NOTATION_VALUE, /* 527 */ + XML_DTD_NOT_EMPTY, /* 528 */ + XML_DTD_NOT_PCDATA, /* 529 */ + XML_DTD_NOT_STANDALONE, /* 530 */ + XML_DTD_ROOT_NAME, /* 531 */ + XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */ + XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */ + XML_DTD_UNKNOWN_ELEM, /* 534 */ + XML_DTD_UNKNOWN_ENTITY, /* 535 */ + XML_DTD_UNKNOWN_ID, /* 536 */ + XML_DTD_UNKNOWN_NOTATION, /* 537 */ + XML_DTD_STANDALONE_DEFAULTED, /* 538 */ + XML_DTD_XMLID_VALUE, /* 539 */ + XML_DTD_XMLID_TYPE, /* 540 */ + XML_DTD_DUP_TOKEN, /* 541 */ + XML_HTML_STRUCURE_ERROR = 800, + XML_HTML_UNKNOWN_TAG, /* 801 */ + XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000, + XML_RNGP_ATTR_CONFLICT, /* 1001 */ + XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */ + XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */ + XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */ + XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */ + XML_RNGP_CHOICE_CONTENT, /* 1006 */ + XML_RNGP_CHOICE_EMPTY, /* 1007 */ + XML_RNGP_CREATE_FAILURE, /* 1008 */ + XML_RNGP_DATA_CONTENT, /* 1009 */ + XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */ + XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */ + XML_RNGP_DEFINE_EMPTY, /* 1012 */ + XML_RNGP_DEFINE_MISSING, /* 1013 */ + XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */ + XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */ + XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */ + XML_RNGP_ELEMENT_EMPTY, /* 1017 */ + XML_RNGP_ELEMENT_CONTENT, /* 1018 */ + XML_RNGP_ELEMENT_NAME, /* 1019 */ + XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */ + XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */ + XML_RNGP_EMPTY, /* 1022 */ + XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */ + XML_RNGP_EMPTY_CONTENT, /* 1024 */ + XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */ + XML_RNGP_ERROR_TYPE_LIB, /* 1026 */ + XML_RNGP_EXCEPT_EMPTY, /* 1027 */ + XML_RNGP_EXCEPT_MISSING, /* 1028 */ + XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */ + XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */ + XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */ + XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */ + XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */ + XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */ + XML_RNGP_FOREIGN_ELEMENT, /* 1035 */ + XML_RNGP_GRAMMAR_CONTENT, /* 1036 */ + XML_RNGP_GRAMMAR_EMPTY, /* 1037 */ + XML_RNGP_GRAMMAR_MISSING, /* 1038 */ + XML_RNGP_GRAMMAR_NO_START, /* 1039 */ + XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */ + XML_RNGP_HREF_ERROR, /* 1041 */ + XML_RNGP_INCLUDE_EMPTY, /* 1042 */ + XML_RNGP_INCLUDE_FAILURE, /* 1043 */ + XML_RNGP_INCLUDE_RECURSE, /* 1044 */ + XML_RNGP_INTERLEAVE_ADD, /* 1045 */ + XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */ + XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */ + XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */ + XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */ + XML_RNGP_INVALID_URI, /* 1050 */ + XML_RNGP_INVALID_VALUE, /* 1051 */ + XML_RNGP_MISSING_HREF, /* 1052 */ + XML_RNGP_NAME_MISSING, /* 1053 */ + XML_RNGP_NEED_COMBINE, /* 1054 */ + XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */ + XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */ + XML_RNGP_NSNAME_NO_NS, /* 1057 */ + XML_RNGP_PARAM_FORBIDDEN, /* 1058 */ + XML_RNGP_PARAM_NAME_MISSING, /* 1059 */ + XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */ + XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */ + XML_RNGP_PARENTREF_NO_NAME, /* 1062 */ + XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */ + XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */ + XML_RNGP_PARSE_ERROR, /* 1065 */ + XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */ + XML_RNGP_PAT_ATTR_ATTR, /* 1067 */ + XML_RNGP_PAT_ATTR_ELEM, /* 1068 */ + XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */ + XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */ + XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */ + XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */ + XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */ + XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */ + XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */ + XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */ + XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */ + XML_RNGP_PAT_LIST_ATTR, /* 1078 */ + XML_RNGP_PAT_LIST_ELEM, /* 1079 */ + XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */ + XML_RNGP_PAT_LIST_LIST, /* 1081 */ + XML_RNGP_PAT_LIST_REF, /* 1082 */ + XML_RNGP_PAT_LIST_TEXT, /* 1083 */ + XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */ + XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */ + XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */ + XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */ + XML_RNGP_PAT_START_ATTR, /* 1088 */ + XML_RNGP_PAT_START_DATA, /* 1089 */ + XML_RNGP_PAT_START_EMPTY, /* 1090 */ + XML_RNGP_PAT_START_GROUP, /* 1091 */ + XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */ + XML_RNGP_PAT_START_LIST, /* 1093 */ + XML_RNGP_PAT_START_ONEMORE, /* 1094 */ + XML_RNGP_PAT_START_TEXT, /* 1095 */ + XML_RNGP_PAT_START_VALUE, /* 1096 */ + XML_RNGP_PREFIX_UNDEFINED, /* 1097 */ + XML_RNGP_REF_CREATE_FAILED, /* 1098 */ + XML_RNGP_REF_CYCLE, /* 1099 */ + XML_RNGP_REF_NAME_INVALID, /* 1100 */ + XML_RNGP_REF_NO_DEF, /* 1101 */ + XML_RNGP_REF_NO_NAME, /* 1102 */ + XML_RNGP_REF_NOT_EMPTY, /* 1103 */ + XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */ + XML_RNGP_START_CONTENT, /* 1105 */ + XML_RNGP_START_EMPTY, /* 1106 */ + XML_RNGP_START_MISSING, /* 1107 */ + XML_RNGP_TEXT_EXPECTED, /* 1108 */ + XML_RNGP_TEXT_HAS_CHILD, /* 1109 */ + XML_RNGP_TYPE_MISSING, /* 1110 */ + XML_RNGP_TYPE_NOT_FOUND, /* 1111 */ + XML_RNGP_TYPE_VALUE, /* 1112 */ + XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */ + XML_RNGP_UNKNOWN_COMBINE, /* 1114 */ + XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */ + XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */ + XML_RNGP_URI_FRAGMENT, /* 1117 */ + XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */ + XML_RNGP_VALUE_EMPTY, /* 1119 */ + XML_RNGP_VALUE_NO_CONTENT, /* 1120 */ + XML_RNGP_XMLNS_NAME, /* 1121 */ + XML_RNGP_XML_NS, /* 1122 */ + XML_XPATH_EXPRESSION_OK = 1200, + XML_XPATH_NUMBER_ERROR, /* 1201 */ + XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */ + XML_XPATH_START_LITERAL_ERROR, /* 1203 */ + XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */ + XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */ + XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */ + XML_XPATH_EXPR_ERROR, /* 1207 */ + XML_XPATH_UNCLOSED_ERROR, /* 1208 */ + XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */ + XML_XPATH_INVALID_OPERAND, /* 1210 */ + XML_XPATH_INVALID_TYPE, /* 1211 */ + XML_XPATH_INVALID_ARITY, /* 1212 */ + XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */ + XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */ + XML_XPATH_MEMORY_ERROR, /* 1215 */ + XML_XPTR_SYNTAX_ERROR, /* 1216 */ + XML_XPTR_RESOURCE_ERROR, /* 1217 */ + XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */ + XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */ + XML_XPATH_ENCODING_ERROR, /* 1220 */ + XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */ + XML_TREE_INVALID_HEX = 1300, + XML_TREE_INVALID_DEC, /* 1301 */ + XML_TREE_UNTERMINATED_ENTITY, /* 1302 */ + XML_TREE_NOT_UTF8, /* 1303 */ + XML_SAVE_NOT_UTF8 = 1400, + XML_SAVE_CHAR_INVALID, /* 1401 */ + XML_SAVE_NO_DOCTYPE, /* 1402 */ + XML_SAVE_UNKNOWN_ENCODING, /* 1403 */ + XML_REGEXP_COMPILE_ERROR = 1450, + XML_IO_UNKNOWN = 1500, + XML_IO_EACCES, /* 1501 */ + XML_IO_EAGAIN, /* 1502 */ + XML_IO_EBADF, /* 1503 */ + XML_IO_EBADMSG, /* 1504 */ + XML_IO_EBUSY, /* 1505 */ + XML_IO_ECANCELED, /* 1506 */ + XML_IO_ECHILD, /* 1507 */ + XML_IO_EDEADLK, /* 1508 */ + XML_IO_EDOM, /* 1509 */ + XML_IO_EEXIST, /* 1510 */ + XML_IO_EFAULT, /* 1511 */ + XML_IO_EFBIG, /* 1512 */ + XML_IO_EINPROGRESS, /* 1513 */ + XML_IO_EINTR, /* 1514 */ + XML_IO_EINVAL, /* 1515 */ + XML_IO_EIO, /* 1516 */ + XML_IO_EISDIR, /* 1517 */ + XML_IO_EMFILE, /* 1518 */ + XML_IO_EMLINK, /* 1519 */ + XML_IO_EMSGSIZE, /* 1520 */ + XML_IO_ENAMETOOLONG, /* 1521 */ + XML_IO_ENFILE, /* 1522 */ + XML_IO_ENODEV, /* 1523 */ + XML_IO_ENOENT, /* 1524 */ + XML_IO_ENOEXEC, /* 1525 */ + XML_IO_ENOLCK, /* 1526 */ + XML_IO_ENOMEM, /* 1527 */ + XML_IO_ENOSPC, /* 1528 */ + XML_IO_ENOSYS, /* 1529 */ + XML_IO_ENOTDIR, /* 1530 */ + XML_IO_ENOTEMPTY, /* 1531 */ + XML_IO_ENOTSUP, /* 1532 */ + XML_IO_ENOTTY, /* 1533 */ + XML_IO_ENXIO, /* 1534 */ + XML_IO_EPERM, /* 1535 */ + XML_IO_EPIPE, /* 1536 */ + XML_IO_ERANGE, /* 1537 */ + XML_IO_EROFS, /* 1538 */ + XML_IO_ESPIPE, /* 1539 */ + XML_IO_ESRCH, /* 1540 */ + XML_IO_ETIMEDOUT, /* 1541 */ + XML_IO_EXDEV, /* 1542 */ + XML_IO_NETWORK_ATTEMPT, /* 1543 */ + XML_IO_ENCODER, /* 1544 */ + XML_IO_FLUSH, /* 1545 */ + XML_IO_WRITE, /* 1546 */ + XML_IO_NO_INPUT, /* 1547 */ + XML_IO_BUFFER_FULL, /* 1548 */ + XML_IO_LOAD_ERROR, /* 1549 */ + XML_IO_ENOTSOCK, /* 1550 */ + XML_IO_EISCONN, /* 1551 */ + XML_IO_ECONNREFUSED, /* 1552 */ + XML_IO_ENETUNREACH, /* 1553 */ + XML_IO_EADDRINUSE, /* 1554 */ + XML_IO_EALREADY, /* 1555 */ + XML_IO_EAFNOSUPPORT, /* 1556 */ + XML_XINCLUDE_RECURSION=1600, + XML_XINCLUDE_PARSE_VALUE, /* 1601 */ + XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */ + XML_XINCLUDE_NO_HREF, /* 1603 */ + XML_XINCLUDE_NO_FALLBACK, /* 1604 */ + XML_XINCLUDE_HREF_URI, /* 1605 */ + XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */ + XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */ + XML_XINCLUDE_INVALID_CHAR, /* 1608 */ + XML_XINCLUDE_BUILD_FAILED, /* 1609 */ + XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */ + XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */ + XML_XINCLUDE_XPTR_FAILED, /* 1612 */ + XML_XINCLUDE_XPTR_RESULT, /* 1613 */ + XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */ + XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */ + XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */ + XML_XINCLUDE_DEPRECATED_NS, /* 1617 */ + XML_XINCLUDE_FRAGMENT_ID, /* 1618 */ + XML_CATALOG_MISSING_ATTR = 1650, + XML_CATALOG_ENTRY_BROKEN, /* 1651 */ + XML_CATALOG_PREFER_VALUE, /* 1652 */ + XML_CATALOG_NOT_CATALOG, /* 1653 */ + XML_CATALOG_RECURSION, /* 1654 */ + XML_SCHEMAP_PREFIX_UNDEFINED = 1700, + XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */ + XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */ + XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */ + XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */ + XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */ + XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */ + XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */ + XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */ + XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */ + XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */ + XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */ + XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */ + XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */ + XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */ + XML_SCHEMAP_INVALID_ENUM, /* 1715 */ + XML_SCHEMAP_INVALID_FACET, /* 1716 */ + XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */ + XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */ + XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */ + XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */ + XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */ + XML_SCHEMAP_NOATTR_NOREF, /* 1722 */ + XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */ + XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */ + XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */ + XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */ + XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */ + XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */ + XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */ + XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */ + XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */ + XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */ + XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */ + XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */ + XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */ + XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */ + XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */ + XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */ + XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */ + XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */ + XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */ + XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */ + XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */ + XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */ + XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */ + XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */ + XML_SCHEMAP_UNKNOWN_REF, /* 1747 */ + XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */ + XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */ + XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */ + XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */ + XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */ + XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */ + XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */ + XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */ + XML_SCHEMAP_REGEXP_INVALID, /* 1756 */ + XML_SCHEMAP_FAILED_LOAD, /* 1757 */ + XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */ + XML_SCHEMAP_NOROOT, /* 1759 */ + XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */ + XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */ + XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */ + XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */ + XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */ + XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */ + XML_SCHEMAP_FAILED_PARSE, /* 1766 */ + XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */ + XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */ + XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */ + XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */ + XML_SCHEMAP_NOT_SCHEMA, /* 1772 */ + XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */ + XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */ + XML_SCHEMAP_RECURSIVE, /* 1775 */ + XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */ + XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */ + XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */ + XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */ + XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */ + XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */ + XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */ + XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */ + XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */ + XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */ + XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */ + XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */ + XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */ + XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */ + XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */ + XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */ + XML_SCHEMAV_NOROOT = 1801, + XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */ + XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */ + XML_SCHEMAV_MISSING, /* 1804 */ + XML_SCHEMAV_WRONGELEM, /* 1805 */ + XML_SCHEMAV_NOTYPE, /* 1806 */ + XML_SCHEMAV_NOROLLBACK, /* 1807 */ + XML_SCHEMAV_ISABSTRACT, /* 1808 */ + XML_SCHEMAV_NOTEMPTY, /* 1809 */ + XML_SCHEMAV_ELEMCONT, /* 1810 */ + XML_SCHEMAV_HAVEDEFAULT, /* 1811 */ + XML_SCHEMAV_NOTNILLABLE, /* 1812 */ + XML_SCHEMAV_EXTRACONTENT, /* 1813 */ + XML_SCHEMAV_INVALIDATTR, /* 1814 */ + XML_SCHEMAV_INVALIDELEM, /* 1815 */ + XML_SCHEMAV_NOTDETERMINIST, /* 1816 */ + XML_SCHEMAV_CONSTRUCT, /* 1817 */ + XML_SCHEMAV_INTERNAL, /* 1818 */ + XML_SCHEMAV_NOTSIMPLE, /* 1819 */ + XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */ + XML_SCHEMAV_ATTRINVALID, /* 1821 */ + XML_SCHEMAV_VALUE, /* 1822 */ + XML_SCHEMAV_FACET, /* 1823 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */ + XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */ + XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */ + XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */ + XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */ + XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */ + XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */ + XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */ + XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */ + XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */ + XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */ + XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */ + XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */ + XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */ + XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */ + XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */ + XML_SCHEMAV_CVC_ELT_1, /* 1845 */ + XML_SCHEMAV_CVC_ELT_2, /* 1846 */ + XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */ + XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */ + XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */ + XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */ + XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */ + XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */ + XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */ + XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */ + XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */ + XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */ + XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */ + XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */ + XML_SCHEMAV_CVC_ELT_6, /* 1859 */ + XML_SCHEMAV_CVC_ELT_7, /* 1860 */ + XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */ + XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */ + XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */ + XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */ + XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */ + XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */ + XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */ + XML_SCHEMAV_CVC_AU, /* 1874 */ + XML_SCHEMAV_CVC_TYPE_1, /* 1875 */ + XML_SCHEMAV_CVC_TYPE_2, /* 1876 */ + XML_SCHEMAV_CVC_IDC, /* 1877 */ + XML_SCHEMAV_CVC_WILDCARD, /* 1878 */ + XML_SCHEMAV_MISC, /* 1879 */ + XML_XPTR_UNKNOWN_SCHEME = 1900, + XML_XPTR_CHILDSEQ_START, /* 1901 */ + XML_XPTR_EVAL_FAILED, /* 1902 */ + XML_XPTR_EXTRA_OBJECTS, /* 1903 */ + XML_C14N_CREATE_CTXT = 1950, + XML_C14N_REQUIRES_UTF8, /* 1951 */ + XML_C14N_CREATE_STACK, /* 1952 */ + XML_C14N_INVALID_NODE, /* 1953 */ + XML_C14N_UNKNOW_NODE, /* 1954 */ + XML_C14N_RELATIVE_NAMESPACE, /* 1955 */ + XML_FTP_PASV_ANSWER = 2000, + XML_FTP_EPSV_ANSWER, /* 2001 */ + XML_FTP_ACCNT, /* 2002 */ + XML_FTP_URL_SYNTAX, /* 2003 */ + XML_HTTP_URL_SYNTAX = 2020, + XML_HTTP_USE_IP, /* 2021 */ + XML_HTTP_UNKNOWN_HOST, /* 2022 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000, + XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */ + XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */ + XML_SCHEMAP_SRC_RESOLVE, /* 3004 */ + XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */ + XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */ + XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */ + XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */ + XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */ + XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */ + XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */ + XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */ + XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */ + XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */ + XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */ + XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */ + XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */ + XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */ + XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */ + XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */ + XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */ + XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */ + XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */ + XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */ + XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */ + XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */ + XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */ + XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */ + XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */ + XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */ + XML_SCHEMAP_SRC_INCLUDE, /* 3050 */ + XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */ + XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */ + XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */ + XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */ + XML_SCHEMAP_NO_XMLNS, /* 3056 */ + XML_SCHEMAP_NO_XSI, /* 3057 */ + XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */ + XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */ + XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */ + XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */ + XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */ + XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */ + XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */ + XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */ + XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */ + XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */ + XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */ + XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */ + XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */ + XML_SCHEMAP_SRC_CT_1, /* 3076 */ + XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */ + XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */ + XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */ + XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */ + XML_SCHEMAP_SRC_REDEFINE, /* 3081 */ + XML_SCHEMAP_SRC_IMPORT, /* 3082 */ + XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */ + XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */ + XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */ + XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */ + XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */ + XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */ + XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */ + XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */ + XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */ + XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */ + XML_SCHEMATRONV_REPORT, + XML_MODULE_OPEN = 4900, /* 4900 */ + XML_MODULE_CLOSE, /* 4901 */ + XML_CHECK_FOUND_ELEMENT = 5000, + XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */ + XML_CHECK_FOUND_TEXT, /* 5002 */ + XML_CHECK_FOUND_CDATA, /* 5003 */ + XML_CHECK_FOUND_ENTITYREF, /* 5004 */ + XML_CHECK_FOUND_ENTITY, /* 5005 */ + XML_CHECK_FOUND_PI, /* 5006 */ + XML_CHECK_FOUND_COMMENT, /* 5007 */ + XML_CHECK_FOUND_DOCTYPE, /* 5008 */ + XML_CHECK_FOUND_FRAGMENT, /* 5009 */ + XML_CHECK_FOUND_NOTATION, /* 5010 */ + XML_CHECK_UNKNOWN_NODE, /* 5011 */ + XML_CHECK_ENTITY_TYPE, /* 5012 */ + XML_CHECK_NO_PARENT, /* 5013 */ + XML_CHECK_NO_DOC, /* 5014 */ + XML_CHECK_NO_NAME, /* 5015 */ + XML_CHECK_NO_ELEM, /* 5016 */ + XML_CHECK_WRONG_DOC, /* 5017 */ + XML_CHECK_NO_PREV, /* 5018 */ + XML_CHECK_WRONG_PREV, /* 5019 */ + XML_CHECK_NO_NEXT, /* 5020 */ + XML_CHECK_WRONG_NEXT, /* 5021 */ + XML_CHECK_NOT_DTD, /* 5022 */ + XML_CHECK_NOT_ATTR, /* 5023 */ + XML_CHECK_NOT_ATTR_DECL, /* 5024 */ + XML_CHECK_NOT_ELEM_DECL, /* 5025 */ + XML_CHECK_NOT_ENTITY_DECL, /* 5026 */ + XML_CHECK_NOT_NS_DECL, /* 5027 */ + XML_CHECK_NO_HREF, /* 5028 */ + XML_CHECK_WRONG_PARENT,/* 5029 */ + XML_CHECK_NS_SCOPE, /* 5030 */ + XML_CHECK_NS_ANCESTOR, /* 5031 */ + XML_CHECK_NOT_UTF8, /* 5032 */ + XML_CHECK_NO_DICT, /* 5033 */ + XML_CHECK_NOT_NCNAME, /* 5034 */ + XML_CHECK_OUTSIDE_DICT, /* 5035 */ + XML_CHECK_WRONG_NAME, /* 5036 */ + XML_CHECK_NAME_NOT_NULL, /* 5037 */ + XML_I18N_NO_NAME = 6000, + XML_I18N_NO_HANDLER, /* 6001 */ + XML_I18N_EXCESS_HANDLER, /* 6002 */ + XML_I18N_CONV_FAILED, /* 6003 */ + XML_I18N_NO_OUTPUT /* 6004 */ +#if 0 + XML_CHECK_, /* 5033 */ + XML_CHECK_X /* 503 */ +#endif +} xmlParserErrors; + +/** + * xmlGenericErrorFunc: + * @ctx: a parsing context + * @msg: the message + * @...: the extra arguments of the varags to format the message + * + * Signature of the function to use when there is an error and + * no parsing or validity context available . + */ +typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); +/** + * xmlStructuredErrorFunc: + * @userData: user provided data for the error callback + * @error: the error being raised. + * + * Signature of the function to use when there is an error and + * the module handles the new error reporting mechanism. + */ +typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error); + +/* + * Use the following function to reset the two global variables + * xmlGenericError and xmlGenericErrorContext. + */ +XMLPUBFUN void XMLCALL + xmlSetGenericErrorFunc (void *ctx, + xmlGenericErrorFunc handler); +XMLPUBFUN void XMLCALL + initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler); + +XMLPUBFUN void XMLCALL + xmlSetStructuredErrorFunc (void *ctx, + xmlStructuredErrorFunc handler); +/* + * Default message routines used by SAX and Valid context for error + * and warning reporting. + */ +XMLPUBFUN void XMLCDECL + xmlParserError (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); +XMLPUBFUN void XMLCDECL + xmlParserWarning (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); +XMLPUBFUN void XMLCDECL + xmlParserValidityError (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); +XMLPUBFUN void XMLCDECL + xmlParserValidityWarning (void *ctx, + const char *msg, + ...) ATTRIBUTE_PRINTF(2,3); +XMLPUBFUN void XMLCALL + xmlParserPrintFileInfo (xmlParserInputPtr input); +XMLPUBFUN void XMLCALL + xmlParserPrintFileContext (xmlParserInputPtr input); + +/* + * Extended error information routines + */ +XMLPUBFUN xmlErrorPtr XMLCALL + xmlGetLastError (void); +XMLPUBFUN void XMLCALL + xmlResetLastError (void); +XMLPUBFUN xmlErrorPtr XMLCALL + xmlCtxtGetLastError (void *ctx); +XMLPUBFUN void XMLCALL + xmlCtxtResetLastError (void *ctx); +XMLPUBFUN void XMLCALL + xmlResetError (xmlErrorPtr err); +XMLPUBFUN int XMLCALL + xmlCopyError (xmlErrorPtr from, + xmlErrorPtr to); + +#ifdef IN_LIBXML +/* + * Internal callback reporting routine + */ +XMLPUBFUN void XMLCALL + __xmlRaiseError (xmlStructuredErrorFunc schannel, + xmlGenericErrorFunc channel, + void *data, + void *ctx, + void *node, + int domain, + int code, + xmlErrorLevel level, + const char *file, + int line, + const char *str1, + const char *str2, + const char *str3, + int int1, + int col, + const char *msg, + ...) ATTRIBUTE_PRINTF(16,17); +XMLPUBFUN void XMLCALL + __xmlSimpleError (int domain, + int code, + xmlNodePtr node, + const char *msg, + const char *extra); +#endif +#ifdef __cplusplus +} +#endif +#endif /* __XML_ERROR_H__ */ Added: include/libxml/xmlexports.h =================================================================== --- include/libxml/xmlexports.h (rev 0) +++ include/libxml/xmlexports.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,157 @@ +/* + * Summary: macros for marking symbols as exportable/importable. + * Description: macros for marking symbols as exportable/importable. + * + * Copy: See Copyright for the status of this software. + * + * Author: Igor Zlatovic + */ + +#ifndef __XML_EXPORTS_H__ +#define __XML_EXPORTS_H__ + +/** + * XMLPUBFUN, XMLPUBVAR, XMLCALL + * + * Macros which declare an exportable function, an exportable variable and + * the calling convention used for functions. + * + * Please use an extra block for every platform/compiler combination when + * modifying this, rather than overlong #ifdef lines. This helps + * readability as well as the fact that different compilers on the same + * platform might need different definitions. + */ + +/** + * XMLPUBFUN: + * + * Macros which declare an exportable function + */ +#define XMLPUBFUN +/** + * XMLPUBVAR: + * + * Macros which declare an exportable variable + */ +#define XMLPUBVAR extern +/** + * XMLCALL: + * + * Macros which declare the called convention for exported functions + */ +#define XMLCALL +/** + * XMLCDECL: + * + * Macro which declares the calling convention for exported functions that + * use '...'. + */ +#define XMLCDECL + +/** DOC_DISABLE */ + +/* Windows platform with MS compiler */ +#if defined(_WIN32) && defined(_MSC_VER) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #undef XMLCDECL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR extern + #endif + #endif + #if defined(LIBXML_FASTCALL) + #define XMLCALL __fastcall + #else + #define XMLCALL __cdecl + #endif + #define XMLCDECL __cdecl + #if !defined _REENTRANT + #define _REENTRANT + #endif +#endif + +/* Windows platform with Borland compiler */ +#if defined(_WIN32) && defined(__BORLANDC__) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #undef XMLCDECL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) extern + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR extern + #endif + #endif + #define XMLCALL __cdecl + #define XMLCDECL __cdecl + #if !defined _REENTRANT + #define _REENTRANT + #endif +#endif + +/* Windows platform with GNU compiler (Mingw) */ +#if defined(_WIN32) && defined(__MINGW32__) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #undef XMLCDECL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR extern + #endif + #endif + #define XMLCALL __cdecl + #define XMLCDECL __cdecl + #if !defined _REENTRANT + #define _REENTRANT + #endif +#endif + +/* Cygwin platform, GNU compiler */ +#if defined(_WIN32) && defined(__CYGWIN__) + #undef XMLPUBFUN + #undef XMLPUBVAR + #undef XMLCALL + #undef XMLCDECL + #if defined(IN_LIBXML) && !defined(LIBXML_STATIC) + #define XMLPUBFUN __declspec(dllexport) + #define XMLPUBVAR __declspec(dllexport) + #else + #define XMLPUBFUN + #if !defined(LIBXML_STATIC) + #define XMLPUBVAR __declspec(dllimport) extern + #else + #define XMLPUBVAR + #endif + #endif + #define XMLCALL __cdecl + #define XMLCDECL __cdecl +#endif + +/* Compatibility */ +#if !defined(LIBXML_DLL_IMPORT) +#define LIBXML_DLL_IMPORT XMLPUBVAR +#endif + +#endif /* __XML_EXPORTS_H__ */ + + Added: include/libxml/xmlmemory.h =================================================================== --- include/libxml/xmlmemory.h (rev 0) +++ include/libxml/xmlmemory.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,224 @@ +/* + * Summary: interface for the memory allocator + * Description: provides interfaces for the memory allocator, + * including debugging capabilities. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __DEBUG_MEMORY_ALLOC__ +#define __DEBUG_MEMORY_ALLOC__ + +#include +#include + +/** + * DEBUG_MEMORY: + * + * DEBUG_MEMORY replaces the allocator with a collect and debug + * shell to the libc allocator. + * DEBUG_MEMORY should only be activated when debugging + * libxml i.e. if libxml has been configured with --with-debug-mem too. + */ +/* #define DEBUG_MEMORY_FREED */ +/* #define DEBUG_MEMORY_LOCATION */ + +#ifdef DEBUG +#ifndef DEBUG_MEMORY +#define DEBUG_MEMORY +#endif +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * DEBUG_MEMORY_LOCATION should be activated only when debugging + * libxml i.e. if libxml has been configured with --with-debug-mem too. + */ +#ifdef DEBUG_MEMORY_LOCATION +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The XML memory wrapper support 4 basic overloadable functions. + */ +/** + * xmlFreeFunc: + * @mem: an already allocated block of memory + * + * Signature for a free() implementation. + */ +typedef void (XMLCALL *xmlFreeFunc)(void *mem); +/** + * xmlMallocFunc: + * @size: the size requested in bytes + * + * Signature for a malloc() implementation. + * + * Returns a pointer to the newly allocated block or NULL in case of error. + */ +typedef void *(ATTRIBUTE_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size); + +/** + * xmlReallocFunc: + * @mem: an already allocated block of memory + * @size: the new size requested in bytes + * + * Signature for a realloc() implementation. + * + * Returns a pointer to the newly reallocated block or NULL in case of error. + */ +typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size); + +/** + * xmlStrdupFunc: + * @str: a zero terminated string + * + * Signature for an strdup() implementation. + * + * Returns the copy of the string or NULL in case of error. + */ +typedef char *(XMLCALL *xmlStrdupFunc)(const char *str); + +/* + * The 4 interfaces used for all memory handling within libxml. +LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree; +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc; +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic; +LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc; +LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup; + */ + +/* + * The way to overload the existing functions. + * The xmlGc function have an extra entry for atomic block + * allocations useful for garbage collected memory allocators + */ +XMLPUBFUN int XMLCALL + xmlMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int XMLCALL + xmlMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); +XMLPUBFUN int XMLCALL + xmlGcMemSetup (xmlFreeFunc freeFunc, + xmlMallocFunc mallocFunc, + xmlMallocFunc mallocAtomicFunc, + xmlReallocFunc reallocFunc, + xmlStrdupFunc strdupFunc); +XMLPUBFUN int XMLCALL + xmlGcMemGet (xmlFreeFunc *freeFunc, + xmlMallocFunc *mallocFunc, + xmlMallocFunc *mallocAtomicFunc, + xmlReallocFunc *reallocFunc, + xmlStrdupFunc *strdupFunc); + +/* + * Initialization of the memory layer. + */ +XMLPUBFUN int XMLCALL + xmlInitMemory (void); + +/* + * Cleanup of the memory layer. + */ +XMLPUBFUN void XMLCALL + xmlCleanupMemory (void); +/* + * These are specific to the XML debug memory wrapper. + */ +XMLPUBFUN int XMLCALL + xmlMemUsed (void); +XMLPUBFUN int XMLCALL + xmlMemBlocks (void); +XMLPUBFUN void XMLCALL + xmlMemDisplay (FILE *fp); +XMLPUBFUN void XMLCALL + xmlMemDisplayLast(FILE *fp, long nbBytes); +XMLPUBFUN void XMLCALL + xmlMemShow (FILE *fp, int nr); +XMLPUBFUN void XMLCALL + xmlMemoryDump (void); +XMLPUBFUN void * XMLCALL + xmlMemMalloc (size_t size) ATTRIBUTE_ALLOC_SIZE(1); +XMLPUBFUN void * XMLCALL + xmlMemRealloc (void *ptr,size_t size); +XMLPUBFUN void XMLCALL + xmlMemFree (void *ptr); +XMLPUBFUN char * XMLCALL + xmlMemoryStrdup (const char *str); +XMLPUBFUN void * XMLCALL + xmlMallocLoc (size_t size, const char *file, int line) ATTRIBUTE_ALLOC_SIZE(1); +XMLPUBFUN void * XMLCALL + xmlReallocLoc (void *ptr, size_t size, const char *file, int line); +XMLPUBFUN void * XMLCALL + xmlMallocAtomicLoc (size_t size, const char *file, int line) ATTRIBUTE_ALLOC_SIZE(1); +XMLPUBFUN char * XMLCALL + xmlMemStrdupLoc (const char *str, const char *file, int line); + + +#ifdef DEBUG_MEMORY_LOCATION +/** + * xmlMalloc: + * @size: number of bytes to allocate + * + * Wrapper for the malloc() function used in the XML library. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__) +/** + * xmlMallocAtomic: + * @size: number of bytes to allocate + * + * Wrapper for the malloc() function used in the XML library for allocation + * of block not containing pointers to other areas. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__) +/** + * xmlRealloc: + * @ptr: pointer to the existing allocated area + * @size: number of bytes to allocate + * + * Wrapper for the realloc() function used in the XML library. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__) +/** + * xmlMemStrdup: + * @str: pointer to the existing string + * + * Wrapper for the strdup() function, xmlStrdup() is usually preferred. + * + * Returns the pointer to the allocated area or NULL in case of error. + */ +#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__) + +#endif /* DEBUG_MEMORY_LOCATION */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#ifndef __XML_GLOBALS_H +#ifndef __XML_THREADS_H__ +#include +#include +#endif +#endif + +#endif /* __DEBUG_MEMORY_ALLOC__ */ + Added: include/libxml/xmlmodule.h =================================================================== --- include/libxml/xmlmodule.h (rev 0) +++ include/libxml/xmlmodule.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,57 @@ +/* + * Summary: dynamic module loading + * Description: basic API for dynamic module loading, used by + * libexslt added in 2.6.17 + * + * Copy: See Copyright for the status of this software. + * + * Author: Joel W. Reed + */ + +#ifndef __XML_MODULE_H__ +#define __XML_MODULE_H__ + +#include + +#ifdef LIBXML_MODULES_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlModulePtr: + * + * A handle to a dynamically loaded module + */ +typedef struct _xmlModule xmlModule; +typedef xmlModule *xmlModulePtr; + +/** + * xmlModuleOption: + * + * enumeration of options that can be passed down to xmlModuleOpen() + */ +typedef enum { + XML_MODULE_LAZY = 1, /* lazy binding */ + XML_MODULE_LOCAL= 2 /* local binding */ +} xmlModuleOption; + +XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen (const char *filename, + int options); + +XMLPUBFUN int XMLCALL xmlModuleSymbol (xmlModulePtr module, + const char* name, + void **result); + +XMLPUBFUN int XMLCALL xmlModuleClose (xmlModulePtr module); + +XMLPUBFUN int XMLCALL xmlModuleFree (xmlModulePtr module); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_MODULES_ENABLED */ + +#endif /*__XML_MODULE_H__ */ Added: include/libxml/xmlreader.h =================================================================== --- include/libxml/xmlreader.h (rev 0) +++ include/libxml/xmlreader.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,424 @@ +/* + * Summary: the XMLReader implementation + * Description: API of the XML streaming API based on C# interfaces. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLREADER_H__ +#define __XML_XMLREADER_H__ + +#include +#include +#include +#ifdef LIBXML_SCHEMAS_ENABLED +#include +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlParserSeverities: + * + * How severe an error callback is when the per-reader error callback API + * is used. + */ +typedef enum { + XML_PARSER_SEVERITY_VALIDITY_WARNING = 1, + XML_PARSER_SEVERITY_VALIDITY_ERROR = 2, + XML_PARSER_SEVERITY_WARNING = 3, + XML_PARSER_SEVERITY_ERROR = 4 +} xmlParserSeverities; + +#ifdef LIBXML_READER_ENABLED + +/** + * xmlTextReaderMode: + * + * Internal state values for the reader. + */ +typedef enum { + XML_TEXTREADER_MODE_INITIAL = 0, + XML_TEXTREADER_MODE_INTERACTIVE = 1, + XML_TEXTREADER_MODE_ERROR = 2, + XML_TEXTREADER_MODE_EOF =3, + XML_TEXTREADER_MODE_CLOSED = 4, + XML_TEXTREADER_MODE_READING = 5 +} xmlTextReaderMode; + +/** + * xmlParserProperties: + * + * Some common options to use with xmlTextReaderSetParserProp, but it + * is better to use xmlParserOption and the xmlReaderNewxxx and + * xmlReaderForxxx APIs now. + */ +typedef enum { + XML_PARSER_LOADDTD = 1, + XML_PARSER_DEFAULTATTRS = 2, + XML_PARSER_VALIDATE = 3, + XML_PARSER_SUBST_ENTITIES = 4 +} xmlParserProperties; + +/** + * xmlReaderTypes: + * + * Predefined constants for the different types of nodes. + */ +typedef enum { + XML_READER_TYPE_NONE = 0, + XML_READER_TYPE_ELEMENT = 1, + XML_READER_TYPE_ATTRIBUTE = 2, + XML_READER_TYPE_TEXT = 3, + XML_READER_TYPE_CDATA = 4, + XML_READER_TYPE_ENTITY_REFERENCE = 5, + XML_READER_TYPE_ENTITY = 6, + XML_READER_TYPE_PROCESSING_INSTRUCTION = 7, + XML_READER_TYPE_COMMENT = 8, + XML_READER_TYPE_DOCUMENT = 9, + XML_READER_TYPE_DOCUMENT_TYPE = 10, + XML_READER_TYPE_DOCUMENT_FRAGMENT = 11, + XML_READER_TYPE_NOTATION = 12, + XML_READER_TYPE_WHITESPACE = 13, + XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14, + XML_READER_TYPE_END_ELEMENT = 15, + XML_READER_TYPE_END_ENTITY = 16, + XML_READER_TYPE_XML_DECLARATION = 17 +} xmlReaderTypes; + +/** + * xmlTextReader: + * + * Structure for an xmlReader context. + */ +typedef struct _xmlTextReader xmlTextReader; + +/** + * xmlTextReaderPtr: + * + * Pointer to an xmlReader context. + */ +typedef xmlTextReader *xmlTextReaderPtr; + +/* + * Constructors & Destructor + */ +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlNewTextReader (xmlParserInputBufferPtr input, + const char *URI); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlNewTextReaderFilename(const char *URI); + +XMLPUBFUN void XMLCALL + xmlFreeTextReader (xmlTextReaderPtr reader); + +XMLPUBFUN int XMLCALL + xmlTextReaderSetup(xmlTextReaderPtr reader, + xmlParserInputBufferPtr input, const char *URL, + const char *encoding, int options); + +/* + * Iterators + */ +XMLPUBFUN int XMLCALL + xmlTextReaderRead (xmlTextReaderPtr reader); + +#ifdef LIBXML_WRITER_ENABLED +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadInnerXml (xmlTextReaderPtr reader); + +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadOuterXml (xmlTextReaderPtr reader); +#endif + +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderReadString (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader); + +/* + * Attributes of the node + */ +XMLPUBFUN int XMLCALL + xmlTextReaderAttributeCount(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderDepth (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderHasAttributes(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderHasValue(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsDefault (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNodeType (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderQuoteChar (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderReadState (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); + +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstLocalName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstName (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstPrefix (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstString (xmlTextReaderPtr reader, + const xmlChar *str); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstValue (xmlTextReaderPtr reader); + +/* + * use the Const version of the routine for + * better performance and simpler code + */ +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderBaseUri (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLocalName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderName (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderPrefix (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderXmlLang (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderValue (xmlTextReaderPtr reader); + +/* + * Methods of the XmlTextReader + */ +XMLPUBFUN int XMLCALL + xmlTextReaderClose (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, + int no); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttribute (xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN xmlParserInputBufferPtr XMLCALL + xmlTextReaderGetRemainder (xmlTextReaderPtr reader); +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, + const xmlChar *prefix); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, + int no); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, + const xmlChar *name); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, + const xmlChar *localName, + const xmlChar *namespaceURI); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderMoveToElement (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNormalization (xmlTextReaderPtr reader); +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstEncoding (xmlTextReaderPtr reader); + +/* + * Extensions + */ +XMLPUBFUN int XMLCALL + xmlTextReaderSetParserProp (xmlTextReaderPtr reader, + int prop, + int value); +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserProp (xmlTextReaderPtr reader, + int prop); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderCurrentNode (xmlTextReaderPtr reader); + +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader); + +XMLPUBFUN int XMLCALL + xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader); + +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderPreserve (xmlTextReaderPtr reader); +#ifdef LIBXML_PATTERN_ENABLED +XMLPUBFUN int XMLCALL + xmlTextReaderPreservePattern(xmlTextReaderPtr reader, + const xmlChar *pattern, + const xmlChar **namespaces); +#endif /* LIBXML_PATTERN_ENABLED */ +XMLPUBFUN xmlDocPtr XMLCALL + xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); +XMLPUBFUN xmlNodePtr XMLCALL + xmlTextReaderExpand (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNext (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderNextSibling (xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderIsValid (xmlTextReaderPtr reader); +#ifdef LIBXML_SCHEMAS_ENABLED +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, + const char *rng); +XMLPUBFUN int XMLCALL + xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, + xmlRelaxNGPtr schema); +XMLPUBFUN int XMLCALL + xmlTextReaderSchemaValidate (xmlTextReaderPtr reader, + const char *xsd); +XMLPUBFUN int XMLCALL + xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader, + xmlSchemaValidCtxtPtr ctxt, + int options); +XMLPUBFUN int XMLCALL + xmlTextReaderSetSchema (xmlTextReaderPtr reader, + xmlSchemaPtr schema); +#endif +XMLPUBFUN const xmlChar * XMLCALL + xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); +XMLPUBFUN int XMLCALL + xmlTextReaderStandalone (xmlTextReaderPtr reader); + + +/* + * Index lookup + */ +XMLPUBFUN long XMLCALL + xmlTextReaderByteConsumed (xmlTextReaderPtr reader); + +/* + * New more complete APIs for simpler creation and reuse of readers + */ +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderWalker (xmlDocPtr doc); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForDoc (const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForFile (const char *filename, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForMemory (const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForFd (int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN xmlTextReaderPtr XMLCALL + xmlReaderForIO (xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); + +XMLPUBFUN int XMLCALL + xmlReaderNewWalker (xmlTextReaderPtr reader, + xmlDocPtr doc); +XMLPUBFUN int XMLCALL + xmlReaderNewDoc (xmlTextReaderPtr reader, + const xmlChar * cur, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewFile (xmlTextReaderPtr reader, + const char *filename, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewMemory (xmlTextReaderPtr reader, + const char *buffer, + int size, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewFd (xmlTextReaderPtr reader, + int fd, + const char *URL, + const char *encoding, + int options); +XMLPUBFUN int XMLCALL + xmlReaderNewIO (xmlTextReaderPtr reader, + xmlInputReadCallback ioread, + xmlInputCloseCallback ioclose, + void *ioctx, + const char *URL, + const char *encoding, + int options); +/* + * Error handling extensions + */ +typedef void * xmlTextReaderLocatorPtr; + +/** + * xmlTextReaderErrorFunc: + * @arg: the user argument + * @msg: the message + * @severity: the severity of the error + * @locator: a locator indicating where the error occured + * + * Signature of an error callback from a reader parser + */ +typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg, + const char *msg, + xmlParserSeverities severity, + xmlTextReaderLocatorPtr locator); +XMLPUBFUN int XMLCALL + xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); +/*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/ +XMLPUBFUN xmlChar * XMLCALL + xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); +XMLPUBFUN void XMLCALL + xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc f, + void *arg); +XMLPUBFUN void XMLCALL + xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, + xmlStructuredErrorFunc f, + void *arg); +XMLPUBFUN void XMLCALL + xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, + xmlTextReaderErrorFunc *f, + void **arg); + +#endif /* LIBXML_READER_ENABLED */ + +#ifdef __cplusplus +} +#endif + +#endif /* __XML_XMLREADER_H__ */ + Added: include/libxml/xmlregexp.h =================================================================== --- include/libxml/xmlregexp.h (rev 0) +++ include/libxml/xmlregexp.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,222 @@ +/* + * Summary: regular expressions handling + * Description: basic API for libxml regular expressions handling used + * for XML Schemas and validation. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_REGEXP_H__ +#define __XML_REGEXP_H__ + +#include + +#ifdef LIBXML_REGEXP_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlRegexpPtr: + * + * A libxml regular expression, they can actually be far more complex + * thank the POSIX regex expressions. + */ +typedef struct _xmlRegexp xmlRegexp; +typedef xmlRegexp *xmlRegexpPtr; + +/** + * xmlRegExecCtxtPtr: + * + * A libxml progressive regular expression evaluation context + */ +typedef struct _xmlRegExecCtxt xmlRegExecCtxt; +typedef xmlRegExecCtxt *xmlRegExecCtxtPtr; + +#ifdef __cplusplus +} +#endif +#include +#include +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The POSIX like API + */ +XMLPUBFUN xmlRegexpPtr XMLCALL + xmlRegexpCompile (const xmlChar *regexp); +XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp); +XMLPUBFUN int XMLCALL + xmlRegexpExec (xmlRegexpPtr comp, + const xmlChar *value); +XMLPUBFUN void XMLCALL + xmlRegexpPrint (FILE *output, + xmlRegexpPtr regexp); +XMLPUBFUN int XMLCALL + xmlRegexpIsDeterminist(xmlRegexpPtr comp); + +/** + * xmlRegExecCallbacks: + * @exec: the regular expression context + * @token: the current token string + * @transdata: transition data + * @inputdata: input data + * + * Callback function when doing a transition in the automata + */ +typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec, + const xmlChar *token, + void *transdata, + void *inputdata); + +/* + * The progressive API + */ +XMLPUBFUN xmlRegExecCtxtPtr XMLCALL + xmlRegNewExecCtxt (xmlRegexpPtr comp, + xmlRegExecCallbacks callback, + void *data); +XMLPUBFUN void XMLCALL + xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); +XMLPUBFUN int XMLCALL + xmlRegExecPushString(xmlRegExecCtxtPtr exec, + const xmlChar *value, + void *data); +XMLPUBFUN int XMLCALL + xmlRegExecPushString2(xmlRegExecCtxtPtr exec, + const xmlChar *value, + const xmlChar *value2, + void *data); + +XMLPUBFUN int XMLCALL + xmlRegExecNextValues(xmlRegExecCtxtPtr exec, + int *nbval, + int *nbneg, + xmlChar **values, + int *terminal); +XMLPUBFUN int XMLCALL + xmlRegExecErrInfo (xmlRegExecCtxtPtr exec, + const xmlChar **string, + int *nbval, + int *nbneg, + xmlChar **values, + int *terminal); +#ifdef LIBXML_EXPR_ENABLED +/* + * Formal regular expression handling + * Its goal is to do some formal work on content models + */ + +/* expressions are used within a context */ +typedef struct _xmlExpCtxt xmlExpCtxt; +typedef xmlExpCtxt *xmlExpCtxtPtr; + +XMLPUBFUN void XMLCALL + xmlExpFreeCtxt (xmlExpCtxtPtr ctxt); +XMLPUBFUN xmlExpCtxtPtr XMLCALL + xmlExpNewCtxt (int maxNodes, + xmlDictPtr dict); + +XMLPUBFUN int XMLCALL + xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt); + +/* Expressions are trees but the tree is opaque */ +typedef struct _xmlExpNode xmlExpNode; +typedef xmlExpNode *xmlExpNodePtr; + +typedef enum { + XML_EXP_EMPTY = 0, + XML_EXP_FORBID = 1, + XML_EXP_ATOM = 2, + XML_EXP_SEQ = 3, + XML_EXP_OR = 4, + XML_EXP_COUNT = 5 +} xmlExpNodeType; + +/* + * 2 core expressions shared by all for the empty language set + * and for the set with just the empty token + */ +XMLPUBVAR xmlExpNodePtr forbiddenExp; +XMLPUBVAR xmlExpNodePtr emptyExp; + +/* + * Expressions are reference counted internally + */ +XMLPUBFUN void XMLCALL + xmlExpFree (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr); +XMLPUBFUN void XMLCALL + xmlExpRef (xmlExpNodePtr expr); + +/* + * constructors can be either manual or from a string + */ +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpParse (xmlExpCtxtPtr ctxt, + const char *expr); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewAtom (xmlExpCtxtPtr ctxt, + const xmlChar *name, + int len); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewOr (xmlExpCtxtPtr ctxt, + xmlExpNodePtr left, + xmlExpNodePtr right); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewSeq (xmlExpCtxtPtr ctxt, + xmlExpNodePtr left, + xmlExpNodePtr right); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpNewRange (xmlExpCtxtPtr ctxt, + xmlExpNodePtr subset, + int min, + int max); +/* + * The really interesting APIs + */ +XMLPUBFUN int XMLCALL + xmlExpIsNillable(xmlExpNodePtr expr); +XMLPUBFUN int XMLCALL + xmlExpMaxToken (xmlExpNodePtr expr); +XMLPUBFUN int XMLCALL + xmlExpGetLanguage(xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + const xmlChar**langList, + int len); +XMLPUBFUN int XMLCALL + xmlExpGetStart (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + const xmlChar**tokList, + int len); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpStringDerive(xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + const xmlChar *str, + int len); +XMLPUBFUN xmlExpNodePtr XMLCALL + xmlExpExpDerive (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + xmlExpNodePtr sub); +XMLPUBFUN int XMLCALL + xmlExpSubsume (xmlExpCtxtPtr ctxt, + xmlExpNodePtr expr, + xmlExpNodePtr sub); +XMLPUBFUN void XMLCALL + xmlExpDump (xmlBufferPtr buf, + xmlExpNodePtr expr); +#endif /* LIBXML_EXPR_ENABLED */ +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_REGEXP_ENABLED */ + +#endif /*__XML_REGEXP_H__ */ Added: include/libxml/xmlsave.h =================================================================== --- include/libxml/xmlsave.h (rev 0) +++ include/libxml/xmlsave.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,87 @@ +/* + * Summary: the XML document serializer + * Description: API to save document or subtree of document + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XMLSAVE_H__ +#define __XML_XMLSAVE_H__ + +#include +#include +#include +#include + +#ifdef LIBXML_OUTPUT_ENABLED +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlSaveOption: + * + * This is the set of XML save options that can be passed down + * to the xmlSaveToFd() and similar calls. + */ +typedef enum { + XML_SAVE_FORMAT = 1<<0, /* format save output */ + XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */ + XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */ + XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */ + XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */ + XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */ + XML_SAVE_AS_HTML = 1<<6 /* force HTML serialization on XML doc */ +} xmlSaveOption; + + +typedef struct _xmlSaveCtxt xmlSaveCtxt; +typedef xmlSaveCtxt *xmlSaveCtxtPtr; + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToFd (int fd, + const char *encoding, + int options); +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToFilename (const char *filename, + const char *encoding, + int options); + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToBuffer (xmlBufferPtr buffer, + const char *encoding, + int options); + +XMLPUBFUN xmlSaveCtxtPtr XMLCALL + xmlSaveToIO (xmlOutputWriteCallback iowrite, + xmlOutputCloseCallback ioclose, + void *ioctx, + const char *encoding, + int options); + +XMLPUBFUN long XMLCALL + xmlSaveDoc (xmlSaveCtxtPtr ctxt, + xmlDocPtr doc); +XMLPUBFUN long XMLCALL + xmlSaveTree (xmlSaveCtxtPtr ctxt, + xmlNodePtr node); + +XMLPUBFUN int XMLCALL + xmlSaveFlush (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSaveClose (xmlSaveCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSaveSetEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +XMLPUBFUN int XMLCALL + xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, + xmlCharEncodingOutputFunc escape); +#ifdef __cplusplus +} +#endif +#endif /* LIBXML_OUTPUT_ENABLED */ +#endif /* __XML_XMLSAVE_H__ */ + + Added: include/libxml/xmlschemas.h =================================================================== --- include/libxml/xmlschemas.h (rev 0) +++ include/libxml/xmlschemas.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,218 @@ +/* + * Summary: incomplete XML Schemas structure implementation + * Description: interface to the XML Schemas handling and schema validity + * checking, it is incomplete right now. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_H__ +#define __XML_SCHEMA_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This error codes are obsolete; not used any more. + */ +typedef enum { + XML_SCHEMAS_ERR_OK = 0, + XML_SCHEMAS_ERR_NOROOT = 1, + XML_SCHEMAS_ERR_UNDECLAREDELEM, + XML_SCHEMAS_ERR_NOTTOPLEVEL, + XML_SCHEMAS_ERR_MISSING, + XML_SCHEMAS_ERR_WRONGELEM, + XML_SCHEMAS_ERR_NOTYPE, + XML_SCHEMAS_ERR_NOROLLBACK, + XML_SCHEMAS_ERR_ISABSTRACT, + XML_SCHEMAS_ERR_NOTEMPTY, + XML_SCHEMAS_ERR_ELEMCONT, + XML_SCHEMAS_ERR_HAVEDEFAULT, + XML_SCHEMAS_ERR_NOTNILLABLE, + XML_SCHEMAS_ERR_EXTRACONTENT, + XML_SCHEMAS_ERR_INVALIDATTR, + XML_SCHEMAS_ERR_INVALIDELEM, + XML_SCHEMAS_ERR_NOTDETERMINIST, + XML_SCHEMAS_ERR_CONSTRUCT, + XML_SCHEMAS_ERR_INTERNAL, + XML_SCHEMAS_ERR_NOTSIMPLE, + XML_SCHEMAS_ERR_ATTRUNKNOWN, + XML_SCHEMAS_ERR_ATTRINVALID, + XML_SCHEMAS_ERR_VALUE, + XML_SCHEMAS_ERR_FACET, + XML_SCHEMAS_ERR_, + XML_SCHEMAS_ERR_XXX +} xmlSchemaValidError; + +/* +* ATTENTION: Change xmlSchemaSetValidOptions's check +* for invalid values, if adding to the validation +* options below. +*/ +/** + * xmlSchemaValidOption: + * + * This is the set of XML Schema validation options. + */ +typedef enum { + XML_SCHEMA_VAL_VC_I_CREATE = 1<<0 + /* Default/fixed: create an attribute node + * or an element's text node on the instance. + */ +} xmlSchemaValidOption; + +/* + XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1, + * assemble schemata using + * xsi:schemaLocation and + * xsi:noNamespaceSchemaLocation +*/ + +/** + * The schemas related types are kept internal + */ +typedef struct _xmlSchema xmlSchema; +typedef xmlSchema *xmlSchemaPtr; + +/** + * xmlSchemaValidityErrorFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of an error callback from an XSD validation + */ +typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3); + +/** + * xmlSchemaValidityWarningFunc: + * @ctx: the validation context + * @msg: the message + * @...: extra arguments + * + * Signature of a warning callback from an XSD validation + */ +typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...) ATTRIBUTE_PRINTF(2,3); + +/** + * A schemas validation context + */ +typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt; +typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr; + +typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt; +typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr; + +/* + * Interfaces for parsing. + */ +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewParserCtxt (const char *URL); +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewMemParserCtxt (const char *buffer, + int size); +XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL + xmlSchemaNewDocParserCtxt (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN void XMLCALL + xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt, + xmlSchemaValidityErrorFunc * err, + xmlSchemaValidityWarningFunc * warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt); + +XMLPUBFUN xmlSchemaPtr XMLCALL + xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt); +XMLPUBFUN void XMLCALL + xmlSchemaFree (xmlSchemaPtr schema); +#ifdef LIBXML_OUTPUT_ENABLED +XMLPUBFUN void XMLCALL + xmlSchemaDump (FILE *output, + xmlSchemaPtr schema); +#endif /* LIBXML_OUTPUT_ENABLED */ +/* + * Interfaces for validating + */ +XMLPUBFUN void XMLCALL + xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc err, + xmlSchemaValidityWarningFunc warn, + void *ctx); +XMLPUBFUN void XMLCALL + xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt, + xmlStructuredErrorFunc serror, + void *ctx); +XMLPUBFUN int XMLCALL + xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt, + xmlSchemaValidityErrorFunc *err, + xmlSchemaValidityWarningFunc *warn, + void **ctx); +XMLPUBFUN int XMLCALL + xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt, + int options); +XMLPUBFUN int XMLCALL + xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt); + +XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL + xmlSchemaNewValidCtxt (xmlSchemaPtr schema); +XMLPUBFUN void XMLCALL + xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt); +XMLPUBFUN int XMLCALL + xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt, + xmlDocPtr instance); +XMLPUBFUN int XMLCALL + xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt, + xmlNodePtr elem); +XMLPUBFUN int XMLCALL + xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt, + xmlParserInputBufferPtr input, + xmlCharEncoding enc, + xmlSAXHandlerPtr sax, + void *user_data); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt, + const char * filename, + int options); + +XMLPUBFUN xmlParserCtxtPtr XMLCALL + xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt); + +/* + * Interface to insert Schemas SAX validation in a SAX stream + */ +typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct; +typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr; + +XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL + xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt, + xmlSAXHandlerPtr *sax, + void **user_data); +XMLPUBFUN int XMLCALL + xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_H__ */ Added: include/libxml/xmlschemastypes.h =================================================================== --- include/libxml/xmlschemastypes.h (rev 0) +++ include/libxml/xmlschemastypes.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,151 @@ +/* + * Summary: implementation of XML Schema Datatypes + * Description: module providing the XML Schema Datatypes implementation + * both definition and validity checking + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + + +#ifndef __XML_SCHEMA_TYPES_H__ +#define __XML_SCHEMA_TYPES_H__ + +#include + +#ifdef LIBXML_SCHEMAS_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + XML_SCHEMA_WHITESPACE_UNKNOWN = 0, + XML_SCHEMA_WHITESPACE_PRESERVE = 1, + XML_SCHEMA_WHITESPACE_REPLACE = 2, + XML_SCHEMA_WHITESPACE_COLLAPSE = 3 +} xmlSchemaWhitespaceValueType; + +XMLPUBFUN void XMLCALL + xmlSchemaInitTypes (void); +XMLPUBFUN void XMLCALL + xmlSchemaCleanupTypes (void); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetPredefinedType (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN int XMLCALL + xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val); +XMLPUBFUN int XMLCALL + xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFacet (xmlSchemaTypePtr base, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val); +XMLPUBFUN int XMLCALL + xmlSchemaValidateFacetWhtsp (xmlSchemaFacetPtr facet, + xmlSchemaWhitespaceValueType fws, + xmlSchemaValType valType, + const xmlChar *value, + xmlSchemaValPtr val, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN void XMLCALL + xmlSchemaFreeValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaFacetPtr XMLCALL + xmlSchemaNewFacet (void); +XMLPUBFUN int XMLCALL + xmlSchemaCheckFacet (xmlSchemaFacetPtr facet, + xmlSchemaTypePtr typeDecl, + xmlSchemaParserCtxtPtr ctxt, + const xmlChar *name); +XMLPUBFUN void XMLCALL + xmlSchemaFreeFacet (xmlSchemaFacetPtr facet); +XMLPUBFUN int XMLCALL + xmlSchemaCompareValues (xmlSchemaValPtr x, + xmlSchemaValPtr y); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaTypePtr type); +XMLPUBFUN int XMLCALL + xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacetPtr facet, + const xmlChar *value, + unsigned long actualLen, + unsigned long *expectedLen); +XMLPUBFUN xmlSchemaTypePtr XMLCALL + xmlSchemaGetBuiltInType (xmlSchemaValType type); +XMLPUBFUN int XMLCALL + xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type, + int facetType); +XMLPUBFUN xmlChar * XMLCALL + xmlSchemaCollapseString (const xmlChar *value); +XMLPUBFUN xmlChar * XMLCALL + xmlSchemaWhiteSpaceReplace (const xmlChar *value); +XMLPUBFUN unsigned long XMLCALL + xmlSchemaGetFacetValueAsULong (xmlSchemaFacetPtr facet); +XMLPUBFUN int XMLCALL + xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type, + xmlSchemaFacetPtr facet, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length); +XMLPUBFUN int XMLCALL + xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, + xmlSchemaValType valType, + const xmlChar *value, + xmlSchemaValPtr val, + unsigned long *length, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN int XMLCALL + xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type, + const xmlChar *value, + xmlSchemaValPtr *val, + xmlNodePtr node); +XMLPUBFUN int XMLCALL + xmlSchemaGetCanonValue (xmlSchemaValPtr val, + const xmlChar **retValue); +XMLPUBFUN int XMLCALL + xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val, + const xmlChar **retValue, + xmlSchemaWhitespaceValueType ws); +XMLPUBFUN int XMLCALL + xmlSchemaValueAppend (xmlSchemaValPtr prev, + xmlSchemaValPtr cur); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaValueGetNext (xmlSchemaValPtr cur); +XMLPUBFUN const xmlChar * XMLCALL + xmlSchemaValueGetAsString (xmlSchemaValPtr val); +XMLPUBFUN int XMLCALL + xmlSchemaValueGetAsBoolean (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaNewStringValue (xmlSchemaValType type, + const xmlChar *value); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaNewNOTATIONValue (const xmlChar *name, + const xmlChar *ns); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaNewQNameValue (const xmlChar *namespaceName, + const xmlChar *localName); +XMLPUBFUN int XMLCALL + xmlSchemaCompareValuesWhtsp (xmlSchemaValPtr x, + xmlSchemaWhitespaceValueType xws, + xmlSchemaValPtr y, + xmlSchemaWhitespaceValueType yws); +XMLPUBFUN xmlSchemaValPtr XMLCALL + xmlSchemaCopyValue (xmlSchemaValPtr val); +XMLPUBFUN xmlSchemaValType XMLCALL + xmlSchemaGetValType (xmlSchemaValPtr val); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_SCHEMAS_ENABLED */ +#endif /* __XML_SCHEMA_TYPES_H__ */ Added: include/libxml/xmlstring.h =================================================================== --- include/libxml/xmlstring.h (rev 0) +++ include/libxml/xmlstring.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,140 @@ +/* + * Summary: set of routines to process strings + * Description: type and interfaces needed for the internal string handling + * of the library, especially UTF8 processing. + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_STRING_H__ +#define __XML_STRING_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * xmlChar: + * + * This is a basic byte in an UTF-8 encoded string. + * It's unsigned allowing to pinpoint case where char * are assigned + * to xmlChar * (possibly making serialization back impossible). + */ +typedef unsigned char xmlChar; + +/** + * BAD_CAST: + * + * Macro to cast a string to an xmlChar * when one know its safe. + */ +#define BAD_CAST (xmlChar *) + +/* + * xmlChar handling + */ +XMLPUBFUN xmlChar * XMLCALL + xmlStrdup (const xmlChar *cur); +XMLPUBFUN xmlChar * XMLCALL + xmlStrndup (const xmlChar *cur, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlCharStrndup (const char *cur, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlCharStrdup (const char *cur); +XMLPUBFUN xmlChar * XMLCALL + xmlStrsub (const xmlChar *str, + int start, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrchr (const xmlChar *str, + xmlChar val); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrstr (const xmlChar *str, + const xmlChar *val); +XMLPUBFUN const xmlChar * XMLCALL + xmlStrcasestr (const xmlChar *str, + xmlChar *val); +XMLPUBFUN int XMLCALL + xmlStrcmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrncmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrcasecmp (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrncasecmp (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrEqual (const xmlChar *str1, + const xmlChar *str2); +XMLPUBFUN int XMLCALL + xmlStrQEqual (const xmlChar *pref, + const xmlChar *name, + const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlStrlen (const xmlChar *str); +XMLPUBFUN xmlChar * XMLCALL + xmlStrcat (xmlChar *cur, + const xmlChar *add); +XMLPUBFUN xmlChar * XMLCALL + xmlStrncat (xmlChar *cur, + const xmlChar *add, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlStrncatNew (const xmlChar *str1, + const xmlChar *str2, + int len); +XMLPUBFUN int XMLCALL + xmlStrPrintf (xmlChar *buf, + int len, + const xmlChar *msg, + ...); +XMLPUBFUN int XMLCALL + xmlStrVPrintf (xmlChar *buf, + int len, + const xmlChar *msg, + va_list ap); + +XMLPUBFUN int XMLCALL + xmlGetUTF8Char (const unsigned char *utf, + int *len); +XMLPUBFUN int XMLCALL + xmlCheckUTF8 (const unsigned char *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Strsize (const xmlChar *utf, + int len); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strndup (const xmlChar *utf, + int len); +XMLPUBFUN const xmlChar * XMLCALL + xmlUTF8Strpos (const xmlChar *utf, + int pos); +XMLPUBFUN int XMLCALL + xmlUTF8Strloc (const xmlChar *utf, + const xmlChar *utfchar); +XMLPUBFUN xmlChar * XMLCALL + xmlUTF8Strsub (const xmlChar *utf, + int start, + int len); +XMLPUBFUN int XMLCALL + xmlUTF8Strlen (const xmlChar *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Size (const xmlChar *utf); +XMLPUBFUN int XMLCALL + xmlUTF8Charcmp (const xmlChar *utf1, + const xmlChar *utf2); + +#ifdef __cplusplus +} +#endif +#endif /* __XML_STRING_H__ */ Added: include/libxml/xmlunicode.h =================================================================== --- include/libxml/xmlunicode.h (rev 0) +++ include/libxml/xmlunicode.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,202 @@ +/* + * Summary: Unicode character APIs + * Description: API for the Unicode character APIs + * + * This file is automatically generated from the + * UCS description files of the Unicode Character Database + * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html + * using the genUnicode.py Python script. + * + * Generation date: Mon Mar 27 11:09:52 2006 + * Sources: Blocks-4.0.1.txt UnicodeData-4.0.1.txt + * Author: Daniel Veillard + */ + +#ifndef __XML_UNICODE_H__ +#define __XML_UNICODE_H__ + +#include + +#ifdef LIBXML_UNICODE_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +XMLPUBFUN int XMLCALL xmlUCSIsAegeanNumbers (int code); +XMLPUBFUN int XMLCALL xmlUCSIsAlphabeticPresentationForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArmenian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsArrows (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBasicLatin (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBengali (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBlockElements (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBopomofo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBopomofoExtended (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBoxDrawing (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBraillePatterns (int code); +XMLPUBFUN int XMLCALL xmlUCSIsBuhid (int code); +XMLPUBFUN int XMLCALL xmlUCSIsByzantineMusicalSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibility (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKRadicalsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKSymbolsandPunctuation (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCherokee (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarks (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarksforSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningHalfMarks (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCombiningMarksforSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsControlPictures (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCurrencySymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCypriotSyllabary (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCyrillic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCyrillicSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDeseret (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDevanagari (int code); +XMLPUBFUN int XMLCALL xmlUCSIsDingbats (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEnclosedAlphanumerics (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEnclosedCJKLettersandMonths (int code); +XMLPUBFUN int XMLCALL xmlUCSIsEthiopic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeneralPunctuation (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeometricShapes (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGeorgian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGothic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreek (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreekExtended (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGreekandCoptic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGujarati (int code); +XMLPUBFUN int XMLCALL xmlUCSIsGurmukhi (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHalfwidthandFullwidthForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulCompatibilityJamo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulJamo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHangulSyllables (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHanunoo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHebrew (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHighPrivateUseSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHighSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsHiragana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsIPAExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsIdeographicDescriptionCharacters (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKanbun (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKangxiRadicals (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKannada (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKatakana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKatakanaPhoneticExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKhmer (int code); +XMLPUBFUN int XMLCALL xmlUCSIsKhmerSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLao (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatin1Supplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedAdditional (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLetterlikeSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLimbu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLinearBIdeograms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLinearBSyllabary (int code); +XMLPUBFUN int XMLCALL xmlUCSIsLowSurrogates (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMalayalam (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMathematicalAlphanumericSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMathematicalOperators (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbolsandArrows (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousTechnical (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMongolian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMusicalSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsMyanmar (int code); +XMLPUBFUN int XMLCALL xmlUCSIsNumberForms (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOgham (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOldItalic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOpticalCharacterRecognition (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOriya (int code); +XMLPUBFUN int XMLCALL xmlUCSIsOsmanya (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPhoneticExtensions (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPrivateUse (int code); +XMLPUBFUN int XMLCALL xmlUCSIsPrivateUseArea (int code); +XMLPUBFUN int XMLCALL xmlUCSIsRunic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsShavian (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSinhala (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSmallFormVariants (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSpacingModifierLetters (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSpecials (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSuperscriptsandSubscripts (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementalMathematicalOperators (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaA (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaB (int code); +XMLPUBFUN int XMLCALL xmlUCSIsSyriac (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTagalog (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTagbanwa (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTags (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTaiLe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTaiXuanJingSymbols (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTamil (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTelugu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsThaana (int code); +XMLPUBFUN int XMLCALL xmlUCSIsThai (int code); +XMLPUBFUN int XMLCALL xmlUCSIsTibetan (int code); +XMLPUBFUN int XMLCALL xmlUCSIsUgaritic (int code); +XMLPUBFUN int XMLCALL xmlUCSIsUnifiedCanadianAboriginalSyllabics (int code); +XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectors (int code); +XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectorsSupplement (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYiRadicals (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYiSyllables (int code); +XMLPUBFUN int XMLCALL xmlUCSIsYijingHexagramSymbols (int code); + +XMLPUBFUN int XMLCALL xmlUCSIsBlock (int code, const char *block); + +XMLPUBFUN int XMLCALL xmlUCSIsCatC (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCf (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatCs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatL (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLm (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLt (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatLu (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatM (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatMn (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatN (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNd (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatNo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatP (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPd (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPe (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPf (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPi (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatPs (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatS (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSc (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSk (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSm (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatSo (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZ (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZl (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZp (int code); +XMLPUBFUN int XMLCALL xmlUCSIsCatZs (int code); + +XMLPUBFUN int XMLCALL xmlUCSIsCat (int code, const char *cat); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_UNICODE_ENABLED */ + +#endif /* __XML_UNICODE_H__ */ Added: include/libxml/xmlversion.h =================================================================== --- include/libxml/xmlversion.h (rev 0) +++ include/libxml/xmlversion.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,458 @@ +/* + * Summary: compile-time version informations + * Description: compile-time version informations for the XML library + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_VERSION_H__ +#define __XML_VERSION_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * use those to be sure nothing nasty will happen if + * your library and includes mismatch + */ +#ifndef LIBXML2_COMPILING_MSCCDEF +XMLPUBFUN void XMLCALL xmlCheckVersion(int version); +#endif /* LIBXML2_COMPILING_MSCCDEF */ + +/** + * LIBXML_DOTTED_VERSION: + * + * the version string like "1.2.3" + */ +#define LIBXML_DOTTED_VERSION "2.7.3" + +/** + * LIBXML_VERSION: + * + * the version number: 1.2.3 value is 10203 + */ +#define LIBXML_VERSION 20703 + +/** + * LIBXML_VERSION_STRING: + * + * the version number string, 1.2.3 value is "10203" + */ +#define LIBXML_VERSION_STRING "20703" + +/** + * LIBXML_VERSION_EXTRA: + * + * extra version information, used to show a CVS compilation + */ +#define LIBXML_VERSION_EXTRA "" + +/** + * LIBXML_TEST_VERSION: + * + * Macro to check that the libxml version in use is compatible with + * the version the software has been compiled against + */ +#define LIBXML_TEST_VERSION xmlCheckVersion(20703); + +#ifndef VMS +#if 0 +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO +#else +/** + * WITHOUT_TRIO: + * + * defined if the trio support should not be configured in + */ +#define WITHOUT_TRIO +#endif +#else /* VMS */ +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO 1 +#endif /* VMS */ + +/** + * LIBXML_THREAD_ENABLED: + * + * Whether the thread support is configured in + */ +#if 1 +#if defined(_REENTRANT) || defined(__MT__) || \ + (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L)) +#define LIBXML_THREAD_ENABLED +#endif +#endif + +/** + * LIBXML_TREE_ENABLED: + * + * Whether the DOM like tree manipulation API support is configured in + */ +#if 1 +#define LIBXML_TREE_ENABLED +#endif + +/** + * LIBXML_OUTPUT_ENABLED: + * + * Whether the serialization/saving support is configured in + */ +#if 1 +#define LIBXML_OUTPUT_ENABLED +#endif + +/** + * LIBXML_PUSH_ENABLED: + * + * Whether the push parsing interfaces are configured in + */ +#if 1 +#define LIBXML_PUSH_ENABLED +#endif + +/** + * LIBXML_READER_ENABLED: + * + * Whether the xmlReader parsing interface is configured in + */ +#if 1 +#define LIBXML_READER_ENABLED +#endif + +/** + * LIBXML_PATTERN_ENABLED: + * + * Whether the xmlPattern node selection interface is configured in + */ +#if 1 +#define LIBXML_PATTERN_ENABLED +#endif + +/** + * LIBXML_WRITER_ENABLED: + * + * Whether the xmlWriter saving interface is configured in + */ +#if 1 +#define LIBXML_WRITER_ENABLED +#endif + +/** + * LIBXML_SAX1_ENABLED: + * + * Whether the older SAX1 interface is configured in + */ +#if 1 +#define LIBXML_SAX1_ENABLED +#endif + +/** + * LIBXML_FTP_ENABLED: + * + * Whether the FTP support is configured in + */ +#if 1 +#define LIBXML_FTP_ENABLED +#endif + +/** + * LIBXML_HTTP_ENABLED: + * + * Whether the HTTP support is configured in + */ +#if 1 +#define LIBXML_HTTP_ENABLED +#endif + +/** + * LIBXML_VALID_ENABLED: + * + * Whether the DTD validation support is configured in + */ +#if 1 +#define LIBXML_VALID_ENABLED +#endif + +/** + * LIBXML_HTML_ENABLED: + * + * Whether the HTML support is configured in + */ +#if 1 +#define LIBXML_HTML_ENABLED +#endif + +/** + * LIBXML_LEGACY_ENABLED: + * + * Whether the deprecated APIs are compiled in for compatibility + */ +#if 1 +#define LIBXML_LEGACY_ENABLED +#endif + +/** + * LIBXML_C14N_ENABLED: + * + * Whether the Canonicalization support is configured in + */ +#if 1 +#define LIBXML_C14N_ENABLED +#endif + +/** + * LIBXML_CATALOG_ENABLED: + * + * Whether the Catalog support is configured in + */ +#if 1 +#define LIBXML_CATALOG_ENABLED +#endif + +/** + * LIBXML_DOCB_ENABLED: + * + * Whether the SGML Docbook support is configured in + */ +#if 1 +#define LIBXML_DOCB_ENABLED +#endif + +/** + * LIBXML_XPATH_ENABLED: + * + * Whether XPath is configured in + */ +#if 1 +#define LIBXML_XPATH_ENABLED +#endif + +/** + * LIBXML_XPTR_ENABLED: + * + * Whether XPointer is configured in + */ +#if 1 +#define LIBXML_XPTR_ENABLED +#endif + +/** + * LIBXML_XINCLUDE_ENABLED: + * + * Whether XInclude is configured in + */ +#if 1 +#define LIBXML_XINCLUDE_ENABLED +#endif + +/** + * LIBXML_ICONV_ENABLED: + * + * Whether iconv support is available + */ +#if 1 +#define LIBXML_ICONV_ENABLED +#endif + +/** + * LIBXML_ISO8859X_ENABLED: + * + * Whether ISO-8859-* support is made available in case iconv is not + */ +#if 0 +#define LIBXML_ISO8859X_ENABLED +#endif + +/** + * LIBXML_DEBUG_ENABLED: + * + * Whether Debugging module is configured in + */ +#if 1 +#define LIBXML_DEBUG_ENABLED +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * Whether the memory debugging is configured in + */ +#if 0 +#define DEBUG_MEMORY_LOCATION +#endif + +/** + * LIBXML_DEBUG_RUNTIME: + * + * Whether the runtime debugging is configured in + */ +#if 0 +#define LIBXML_DEBUG_RUNTIME +#endif + +/** + * LIBXML_UNICODE_ENABLED: + * + * Whether the Unicode related interfaces are compiled in + */ +#if 1 +#define LIBXML_UNICODE_ENABLED +#endif + +/** + * LIBXML_REGEXP_ENABLED: + * + * Whether the regular expressions interfaces are compiled in + */ +#if 1 +#define LIBXML_REGEXP_ENABLED +#endif + +/** + * LIBXML_AUTOMATA_ENABLED: + * + * Whether the automata interfaces are compiled in + */ +#if 1 +#define LIBXML_AUTOMATA_ENABLED +#endif + +/** + * LIBXML_EXPR_ENABLED: + * + * Whether the formal expressions interfaces are compiled in + */ +#if 1 +#define LIBXML_EXPR_ENABLED +#endif + +/** + * LIBXML_SCHEMAS_ENABLED: + * + * Whether the Schemas validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMAS_ENABLED +#endif + +/** + * LIBXML_SCHEMATRON_ENABLED: + * + * Whether the Schematron validation interfaces are compiled in + */ +#if 1 +#define LIBXML_SCHEMATRON_ENABLED +#endif + +/** + * LIBXML_MODULES_ENABLED: + * + * Whether the module interfaces are compiled in + */ +#if 1 +#define LIBXML_MODULES_ENABLED +/** + * LIBXML_MODULE_EXTENSION: + * + * the string suffix used by dynamic modules (usually shared libraries) + */ +#define LIBXML_MODULE_EXTENSION ".dll" +#endif + +/** + * LIBXML_ZLIB_ENABLED: + * + * Whether the Zlib support is compiled in + */ +#if 1 +#define LIBXML_ZLIB_ENABLED +#endif + +#ifdef __GNUC__ +#ifdef HAVE_ANSIDECL_H +#include +#endif + +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ + +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED __attribute__((unused)) +#endif + +/** + * ATTRIBUTE_ALLOC_SIZE: + * + * Macro used to indicate to GCC this is an allocator function + */ + +#ifndef ATTRIBUTE_ALLOC_SIZE +# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) +# define ATTRIBUTE_ALLOC_SIZE(x) __attribute__((alloc_size(x))) +# else +# define ATTRIBUTE_ALLOC_SIZE(x) +# endif +#else +# define ATTRIBUTE_ALLOC_SIZE(x) +#endif + +/** + * ATTRIBUTE_PRINTF: + * + * Macro used to indicate to GCC the parameter are printf like + */ + +#ifndef ATTRIBUTE_PRINTF +# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) +# define ATTRIBUTE_PRINTF(fmt,args) __attribute__((__format__(__printf__,fmt,args))) +# else +# define ATTRIBUTE_PRINTF(fmt,args) +# endif +#else +# define ATTRIBUTE_PRINTF(fmt,args) +#endif + +#else /* ! __GNUC__ */ +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ +#define ATTRIBUTE_UNUSED +/** + * ATTRIBUTE_ALLOC_SIZE: + * + * Macro used to indicate to GCC this is an allocator function + */ +#define ATTRIBUTE_ALLOC_SIZE(x) +/** + * ATTRIBUTE_PRINTF: + * + * Macro used to indicate to GCC the parameter are printf like + */ +#define ATTRIBUTE_PRINTF(fmt,args) +#endif /* __GNUC__ */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif + + Added: include/libxml/xmlwin32version.h =================================================================== --- include/libxml/xmlwin32version.h (rev 0) +++ include/libxml/xmlwin32version.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,242 @@ +/* + * Summary: compile-time version informations on Windows + * Description: compile-time version informations for the XML library + * when compiled on the Windows platform + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_VERSION_H__ +#define __XML_VERSION_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * use those to be sure nothing nasty will happen if + * your library and includes mismatch + */ +#ifndef LIBXML2_COMPILING_MSCCDEF +extern void xmlCheckVersion(int version); +#endif /* LIBXML2_COMPILING_MSCCDEF */ + +/** + * LIBXML_DOTTED_VERSION: + * + * the version string like "1.2.3" + */ +#define LIBXML_DOTTED_VERSION "2.4.26" + +/** + * LIBXML_VERSION: + * + * the version number: 1.2.3 value is 1002003 + */ +#define LIBXML_VERSION 20426 + +/** + * LIBXML_VERSION_STRING: + * + * the version number string, 1.2.3 value is "1002003" + */ +#define LIBXML_VERSION_STRING "20426" + +/** + * LIBXML_TEST_VERSION: + * + * Macro to check that the libxml version in use is compatible with + * the version the software has been compiled against + */ +#define LIBXML_TEST_VERSION xmlCheckVersion(20426); + +#if 0 +/** + * WITH_TRIO: + * + * defined if the trio support need to be configured in + */ +#define WITH_TRIO +#else +/** + * WITHOUT_TRIO: + * + * defined if the trio support should not be configured in + */ +#define WITHOUT_TRIO +#endif + +/** + * LIBXML_THREAD_ENABLED: + * + * Whether the thread support is configured in + */ +#if 0 +#define LIBXML_THREAD_ENABLED +#endif + +/** + * LIBXML_FTP_ENABLED: + * + * Whether the FTP support is configured in + */ +#if 1 +#define LIBXML_FTP_ENABLED +#endif + +/** + * LIBXML_HTTP_ENABLED: + * + * Whether the HTTP support is configured in + */ +#if 1 +#define LIBXML_HTTP_ENABLED +#endif + +/** + * LIBXML_HTML_ENABLED: + * + * Whether the HTML support is configured in + */ +#if 1 +#define LIBXML_HTML_ENABLED +#endif + +/** + * LIBXML_CATALOG_ENABLED: + * + * Whether the Catalog support is configured in + */ +#if 1 +#define LIBXML_CATALOG_ENABLED +#endif + +/** + * LIBXML_DOCB_ENABLED: + * + * Whether the SGML Docbook support is configured in + */ +#if 1 +#define LIBXML_DOCB_ENABLED +#endif + +/** + * LIBXML_XPATH_ENABLED: + * + * Whether XPath is configured in + */ +#if 1 +#define LIBXML_XPATH_ENABLED +#endif + +/** + * LIBXML_XPTR_ENABLED: + * + * Whether XPointer is configured in + */ +#if 1 +#define LIBXML_XPTR_ENABLED +#endif + +/** + * LIBXML_C14N_ENABLED: + * + * Whether the Canonicalization support is configured in + */ +#if 0 +#define LIBXML_C14N_ENABLED +#endif + +/** + * LIBXML_XINCLUDE_ENABLED: + * + * Whether XInclude is configured in + */ +#if 1 +#define LIBXML_XINCLUDE_ENABLED +#endif + +/** + * LIBXML_ICONV_ENABLED: + * + * Whether iconv support is available + */ +#if 0 +#define LIBXML_ICONV_ENABLED +#endif + +/** + * LIBXML_DEBUG_ENABLED: + * + * Whether Debugging module is configured in + */ +#if 1 +#define LIBXML_DEBUG_ENABLED +#endif + +/** + * DEBUG_MEMORY_LOCATION: + * + * Whether the memory debugging is configured in + */ +#if 0 +#define DEBUG_MEMORY_LOCATION +#endif + +/** + * LIBXML_DLL_IMPORT: + * + * Used on Windows (MS C compiler only) to declare a variable as + * imported from the library. This macro should be empty when compiling + * libxml itself. It should expand to __declspec(dllimport) + * when the client code includes this header, and that only if the client + * links dynamically against libxml. + * For this to work, we need three macros. One tells us which compiler is + * being used and luckily the compiler defines such a thing: _MSC_VER. The + * second macro tells us if we are compiling libxml or the client code and + * we define the macro IN_LIBXML on the compiler's command line for this + * purpose. The third macro, LIBXML_STATIC, must be defined by any client + * code which links against libxml statically. + */ +#ifndef LIBXML_DLL_IMPORT +#if defined(_MSC_VER) && !defined(IN_LIBXML) && !defined(LIBXML_STATIC) +#define LIBXML_DLL_IMPORT __declspec(dllimport) +#else +#define LIBXML_DLL_IMPORT +#endif +#endif + +/** + * ATTRIBUTE_UNUSED: + * + * Macro used to signal to GCC unused function parameters + */ +#ifdef __GNUC__ +#ifdef HAVE_ANSIDECL_H +#include +#endif +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED +#endif +#else +#define ATTRIBUTE_UNUSED +#endif + +/* + * #pragma comment(lib, "iconv.lib") + * + * pragma understood my MS compiler which enables a conditional link with + * iconv. + */ +#ifdef _MSC_VER +#if defined LIBXML_ICONV_ENABLED && !defined LIBXML2_COMPILING_MSCCDEF +#pragma comment(lib, "iconv.lib") +#endif +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif Added: include/libxml/xmlwriter.h =================================================================== --- include/libxml/xmlwriter.h (rev 0) +++ include/libxml/xmlwriter.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,485 @@ + +/* + * Summary: text writing API for XML + * Description: text writing API for XML + * + * Copy: See Copyright for the status of this software. + * + * Author: Alfred Mickautsch + */ + +#ifndef __XML_XMLWRITER_H__ +#define __XML_XMLWRITER_H__ + +#include + +#ifdef LIBXML_WRITER_ENABLED + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _xmlTextWriter xmlTextWriter; + typedef xmlTextWriter *xmlTextWriterPtr; + +/* + * Constructors & Destructor + */ + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriter(xmlOutputBufferPtr out); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterFilename(const char *uri, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterMemory(xmlBufferPtr buf, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterDoc(xmlDocPtr * doc, int compression); + XMLPUBFUN xmlTextWriterPtr XMLCALL + xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, + int compression); + XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer); + +/* + * Functions + */ + + +/* + * Document + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDocument(xmlTextWriterPtr writer, + const char *version, + const char *encoding, + const char *standalone); + XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr + writer); + +/* + * Comments + */ + XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr + writer); + XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, + const char *format, ...) + ATTRIBUTE_PRINTF(2,3); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(2,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr + writer, + const xmlChar * + content); + +/* + * Elements + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI); + XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr + writer); + +/* + * Elements conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + ATTRIBUTE_PRINTF(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...) + ATTRIBUTE_PRINTF(5,6); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(5,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * Text + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, + const char *format, ...) + ATTRIBUTE_PRINTF(2,3); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, + const char *format, va_list argptr) + ATTRIBUTE_PRINTF(2,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, + const xmlChar * content, int len); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteRaw(xmlTextWriterPtr writer, + const xmlChar * content); + XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr + writer, + const char + *format, ...) + ATTRIBUTE_PRINTF(2,3); + XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr + writer, + const char + *format, + va_list argptr) + ATTRIBUTE_PRINTF(2,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer, + const xmlChar * + content); + XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer, + const char *data, + int start, int len); + XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, + const char *data, + int start, int len); + +/* + * Attributes + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartAttribute(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI); + XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr + writer); + +/* + * Attributes conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + ATTRIBUTE_PRINTF(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr + writer, + const xmlChar * name, + const xmlChar * + content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, ...) + ATTRIBUTE_PRINTF(5,6); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, + const xmlChar * prefix, + const xmlChar * name, + const xmlChar * namespaceURI, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(5,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr + writer, + const xmlChar * + prefix, + const xmlChar * + name, + const xmlChar * + namespaceURI, + const xmlChar * + content); + +/* + * PI's + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartPI(xmlTextWriterPtr writer, + const xmlChar * target); + XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer); + +/* + * PI conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, ...) + ATTRIBUTE_PRINTF(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, + const xmlChar * target, + const char *format, va_list argptr) + ATTRIBUTE_PRINTF(3,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWritePI(xmlTextWriterPtr writer, + const xmlChar * target, + const xmlChar * content); + +/** + * xmlTextWriterWriteProcessingInstruction: + * + * This macro maps to xmlTextWriterWritePI + */ +#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI + +/* + * CDATA + */ + XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer); + XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer); + +/* + * CDATA conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, + const char *format, ...) + ATTRIBUTE_PRINTF(2,3); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, + const char *format, va_list argptr) + ATTRIBUTE_PRINTF(2,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, + const xmlChar * content); + +/* + * DTD + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer); + +/* + * DTD conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, ...) + ATTRIBUTE_PRINTF(5,6); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const char *format, va_list argptr) + ATTRIBUTE_PRINTF(5,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTD(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * subset); + +/** + * xmlTextWriterWriteDocType: + * + * this macro maps to xmlTextWriterWriteDTD + */ +#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD + +/* + * DTD element definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr + writer); + +/* + * DTD element definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + ATTRIBUTE_PRINTF(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD attribute list definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr + writer); + +/* + * DTD attribute list definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, ...) + ATTRIBUTE_PRINTF(3,4); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, + const xmlChar * name, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(3,0); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr + writer, + const xmlChar * + name, + const xmlChar * + content); + +/* + * DTD entity definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, + int pe, const xmlChar * name); + XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr + writer); + +/* + * DTD entity definition conveniency functions + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, ...) + ATTRIBUTE_PRINTF(4,5); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const char *format, + va_list argptr) + ATTRIBUTE_PRINTF(4,0); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * content); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, + int pe, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * ndataid); + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr + writer, + const xmlChar * pubid, + const xmlChar * sysid, + const xmlChar * + ndataid); + XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr + writer, int pe, + const xmlChar * name, + const xmlChar * + pubid, + const xmlChar * + sysid, + const xmlChar * + ndataid, + const xmlChar * + content); + +/* + * DTD notation definition + */ + XMLPUBFUN int XMLCALL + xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, + const xmlChar * name, + const xmlChar * pubid, + const xmlChar * sysid); + +/* + * Indentation + */ + XMLPUBFUN int XMLCALL + xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent); + XMLPUBFUN int XMLCALL + xmlTextWriterSetIndentString(xmlTextWriterPtr writer, + const xmlChar * str); + +/* + * misc + */ + XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_WRITER_ENABLED */ + +#endif /* __XML_XMLWRITER_H__ */ Added: include/libxml/xpath.h =================================================================== --- include/libxml/xpath.h (rev 0) +++ include/libxml/xpath.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,546 @@ +/* + * Summary: XML Path Language implementation + * Description: API for the XML Path Language implementation + * + * XML Path Language implementation + * XPath is a language for addressing parts of an XML document, + * designed to be used by both XSLT and XPointer + * http://www.w3.org/TR/xpath + * + * Implements + * W3C Recommendation 16 November 1999 + * http://www.w3.org/TR/1999/REC-xpath-19991116 + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_H__ +#define __XML_XPATH_H__ + +#include + +#ifdef LIBXML_XPATH_ENABLED + +#include +#include +#include +#endif /* LIBXML_XPATH_ENABLED */ + +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +#ifdef __cplusplus +extern "C" { +#endif +#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */ + +#ifdef LIBXML_XPATH_ENABLED + +typedef struct _xmlXPathContext xmlXPathContext; +typedef xmlXPathContext *xmlXPathContextPtr; +typedef struct _xmlXPathParserContext xmlXPathParserContext; +typedef xmlXPathParserContext *xmlXPathParserContextPtr; + +/** + * The set of XPath error codes. + */ + +typedef enum { + XPATH_EXPRESSION_OK = 0, + XPATH_NUMBER_ERROR, + XPATH_UNFINISHED_LITERAL_ERROR, + XPATH_START_LITERAL_ERROR, + XPATH_VARIABLE_REF_ERROR, + XPATH_UNDEF_VARIABLE_ERROR, + XPATH_INVALID_PREDICATE_ERROR, + XPATH_EXPR_ERROR, + XPATH_UNCLOSED_ERROR, + XPATH_UNKNOWN_FUNC_ERROR, + XPATH_INVALID_OPERAND, + XPATH_INVALID_TYPE, + XPATH_INVALID_ARITY, + XPATH_INVALID_CTXT_SIZE, + XPATH_INVALID_CTXT_POSITION, + XPATH_MEMORY_ERROR, + XPTR_SYNTAX_ERROR, + XPTR_RESOURCE_ERROR, + XPTR_SUB_RESOURCE_ERROR, + XPATH_UNDEF_PREFIX_ERROR, + XPATH_ENCODING_ERROR, + XPATH_INVALID_CHAR_ERROR, + XPATH_INVALID_CTXT +} xmlXPathError; + +/* + * A node-set (an unordered collection of nodes without duplicates). + */ +typedef struct _xmlNodeSet xmlNodeSet; +typedef xmlNodeSet *xmlNodeSetPtr; +struct _xmlNodeSet { + int nodeNr; /* number of nodes in the set */ + int nodeMax; /* size of the array as allocated */ + xmlNodePtr *nodeTab; /* array of nodes in no particular order */ + /* @@ with_ns to check wether namespace nodes should be looked at @@ */ +}; + +/* + * An expression is evaluated to yield an object, which + * has one of the following four basic types: + * - node-set + * - boolean + * - number + * - string + * + * @@ XPointer will add more types ! + */ + +typedef enum { + XPATH_UNDEFINED = 0, + XPATH_NODESET = 1, + XPATH_BOOLEAN = 2, + XPATH_NUMBER = 3, + XPATH_STRING = 4, + XPATH_POINT = 5, + XPATH_RANGE = 6, + XPATH_LOCATIONSET = 7, + XPATH_USERS = 8, + XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */ +} xmlXPathObjectType; + +typedef struct _xmlXPathObject xmlXPathObject; +typedef xmlXPathObject *xmlXPathObjectPtr; +struct _xmlXPathObject { + xmlXPathObjectType type; + xmlNodeSetPtr nodesetval; + int boolval; + double floatval; + xmlChar *stringval; + void *user; + int index; + void *user2; + int index2; +}; + +/** + * xmlXPathConvertFunc: + * @obj: an XPath object + * @type: the number of the target type + * + * A conversion function is associated to a type and used to cast + * the new type to primitive values. + * + * Returns -1 in case of error, 0 otherwise + */ +typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type); + +/* + * Extra type: a name and a conversion function. + */ + +typedef struct _xmlXPathType xmlXPathType; +typedef xmlXPathType *xmlXPathTypePtr; +struct _xmlXPathType { + const xmlChar *name; /* the type name */ + xmlXPathConvertFunc func; /* the conversion function */ +}; + +/* + * Extra variable: a name and a value. + */ + +typedef struct _xmlXPathVariable xmlXPathVariable; +typedef xmlXPathVariable *xmlXPathVariablePtr; +struct _xmlXPathVariable { + const xmlChar *name; /* the variable name */ + xmlXPathObjectPtr value; /* the value */ +}; + +/** + * xmlXPathEvalFunc: + * @ctxt: an XPath parser context + * @nargs: the number of arguments passed to the function + * + * An XPath evaluation function, the parameters are on the XPath context stack. + */ + +typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, + int nargs); + +/* + * Extra function: a name and a evaluation function. + */ + +typedef struct _xmlXPathFunct xmlXPathFunct; +typedef xmlXPathFunct *xmlXPathFuncPtr; +struct _xmlXPathFunct { + const xmlChar *name; /* the function name */ + xmlXPathEvalFunc func; /* the evaluation function */ +}; + +/** + * xmlXPathAxisFunc: + * @ctxt: the XPath interpreter context + * @cur: the previous node being explored on that axis + * + * An axis traversal function. To traverse an axis, the engine calls + * the first time with cur == NULL and repeat until the function returns + * NULL indicating the end of the axis traversal. + * + * Returns the next node in that axis or NULL if at the end of the axis. + */ + +typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr cur); + +/* + * Extra axis: a name and an axis function. + */ + +typedef struct _xmlXPathAxis xmlXPathAxis; +typedef xmlXPathAxis *xmlXPathAxisPtr; +struct _xmlXPathAxis { + const xmlChar *name; /* the axis name */ + xmlXPathAxisFunc func; /* the search function */ +}; + +/** + * xmlXPathFunction: + * @ctxt: the XPath interprestation context + * @nargs: the number of arguments + * + * An XPath function. + * The arguments (if any) are popped out from the context stack + * and the result is pushed on the stack. + */ + +typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs); + +/* + * Function and Variable Lookup. + */ + +/** + * xmlXPathVariableLookupFunc: + * @ctxt: an XPath context + * @name: name of the variable + * @ns_uri: the namespace name hosting this variable + * + * Prototype for callbacks used to plug variable lookup in the XPath + * engine. + * + * Returns the XPath object value or NULL if not found. + */ +typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFuncLookupFunc: + * @ctxt: an XPath context + * @name: name of the function + * @ns_uri: the namespace name hosting this function + * + * Prototype for callbacks used to plug function lookup in the XPath + * engine. + * + * Returns the XPath function or NULL if not found. + */ +typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt, + const xmlChar *name, + const xmlChar *ns_uri); + +/** + * xmlXPathFlags: + * Flags for XPath engine compilation and runtime + */ +/** + * XML_XPATH_CHECKNS: + * + * check namespaces at compilation + */ +#define XML_XPATH_CHECKNS (1<<0) +/** + * XML_XPATH_NOVAR: + * + * forbid variables in expression + */ +#define XML_XPATH_NOVAR (1<<1) + +/** + * xmlXPathContext: + * + * Expression evaluation occurs with respect to a context. + * he context consists of: + * - a node (the context node) + * - a node list (the context node list) + * - a set of variable bindings + * - a function library + * - the set of namespace declarations in scope for the expression + * Following the switch to hash tables, this need to be trimmed up at + * the next binary incompatible release. + * The node may be modified when the context is passed to libxml2 + * for an XPath evaluation so you may need to initialize it again + * before the next call. + */ + +struct _xmlXPathContext { + xmlDocPtr doc; /* The current document */ + xmlNodePtr node; /* The current node */ + + int nb_variables_unused; /* unused (hash table) */ + int max_variables_unused; /* unused (hash table) */ + xmlHashTablePtr varHash; /* Hash table of defined variables */ + + int nb_types; /* number of defined types */ + int max_types; /* max number of types */ + xmlXPathTypePtr types; /* Array of defined types */ + + int nb_funcs_unused; /* unused (hash table) */ + int max_funcs_unused; /* unused (hash table) */ + xmlHashTablePtr funcHash; /* Hash table of defined funcs */ + + int nb_axis; /* number of defined axis */ + int max_axis; /* max number of axis */ + xmlXPathAxisPtr axis; /* Array of defined axis */ + + /* the namespace nodes of the context node */ + xmlNsPtr *namespaces; /* Array of namespaces */ + int nsNr; /* number of namespace in scope */ + void *user; /* function to free */ + + /* extra variables */ + int contextSize; /* the context size */ + int proximityPosition; /* the proximity position */ + + /* extra stuff for XPointer */ + int xptr; /* is this an XPointer context? */ + xmlNodePtr here; /* for here() */ + xmlNodePtr origin; /* for origin() */ + + /* the set of namespace declarations in scope for the expression */ + xmlHashTablePtr nsHash; /* The namespaces hash table */ + xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */ + void *varLookupData; /* variable lookup data */ + + /* Possibility to link in an extra item */ + void *extra; /* needed for XSLT */ + + /* The function name and URI when calling a function */ + const xmlChar *function; + const xmlChar *functionURI; + + /* function lookup function and data */ + xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */ + void *funcLookupData; /* function lookup data */ + + /* temporary namespace lists kept for walking the namespace axis */ + xmlNsPtr *tmpNsList; /* Array of namespaces */ + int tmpNsNr; /* number of namespaces in scope */ + + /* error reporting mechanism */ + void *userData; /* user specific data block */ + xmlStructuredErrorFunc error; /* the callback in case of errors */ + xmlError lastError; /* the last error */ + xmlNodePtr debugNode; /* the source node XSLT */ + + /* dictionary */ + xmlDictPtr dict; /* dictionary if any */ + + int flags; /* flags to control compilation */ + + /* Cache for reusal of XPath objects */ + void *cache; +}; + +/* + * The structure of a compiled expression form is not public. + */ + +typedef struct _xmlXPathCompExpr xmlXPathCompExpr; +typedef xmlXPathCompExpr *xmlXPathCompExprPtr; + +/** + * xmlXPathParserContext: + * + * An XPath parser context. It contains pure parsing informations, + * an xmlXPathContext, and the stack of objects. + */ +struct _xmlXPathParserContext { + const xmlChar *cur; /* the current char being parsed */ + const xmlChar *base; /* the full expression */ + + int error; /* error code */ + + xmlXPathContextPtr context; /* the evaluation context */ + xmlXPathObjectPtr value; /* the current value */ + int valueNr; /* number of values stacked */ + int valueMax; /* max number of values stacked */ + xmlXPathObjectPtr *valueTab; /* stack of values */ + + xmlXPathCompExprPtr comp; /* the precompiled expression */ + int xptr; /* it this an XPointer expression */ + xmlNodePtr ancestor; /* used for walking preceding axis */ +}; + +/************************************************************************ + * * + * Public API * + * * + ************************************************************************/ + +/** + * Objects and Nodesets handling + */ + +XMLPUBVAR double xmlXPathNAN; +XMLPUBVAR double xmlXPathPINF; +XMLPUBVAR double xmlXPathNINF; + +/* These macros may later turn into functions */ +/** + * xmlXPathNodeSetGetLength: + * @ns: a node-set + * + * Implement a functionality similar to the DOM NodeList.length. + * + * Returns the number of nodes in the node-set. + */ +#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0) +/** + * xmlXPathNodeSetItem: + * @ns: a node-set + * @index: index of a node in the set + * + * Implements a functionality similar to the DOM NodeList.item(). + * + * Returns the xmlNodePtr at the given @index in @ns or NULL if + * @index is out of range (0 to length-1) + */ +#define xmlXPathNodeSetItem(ns, index) \ + ((((ns) != NULL) && \ + ((index) >= 0) && ((index) < (ns)->nodeNr)) ? \ + (ns)->nodeTab[(index)] \ + : NULL) +/** + * xmlXPathNodeSetIsEmpty: + * @ns: a node-set + * + * Checks whether @ns is empty or not. + * + * Returns %TRUE if @ns is an empty node-set. + */ +#define xmlXPathNodeSetIsEmpty(ns) \ + (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL)) + + +XMLPUBFUN void XMLCALL + xmlXPathFreeObject (xmlXPathObjectPtr obj); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeSetCreate (xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj); +XMLPUBFUN void XMLCALL + xmlXPathFreeNodeSet (xmlNodeSetPtr obj); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathObjectCopy (xmlXPathObjectPtr val); +XMLPUBFUN int XMLCALL + xmlXPathCmpNodes (xmlNodePtr node1, + xmlNodePtr node2); +/** + * Conversion functions to basic types. + */ +XMLPUBFUN int XMLCALL + xmlXPathCastNumberToBoolean (double val); +XMLPUBFUN int XMLCALL + xmlXPathCastStringToBoolean (const xmlChar * val); +XMLPUBFUN int XMLCALL + xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns); +XMLPUBFUN int XMLCALL + xmlXPathCastToBoolean (xmlXPathObjectPtr val); + +XMLPUBFUN double XMLCALL + xmlXPathCastBooleanToNumber (int val); +XMLPUBFUN double XMLCALL + xmlXPathCastStringToNumber (const xmlChar * val); +XMLPUBFUN double XMLCALL + xmlXPathCastNodeToNumber (xmlNodePtr node); +XMLPUBFUN double XMLCALL + xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns); +XMLPUBFUN double XMLCALL + xmlXPathCastToNumber (xmlXPathObjectPtr val); + +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastBooleanToString (int val); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNumberToString (double val); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNodeToString (xmlNodePtr node); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastNodeSetToString (xmlNodeSetPtr ns); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathCastToString (xmlXPathObjectPtr val); + +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertBoolean (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertNumber (xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathConvertString (xmlXPathObjectPtr val); + +/** + * Context handling. + */ +XMLPUBFUN xmlXPathContextPtr XMLCALL + xmlXPathNewContext (xmlDocPtr doc); +XMLPUBFUN void XMLCALL + xmlXPathFreeContext (xmlXPathContextPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXPathContextSetCache(xmlXPathContextPtr ctxt, + int active, + int value, + int options); +/** + * Evaluation functions. + */ +XMLPUBFUN long XMLCALL + xmlXPathOrderDocElems (xmlDocPtr doc); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathEvalExpression (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN int XMLCALL + xmlXPathEvalPredicate (xmlXPathContextPtr ctxt, + xmlXPathObjectPtr res); +/** + * Separate compilation/evaluation entry points. + */ +XMLPUBFUN xmlXPathCompExprPtr XMLCALL + xmlXPathCompile (const xmlChar *str); +XMLPUBFUN xmlXPathCompExprPtr XMLCALL + xmlXPathCtxtCompile (xmlXPathContextPtr ctxt, + const xmlChar *str); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathCompiledEval (xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctx); +XMLPUBFUN int XMLCALL + xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp, + xmlXPathContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp); +#endif /* LIBXML_XPATH_ENABLED */ +#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +XMLPUBFUN void XMLCALL + xmlXPathInit (void); +XMLPUBFUN int XMLCALL + xmlXPathIsNaN (double val); +XMLPUBFUN int XMLCALL + xmlXPathIsInf (double val); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*/ +#endif /* ! __XML_XPATH_H__ */ Added: include/libxml/xpathInternals.h =================================================================== --- include/libxml/xpathInternals.h (rev 0) +++ include/libxml/xpathInternals.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,630 @@ +/* + * Summary: internal interfaces for XML Path Language implementation + * Description: internal interfaces for XML Path Language implementation + * used to build new modules on top of XPath like XPointer and + * XSLT + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPATH_INTERNALS_H__ +#define __XML_XPATH_INTERNALS_H__ + +#include +#include + +#ifdef LIBXML_XPATH_ENABLED + +#ifdef __cplusplus +extern "C" { +#endif + +/************************************************************************ + * * + * Helpers * + * * + ************************************************************************/ + +/* + * Many of these macros may later turn into functions. They + * shouldn't be used in #ifdef's preprocessor instructions. + */ +/** + * xmlXPathSetError: + * @ctxt: an XPath parser context + * @err: an xmlXPathError code + * + * Raises an error. + */ +#define xmlXPathSetError(ctxt, err) \ + { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \ + if ((ctxt) != NULL) (ctxt)->error = (err); } + +/** + * xmlXPathSetArityError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_ARITY error. + */ +#define xmlXPathSetArityError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_ARITY) + +/** + * xmlXPathSetTypeError: + * @ctxt: an XPath parser context + * + * Raises an XPATH_INVALID_TYPE error. + */ +#define xmlXPathSetTypeError(ctxt) \ + xmlXPathSetError((ctxt), XPATH_INVALID_TYPE) + +/** + * xmlXPathGetError: + * @ctxt: an XPath parser context + * + * Get the error code of an XPath context. + * + * Returns the context error. + */ +#define xmlXPathGetError(ctxt) ((ctxt)->error) + +/** + * xmlXPathCheckError: + * @ctxt: an XPath parser context + * + * Check if an XPath error was raised. + * + * Returns true if an error has been raised, false otherwise. + */ +#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK) + +/** + * xmlXPathGetDocument: + * @ctxt: an XPath parser context + * + * Get the document of an XPath context. + * + * Returns the context document. + */ +#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc) + +/** + * xmlXPathGetContextNode: + * @ctxt: an XPath parser context + * + * Get the context node of an XPath context. + * + * Returns the context node. + */ +#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node) + +XMLPUBFUN int XMLCALL + xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt); +XMLPUBFUN double XMLCALL + xmlXPathPopNumber (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathPopString (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void * XMLCALL + xmlXPathPopExternal (xmlXPathParserContextPtr ctxt); + +/** + * xmlXPathReturnBoolean: + * @ctxt: an XPath parser context + * @val: a boolean + * + * Pushes the boolean @val on the context stack. + */ +#define xmlXPathReturnBoolean(ctxt, val) \ + valuePush((ctxt), xmlXPathNewBoolean(val)) + +/** + * xmlXPathReturnTrue: + * @ctxt: an XPath parser context + * + * Pushes true on the context stack. + */ +#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1) + +/** + * xmlXPathReturnFalse: + * @ctxt: an XPath parser context + * + * Pushes false on the context stack. + */ +#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0) + +/** + * xmlXPathReturnNumber: + * @ctxt: an XPath parser context + * @val: a double + * + * Pushes the double @val on the context stack. + */ +#define xmlXPathReturnNumber(ctxt, val) \ + valuePush((ctxt), xmlXPathNewFloat(val)) + +/** + * xmlXPathReturnString: + * @ctxt: an XPath parser context + * @str: a string + * + * Pushes the string @str on the context stack. + */ +#define xmlXPathReturnString(ctxt, str) \ + valuePush((ctxt), xmlXPathWrapString(str)) + +/** + * xmlXPathReturnEmptyString: + * @ctxt: an XPath parser context + * + * Pushes an empty string on the stack. + */ +#define xmlXPathReturnEmptyString(ctxt) \ + valuePush((ctxt), xmlXPathNewCString("")) + +/** + * xmlXPathReturnNodeSet: + * @ctxt: an XPath parser context + * @ns: a node-set + * + * Pushes the node-set @ns on the context stack. + */ +#define xmlXPathReturnNodeSet(ctxt, ns) \ + valuePush((ctxt), xmlXPathWrapNodeSet(ns)) + +/** + * xmlXPathReturnEmptyNodeSet: + * @ctxt: an XPath parser context + * + * Pushes an empty node-set on the context stack. + */ +#define xmlXPathReturnEmptyNodeSet(ctxt) \ + valuePush((ctxt), xmlXPathNewNodeSet(NULL)) + +/** + * xmlXPathReturnExternal: + * @ctxt: an XPath parser context + * @val: user data + * + * Pushes user data on the context stack. + */ +#define xmlXPathReturnExternal(ctxt, val) \ + valuePush((ctxt), xmlXPathWrapExternal(val)) + +/** + * xmlXPathStackIsNodeSet: + * @ctxt: an XPath parser context + * + * Check if the current value on the XPath stack is a node set or + * an XSLT value tree. + * + * Returns true if the current object on the stack is a node-set. + */ +#define xmlXPathStackIsNodeSet(ctxt) \ + (((ctxt)->value != NULL) \ + && (((ctxt)->value->type == XPATH_NODESET) \ + || ((ctxt)->value->type == XPATH_XSLT_TREE))) + +/** + * xmlXPathStackIsExternal: + * @ctxt: an XPath parser context + * + * Checks if the current value on the XPath stack is an external + * object. + * + * Returns true if the current object on the stack is an external + * object. + */ +#define xmlXPathStackIsExternal(ctxt) \ + ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS)) + +/** + * xmlXPathEmptyNodeSet: + * @ns: a node-set + * + * Empties a node-set. + */ +#define xmlXPathEmptyNodeSet(ns) \ + { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; } + +/** + * CHECK_ERROR: + * + * Macro to return from the function if an XPath error was detected. + */ +#define CHECK_ERROR \ + if (ctxt->error != XPATH_EXPRESSION_OK) return + +/** + * CHECK_ERROR0: + * + * Macro to return 0 from the function if an XPath error was detected. + */ +#define CHECK_ERROR0 \ + if (ctxt->error != XPATH_EXPRESSION_OK) return(0) + +/** + * XP_ERROR: + * @X: the error code + * + * Macro to raise an XPath error and return. + */ +#define XP_ERROR(X) \ + { xmlXPathErr(ctxt, X); return; } + +/** + * XP_ERROR0: + * @X: the error code + * + * Macro to raise an XPath error and return 0. + */ +#define XP_ERROR0(X) \ + { xmlXPathErr(ctxt, X); return(0); } + +/** + * CHECK_TYPE: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. + */ +#define CHECK_TYPE(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR(XPATH_INVALID_TYPE) + +/** + * CHECK_TYPE0: + * @typeval: the XPath type + * + * Macro to check that the value on top of the XPath stack is of a given + * type. Return(0) in case of failure + */ +#define CHECK_TYPE0(typeval) \ + if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ + XP_ERROR0(XPATH_INVALID_TYPE) + +/** + * CHECK_ARITY: + * @x: the number of expected args + * + * Macro to check that the number of args passed to an XPath function matches. + */ +#define CHECK_ARITY(x) \ + if (ctxt == NULL) return; \ + if (nargs != (x)) \ + XP_ERROR(XPATH_INVALID_ARITY); + +/** + * CAST_TO_STRING: + * + * Macro to try to cast the value on the top of the XPath stack to a string. + */ +#define CAST_TO_STRING \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \ + xmlXPathStringFunction(ctxt, 1); + +/** + * CAST_TO_NUMBER: + * + * Macro to try to cast the value on the top of the XPath stack to a number. + */ +#define CAST_TO_NUMBER \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \ + xmlXPathNumberFunction(ctxt, 1); + +/** + * CAST_TO_BOOLEAN: + * + * Macro to try to cast the value on the top of the XPath stack to a boolean. + */ +#define CAST_TO_BOOLEAN \ + if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \ + xmlXPathBooleanFunction(ctxt, 1); + +/* + * Variable Lookup forwarding. + */ + +XMLPUBFUN void XMLCALL + xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt, + xmlXPathVariableLookupFunc f, + void *data); + +/* + * Function Lookup forwarding. + */ + +XMLPUBFUN void XMLCALL + xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt, + xmlXPathFuncLookupFunc f, + void *funcCtxt); + +/* + * Error reporting. + */ +XMLPUBFUN void XMLCALL + xmlXPatherror (xmlXPathParserContextPtr ctxt, + const char *file, + int line, + int no); + +XMLPUBFUN void XMLCALL + xmlXPathErr (xmlXPathParserContextPtr ctxt, + int error); + +#ifdef LIBXML_DEBUG_ENABLED +XMLPUBFUN void XMLCALL + xmlXPathDebugDumpObject (FILE *output, + xmlXPathObjectPtr cur, + int depth); +XMLPUBFUN void XMLCALL + xmlXPathDebugDumpCompExpr(FILE *output, + xmlXPathCompExprPtr comp, + int depth); +#endif +/** + * NodeSet handling. + */ +XMLPUBFUN int XMLCALL + xmlXPathNodeSetContains (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDifference (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathIntersection (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDistinctSorted (xmlNodeSetPtr nodes); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathDistinct (xmlNodeSetPtr nodes); + +XMLPUBFUN int XMLCALL + xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeLeading (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathLeading (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeTrailing (xmlNodeSetPtr nodes, + xmlNodePtr node); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathTrailing (xmlNodeSetPtr nodes1, + xmlNodeSetPtr nodes2); + + +/** + * Extending a context. + */ + +XMLPUBFUN int XMLCALL + xmlXPathRegisterNs (xmlXPathContextPtr ctxt, + const xmlChar *prefix, + const xmlChar *ns_uri); +XMLPUBFUN const xmlChar * XMLCALL + xmlXPathNsLookup (xmlXPathContextPtr ctxt, + const xmlChar *prefix); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt); + +XMLPUBFUN int XMLCALL + xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathFunction f); +XMLPUBFUN int XMLCALL + xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathFunction f); +XMLPUBFUN int XMLCALL + xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, + const xmlChar *name, + xmlXPathObjectPtr value); +XMLPUBFUN int XMLCALL + xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri, + xmlXPathObjectPtr value); +XMLPUBFUN xmlXPathFunction XMLCALL + xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathFunction XMLCALL + xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathVariableLookup (xmlXPathContextPtr ctxt, + const xmlChar *name); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt, + const xmlChar *name, + const xmlChar *ns_uri); +XMLPUBFUN void XMLCALL + xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); + +/** + * Utilities to extend XPath. + */ +XMLPUBFUN xmlXPathParserContextPtr XMLCALL + xmlXPathNewParserContext (const xmlChar *str, + xmlXPathContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); + +/* TODO: remap to xmlXPathValuePop and Push. */ +XMLPUBFUN xmlXPathObjectPtr XMLCALL + valuePop (xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL + valuePush (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr value); + +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewString (const xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewCString (const char *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapString (xmlChar *val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapCString (char * val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewFloat (double val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewBoolean (int val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewNodeSet (xmlNodePtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewValueTree (xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetAdd (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetAddNs (xmlNodeSetPtr cur, + xmlNodePtr node, + xmlNsPtr ns); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetSort (xmlNodeSetPtr set); + +XMLPUBFUN void XMLCALL + xmlXPathRoot (xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL + xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathParseName (xmlXPathParserContextPtr ctxt); +XMLPUBFUN xmlChar * XMLCALL + xmlXPathParseNCName (xmlXPathParserContextPtr ctxt); + +/* + * Existing functions. + */ +XMLPUBFUN double XMLCALL + xmlXPathStringEvalNumber (const xmlChar *str); +XMLPUBFUN int XMLCALL + xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt, + xmlXPathObjectPtr res); +XMLPUBFUN void XMLCALL + xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt); +XMLPUBFUN xmlNodeSetPtr XMLCALL + xmlXPathNodeSetMerge (xmlNodeSetPtr val1, + xmlNodeSetPtr val2); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetDel (xmlNodeSetPtr cur, + xmlNodePtr val); +XMLPUBFUN void XMLCALL + xmlXPathNodeSetRemove (xmlNodeSetPtr cur, + int val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathNewNodeSetList (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapNodeSet (xmlNodeSetPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPathWrapExternal (void *val); + +XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); +XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt); +XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt); + +XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name); + +/* + * Some of the axis navigation routines. + */ +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, + xmlNodePtr cur); +/* + * The official core of XPath functions. + */ +XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); +XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs); + +/** + * Really internal functions + */ +XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns); + +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPATH_ENABLED */ +#endif /* ! __XML_XPATH_INTERNALS_H__ */ Added: include/libxml/xpointer.h =================================================================== --- include/libxml/xpointer.h (rev 0) +++ include/libxml/xpointer.h 2009-03-12 21:56:41 UTC (rev 64) @@ -0,0 +1,114 @@ +/* + * Summary: API to handle XML Pointers + * Description: API to handle XML Pointers + * Base implementation was made accordingly to + * W3C Candidate Recommendation 7 June 2000 + * http://www.w3.org/TR/2000/CR-xptr-20000607 + * + * Added support for the element() scheme described in: + * W3C Proposed Recommendation 13 November 2002 + * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ + * + * Copy: See Copyright for the status of this software. + * + * Author: Daniel Veillard + */ + +#ifndef __XML_XPTR_H__ +#define __XML_XPTR_H__ + +#include + +#ifdef LIBXML_XPTR_ENABLED + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * A Location Set + */ +typedef struct _xmlLocationSet xmlLocationSet; +typedef xmlLocationSet *xmlLocationSetPtr; +struct _xmlLocationSet { + int locNr; /* number of locations in the set */ + int locMax; /* size of the array as allocated */ + xmlXPathObjectPtr *locTab;/* array of locations */ +}; + +/* + * Handling of location sets. + */ + +XMLPUBFUN xmlLocationSetPtr XMLCALL + xmlXPtrLocationSetCreate (xmlXPathObjectPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); +XMLPUBFUN xmlLocationSetPtr XMLCALL + xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, + xmlLocationSetPtr val2); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRange (xmlNodePtr start, + int startindex, + xmlNodePtr end, + int endindex); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangePoints (xmlXPathObjectPtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodePoint (xmlNodePtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangePointNode (xmlXPathObjectPtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodes (xmlNodePtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewLocationSetNodes (xmlNodePtr start, + xmlNodePtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewRangeNodeObject (xmlNodePtr start, + xmlXPathObjectPtr end); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrNewCollapsedRange (xmlNodePtr start); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, + xmlXPathObjectPtr val); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrWrapLocationSet (xmlLocationSetPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetDel (xmlLocationSetPtr cur, + xmlXPathObjectPtr val); +XMLPUBFUN void XMLCALL + xmlXPtrLocationSetRemove (xmlLocationSetPtr cur, + int val); + +/* + * Functions. + */ +XMLPUBFUN xmlXPathContextPtr XMLCALL + xmlXPtrNewContext (xmlDocPtr doc, + xmlNodePtr here, + xmlNodePtr origin); +XMLPUBFUN xmlXPathObjectPtr XMLCALL + xmlXPtrEval (const xmlChar *str, + xmlXPathContextPtr ctx); +XMLPUBFUN void XMLCALL + xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt, + int nargs); +XMLPUBFUN xmlNodePtr XMLCALL + xmlXPtrBuildNodeList (xmlXPathObjectPtr obj); +XMLPUBFUN void XMLCALL + xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt); +#ifdef __cplusplus +} +#endif + +#endif /* LIBXML_XPTR_ENABLED */ +#endif /* __XML_XPTR_H__ */ Added: lib/iconv.lib =================================================================== (Binary files differ) Property changes on: lib/iconv.lib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: lib/libxml2.lib =================================================================== (Binary files differ) Property changes on: lib/libxml2.lib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream From anders at brander.dk Fri Mar 13 08:15:14 2009 From: anders at brander.dk (Anders Brander) Date: Fri, 13 Mar 2009 08:15:14 +0100 Subject: [Rawstudio-commit] rawspeed r65 - RawSpeed Message-ID: Author: abrander Date: 2009-03-13 08:15:13 +0100 (Fri, 13 Mar 2009) New Revision: 65 Modified: RawSpeed/Camera.cpp RawSpeed/CameraMetadataException.cpp RawSpeed/CameraMetadataException.h RawSpeed/rawstudio-plugin-api.cpp RawSpeed/rawstudio-plugin.makefile Log: - Ported changes in r63:64 to unix. Modified: RawSpeed/Camera.cpp =================================================================== --- RawSpeed/Camera.cpp 2009-03-12 21:56:41 UTC (rev 64) +++ RawSpeed/Camera.cpp 2009-03-13 07:15:13 UTC (rev 65) @@ -131,7 +131,11 @@ { int i; +#ifdef __unix__ + if (EOF == sscanf((const char*)in, "%d", &i)) +#else if (EOF == sscanf_s((const char*)in, "%d", &i)) +#endif ThrowCME("Error parsing attribute %s in tag %s, in camera %s %s.", attribute, tag, make.c_str(), model.c_str()); return i; Modified: RawSpeed/CameraMetadataException.cpp =================================================================== --- RawSpeed/CameraMetadataException.cpp 2009-03-12 21:56:41 UTC (rev 64) +++ RawSpeed/CameraMetadataException.cpp 2009-03-13 07:15:13 UTC (rev 65) @@ -5,17 +5,17 @@ va_list val; va_start(val, fmt); char buf[8192]; +#ifdef __unix__ + vsnprintf(buf, 8192, fmt, val); +#else vsprintf_s(buf, 8192, fmt, val); +#endif va_end(val); _RPT1(0, "EXCEPTION: %s\n",buf); throw CameraMetadataException(buf); -} +} CameraMetadataException::CameraMetadataException(const string _msg): runtime_error(_msg) { _RPT1(0, "CameraMetadata Exception: %s\n", _msg.c_str()); } - -CameraMetadataException::~CameraMetadataException(void) -{ -} Modified: RawSpeed/CameraMetadataException.h =================================================================== --- RawSpeed/CameraMetadataException.h 2009-03-12 21:56:41 UTC (rev 64) +++ RawSpeed/CameraMetadataException.h 2009-03-13 07:15:13 UTC (rev 65) @@ -7,6 +7,4 @@ { public: CameraMetadataException(const string _msg); -public: - ~CameraMetadataException(void); }; Modified: RawSpeed/rawstudio-plugin-api.cpp =================================================================== --- RawSpeed/rawstudio-plugin-api.cpp 2009-03-12 21:56:41 UTC (rev 64) +++ RawSpeed/rawstudio-plugin-api.cpp 2009-03-13 07:15:13 UTC (rev 65) @@ -25,17 +25,21 @@ #include "FileReader.h" #include "TiffParser.h" #include "RawDecoder.h" +#include "CameraMetaData.h" #include "rawstudio-plugin-api.h" extern "C" { -CameraMetaData c* = 0; - RS_IMAGE16 * load_rawspeed(const gchar *filename) { - if (!c) - c = new CameraMetaData("~/.rawstudio/cameras.xml"); + static CameraMetaData *c = NULL; + if (!c) + { + gchar *path = g_build_filename(rs_confdir_get(), "cameras.xml", NULL); + c = new CameraMetaData(path); + g_free(path); + } RS_IMAGE16 *image = NULL; FileReader f((char *) filename); RawDecoder *d = 0; @@ -51,9 +55,6 @@ try { gint col, row; - gint black = 0xffff; - gint max = 0x0; - gint shift = 0; gint cpp; GTimer *gt = g_timer_new(); @@ -84,12 +85,12 @@ if (r->isCFA) { printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); - printf(r->cfa.asString().c_str()); + printf("%s", r->cfa.asString().c_str()); } - if (cpp = 1) + if (cpp == 1) { - BitBlt(GET_PIXEL(image,0,0),image->pitch/2, - r->getData(0,0), r->pitch, r->bpp*r->dim.x,r->pitch, r->dim.y); + BitBlt((guchar *)(GET_PIXEL(image,0,0)),image->pitch/2, + r->getData(0,0), r->pitch, r->bpp*r->dim.x, r->dim.y); } else { for(row=0;rowh;row++) Modified: RawSpeed/rawstudio-plugin.makefile =================================================================== --- RawSpeed/rawstudio-plugin.makefile 2009-03-12 21:56:41 UTC (rev 64) +++ RawSpeed/rawstudio-plugin.makefile 2009-03-13 07:15:13 UTC (rev 65) @@ -1,14 +1,18 @@ CC=g++ -CFLAGS=-fPIC -Wall -O4 `pkg-config --cflags rawstudio-1.1` -LDFLAGS=`pkg-config --libs rawstudio-1.1` -INSTALLPATH=`pkg-config --variable=plugindir rawstudio-1.1` +CFLAGS=-fPIC -Wall -O4 `pkg-config --cflags rawstudio-1.1 libxml-2.0` +LDFLAGS=`pkg-config --libs rawstudio-1.1 libxml-2.0` +INSTALLPATH=`pkg-config --variable=plugindir rawstudio-1.1 libxml-2.0` CPP_SOURCES= rawstudio-plugin-api.cpp \ ArwDecoder.cpp \ BitPumpJPEG.cpp \ BitPumpMSB.cpp \ BitPumpPlain.cpp \ + BlackArea.cpp \ ByteStream.cpp \ + Camera.cpp \ + CameraMetaData.cpp \ + CameraMetadataException.cpp \ ColorFilterArray.cpp \ Common.cpp \ Cr2Decoder.cpp \ From anders at brander.dk Fri Mar 13 08:42:49 2009 From: anders at brander.dk (Anders Brander) Date: Fri, 13 Mar 2009 08:42:49 +0100 Subject: [Rawstudio-commit] rawspeed r66 - RawSpeed Message-ID: Author: abrander Date: 2009-03-13 08:42:49 +0100 (Fri, 13 Mar 2009) New Revision: 66 Modified: RawSpeed/rawstudio-plugin-api.cpp Log: - Fixed bitblit in load_rawspeed(). Modified: RawSpeed/rawstudio-plugin-api.cpp =================================================================== --- RawSpeed/rawstudio-plugin-api.cpp 2009-03-13 07:15:13 UTC (rev 65) +++ RawSpeed/rawstudio-plugin-api.cpp 2009-03-13 07:42:49 UTC (rev 66) @@ -89,8 +89,8 @@ } if (cpp == 1) { - BitBlt((guchar *)(GET_PIXEL(image,0,0)),image->pitch/2, - r->getData(0,0), r->pitch, r->bpp*r->dim.x, r->dim.y); + BitBlt((guchar *)(GET_PIXEL(image,0,0)),image->pitch*2, + r->getData(0,0), r->pitch, r->dim.x*2, r->dim.y); } else { for(row=0;rowh;row++) From anders at brander.dk Fri Mar 13 08:45:11 2009 From: anders at brander.dk (Anders Brander) Date: Fri, 13 Mar 2009 08:45:11 +0100 Subject: [Rawstudio-commit] rawspeed r67 - RawSpeed Message-ID: Author: abrander Date: 2009-03-13 08:45:11 +0100 (Fri, 13 Mar 2009) New Revision: 67 Modified: RawSpeed/rawstudio-plugin-api.cpp Log: - Really fixed bitblit in load_rawspeed() :). Modified: RawSpeed/rawstudio-plugin-api.cpp =================================================================== --- RawSpeed/rawstudio-plugin-api.cpp 2009-03-13 07:42:49 UTC (rev 66) +++ RawSpeed/rawstudio-plugin-api.cpp 2009-03-13 07:45:11 UTC (rev 67) @@ -90,7 +90,7 @@ if (cpp == 1) { BitBlt((guchar *)(GET_PIXEL(image,0,0)),image->pitch*2, - r->getData(0,0), r->pitch, r->dim.x*2, r->dim.y); + r->getData(0,0), r->pitch, r->bpp*r->dim.x, r->dim.y); } else { for(row=0;rowh;row++) From anders at brander.dk Fri Mar 13 22:04:47 2009 From: anders at brander.dk (Anders Brander) Date: Fri, 13 Mar 2009 22:04:47 +0100 Subject: [Rawstudio-commit] r2239 - in trunk: . librawstudio plugins plugins/denoise src Message-ID: Author: abrander Date: 2009-03-13 22:04:45 +0100 (Fri, 13 Mar 2009) New Revision: 2239 Added: trunk/plugins/denoise/ trunk/plugins/denoise/Makefile.am trunk/plugins/denoise/complexblock.cpp trunk/plugins/denoise/complexblock.h trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h trunk/plugins/denoise/denoise.c trunk/plugins/denoise/denoiseinterface.h trunk/plugins/denoise/denoisethread.cpp trunk/plugins/denoise/denoisethread.h trunk/plugins/denoise/fftdenoiser.cpp trunk/plugins/denoise/fftdenoiser.h trunk/plugins/denoise/fftdenoiseryuv.cpp trunk/plugins/denoise/fftdenoiseryuv.h trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/fftwindow.h trunk/plugins/denoise/floatimageplane.cpp trunk/plugins/denoise/floatimageplane.h trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/floatplanarimage.h trunk/plugins/denoise/jobqueue.cpp trunk/plugins/denoise/jobqueue.h trunk/plugins/denoise/planarimageslice.cpp trunk/plugins/denoise/planarimageslice.h Modified: trunk/configure.in trunk/librawstudio/rs-settings.c trunk/librawstudio/rs-settings.h trunk/plugins/Makefile.am trunk/src/conf_interface.h trunk/src/rs-cache.c trunk/src/rs-photo.c trunk/src/rs-preview-widget.c trunk/src/toolbox.c Log: Added new denoise/sharpen filter (Patch by Klaus Post). Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/configure.in 2009-03-13 21:04:45 UTC (rev 2239) @@ -56,7 +56,7 @@ fi AC_SUBST(LIBTIFF) -pkg_modules="gtk+-2.0 >= 2.8.0 libxml-2.0 >= 2.4 gconf-2.0 >= 2.0 lcms dbus-1 exiv2" +pkg_modules="gtk+-2.0 >= 2.8.0 libxml-2.0 >= 2.4 gconf-2.0 >= 2.0 lcms dbus-1 exiv2 fftw3f" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) @@ -78,6 +78,7 @@ plugins/cache/Makefile plugins/crop/Makefile plugins/demosaic/Makefile +plugins/denoise/Makefile plugins/gtk-view/Makefile plugins/input-file/Makefile plugins/input-image16/Makefile Modified: trunk/librawstudio/rs-settings.c =================================================================== --- trunk/librawstudio/rs-settings.c 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/librawstudio/rs-settings.c 2009-03-13 21:04:45 UTC (rev 2239) @@ -50,6 +50,8 @@ PROP_WARMTH, PROP_TINT, PROP_SHARPEN, + PROP_DENOISE_LUMA, + PROP_DENOISE_CHROMA }; static void @@ -93,8 +95,18 @@ g_object_class_install_property(object_class, PROP_SHARPEN, g_param_spec_float( "sharpen", _("Sharpen"), _("Sharpen"), - 0.0, 10.0, 0.0, G_PARAM_READWRITE) + 0.0, 100.0, 0.0, G_PARAM_READWRITE) ); + g_object_class_install_property(object_class, + PROP_DENOISE_LUMA, g_param_spec_float( /* FIXME: ? */ + "denoise_luma", _("Denoise"), _("FIXME"), + 0.0, 100.0, 0.0, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_DENOISE_CHROMA, g_param_spec_float( /* FIXME: ? */ + "denoise_chroma", _("Color Denoise"), _("FIXME"), + 0.0, 100.0, 0.0, G_PARAM_READWRITE) + ); signals[SETTINGS_CHANGED] = g_signal_new ("settings-changed", G_TYPE_FROM_CLASS (klass), @@ -139,6 +151,8 @@ CASE(WARMTH, warmth); CASE(TINT, tint); CASE(SHARPEN, sharpen); + CASE(DENOISE_LUMA, denoise_luma); + CASE(DENOISE_CHROMA, denoise_chroma); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -168,6 +182,8 @@ CASE(WARMTH, warmth); CASE(TINT, tint); CASE(SHARPEN, sharpen); + CASE(DENOISE_LUMA, denoise_luma); + CASE(DENOISE_CHROMA, denoise_chroma); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -215,6 +231,12 @@ if (mask & MASK_SHARPEN) rs_object_class_property_reset(settings, "sharpen"); + if (mask & MASK_DENOISE_LUMA) + rs_object_class_property_reset(settings, "denoise_luma"); + + if (mask & MASK_DENOISE_CHROMA) + rs_object_class_property_reset(settings, "denoise_chroma"); + if (mask && MASK_CURVE) { if (settings->curve_knots) @@ -302,6 +324,8 @@ SETTINGS_COPY(WARMTH, warmth); SETTINGS_COPY(TINT, tint); SETTINGS_COPY(SHARPEN, sharpen); + SETTINGS_COPY(DENOISE_LUMA, denoise_luma); + SETTINGS_COPY(DENOISE_CHROMA, denoise_chroma); #undef SETTINGS_COPY if (mask & MASK_CURVE) Modified: trunk/librawstudio/rs-settings.h =================================================================== --- trunk/librawstudio/rs-settings.h 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/librawstudio/rs-settings.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -33,16 +33,18 @@ #define RS_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_SETTINGS, RSSettingsClass)) typedef enum { - MASK_EXPOSURE = (1<<0), - MASK_SATURATION = (1<<1), - MASK_HUE = (1<<2), - MASK_CONTRAST = (1<<3), - MASK_WARMTH = (1<<4), - MASK_TINT = (1<<5), - MASK_WB = MASK_WARMTH | MASK_TINT, - MASK_CURVE = (1<<6), - MASK_SHARPEN = (1<<7), - MASK_ALL = 0x00ffffff, + MASK_EXPOSURE = (1<<0), + MASK_SATURATION = (1<<1), + MASK_HUE = (1<<2), + MASK_CONTRAST = (1<<3), + MASK_WARMTH = (1<<4), + MASK_TINT = (1<<5), + MASK_WB = MASK_WARMTH | MASK_TINT, + MASK_CURVE = (1<<6), + MASK_SHARPEN = (1<<7), + MASK_DENOISE_LUMA = (1<<8), + MASK_DENOISE_CHROMA = (1<<9), + MASK_ALL = 0x00ffffff, } RSSettingsMask; typedef struct _RSsettings { @@ -56,6 +58,8 @@ gfloat warmth; gfloat tint; gfloat sharpen; + gfloat denoise_luma; + gfloat denoise_chroma; gint curve_nknots; gfloat *curve_knots; } RSSettings; Modified: trunk/plugins/Makefile.am =================================================================== --- trunk/plugins/Makefile.am 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/plugins/Makefile.am 2009-03-13 21:04:45 UTC (rev 2239) @@ -2,6 +2,7 @@ cache \ crop \ demosaic \ + denoise \ gtk-view \ input-file \ input-image16 \ Added: trunk/plugins/denoise/Makefile.am =================================================================== --- trunk/plugins/denoise/Makefile.am (rev 0) +++ trunk/plugins/denoise/Makefile.am 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,32 @@ +plugindir = $(libdir)/rawstudio/plugins + +AM_CFLAGS =\ + -Wall \ + -g3 \ + -O4 + +AM_CXXFLAGS = $(AM_CFLAGS) + +INCLUDES = \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + @PACKAGE_CFLAGS@ \ + -I../../librawstudio/ + +lib_LTLIBRARIES = denoise.la + +libdir = $(datadir)/rawstudio/plugins/ + +denoise_la_LIBADD = @PACKAGE_LIBS@ +denoise_la_LDFLAGS = -module -avoid-version +denoise_la_SOURCES = denoise.c \ + complexblock.cpp \ + complexfilter.cpp \ + denoisethread.cpp \ + fftdenoiser.cpp \ + fftdenoiseryuv.cpp\ + fftwindow.cpp \ + floatimageplane.cpp \ + floatplanarimage.cpp \ + jobqueue.cpp \ + planarimageslice.cpp Added: trunk/plugins/denoise/complexblock.cpp =================================================================== --- trunk/plugins/denoise/complexblock.cpp (rev 0) +++ trunk/plugins/denoise/complexblock.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,34 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "complexblock.h" +#include + + +ComplexBlock::ComplexBlock(int _w, int _h): w(_w), h(_h) +{ + pitch = w * sizeof(fftwf_complex); + complex = (fftwf_complex*)fftwf_malloc(h*pitch); + g_assert(complex); +} + +ComplexBlock::~ComplexBlock(void) +{ + fftwf_free(complex); + complex = 0; +} + Added: trunk/plugins/denoise/complexblock.h =================================================================== --- trunk/plugins/denoise/complexblock.h (rev 0) +++ trunk/plugins/denoise/complexblock.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,35 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef complexblock_h__ +#define complexblock_h__ +#include "fftw3.h" +#include + +class ComplexBlock +{ +public: + ComplexBlock(int w, int h); + ~ComplexBlock(void); + fftwf_complex* complex; + const int w; + const int h; +private: + int pitch; +}; +#endif // complexblock_h__ Added: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp (rev 0) +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,282 @@ +/* +* Copyright (C) 2009 Klaus Post +* Based on FFT3DFilter plugin for Avisynth 2.5 - 3D Frequency Domain filter +* Copyright(C)2004-2005 A.G.Balakhnin aka Fizick, email: bag at hotmail.ru, web: http://bag.hotmail.ru +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "complexfilter.h" +#include +#include "fftwindow.h" + + /* + * These classes define the processing that must be done + * to each block. + * Note that the process() function must be re-entrant, + * as all threads will use the same instance for each plane. + * + */ +#ifndef MAX +#define MAX(x,y) ((x) > (y) ? (x) : (y)) +#endif + + /**** BASE CLASS *****/ + +ComplexFilter::ComplexFilter( int block_width, int block_height ) : +bw(block_width), bh(block_height), norm(1.0f/(block_width*block_height)), +sharpen(0), sigmaSquaredSharpenMin(0), sigmaSquaredSharpenMax(0), sharpenWindow(0) +{} + +ComplexFilter::~ComplexFilter(void) +{ + if (sharpenWindow) + delete sharpenWindow; + sharpenWindow = 0; +} + +void ComplexFilter::setSharpen( float _sharpen, float sigmaSharpenMin, float sigmaSharpenMax, float scutoff ) +{ + if (ABS(_sharpen) <0.001f) + return; + sharpen = _sharpen; + sigmaSquaredSharpenMin = sigmaSharpenMin*sigmaSharpenMin/norm; + sigmaSquaredSharpenMax = sigmaSharpenMax*sigmaSharpenMax/norm; + // window for sharpen + float svr = 1.0f; // Horizontal to vertical ratio + if (!sharpenWindow) { + sharpenWindow = new FloatImagePlane(bw, bh); + sharpenWindow->allocateImage(); + } + + for (int j=0; j=bh/2) + dj = bh-j; + float d2v = float(dj*dj)*(svr*svr)/((bh/2)*(bh/2)); + float *wsharpen = sharpenWindow->getLine(j); + for (int i=0; i0.001f) + processSharpen(block); + else + processNoSharpen(block); +} + +/**** Basic Wiener Filter *****/ + + +ComplexWienerFilter::ComplexWienerFilter( int block_width, int block_height,float _beta, float _sigma ) : +ComplexFilter(block_width, block_height), +beta(_beta) +{ + sigmaSquaredNoiseNormed = _sigma*_sigma/norm; +} + + +ComplexWienerFilter::~ComplexWienerFilter( void ){} + +void ComplexWienerFilter::processNoSharpen( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + int x,y; + float psd; + float WienerFactor; + fftwf_complex* outcur = block->complex; + g_assert(bw == block->w); + g_assert(bh == block->h); + + for (y=0; y=0 + int x,y; + float psd; + float WienerFactor; + fftwf_complex* outcur = block->complex; + g_assert(bw == block->w); + g_assert(bh == block->h); + for (y=0; ygetLine(y); + for (x=0; x=0 + g_assert(bw == block->w); + g_assert(bh == block->h); + int x,y; + float psd; + fftwf_complex* outcur = block->complex; + float* pattern2d = pattern->data; + float patternfactor; + + for (y=0; ypitch; + } +} + +void ComplexPatternFilter::processSharpen( ComplexBlock* block ) +{ + g_assert(!"Not implemented"); +} + +ComplexWienerFilterDeGrid::ComplexWienerFilterDeGrid( int block_width, int block_height, + float _beta, float _sigma, float _degrid, + fftwf_plan plan_forward, FFTWindow *_window) +: +ComplexFilter(block_width, block_height), +beta(_beta), +degrid(_degrid), +window(_window) +{ + sigmaSquaredNoiseNormed = _sigma*_sigma/norm; + grid = new ComplexBlock(bw, bh); + FloatImagePlane realGrid(bw, bh); + realGrid.allocateImage(); + float* f = realGrid.data; + int count = bh*realGrid.pitch; + + for (int i = 0 ; i < count; i++){ + f[i] = 65535.0f; + } + window->applyAnalysisWindow(&realGrid,&realGrid); + fftwf_execute_dft_r2c(plan_forward, f, grid->complex); +} + +ComplexWienerFilterDeGrid::~ComplexWienerFilterDeGrid( void ) +{ + delete grid; +} + + + +void ComplexWienerFilterDeGrid::processNoSharpen( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + int x,y; + float psd; + float WienerFactor; + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + for (y=0; y=0 + int x,y; + float psd; + float WienerFactor; + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + for (y=0; ygetLine(y); + for (x=0; x and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* Plugin tmpl version 4 */ + +#include +#include +#include "denoiseinterface.h" + +#define RS_TYPE_DENOISE (rs_denoise_type) +#define RS_DENOISE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_DENOISE, RSDenoise)) +#define RS_DENOISE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_DENOISE, RSDenoiseClass)) +#define RS_IS_DENOISE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_DENOISE)) + +typedef struct _RSDenoise RSDenoise; +typedef struct _RSDenoiseClass RSDenoiseClass; + +struct _RSDenoise { + RSFilter parent; + + FFTDenoiseInfo info; + gint sharpen; + gint denoise_luma; + gint denoise_chroma; +}; + +struct _RSDenoiseClass { + RSFilterClass parent_class; +}; + +RS_DEFINE_FILTER(rs_denoise, RSDenoise) + +enum { + PROP_0, + PROP_SHARPEN, + PROP_DENOISE_LUMA, + PROP_DENOISE_CHROMA +}; + +static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); +static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +static RS_IMAGE16 *get_image(RSFilter *filter); + +static RSFilterClass *rs_denoise_parent_class = NULL; + +G_MODULE_EXPORT void +rs_plugin_load(RSPlugin *plugin) +{ + rs_denoise_get_type(G_TYPE_MODULE(plugin)); +} + +static void +rs_denoise_class_init(RSDenoiseClass *klass) +{ + RSFilterClass *filter_class = RS_FILTER_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + rs_denoise_parent_class = g_type_class_peek_parent (klass); + + object_class->get_property = get_property; + object_class->set_property = set_property; + + g_object_class_install_property(object_class, + PROP_SHARPEN, g_param_spec_int ( + "sharpen", + _("Sharpen Amount"), + _("How much image will be sharpened"), + 0, 100, 0, + G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_DENOISE_LUMA, g_param_spec_int ( + "denoise_luma", + _("Denoise"), + "FIXME", + 0, 100, 0, + G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, + PROP_DENOISE_CHROMA, g_param_spec_int ( + "denoise_chroma", + _("Color denoise"), + "FIXME", + 0, 100, 0, + G_PARAM_READWRITE) + ); + + filter_class->name = "FFT denoise filter"; + filter_class->get_image = get_image; +} + +static void +rs_denoise_init(RSDenoise *denoise) +{ + denoise->info.processMode = PROCESS_YUV; + initDenoiser(&denoise->info); + denoise->sharpen = 0; + denoise->denoise_luma = 0; + denoise->denoise_chroma = 0; + /* FIXME: Remember to destroy */ +} + +static void +get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + RSDenoise *denoise = RS_DENOISE(object); + + switch (property_id) + { + case PROP_SHARPEN: + g_value_set_int(value, denoise->sharpen); + break; + case PROP_DENOISE_LUMA: + g_value_set_int(value, denoise->denoise_luma); + break; + case PROP_DENOISE_CHROMA: + g_value_set_int(value, denoise->denoise_chroma); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + RSDenoise *denoise = RS_DENOISE(object); + RSFilter *filter = RS_FILTER(denoise); + + switch (property_id) + { + case PROP_SHARPEN: + if ((denoise->sharpen-g_value_get_int(value)) != 0) + { + denoise->sharpen = g_value_get_int(value); + rs_filter_changed(filter); + } + break; + case PROP_DENOISE_LUMA: + if ((denoise->denoise_luma-g_value_get_int(value)) != 0) + { + denoise->denoise_luma = g_value_get_int(value); + rs_filter_changed(filter); + } + break; + case PROP_DENOISE_CHROMA: + if ((denoise->denoise_chroma-g_value_get_int(value)) != 0) + { + denoise->denoise_chroma = g_value_get_int(value); + rs_filter_changed(filter); + } + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static RS_IMAGE16 * +get_image(RSFilter *filter) +{ + RSDenoise *denoise = RS_DENOISE(filter); + RS_IMAGE16 *input; + RS_IMAGE16 *output; + input = rs_filter_get_image(filter->previous); + + if ((denoise->sharpen + denoise->denoise_luma + denoise->denoise_chroma) == 0) + return input; + + output = rs_image16_copy(input, TRUE); + g_object_unref(input); + + denoise->info.image = output; + denoise->info.sigmaLuma = ((float) denoise->denoise_luma) / 5.0; + denoise->info.sigmaChroma = ((float) denoise->denoise_chroma) / 5.0; + denoise->info.sharpenLuma = ((float) denoise->sharpen) / 40.0; + denoise->info.beta = 1.0; + + denoise->info.sharpenMinSigmaLuma = denoise->info.sigmaLuma + 2.0; + + GTimer *gt = g_timer_new(); + denoiseImage(&denoise->info); + printf("Denoising with sigma:%f. sigmaChroma:%f Took:%.03fsec\n", denoise->info.sigmaLuma, denoise->info.sigmaChroma, g_timer_elapsed(gt, NULL)); + g_timer_destroy(gt); + + return output; +} Added: trunk/plugins/denoise/denoiseinterface.h =================================================================== --- trunk/plugins/denoise/denoiseinterface.h (rev 0) +++ trunk/plugins/denoise/denoiseinterface.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,70 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef denoiseinterface_h__ +#define denoiseinterface_h__ +#ifndef WIN32 +#include +#else +#include "..\..\..\..\win32\rawstudio.h" +#endif + +#ifdef _unix_ +G_BEGIN_DECLS +#endif + +#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */ +extern "C" { +#endif + +typedef enum { + PROCESS_RGB, PROCESS_YUV, PROCESS_PATTERN_RGB, PROCESS_PATTERN_YUV +} InitDenoiseMode; + +typedef struct { + InitDenoiseMode processMode; // Set this before initializing, DO NOT modify after that. + RS_IMAGE16* image; // This will be input and output + float sigmaLuma; // In RGB mode this is used for all planes, YUV mode only luma. + float sigmaChroma; // Used only in YUV mode. + float beta; // Used in all modes. + /* Sharpening - Luma is used for all planes in RGB */ + float sharpenLuma; // sharpening strength (default=0 - not sharpen) + float sharpenCutoffLuma; // sharpening cutoff frequency, relative to max (default=0.3) + float sharpenMinSigmaLuma; // Minimum limit (approximate noise margin) for sharpening stage (default=4.0) + float sharpenMaxSigmaLuma; // Maximum limit (approximate oversharping margin) for sharpening stage (default=20.0) + float sharpenChroma; // sharpening strength (default=0 - not sharpen) + float sharpenCutoffChroma; // sharpening cutoff frequency, relative to max (default=0.3) + float sharpenMinSigmaChroma; // Minimum limit (approximate noise margin) for sharpening stage (default=4.0) + float sharpenMaxSigmaChroma; // Maximum limit (approximate oversharping margin) for sharpening stage (default=20.0) + + void* _this; // Do not modify this value. +} FFTDenoiseInfo; + +void initDenoiser(FFTDenoiseInfo* info); +void denoiseImage(FFTDenoiseInfo* info); +void destroyDenoiser(FFTDenoiseInfo* info); +void abortDenoiser(FFTDenoiseInfo* info); + +#ifdef _unix_ +G_END_DECLS +#endif + +#ifdef __cplusplus /* If this is a C++ compiler, end C linkage */ +} +#endif +#endif // denoiseinterface_h__ Added: trunk/plugins/denoise/denoisethread.cpp =================================================================== --- trunk/plugins/denoise/denoisethread.cpp (rev 0) +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,114 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "denoisethread.h" +#include "complexfilter.h" +#include "fftwindow.h" + +void *StartDenoiseThread(void *_this) { + DenoiseThread *d = (DenoiseThread*)_this; + d->threadExited = false; + d->runDenoise(); + d->threadExited = true; + pthread_exit(NULL); + return NULL; +} + +DenoiseThread::DenoiseThread(void) { + exitThread = false; + threadExited = false; + pthread_mutex_init(&run_thread_mutex, NULL); + pthread_cond_init (&run_thread, NULL); // Signal thread to run + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_create(&thread_id,&attr,StartDenoiseThread,this); + pthread_attr_destroy(&attr); + complex = 0; + input_plane = 0; +} + +DenoiseThread::~DenoiseThread(void) { + if (!threadExited) + exitThread = true; + pthread_mutex_lock(&run_thread_mutex); + pthread_cond_signal(&run_thread); // Start thread + pthread_mutex_unlock(&run_thread_mutex); + pthread_join(thread_id, NULL); + pthread_mutex_destroy(&run_thread_mutex); + pthread_cond_destroy(&run_thread); + if (complex) + delete complex; + complex = 0; + if (input_plane) + delete input_plane; + input_plane = 0; +} + +void DenoiseThread::addJobs( JobQueue *_waiting, JobQueue *_finished ) +{ + pthread_mutex_lock(&run_thread_mutex); + waiting = _waiting; + finished = _finished; + pthread_cond_signal(&run_thread); + pthread_mutex_unlock(&run_thread_mutex); +} + +void DenoiseThread::runDenoise() { + while (!exitThread) { + pthread_mutex_lock(&run_thread_mutex); + pthread_cond_wait(&run_thread,&run_thread_mutex); // Wait for jobs + pthread_mutex_unlock(&run_thread_mutex); + vector jobs = waiting->getJobsPercent(10); + while (!exitThread && !jobs.empty()) { + Job* j = jobs[0]; + jobs.erase(jobs.begin()); + + FloatImagePlane* input = j->p->in; + + if (!complex) + complex = new ComplexBlock(input->w, input->h); + if (!input_plane) { + input_plane = new FloatImagePlane(input->w, input->h); + input_plane->allocateImage(); + } + + j->p->window->applyAnalysisWindow(input, input_plane); + + fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); + + g_assert(j->p->filter); + if (j->p->filter) + j->p->filter->process(complex); + + j->p->allocateOut(); + + fftwf_execute_dft_c2r(reverse, complex->complex, j->p->out->data); + //j->p->window->applySynthesisWindow(j->p->out); + + finished->addJob(j); + + if (jobs.empty()) + jobs = waiting->getJobsPercent(10); + + } + } +} + +#undef PTR_OFF +#undef ALIGN_OFFSET + \ No newline at end of file Added: trunk/plugins/denoise/denoisethread.h =================================================================== --- trunk/plugins/denoise/denoisethread.h (rev 0) +++ trunk/plugins/denoise/denoisethread.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,49 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef denoisethread_h__ +#define denoisethread_h__ + +#include "fftw3.h" +#include "jobqueue.h" +#include "pthread.h" +#include "complexblock.h" +#include "floatimageplane.h" + +class DenoiseThread +{ +public: + DenoiseThread(void); + virtual ~DenoiseThread(void); + void addJobs(JobQueue *waiting, JobQueue *finished); + void runDenoise(); + fftwf_plan forward; + fftwf_plan reverse; + ComplexBlock *complex; + FloatImagePlane *input_plane; + pthread_t thread_id; + pthread_cond_t run_thread; + pthread_mutex_t run_thread_mutex; + gboolean exitThread; + gboolean threadExited; +private: + JobQueue *waiting; + JobQueue *finished; + +}; +#endif // denoisethread_h__ Added: trunk/plugins/denoise/fftdenoiser.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiser.cpp (rev 0) +++ trunk/plugins/denoise/fftdenoiser.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,185 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "fftdenoiser.h" +#include "complexblock.h" +#include "fftdenoiseryuv.h" + +#ifdef WIN32 +int rs_get_number_of_processor_cores(){return 4;} +#endif + +FFTDenoiser::FFTDenoiser(void) +{ + nThreads = rs_get_number_of_processor_cores(); + threads = new DenoiseThread[nThreads]; + initializeFFT(); +} + +FFTDenoiser::~FFTDenoiser(void) +{ + delete[] threads; + fftwf_destroy_plan(plan_forward); + fftwf_destroy_plan(plan_reverse); +} + +void FFTDenoiser::denoiseImage( RS_IMAGE16* image ) +{ + FloatPlanarImage img; + img.bw = FFT_BLOCK_SIZE; + img.bh = FFT_BLOCK_SIZE; + img.ox = FFT_BLOCK_OVERLAP; + img.oy = FFT_BLOCK_OVERLAP; + + if (image->channels > 1 && image->filters==0) { + img.unpackInterleaved(image); + } else { + return; + } + if (abort) return; + + img.mirrorEdges(); + if (abort) return; + + FFTWindow window(img.bw,img.bh); + window.createHalfCosineWindow(img.ox, img.oy); + + img.setFilter(0,new ComplexWienerFilter(img.bw, img.bh, beta, sigma),&window); + img.setFilter(1,new ComplexWienerFilter(img.bw, img.bh, beta, sigma),&window); + img.setFilter(2,new ComplexWienerFilter(img.bw, img.bh, beta, sigma),&window); + + FloatPlanarImage outImg(img); + + processJobs(img, outImg); + if (abort) return; + + // Convert back + if (image->channels > 1 && image->filters==0) { + outImg.packInterleaved(image); + } +} + +void FFTDenoiser::processJobs(FloatPlanarImage &img, FloatPlanarImage &outImg) +{ + JobQueue* waiting_jobs = img.getJobs(); + JobQueue* finished_jobs = new JobQueue(); + + gint njobs = waiting_jobs->jobsLeft(); + + for (guint i = 0; i < nThreads; i++) { + threads[i].addJobs(waiting_jobs,finished_jobs); + } + + // Prepare for reassembling the image + outImg.allocate_planes(); + + gint jobs_added = 0; + while (jobs_added < njobs) { + Job *j = finished_jobs->waitForJob(); + if (j) { + outImg.applySlice(j->p); + } + delete j; + jobs_added++; + if (abort) { + jobs_added += waiting_jobs->removeRemaining(); + jobs_added += finished_jobs->removeRemaining(); + } + } +} + +gboolean FFTDenoiser::initializeFFT() +{ + // Create dummy block + FloatImagePlane plane(FFT_BLOCK_SIZE,FFT_BLOCK_SIZE); + plane.allocateImage(); + ComplexBlock complex(FFT_BLOCK_SIZE,FFT_BLOCK_SIZE); + int dim[2]; + dim[0] = FFT_BLOCK_SIZE; + dim[1] = FFT_BLOCK_SIZE; + plan_forward = fftwf_plan_dft_r2c(2, dim, plane.data, complex.complex,FFTW_MEASURE); + plan_reverse = fftwf_plan_dft_c2r(2, dim, complex.complex, plane.data,FFTW_MEASURE); + for (guint i = 0; i < nThreads; i++) { + threads[i].forward = plan_forward; + threads[i].reverse = plan_reverse; + threads[i].complex = new ComplexBlock(FFT_BLOCK_SIZE, FFT_BLOCK_SIZE); + } + return (plan_forward && plan_reverse); +} + + +void FFTDenoiser::setParameters( FFTDenoiseInfo *info ) +{ + sigma = info->sigmaLuma *SIGMA_FACTOR; + beta = max(1.0f, info->beta); + sharpen = info->sharpenLuma; + sharpenCutoff = info->sharpenCutoffLuma; + sharpenMinSigma = info->sharpenMinSigmaLuma*SIGMA_FACTOR; + sharpenMaxSigma = info->sharpenMaxSigmaLuma*SIGMA_FACTOR; +} + + + +extern "C" { + + /** INTERFACE **/ + + void initDenoiser(FFTDenoiseInfo* info) { + FFTDenoiser *t; + switch (info->processMode) { + case PROCESS_RGB: + t = new FFTDenoiser(); + break; + case PROCESS_YUV: + t = new FFTDenoiserYUV(); + break; + default: + g_assert(false); + } + info->_this = t; + // Initialize parameters to default + info->beta = 1.0f; + info->sigmaLuma = 1.0f; + info->sigmaChroma = 1.0f; + info->sharpenLuma = 0.0f; + info->sharpenChroma = 0.0f; + info->sharpenCutoffLuma = 0.3f; + info->sharpenCutoffChroma = 0.3f; + info->sharpenMinSigmaLuma = 4.0f; + info->sharpenMinSigmaChroma = 4.0f; + info->sharpenMaxSigmaLuma = 20.0f; + info->sharpenMaxSigmaChroma = 20.0f; + } + + void denoiseImage(FFTDenoiseInfo* info) { + FFTDenoiser *t = (FFTDenoiser*)info->_this; + t->abort = false; + t->setParameters(info); + t->denoiseImage(info->image); + } + + void destroyDenoiser(FFTDenoiseInfo* info) { + FFTDenoiser *t = (FFTDenoiser*)info->_this; + delete t; + } + + void abortDenoiser(FFTDenoiseInfo* info) { + FFTDenoiser *t = (FFTDenoiser*)info->_this; + t->abort = true; + } + +} // extern "C" Added: trunk/plugins/denoise/fftdenoiser.h =================================================================== --- trunk/plugins/denoise/fftdenoiser.h (rev 0) +++ trunk/plugins/denoise/fftdenoiser.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,51 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef fftdenoiser_h__ +#define fftdenoiser_h__ +#include +#include "floatplanarimage.h" +#include "denoisethread.h" +#include "denoiseinterface.h" + +#define FFT_BLOCK_SIZE 64 // Preferable able to be factorized into primes. +#define FFT_BLOCK_OVERLAP 16 // Preferably dividable by 4 (OVERLAP * 2 must be < SIZE) +#define SIGMA_FACTOR 20.0f; // Amount to multiply sigma by to give reasonable amount +class FFTDenoiser +{ +public: + FFTDenoiser(void); + virtual ~FFTDenoiser(void); + gboolean initializeFFT(); + virtual void setParameters( FFTDenoiseInfo *info); + virtual void denoiseImage(RS_IMAGE16* image); + gboolean abort; +protected: + virtual void processJobs(FloatPlanarImage &img, FloatPlanarImage &outImg); + guint nThreads; + DenoiseThread *threads; + fftwf_plan plan_forward; + fftwf_plan plan_reverse; + float sigma; + float beta; + float sharpen; + float sharpenCutoff; + float sharpenMinSigma; + float sharpenMaxSigma; +}; +#endif // fftdenoiser_h__ Added: trunk/plugins/denoise/fftdenoiseryuv.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiseryuv.cpp (rev 0) +++ trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,83 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "fftdenoiseryuv.h" + +FFTDenoiserYUV::FFTDenoiserYUV(void) +{ +} + +FFTDenoiserYUV::~FFTDenoiserYUV(void) +{ +} + +void FFTDenoiserYUV::denoiseImage( RS_IMAGE16* image ) +{ + FloatPlanarImage img; + img.bw = FFT_BLOCK_SIZE; + img.bh = FFT_BLOCK_SIZE; + img.ox = FFT_BLOCK_OVERLAP; + img.oy = FFT_BLOCK_OVERLAP; + + g_assert(image->channels == 3); + + img.unpackInterleaved_RGB_YUV(image); + + if (abort) return; + + img.mirrorEdges(); + if (abort) return; + + FFTWindow window(img.bw,img.bh); + window.createHalfCosineWindow(img.ox, img.oy); + + ComplexFilter *filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, beta, sigmaLuma, 1.0, plan_forward, &window); + filter->setSharpen(sharpen, sharpenMinSigma, sharpenMaxSigma, sharpenCutoff); + img.setFilter(0,filter,&window); + + filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, beta, sigmaChroma, 1.0, plan_forward, &window); + filter->setSharpen(sharpenChroma, sharpenMinSigmaChroma, sharpenMaxSigmaChroma, sharpenCutoffChroma); + img.setFilter(1,filter,&window); + + filter = new ComplexWienerFilterDeGrid(img.bw, img.bh, beta, sigmaChroma, 1.0, plan_forward, &window); + filter->setSharpen(sharpenChroma, sharpenMinSigmaChroma, sharpenMaxSigmaChroma, sharpenCutoffChroma); + img.setFilter(2,filter,&window); + + FloatPlanarImage outImg(img); + + processJobs(img, outImg); + if (abort) return; + + // Convert back + outImg.packInterleaved_YUV_RGB(image); +} + + +void FFTDenoiserYUV::setParameters( FFTDenoiseInfo *info ) +{ + FFTDenoiser::setParameters(info); + sigmaLuma = info->sigmaLuma*SIGMA_FACTOR; + sigmaChroma = info->sigmaChroma*SIGMA_FACTOR; + sharpen = info->sharpenLuma; + sharpenCutoff = info->sharpenCutoffLuma; + sharpenMinSigma = info->sharpenMinSigmaLuma*SIGMA_FACTOR; + sharpenMaxSigma = info->sharpenMaxSigmaLuma*SIGMA_FACTOR; + sharpenChroma = info->sharpenChroma; + sharpenCutoffChroma = info->sharpenCutoffChroma; + sharpenMinSigmaChroma = info->sharpenMinSigmaChroma*SIGMA_FACTOR; + sharpenMaxSigmaChroma = info->sharpenMaxSigmaChroma*SIGMA_FACTOR; +} \ No newline at end of file Added: trunk/plugins/denoise/fftdenoiseryuv.h =================================================================== --- trunk/plugins/denoise/fftdenoiseryuv.h (rev 0) +++ trunk/plugins/denoise/fftdenoiseryuv.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,39 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef fftdenoiseryuv_h__ +#define fftdenoiseryuv_h__ + +#include "fftdenoiser.h" + +class FFTDenoiserYUV : + public FFTDenoiser +{ +public: + FFTDenoiserYUV(); + virtual ~FFTDenoiserYUV(void); + virtual void denoiseImage(RS_IMAGE16* image); + virtual void setParameters( FFTDenoiseInfo *info); + float sigmaLuma; + float sigmaChroma; + float sharpenChroma; + float sharpenCutoffChroma; + float sharpenMinSigmaChroma; + float sharpenMaxSigmaChroma; +}; +#endif // fftdenoiseryuv_h__ Added: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp (rev 0) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,155 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* Contains code from: +* +* Based on FFT3DFilter plugin for Avisynth 2.5 - 3D Frequency Domain filter +* Copyright(C)2004-2005 A.G.Balakhnin aka Fizick, email: bag at hotmail.ru, web: http://bag.hotmail.ru + +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + + +#include "fftwindow.h" +#include + +#define PI_F 3.14159265358979323846f + + +FFTWindow::FFTWindow( int _w, int _h ) : +analysis(FloatImagePlane(_w, _h)), +synthesis(FloatImagePlane(_w,_h)) +{ + analysis.allocateImage(); + synthesis.allocateImage(); +} + + +FFTWindow::~FFTWindow(void) +{} + + +void FFTWindow::createHalfCosineWindow( int ox, int oy ) +{ + float *wanx=new float[ox];//analysis windox + float *wsynx=new float[ox];//syntesis windox + + //Calc 1d half-cosine window + for(int i=0;ibh-overlap) + yfactor *= weight[bh - y]; + + float *m = window.getLine(y); + + for (int x = 0; x < bw; x++) { + float factor = yfactor; + if (x bw-overlap) + factor *= weight[bw - x]; + + m[x] = factor; + } + } +} +// FIXME: SSE2 me +void FFTWindow::applyAnalysisWindow( FloatImagePlane *image, FloatImagePlane *dst ) +{ + g_assert(image->w == analysis.w); + g_assert(image->h == analysis.h); + g_assert(dst->w == analysis.w); + g_assert(dst->h == analysis.h); + for (int y = 0; y < analysis.h; y++) { + float *srcp1 = analysis.getLine(y); + float *srcp2 = image->getLine(y); + float *dstp = dst->getLine(y); + for (int x = 0; x < analysis.w; x++) { + dstp[x] = srcp1[x] * srcp2[x]; + } + } +} + +// FIXME: SSE2 me +void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) +{ + g_assert(image->w == synthesis.w); + g_assert(image->h == synthesis.h); + for (int y = 0; y < synthesis.h; y++) { + float *srcp1 = image->getLine(y); + float *srcp2 = synthesis.getLine(y); + for (int x = 0; x < synthesis.w; x++) { + srcp1[x] *= srcp2[x]; + } + } +} \ No newline at end of file Added: trunk/plugins/denoise/fftwindow.h =================================================================== --- trunk/plugins/denoise/fftwindow.h (rev 0) +++ trunk/plugins/denoise/fftwindow.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,39 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#ifndef fftwindow_h__ +#define fftwindow_h__ +#include "floatimageplane.h" + + +class FFTWindow +{ +public: + FFTWindow(int _w, int _h); + virtual ~FFTWindow(void); + FloatImagePlane analysis; + FloatImagePlane synthesis; + void createHalfCosineWindow(int ox, int oy); + void createRaisedCosineWindow(int ox, int oy); + void createSqrtHalfCosineWindow(int ox, int oy); + void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); + void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image +private: + void createWindow( FloatImagePlane &window, int ox, float* wx); +}; + +#endif // fftwindow_h__ Added: trunk/plugins/denoise/floatimageplane.cpp =================================================================== --- trunk/plugins/denoise/floatimageplane.cpp (rev 0) +++ trunk/plugins/denoise/floatimageplane.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,160 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "floatimageplane.h" +#include "fftw3.h" +#include + +FloatImagePlane::FloatImagePlane( int _w, int _h, int _plane_id ) : +w(_w), h(_h), data(0), plane_id(_plane_id), filter(0), window(0), pitch(0), allocated(0) +{ +} + +FloatImagePlane::FloatImagePlane( const FloatImagePlane& p ) : +w(p.w), h(p.h),data(p.data), plane_id(p.plane_id), filter(0), window(p.window), +pitch(p.pitch), allocated(0) +{ +} + +FloatImagePlane::~FloatImagePlane(void) +{ + if (allocated) + fftwf_free(allocated); + if (filter) + delete filter; + filter = 0; + allocated = 0; +} + +void FloatImagePlane::allocateImage() +{ + if (allocated) + return; + pitch = ((w+3)/4)*4; + allocated = (gfloat *) fftwf_malloc(pitch*h*sizeof(gfloat)); + g_assert(allocated); + data = allocated; +} + +gfloat* FloatImagePlane::getLine( int y ) { + return &data[pitch*y]; +} + +gfloat* FloatImagePlane::getAt( int x, int y ) { + return &data[pitch*y+x]; +} + +void FloatImagePlane::mirrorEdges( int mirror_x, int mirror_y ) { + // Mirror top + for (int y = 0; yin = getSlice(start_x, start_y, bw, bh); + s->offset_x = start_x; + s->offset_y = start_y; + s->overlap_x = ox; + s->overlap_y = oy; + s->filter = filter; + s->window = window; + jobs->addJob(new Job(s)); + if (start_x + bw*2 - ox*2 >= w) { //Will next block be out of frame? + if (start_x == w - bw) + endx = true; + start_x = w - bw; // Add last possible block + } else { + start_x += bw - ox*2; + } + } // end while x + if (start_y + bh*2 - oy*2 >= h) { //Will next block be out of frame? + if (start_y == h - bh) + endy = true; + start_y = h - bh; // Add last possible block + } else { + start_y += bh - oy*2; + } + }//end while y +} + +FloatImagePlane* FloatImagePlane::getSlice( int x, int y,int new_w, int new_h ) +{ + g_assert(x+new_w<=w); + g_assert(y+new_h<=h); + FloatImagePlane* s = new FloatImagePlane(new_w, new_h, plane_id); + s->data = getAt(x,y); + s->pitch = pitch; + return s; +} + +void FloatImagePlane::applySlice( PlanarImageSlice *p ) { + int start_y = p->offset_y + p->overlap_y; + int end_y = p->offset_y + p->out->h - p->overlap_y; + int start_x = p->offset_x + p->overlap_x; + int end_x = p->offset_x + p->out->w - p->overlap_x; + float normalization = 1.0f / (float)(p->out->w * p->out->h); + + for (int y = start_y; y < end_y; y++ ) { + float* src = p->out->getAt(p->overlap_x,y-start_y+p->overlap_y); + float* dst = getAt(start_x,y); + for (int x = start_x; x < end_x; x++) { + *dst++ = normalization * (*src++); + } + } +} + +//TODO: SSE2 me. +void FBitBlt(guchar* dstp, int dst_pitch, const guchar* srcp, int src_pitch, int row_size, int height) { + if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { + memcpy(dstp, srcp, row_size*height); + return; + } + for (int y=height; y>0; --y) { + memcpy(dstp, srcp, row_size); + dstp += dst_pitch; + srcp += src_pitch; + } +} + +void FloatImagePlane::blitOnto( FloatImagePlane *p ) { + g_assert(p->w == w); + g_assert(p->h == h); + FBitBlt((guchar*)p->data, p->pitch*sizeof(float),(guchar*)data,pitch*sizeof(float),w*sizeof(float),h); +} \ No newline at end of file Added: trunk/plugins/denoise/floatimageplane.h =================================================================== --- trunk/plugins/denoise/floatimageplane.h (rev 0) +++ trunk/plugins/denoise/floatimageplane.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef imageplane_h__ +#define imageplane_h__ +#include "jobqueue.h" +#include +#include +#include "complexfilter.h" + + +using namespace std; +class FFTWindow; + +class FloatImagePlane +{ +public: + FloatImagePlane(int _w, int _h, int id = -1); + FloatImagePlane(const FloatImagePlane& p); + virtual ~FloatImagePlane(void); + void allocateImage(); + void mirrorEdges(int mirror_x, int mirror_y); + gfloat* getLine(int y); + gfloat* getAt(int x, int y); + FloatImagePlane* getSlice(int x,int y,int new_w, int new_h); + void blitOnto(FloatImagePlane *p); + void addJobs(JobQueue *jobs, int bw, int bh, int ox, int oy); + void applySlice(PlanarImageSlice *p); + const int w; + const int h; + gfloat* data; + int plane_id; + ComplexFilter* filter; + FFTWindow* window; + int pitch; // Not in bytes, but in floats +private: + gfloat* allocated; +}; + +void FBitBlt(guchar* dstp, int dst_pitch, const guchar* srcp, int src_pitch, int row_size, int height); + +#endif // imageplane_h__ Added: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp (rev 0) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,197 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "floatplanarimage.h" +#include "complexfilter.h" + +FloatPlanarImage::FloatPlanarImage(void) { + p = 0; +} + +FloatPlanarImage::FloatPlanarImage( const FloatPlanarImage &img ) +{ + nPlanes = img.nPlanes; + p = new FloatImagePlane*[nPlanes]; + for (int i = 0; i < nPlanes; i++) + p[i] = new FloatImagePlane(img.p[i]->w, img.p[i]->h, i); + + bw = img.bw; + bh = img.bh; + ox = img.ox; + oy = img.oy; +} + +FloatPlanarImage::~FloatPlanarImage(void) { + if (p != 0) { + for (int i = 0; i < nPlanes; i++) { + if (p[i]) + delete p[i]; + p[i] = 0; + } + delete[] p; + p = 0; + } +} + +void FloatPlanarImage::allocate_planes() { + for (int i = 0; i < nPlanes; i++) + p[i]->allocateImage(); +} + +void FloatPlanarImage::mirrorEdges() +{ + for (int i = 0; i < nPlanes; i++) + p[i]->mirrorEdges(ox, oy); +} + +void FloatPlanarImage::setFilter( int plane, ComplexFilter *f, FFTWindow *window ) +{ + if (plane >= nPlanes) + return; + p[plane]->filter = f; + p[plane]->window = window; +} + +// TODO: Begs to be SSE2 and/or SMP. +void FloatPlanarImage::unpackInterleaved( const RS_IMAGE16* image ) +{ + // Already demosaiced + if (image->channels != 3) + return; + + nPlanes = 3; + g_assert(p == 0); + p = new FloatImagePlane*[nPlanes]; + + for (int i = 0; i < nPlanes; i++) + p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); + + allocate_planes(); + + for (int y = 0; y < image->h; y++ ) { + const gushort* pix = GET_PIXEL(image,0,y); + gfloat *rp = p[0]->getAt(ox, y+oy); + gfloat *gp = p[1]->getAt(ox, y+oy); + gfloat *bp = p[2]->getAt(ox, y+oy); + for (int x=0; xw; x++) { + *rp++ = (float)(*pix); + *gp++ = (float)(*(pix+1)); + *bp++ = (float)(*(pix+2)); + pix += image->pixelsize; + } + } +} + +// TODO: Begs to be SSE2 and/or SMP. Scalar int<->float is incredibly slow. +void FloatPlanarImage::packInterleaved( RS_IMAGE16* image ) +{ + for (int i = 0; i < nPlanes; i++) { + g_assert(p[i]->w == image->w+ox*2); + g_assert(p[i]->h == image->h+oy*2); + } + + for (int y = 0; y < image->h; y++ ) { + for (int c = 0; cgetAt(ox, y+oy); + gushort* out = GET_PIXEL(image,0,y) + c; + for (int x=0; xw; x++) { + int p = (int)*(in++); + *out = clampbits(p,16); + out += image->pixelsize; + } + } + } +} + +// TODO: Begs to be SSE2 and/or SMP. +void FloatPlanarImage::unpackInterleaved_RGB_YUV( const RS_IMAGE16* image ) +{ + // Already demosaiced + if (image->channels != 3) + return; + + g_assert(p == 0); + nPlanes = 3; + p = new FloatImagePlane*[nPlanes]; + + for (int i = 0; i < nPlanes; i++) + p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); + + allocate_planes(); + + for (int y = 0; y < image->h; y++ ) { + const gushort* pix = GET_PIXEL(image,0,y); + gfloat *Y = p[0]->getAt(ox, y+oy); + gfloat *Cb = p[1]->getAt(ox, y+oy); + gfloat *Cr = p[2]->getAt(ox, y+oy); + for (int x=0; xw; x++) { + float r = (float)(*pix); + float g = (float)(*(pix+1)); + float b = (float)(*(pix+2)); + *Y++ = r * 0.299 + g * 0.587 + b * 0.114 ; + *Cb++ = r * -0.169 + g * -0.331 + b * 0.499; + *Cr++ = r * 0.499 + g * -0.418 - b * 0.0813; + pix += image->pixelsize; + } + } +} + +// TODO: Begs to be SSE2 and/or SMP. Scalar int<->float is incredibly slow. +void FloatPlanarImage::packInterleaved_YUV_RGB( RS_IMAGE16* image ) +{ + if (image->channels != 3) + return; + + for (int i = 0; i < nPlanes; i++) { + g_assert(p[i]->w == image->w+ox*2); + g_assert(p[i]->h == image->h+oy*2); + } + + for (int y = 0; y < image->h; y++ ) { + gfloat *Y = p[0]->getAt(ox, y+oy); + gfloat *Cb = p[1]->getAt(ox, y+oy); + gfloat *Cr = p[2]->getAt(ox, y+oy); + gushort* out = GET_PIXEL(image,0,y); + for (int x=0; xw; x++) { + int r = (int)(Y[x] + 1.402 * Cr[x]); + int g = (int)(Y[x] - 0.344 * Cb[x] - 0.714 * Cr[x]); + int b = (int)(Y[x] + 1.772 * Cb[x]); + out[0] = clampbits(r,16); + out[1] = clampbits(g,16); + out[2] = clampbits(b,16); + out += image->pixelsize; + } + } +} + + + +JobQueue* FloatPlanarImage::getJobs() { + JobQueue *jobs = new JobQueue(); + + for (int i = 0; i < nPlanes; i++) + p[i]->addJobs(jobs, bw, bh, ox, oy); + + return jobs; +} + +void FloatPlanarImage::applySlice( PlanarImageSlice *slice ) +{ + int plane = slice->out->plane_id; + g_assert(plane>=0 && planeapplySlice(slice); +} Added: trunk/plugins/denoise/floatplanarimage.h =================================================================== --- trunk/plugins/denoise/floatplanarimage.h (rev 0) +++ trunk/plugins/denoise/floatplanarimage.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,53 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef floatplanarimage_h__ +#define floatplanarimage_h__ +#include "floatimageplane.h" +#include "jobqueue.h" +#include "fftwindow.h" + +// A container and utility class + +class FloatPlanarImage +{ +public: + FloatPlanarImage(void); + FloatPlanarImage( const FloatPlanarImage &img ); // Creates image with similar features + + virtual ~FloatPlanarImage(void); + void allocate_planes(); + void mirrorEdges(); + FloatImagePlane **p; + int nPlanes; + void unpackInterleaved(const RS_IMAGE16* image); + void packInterleaved( RS_IMAGE16* image ); + void applySlice(PlanarImageSlice *p); + void setFilter( int plane, ComplexFilter *f, FFTWindow *window); + JobQueue* getJobs(); + void unpackInterleaved_RGB_YUV( const RS_IMAGE16* image ); + void packInterleaved_YUV_RGB( RS_IMAGE16* image ); + int bw; // Block width + int bh; // Block height + int ox; // Overlap pixels + int oy; // Overlap pixels + +}; +#endif // floatplanarimage_h__ + +inline guint clampbits(gint x, guint n) { guint32 _y_temp; if( (_y_temp=x>>n) ) x = ~_y_temp >> (32-n); return x;} Added: trunk/plugins/denoise/jobqueue.cpp =================================================================== --- trunk/plugins/denoise/jobqueue.cpp (rev 0) +++ trunk/plugins/denoise/jobqueue.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,125 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "jobqueue.h" + +Job::Job( PlanarImageSlice *s ) : p(s) { +} + +Job::~Job( void ) { + if (p) + delete(p); +} + +JobQueue::JobQueue(void) +{ + pthread_mutex_init(&job_mutex, NULL); + pthread_cond_init(&job_added_notify, NULL); +} + +JobQueue::~JobQueue(void) +{ + pthread_mutex_destroy(&job_mutex); + pthread_cond_destroy(&job_added_notify); +} + +Job* JobQueue::getJob() +{ + Job *j; + pthread_mutex_lock(&job_mutex); + if (jobs.empty()) + j = 0; + else { + j = jobs[0]; + jobs.erase(jobs.begin()); + } + pthread_mutex_unlock(&job_mutex); + return j; +} + +vector JobQueue::getJobs(int n) +{ + vector j; + pthread_mutex_lock(&job_mutex); + n = MIN(n,(int)jobs.size()); + for (int i = 0; i < n; i++) { + j.push_back(jobs[0]); + jobs.erase(jobs.begin()); + } + pthread_mutex_unlock(&job_mutex); + return j; +} + +vector JobQueue::getJobsPercent( int percent ) +{ + vector j; + pthread_mutex_lock(&job_mutex); + if (jobs.empty()) { + pthread_mutex_unlock(&job_mutex); + return j; + } + int n = MAX(1, percent * jobs.size() / 100); + for (int i = 0; i < n; i++) { + j.push_back(jobs[0]); + jobs.erase(jobs.begin()); + } + pthread_mutex_unlock(&job_mutex); + return j; +} +void JobQueue::addJob( Job* job) +{ + pthread_mutex_lock(&job_mutex); + jobs.push_back(job); + pthread_cond_signal(&job_added_notify); + pthread_mutex_unlock(&job_mutex); +} + +int JobQueue::jobsLeft(void) { + int size; + pthread_mutex_lock(&job_mutex); + size = jobs.size(); + pthread_mutex_unlock(&job_mutex); + return size; +} + +Job* JobQueue::waitForJob() +{ + Job *j; + pthread_mutex_lock(&job_mutex); + if (jobs.empty()) + pthread_cond_wait(&job_added_notify, &job_mutex); + + j = jobs[0]; + jobs.erase(jobs.begin()); + + pthread_mutex_unlock(&job_mutex); + return j; +} + +int JobQueue::removeRemaining() +{ + pthread_mutex_lock(&job_mutex); + int n = jobs.size(); + for (int i = 0; i < n; i++) { + delete jobs[i]; + } + jobs.clear(); + pthread_mutex_unlock(&job_mutex); + return n; +} + Added: trunk/plugins/denoise/jobqueue.h =================================================================== --- trunk/plugins/denoise/jobqueue.h (rev 0) +++ trunk/plugins/denoise/jobqueue.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef jobqueue_h__ +#define jobqueue_h__ + +#include +#include "planarimageslice.h" +#include "pthread.h" + +using namespace std; + +class Job +{ +public: + Job(PlanarImageSlice *slice); + virtual ~Job(void); + PlanarImageSlice *p; +}; + + +class JobQueue +{ +public: + JobQueue(void); + virtual ~JobQueue(void); + Job* getJob(); + void addJob(Job*); + int removeRemaining(); // Removes remaining jobs, and returns the number of deleted jobs. + int jobsLeft(); + Job* waitForJob(); + vector getJobs(int n); + vector getJobsPercent(int percent); +private: + vector jobs; // Requires a mutex, so private. + pthread_mutex_t job_mutex; + pthread_cond_t job_added_notify; +}; +#endif // jobqueue_h__ Added: trunk/plugins/denoise/planarimageslice.cpp =================================================================== --- trunk/plugins/denoise/planarimageslice.cpp (rev 0) +++ trunk/plugins/denoise/planarimageslice.cpp 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,43 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "planarimageslice.h" +#include "floatimageplane.h" + +PlanarImageSlice::PlanarImageSlice(void) +{ + filter = 0; + in = 0; + out = 0; +} + +PlanarImageSlice::~PlanarImageSlice(void) { + if (out) + delete out; + out = 0; + if (in) + delete in; + in = 0; +} + +void PlanarImageSlice::allocateOut() { + if (out) + return; + out = new FloatImagePlane(in->w, in->h, in->plane_id); + out->allocateImage(); +} Added: trunk/plugins/denoise/planarimageslice.h =================================================================== --- trunk/plugins/denoise/planarimageslice.h (rev 0) +++ trunk/plugins/denoise/planarimageslice.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef planarimageslice_h__ +#define planarimageslice_h__ +#include + + +class FloatImagePlane; +class ComplexFilter; +class FFTWindow; + +class PlanarImageSlice +{ +public: + PlanarImageSlice(void); + virtual ~PlanarImageSlice(void); + FloatImagePlane *in; + FloatImagePlane *out; + void allocateOut(); + gint offset_x; + gint offset_y; + gint overlap_x; + gint overlap_y; + ComplexFilter *filter; + FFTWindow *window; +}; + +#endif // planarimageslice_h__ Modified: trunk/src/conf_interface.h =================================================================== --- trunk/src/conf_interface.h 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/src/conf_interface.h 2009-03-13 21:04:45 UTC (rev 2239) @@ -68,6 +68,8 @@ #define CONF_SHOW_TOOLBOX_CONTRAST "show_toolbox_contrast" #define CONF_SHOW_TOOLBOX_WARMTH "show_toolbox_warmth" #define CONF_SHOW_TOOLBOX_SHARPEN "show_toolbox_sharpen" +#define CONF_SHOW_TOOLBOX_DENOISE_LUMA "show_toolbox_denoise_luma" +#define CONF_SHOW_TOOLBOX_DENOISE_CHROMA "show_toolbox_denoise_chroma" #define CONF_SHOW_TOOLBOX_CURVE "show_toolbox_curve" #define CONF_SHOW_TOOLBOX_TRANSFORM "show_toolbox_transform" #define CONF_SHOW_TOOLBOX_HIST "show_toolbox_hist" @@ -95,6 +97,8 @@ #define DEFAULT_CONF_SHOW_TOOLBOX_CONTRAST TRUE #define DEFAULT_CONF_SHOW_TOOLBOX_WARMTH TRUE #define DEFAULT_CONF_SHOW_TOOLBOX_SHARPEN TRUE +#define DEFAULT_CONF_SHOW_TOOLBOX_DENOISE_LUMA TRUE +#define DEFAULT_CONF_SHOW_TOOLBOX_DENOISE_CHROMA TRUE #define DEFAULT_CONF_SHOW_TOOLBOX_CURVE TRUE #define DEFAULT_CONF_SHOW_TOOLBOX_TRANSFORM TRUE #define DEFAULT_CONF_SHOW_TOOLBOX_HIST TRUE Modified: trunk/src/rs-cache.c =================================================================== --- trunk/src/rs-cache.c 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/src/rs-cache.c 2009-03-13 21:04:45 UTC (rev 2239) @@ -26,7 +26,7 @@ #include "rs-photo.h" /* This will be written to XML files for making backward compatibility easier to implement */ -#define CACHEVERSION 2 +#define CACHEVERSION 3 static guint rs_cache_load_setting(RSSettings *rss, xmlDocPtr doc, xmlNodePtr cur); @@ -107,6 +107,10 @@ if (mask & MASK_SHARPEN) xmlTextWriterWriteFormatElement(writer, BAD_CAST "sharpen", "%f", photo->settings[id]->sharpen); + xmlTextWriterWriteFormatElement(writer, BAD_CAST "denoise_luma", "%f", + photo->settings[id]->denoise_luma); + xmlTextWriterWriteFormatElement(writer, BAD_CAST "denoise_chroma", "%f", + photo->settings[id]->denoise_chroma); if (mask & MASK_CURVE && photo->settings[id]->curve_nknots > 0) { xmlTextWriterStartElement(writer, BAD_CAST "curve"); @@ -170,6 +174,16 @@ mask |= MASK_SHARPEN; target = &rss->sharpen; } + else if ((!xmlStrcmp(cur->name, BAD_CAST "denoise_luma"))) + { + mask |= MASK_DENOISE_LUMA; + target = &rss->denoise_luma; + } + else if ((!xmlStrcmp(cur->name, BAD_CAST "denoise_chroma"))) + { + mask |= MASK_DENOISE_CHROMA; + target = &rss->denoise_chroma; + } else if ((!xmlStrcmp(cur->name, BAD_CAST "curve"))) { gchar **vals; Modified: trunk/src/rs-photo.c =================================================================== --- trunk/src/rs-photo.c 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/src/rs-photo.c 2009-03-13 21:04:45 UTC (rev 2239) @@ -265,6 +265,8 @@ RS_PHOTO_GET_GDOUBLE_VALUE(warmth) RS_PHOTO_GET_GDOUBLE_VALUE(tint) RS_PHOTO_GET_GDOUBLE_VALUE(sharpen) +RS_PHOTO_GET_GDOUBLE_VALUE(denoise_luma) +RS_PHOTO_GET_GDOUBLE_VALUE(denoise_chroma) #undef RS_PHOTO_GET_GDOUBLE_VALUE @@ -286,6 +288,7 @@ RS_PHOTO_SET_GDOUBLE_VALUE(warmth, WARMTH) RS_PHOTO_SET_GDOUBLE_VALUE(tint, TINT) RS_PHOTO_SET_GDOUBLE_VALUE(sharpen, SHARPEN) +/* FIXME: denoise! */ #undef RS_PHOTO_SET_GDOUBLE_VALUE Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/src/rs-preview-widget.c 2009-03-13 21:04:45 UTC (rev 2239) @@ -140,7 +140,7 @@ RSFilter *filter_crop[MAX_VIEWS]; RSFilter *filter_rotate[MAX_VIEWS]; RSFilter *filter_resample[MAX_VIEWS]; - RSFilter *filter_sharpen[MAX_VIEWS]; + RSFilter *filter_denoise[MAX_VIEWS]; RSFilter *filter_cache[MAX_VIEWS]; RSFilter *filter_end[MAX_VIEWS]; /* For convenience */ @@ -307,8 +307,8 @@ preview->filter_crop[i] = rs_filter_new("RSCrop", preview->filter_rotate[i]); preview->filter_resample[i] = rs_filter_new("RSResample", preview->filter_crop[i]); preview->filter_cache[i] = rs_filter_new("RSCache", preview->filter_resample[i]); - preview->filter_sharpen[i] = rs_filter_new("RSSharpen", preview->filter_cache[i]); - preview->filter_cache[i] = rs_filter_new("RSCache", preview->filter_sharpen[i]); + preview->filter_denoise[i] = rs_filter_new("RSDenoise", preview->filter_cache[i]); + preview->filter_cache[i] = rs_filter_new("RSCache", preview->filter_denoise[i]); preview->filter_end[i] = preview->filter_cache[i]; g_signal_connect(preview->filter_end[i], "changed", G_CALLBACK(filter_changed), preview); @@ -432,7 +432,7 @@ g_object_set(preview->filter_input[view], "image", preview->photo->input, NULL); g_object_set(preview->filter_rotate[view], "angle", preview->photo->angle, "orientation", preview->photo->orientation, NULL); g_object_set(preview->filter_crop[view], "rectangle", preview->photo->crop, NULL); - g_object_set(preview->filter_sharpen[view], "amount", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); + g_object_set(preview->filter_denoise[view], "sharpen", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); rescale(preview, view); } } @@ -669,7 +669,7 @@ rs_color_transform_set_from_settings(preview->rct[view], preview->photo->settings[preview->snapshot[view]], MASK_ALL); - g_object_set(preview->filter_sharpen[view], "amount", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); + g_object_set(preview->filter_denoise[view], "sharpen", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); DIRTY(preview->dirty[view], BUFFER); DIRTY(preview->dirty[view], SCREEN); @@ -1226,8 +1226,8 @@ } /* Update sharpen */ - g_object_set(preview->filter_sharpen[view], - "amount", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, + g_object_set(preview->filter_denoise[view], + "sharpen", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); } @@ -2052,8 +2052,25 @@ DIRTY(preview->dirty[view], BUFFER); DIRTY(preview->dirty[view], SCREEN); if (mask & MASK_SHARPEN) - g_object_set(preview->filter_sharpen[view], "amount", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); - if (mask ^ MASK_SHARPEN) + { + gfloat f = 0.0; + g_object_get(preview->photo->settings[preview->snapshot[view]], "sharpen", &f, NULL); + g_object_set(preview->filter_denoise[view], "sharpen", (gint) f, NULL); + } + if (mask & MASK_DENOISE_LUMA) + { + gfloat f = 0.0; + g_object_get(preview->photo->settings[preview->snapshot[view]], "denoise_luma", &f, NULL); + g_object_set(preview->filter_denoise[view], "denoise_luma", (gint) f, NULL); + printf("%.03f\n", f); + } + if (mask & MASK_DENOISE_CHROMA) + { + gfloat f = 0.0; + g_object_get(preview->photo->settings[preview->snapshot[view]], "denoise_chroma", &f, NULL); + g_object_set(preview->filter_denoise[view], "denoise_chroma", (gint) f, NULL); + } + if (mask ^ (MASK_SHARPEN|MASK_DENOISE_LUMA|MASK_DENOISE_CHROMA)) rs_color_transform_set_from_settings(preview->rct[view], preview->photo->settings[preview->snapshot[view]], mask); } } Modified: trunk/src/toolbox.c =================================================================== --- trunk/src/toolbox.c 2009-03-10 02:27:34 UTC (rev 2238) +++ trunk/src/toolbox.c 2009-03-13 21:04:45 UTC (rev 2239) @@ -184,6 +184,8 @@ APPLY(warmth, WARMTH); APPLY(tint, TINT); APPLY(sharpen, SHARPEN); + APPLY(denoise_luma, DENOISE_LUMA); + APPLY(denoise_chroma, DENOISE_CHROMA); #undef APPLY g_signal_handler_unblock(rc->settings, rc->settings_signal_id); } @@ -411,6 +413,8 @@ GtkAdjustment *warmth; GtkAdjustment *tint; GtkAdjustment *sharpen; + GtkAdjustment *denoise_luma; + GtkAdjustment *denoise_chroma; RSCurveWidget *curve; } ToolboxAdjusters; @@ -437,6 +441,8 @@ APPLY(warmth, WARMTH); APPLY(tint, TINT); APPLY(sharpen, SHARPEN); + APPLY(denoise_luma, DENOISE_LUMA); + APPLY(denoise_chroma, DENOISE_CHROMA); #undef APPLY if (mask & MASK_CURVE) @@ -466,6 +472,8 @@ GtkWidget **toolbox_warmth = g_new(GtkWidget *, 3); GtkWidget **toolbox_curve = g_new(GtkWidget *, 3); GtkWidget **toolbox_sharpen = g_new(GtkWidget *, 3); + GtkWidget **toolbox_denoise_luma = g_new(GtkWidget *, 3); + GtkWidget **toolbox_denoise_chroma = g_new(GtkWidget *, 3); GtkWidget *toolbox_transform; GtkWidget *toolbox_hist; GtkWidget *toolboxscroller; @@ -539,7 +547,9 @@ g_signal_connect_after(toolbox_warmth[n], "activate", G_CALLBACK(gui_expander_toggle_callback), toolbox_warmth); g_signal_connect_after(toolbox_warmth[n], "activate", G_CALLBACK(gui_expander_save_status_callback), CONF_SHOW_TOOLBOX_WARMTH); - SLIDER(sharpen, SHARPEN, 0.5); + SLIDER(sharpen, SHARPEN, 10.0); + SLIDER(denoise_luma, DENOISE_LUMA, 10.0); + SLIDER(denoise_chroma, DENOISE_CHROMA, 10.0); /* Curve */ gfloat *knots; From anders at brander.dk Fri Mar 13 22:22:25 2009 From: anders at brander.dk (Anders Brander) Date: Fri, 13 Mar 2009 22:22:25 +0100 Subject: [Rawstudio-commit] r2240 - trunk/src Message-ID: Author: abrander Date: 2009-03-13 22:22:25 +0100 (Fri, 13 Mar 2009) New Revision: 2240 Modified: trunk/src/rs-preview-widget.c Log: Fixed segfault RSPreviewWidget. Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-13 21:04:45 UTC (rev 2239) +++ trunk/src/rs-preview-widget.c 2009-03-13 21:22:25 UTC (rev 2240) @@ -432,7 +432,7 @@ g_object_set(preview->filter_input[view], "image", preview->photo->input, NULL); g_object_set(preview->filter_rotate[view], "angle", preview->photo->angle, "orientation", preview->photo->orientation, NULL); g_object_set(preview->filter_crop[view], "rectangle", preview->photo->crop, NULL); - g_object_set(preview->filter_denoise[view], "sharpen", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); + g_object_set(preview->filter_denoise[view], "sharpen", (gint) (preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen), NULL); rescale(preview, view); } } @@ -669,7 +669,7 @@ rs_color_transform_set_from_settings(preview->rct[view], preview->photo->settings[preview->snapshot[view]], MASK_ALL); - g_object_set(preview->filter_denoise[view], "sharpen", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, NULL); + g_object_set(preview->filter_denoise[view], "sharpen", (gint) (preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen), NULL); DIRTY(preview->dirty[view], BUFFER); DIRTY(preview->dirty[view], SCREEN); From anders at brander.dk Sat Mar 14 11:22:59 2009 From: anders at brander.dk (Anders Brander) Date: Sat, 14 Mar 2009 11:22:59 +0100 Subject: [Rawstudio-commit] r2241 - trunk/src Message-ID: Author: abrander Date: 2009-03-14 11:22:59 +0100 (Sat, 14 Mar 2009) New Revision: 2241 Modified: trunk/src/rs-preview-widget.c Log: Removed debug-printf(). Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-13 21:22:25 UTC (rev 2240) +++ trunk/src/rs-preview-widget.c 2009-03-14 10:22:59 UTC (rev 2241) @@ -2062,7 +2062,6 @@ gfloat f = 0.0; g_object_get(preview->photo->settings[preview->snapshot[view]], "denoise_luma", &f, NULL); g_object_set(preview->filter_denoise[view], "denoise_luma", (gint) f, NULL); - printf("%.03f\n", f); } if (mask & MASK_DENOISE_CHROMA) { From anders at brander.dk Sat Mar 14 12:02:30 2009 From: anders at brander.dk (Anders Brander) Date: Sat, 14 Mar 2009 12:02:30 +0100 Subject: [Rawstudio-commit] r2242 - trunk/src Message-ID: Author: abrander Date: 2009-03-14 12:02:30 +0100 (Sat, 14 Mar 2009) New Revision: 2242 Modified: trunk/src/rs-photo.c Log: Fixed metadata loading with preload (Patch by Krzysztof Ko?\197?\155ciuszkiewicz). Modified: trunk/src/rs-photo.c =================================================================== --- trunk/src/rs-photo.c 2009-03-14 10:22:59 UTC (rev 2241) +++ trunk/src/rs-photo.c 2009-03-14 11:02:30 UTC (rev 2242) @@ -513,20 +513,26 @@ /* Try preloaded first! */ photo = rs_get_preloaded(filename); - if (photo) - return photo; - image = rs_filetype_load(filename); - if (image) + /* If photo not found in cache, try to load it */ + if (!photo) { - photo = rs_photo_new(); + image = rs_filetype_load(filename); + if (image) + { + photo = rs_photo_new(); - /* Set filename */ - photo->filename = g_strdup(filename); + /* Set filename */ + photo->filename = g_strdup(filename); - /* Set input image */ - photo->input = image; + /* Set input image */ + photo->input = image; + } + } + /* If photo available, read & process metadata */ + if (photo) + { /* Load metadata */ if (rs_metadata_load_from_file(photo->metadata, filename)) { From klauspost at gmail.com Sat Mar 14 13:17:16 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 14 Mar 2009 13:17:16 +0100 Subject: [Rawstudio-commit] r2243 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-14 13:17:15 +0100 (Sat, 14 Mar 2009) New Revision: 2243 Modified: trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h Log: Faster sharpen - apply sharpen factor to sharpen window once. Insert pattern complex processing. Protect complex filter variables. Modified: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp 2009-03-14 11:02:30 UTC (rev 2242) +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-14 12:17:15 UTC (rev 2243) @@ -71,9 +71,10 @@ for (int i=0; iapplyAnalysisWindow(&realGrid,&realGrid); + fftwf_execute_dft_r2c(plan_forward, f, grid->complex); +} + +ComplexFilterPatternDeGrid::~ComplexFilterPatternDeGrid( void ) +{ + delete grid; +} + + + +void ComplexFilterPatternDeGrid::processNoSharpen( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + int x,y; + float psd; + float WienerFactor; + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + for (y=0; ygetLine(y); + for (x=0; x=0 + int x,y; + float psd; + float WienerFactor; + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + for (y=0; ygetLine(y); + float *wsharpen = sharpenWindow->getLine(y); + for (x=0; x Author: post Date: 2009-03-14 13:21:18 +0100 (Sat, 14 Mar 2009) New Revision: 2244 Modified: trunk/plugins/denoise/ trunk/plugins/denoise/denoisethread.cpp trunk/plugins/denoise/denoisethread.h trunk/plugins/denoise/fftdenoiser.cpp trunk/plugins/denoise/fftdenoiser.h trunk/plugins/denoise/fftdenoiseryuv.cpp trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/fftwindow.h trunk/plugins/denoise/floatimageplane.cpp trunk/plugins/denoise/floatimageplane.h trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/floatplanarimage.h trunk/plugins/denoise/jobqueue.cpp trunk/plugins/denoise/jobqueue.h Log: Multithreaded YUV<->RGB conversions in denoiser. Optimize flat FFT window functions. Property changes on: trunk/plugins/denoise ___________________________________________________________________ Name: svn:ignore + win32 Modified: trunk/plugins/denoise/denoisethread.cpp =================================================================== --- trunk/plugins/denoise/denoisethread.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -18,6 +18,7 @@ #include "denoisethread.h" #include "complexfilter.h" #include "fftwindow.h" +#include "floatplanarimage.h" void *StartDenoiseThread(void *_this) { DenoiseThread *d = (DenoiseThread*)_this; @@ -45,6 +46,7 @@ DenoiseThread::~DenoiseThread(void) { if (!threadExited) exitThread = true; + waiting = 0; pthread_mutex_lock(&run_thread_mutex); pthread_cond_signal(&run_thread); // Start thread pthread_mutex_unlock(&run_thread_mutex); @@ -73,42 +75,63 @@ pthread_mutex_lock(&run_thread_mutex); pthread_cond_wait(&run_thread,&run_thread_mutex); // Wait for jobs pthread_mutex_unlock(&run_thread_mutex); - vector jobs = waiting->getJobsPercent(10); + vector jobs; + if (waiting) + jobs = waiting->getJobsPercent(10); while (!exitThread && !jobs.empty()) { Job* j = jobs[0]; jobs.erase(jobs.begin()); - FloatImagePlane* input = j->p->in; - - if (!complex) - complex = new ComplexBlock(input->w, input->h); - if (!input_plane) { - input_plane = new FloatImagePlane(input->w, input->h); - input_plane->allocateImage(); + switch (j->type) { + case JOB_FFT: + procesFFT((FFTJob*)j); + break; + case JOB_CONVERT_FROMFLOAT_YUV: + { + ImgConvertJob *job = (ImgConvertJob*)j; + job->img->packInterleavedYUV(job); + break; + } + case JOB_CONVERT_TOFLOAT_YUV: + { + ImgConvertJob *job = (ImgConvertJob*)j; + job->img->unpackInterleavedYUV(job); + break; + } + default: + break; } + finished->addJob(j); + if (jobs.empty()) + jobs = waiting->getJobsPercent(10); - j->p->window->applyAnalysisWindow(input, input_plane); + } + } +} + +void DenoiseThread::procesFFT( FFTJob* j ) +{ + FloatImagePlane* input = j->p->in; - fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); + if (!complex) + complex = new ComplexBlock(input->w, input->h); + if (!input_plane) { + input_plane = new FloatImagePlane(input->w, input->h); + input_plane->allocateImage(); + } - g_assert(j->p->filter); - if (j->p->filter) - j->p->filter->process(complex); + j->p->window->applyAnalysisWindow(input, input_plane); - j->p->allocateOut(); + fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); - fftwf_execute_dft_c2r(reverse, complex->complex, j->p->out->data); - //j->p->window->applySynthesisWindow(j->p->out); + g_assert(j->p->filter); + if (j->p->filter) + j->p->filter->process(complex); - finished->addJob(j); + j->p->allocateOut(); - if (jobs.empty()) - jobs = waiting->getJobsPercent(10); - - } - } + fftwf_execute_dft_c2r(reverse, complex->complex, j->p->out->data); + //j->p->window->applySynthesisWindow(j->p->out); + } - -#undef PTR_OFF -#undef ALIGN_OFFSET \ No newline at end of file Modified: trunk/plugins/denoise/denoisethread.h =================================================================== --- trunk/plugins/denoise/denoisethread.h 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/denoisethread.h 2009-03-14 12:21:18 UTC (rev 2244) @@ -44,6 +44,7 @@ private: JobQueue *waiting; JobQueue *finished; + void procesFFT(FFTJob* job); }; #endif // denoisethread_h__ Modified: trunk/plugins/denoise/fftdenoiser.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiser.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/fftdenoiser.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -89,17 +89,43 @@ gint jobs_added = 0; while (jobs_added < njobs) { + Job *_j = finished_jobs->waitForJob(); + + if (_j->type == JOB_FFT) { + FFTJob* j = (FFTJob*)_j; + if (j) { + outImg.applySlice(j->p); + } + delete j; + jobs_added++; + if (abort) { + jobs_added += waiting_jobs->removeRemaining(); + jobs_added += finished_jobs->removeRemaining(); + } + } + } + delete finished_jobs; + delete waiting_jobs; +} + +void FFTDenoiser::waitForJobs(JobQueue *waiting_jobs) +{ + JobQueue* finished_jobs = new JobQueue(); + + gint njobs = waiting_jobs->jobsLeft(); + + for (guint i = 0; i < nThreads; i++) { + threads[i].addJobs(waiting_jobs,finished_jobs); + } + + gint jobs_added = 0; + while (jobs_added < njobs) { Job *j = finished_jobs->waitForJob(); - if (j) { - outImg.applySlice(j->p); - } delete j; jobs_added++; - if (abort) { - jobs_added += waiting_jobs->removeRemaining(); - jobs_added += finished_jobs->removeRemaining(); - } } + delete waiting_jobs; + delete finished_jobs; } gboolean FFTDenoiser::initializeFFT() Modified: trunk/plugins/denoise/fftdenoiser.h =================================================================== --- trunk/plugins/denoise/fftdenoiser.h 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/fftdenoiser.h 2009-03-14 12:21:18 UTC (rev 2244) @@ -37,6 +37,7 @@ gboolean abort; protected: virtual void processJobs(FloatPlanarImage &img, FloatPlanarImage &outImg); + void waitForJobs(JobQueue *waiting_jobs); guint nThreads; DenoiseThread *threads; fftwf_plan plan_forward; Modified: trunk/plugins/denoise/fftdenoiseryuv.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -35,7 +35,7 @@ g_assert(image->channels == 3); - img.unpackInterleaved_RGB_YUV(image); + waitForJobs(img.getUnpackInterleavedYUVJobs(image)); if (abort) return; @@ -63,7 +63,7 @@ if (abort) return; // Convert back - outImg.packInterleaved_YUV_RGB(image); + waitForJobs(img.getPackInterleavedYUVJobs(image)); } Modified: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -3,8 +3,8 @@ * * Contains code from: * -* Based on FFT3DFilter plugin for Avisynth 2.5 - 3D Frequency Domain filter -* Copyright(C)2004-2005 A.G.Balakhnin aka Fizick, email: bag at hotmail.ru, web: http://bag.hotmail.ru +* Based on FFT3DFilter plugin for Avisynth 2.5 - 3D Frequency Domain filter +* Copyright(C)2004-2005 A.G.Balakhnin aka Fizick, email: bag at hotmail.ru, web: http://bag.hotmail.ru * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -19,88 +19,90 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include "fftwindow.h" -#include - -#define PI_F 3.14159265358979323846f - - -FFTWindow::FFTWindow( int _w, int _h ) : -analysis(FloatImagePlane(_w, _h)), -synthesis(FloatImagePlane(_w,_h)) -{ - analysis.allocateImage(); - synthesis.allocateImage(); -} - - -FFTWindow::~FFTWindow(void) -{} - - -void FFTWindow::createHalfCosineWindow( int ox, int oy ) -{ - float *wanx=new float[ox];//analysis windox - float *wsynx=new float[ox];//syntesis windox - - //Calc 1d half-cosine window - for(int i=0;i + +#define PI_F 3.14159265358979323846f + + +FFTWindow::FFTWindow( int _w, int _h ) : +analysis(FloatImagePlane(_w, _h)), +synthesis(FloatImagePlane(_w,_h)) +{ + analysis.allocateImage(); + synthesis.allocateImage(); +} + + +FFTWindow::~FFTWindow(void) +{} + + +void FFTWindow::createHalfCosineWindow( int ox, int oy ) +{ + float *wanx=new float[ox];//analysis windox + float *wsynx=new float[ox];//syntesis windox + + //Calc 1d half-cosine window + for(int i=0;ibh-overlap) yfactor *= weight[bh - y]; - float *m = window.getLine(y); + float *m = window.getLine(y); for (int x = 0; x < bw; x++) { float factor = yfactor; @@ -120,36 +122,47 @@ factor *= weight[bw - x]; m[x] = factor; - } - } -} -// FIXME: SSE2 me -void FFTWindow::applyAnalysisWindow( FloatImagePlane *image, FloatImagePlane *dst ) -{ - g_assert(image->w == analysis.w); - g_assert(image->h == analysis.h); - g_assert(dst->w == analysis.w); - g_assert(dst->h == analysis.h); - for (int y = 0; y < analysis.h; y++) { - float *srcp1 = analysis.getLine(y); - float *srcp2 = image->getLine(y); - float *dstp = dst->getLine(y); - for (int x = 0; x < analysis.w; x++) { - dstp[x] = srcp1[x] * srcp2[x]; + sum += factor; } - } -} - -// FIXME: SSE2 me -void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) -{ - g_assert(image->w == synthesis.w); - g_assert(image->h == synthesis.h); - for (int y = 0; y < synthesis.h; y++) { - float *srcp1 = image->getLine(y); - float *srcp2 = synthesis.getLine(y); - for (int x = 0; x < synthesis.w; x++) { - srcp1[x] *= srcp2[x]; - } - } + } + if (sum > (bw*bh-1.0f)) { /* Account for some rounding */ + isFlat = true; + } +} +// FIXME: SSE2 me +void FFTWindow::applyAnalysisWindow( FloatImagePlane *image, FloatImagePlane *dst ) +{ + g_assert(image->w == analysis.w); + g_assert(image->h == analysis.h); + g_assert(dst->w == analysis.w); + g_assert(dst->h == analysis.h); + if (isFlat) { + image->blitOnto(dst); + return; + } + for (int y = 0; y < analysis.h; y++) { + float *srcp1 = analysis.getLine(y); + float *srcp2 = image->getLine(y); + float *dstp = dst->getLine(y); + for (int x = 0; x < analysis.w; x++) { + dstp[x] = srcp1[x] * srcp2[x]; + } + } +} + +// FIXME: SSE2 me +void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) +{ + g_assert(image->w == synthesis.w); + g_assert(image->h == synthesis.h); + if (isFlat) + return; + + for (int y = 0; y < synthesis.h; y++) { + float *srcp1 = image->getLine(y); + float *srcp2 = synthesis.getLine(y); + for (int x = 0; x < synthesis.w; x++) { + srcp1[x] *= srcp2[x]; + } + } } \ No newline at end of file Modified: trunk/plugins/denoise/fftwindow.h =================================================================== --- trunk/plugins/denoise/fftwindow.h 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/fftwindow.h 2009-03-14 12:21:18 UTC (rev 2244) @@ -34,6 +34,7 @@ void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image private: void createWindow( FloatImagePlane &window, int ox, float* wx); + bool isFlat; }; #endif // fftwindow_h__ Modified: trunk/plugins/denoise/floatimageplane.cpp =================================================================== --- trunk/plugins/denoise/floatimageplane.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/floatimageplane.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -95,7 +95,7 @@ s->overlap_y = oy; s->filter = filter; s->window = window; - jobs->addJob(new Job(s)); + jobs->addJob(new FFTJob(s)); if (start_x + bw*2 - ox*2 >= w) { //Will next block be out of frame? if (start_x == w - bw) endx = true; @@ -153,8 +153,8 @@ } } -void FloatImagePlane::blitOnto( FloatImagePlane *p ) { +void FloatImagePlane::blitOnto( FloatImagePlane *dst ) { g_assert(p->w == w); g_assert(p->h == h); - FBitBlt((guchar*)p->data, p->pitch*sizeof(float),(guchar*)data,pitch*sizeof(float),w*sizeof(float),h); + FBitBlt((guchar*)dst->data, dst->pitch*sizeof(float),(guchar*)data,pitch*sizeof(float),w*sizeof(float),h); } \ No newline at end of file Modified: trunk/plugins/denoise/floatimageplane.h =================================================================== --- trunk/plugins/denoise/floatimageplane.h 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/floatimageplane.h 2009-03-14 12:21:18 UTC (rev 2244) @@ -38,7 +38,7 @@ gfloat* getLine(int y); gfloat* getAt(int x, int y); FloatImagePlane* getSlice(int x,int y,int new_w, int new_h); - void blitOnto(FloatImagePlane *p); + void blitOnto(FloatImagePlane *dst); void addJobs(JobQueue *jobs, int bw, int bh, int ox, int oy); void applySlice(PlanarImageSlice *p); const int w; Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -117,12 +117,12 @@ } } -// TODO: Begs to be SSE2 and/or SMP. -void FloatPlanarImage::unpackInterleaved_RGB_YUV( const RS_IMAGE16* image ) -{ +JobQueue* FloatPlanarImage::getUnpackInterleavedYUVJobs(RS_IMAGE16* image) { // Already demosaiced + JobQueue* queue = new JobQueue(); + if (image->channels != 3) - return; + return queue; g_assert(p == 0); nPlanes = 3; @@ -132,8 +132,24 @@ p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); allocate_planes(); + int threads = rs_get_number_of_processor_cores()*4; + int hEvery = (image->h+threads)/threads; + for (int i = 0; i < threads; i++) { + ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_TOFLOAT_YUV); + j->start_y = i*hEvery; + j->end_y = MIN((i+1)*hEvery,image->h); + j->rs = image; + queue->addJob(j); + } + return queue; +} - for (int y = 0; y < image->h; y++ ) { +// TODO: Begs to be SSE2. +void FloatPlanarImage::unpackInterleavedYUV( const ImgConvertJob* j ) +{ + RS_IMAGE16* image = j->rs; + + for (int y = j->start_y; y < j->end_y; y++ ) { const gushort* pix = GET_PIXEL(image,0,y); gfloat *Y = p[0]->getAt(ox, y+oy); gfloat *Cb = p[1]->getAt(ox, y+oy); @@ -150,18 +166,35 @@ } } -// TODO: Begs to be SSE2 and/or SMP. Scalar int<->float is incredibly slow. -void FloatPlanarImage::packInterleaved_YUV_RGB( RS_IMAGE16* image ) -{ +JobQueue* FloatPlanarImage::getPackInterleavedYUVJobs(RS_IMAGE16* image) { + JobQueue* queue = new JobQueue(); + if (image->channels != 3) - return; + return queue; for (int i = 0; i < nPlanes; i++) { g_assert(p[i]->w == image->w+ox*2); g_assert(p[i]->h == image->h+oy*2); } - for (int y = 0; y < image->h; y++ ) { + int threads = rs_get_number_of_processor_cores()*4; + int hEvery = (image->h+threads)/threads; + for (int i = 0; i < threads; i++) { + ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_FROMFLOAT_YUV); + j->start_y = i*hEvery; + j->end_y = MIN((i+1)*hEvery,image->h); + j->rs = image; + queue->addJob(j); + } + return queue; +} + +// TODO: Begs to be SSE2. Scalar int<->float is incredibly slow. +void FloatPlanarImage::packInterleavedYUV( const ImgConvertJob* j) +{ + RS_IMAGE16* image = j->rs; + + for (int y = j->start_y; y < j->end_y; y++ ) { gfloat *Y = p[0]->getAt(ox, y+oy); gfloat *Cb = p[1]->getAt(ox, y+oy); gfloat *Cr = p[2]->getAt(ox, y+oy); @@ -195,3 +228,11 @@ g_assert(plane>=0 && planeapplySlice(slice); } + +FloatImagePlane* FloatPlanarImage::getPlaneSliceFrom( int plane, int x, int y ) +{ + g_assert(plane>=0 && planegetSlice(x,y,ox,oy); +} + + Modified: trunk/plugins/denoise/floatplanarimage.h =================================================================== --- trunk/plugins/denoise/floatplanarimage.h 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/floatplanarimage.h 2009-03-14 12:21:18 UTC (rev 2244) @@ -40,8 +40,11 @@ void applySlice(PlanarImageSlice *p); void setFilter( int plane, ComplexFilter *f, FFTWindow *window); JobQueue* getJobs(); - void unpackInterleaved_RGB_YUV( const RS_IMAGE16* image ); - void packInterleaved_YUV_RGB( RS_IMAGE16* image ); + void unpackInterleavedYUV( const ImgConvertJob* j ); + void packInterleavedYUV( const ImgConvertJob* j); + JobQueue* getUnpackInterleavedYUVJobs(RS_IMAGE16* image); + JobQueue* getPackInterleavedYUVJobs(RS_IMAGE16* image); + FloatImagePlane* getPlaneSliceFrom(int plane, int x, int y); int bw; // Block width int bh; // Block height int ox; // Overlap pixels Modified: trunk/plugins/denoise/jobqueue.cpp =================================================================== --- trunk/plugins/denoise/jobqueue.cpp 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/jobqueue.cpp 2009-03-14 12:21:18 UTC (rev 2244) @@ -17,11 +17,12 @@ */ #include "jobqueue.h" +#include "floatplanarimage.h" -Job::Job( PlanarImageSlice *s ) : p(s) { +FFTJob::FFTJob( PlanarImageSlice *s ) : Job(JOB_FFT), p(s) { } -Job::~Job( void ) { +FFTJob::~FFTJob( void ) { if (p) delete(p); } @@ -56,7 +57,7 @@ { vector j; pthread_mutex_lock(&job_mutex); - n = MIN(n,(int)jobs.size()); + n = MIN(n,jobs.size()); for (int i = 0; i < n; i++) { j.push_back(jobs[0]); jobs.erase(jobs.begin()); @@ -123,3 +124,4 @@ return n; } + Modified: trunk/plugins/denoise/jobqueue.h =================================================================== --- trunk/plugins/denoise/jobqueue.h 2009-03-14 12:17:15 UTC (rev 2243) +++ trunk/plugins/denoise/jobqueue.h 2009-03-14 12:21:18 UTC (rev 2244) @@ -23,16 +23,40 @@ #include "planarimageslice.h" #include "pthread.h" +class FloatPlanarImage; using namespace std; +typedef enum { + JOB_FFT, + JOB_CONVERT_TOFLOAT_YUV, + JOB_CONVERT_FROMFLOAT_YUV +} JobType; -class Job +class Job { public: - Job(PlanarImageSlice *slice); - virtual ~Job(void); + Job(JobType _type) : type(_type) {}; + virtual ~Job(void) {}; + JobType type; +}; + +class FFTJob : public Job +{ +public: + FFTJob(PlanarImageSlice *slice); + virtual ~FFTJob(void); PlanarImageSlice *p; }; +class ImgConvertJob : public Job +{ +public: + ImgConvertJob(FloatPlanarImage *_img, JobType _type) : Job(_type), img(_img) {}; + virtual ~ImgConvertJob(void) {}; + RS_IMAGE16 *rs; + FloatPlanarImage *img; + int start_y; + int end_y; +}; class JobQueue { From klauspost at gmail.com Sat Mar 14 13:41:14 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 14 Mar 2009 13:41:14 +0100 Subject: [Rawstudio-commit] r2245 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-14 13:41:13 +0100 (Sat, 14 Mar 2009) New Revision: 2245 Modified: trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/floatimageplane.cpp trunk/plugins/denoise/jobqueue.cpp Log: Fixed release assertion error and compiler warnings in denoise. Modified: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp 2009-03-14 12:21:18 UTC (rev 2244) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-14 12:41:13 UTC (rev 2245) @@ -3,8 +3,8 @@ * * Contains code from: * -* Based on FFT3DFilter plugin for Avisynth 2.5 - 3D Frequency Domain filter -* Copyright(C)2004-2005 A.G.Balakhnin aka Fizick, email: bag at hotmail.ru, web: http://bag.hotmail.ru +* Based on FFT3DFilter plugin for Avisynth 2.5 - 3D Frequency Domain filter +* Copyright(C)2004-2005 A.G.Balakhnin aka Fizick, email: bag at hotmail.ru, web: http://bag.hotmail.ru * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -19,90 +19,89 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include "fftwindow.h" -#include - -#define PI_F 3.14159265358979323846f - - -FFTWindow::FFTWindow( int _w, int _h ) : -analysis(FloatImagePlane(_w, _h)), -synthesis(FloatImagePlane(_w,_h)) -{ - analysis.allocateImage(); - synthesis.allocateImage(); -} - - -FFTWindow::~FFTWindow(void) -{} - - -void FFTWindow::createHalfCosineWindow( int ox, int oy ) -{ - float *wanx=new float[ox];//analysis windox - float *wsynx=new float[ox];//syntesis windox - - //Calc 1d half-cosine window - for(int i=0;i + +#define PI_F 3.14159265358979323846f + + +FFTWindow::FFTWindow( int _w, int _h ) : +analysis(FloatImagePlane(_w, _h)), +synthesis(FloatImagePlane(_w,_h)) +{ + analysis.allocateImage(); + synthesis.allocateImage(); +} + + +FFTWindow::~FFTWindow(void) +{} + + +void FFTWindow::createHalfCosineWindow( int ox, int oy ) +{ + float *wanx=new float[ox];//analysis windox + float *wsynx=new float[ox];//syntesis windox + + //Calc 1d half-cosine window + for(int i=0;ibh-overlap) yfactor *= weight[bh - y]; - float *m = window.getLine(y); + float *m = window.getLine(y); for (int x = 0; x < bw; x++) { float factor = yfactor; @@ -124,45 +123,45 @@ m[x] = factor; sum += factor; } - } - if (sum > (bw*bh-1.0f)) { /* Account for some rounding */ - isFlat = true; - } -} -// FIXME: SSE2 me -void FFTWindow::applyAnalysisWindow( FloatImagePlane *image, FloatImagePlane *dst ) -{ - g_assert(image->w == analysis.w); - g_assert(image->h == analysis.h); - g_assert(dst->w == analysis.w); - g_assert(dst->h == analysis.h); - if (isFlat) { - image->blitOnto(dst); - return; - } - for (int y = 0; y < analysis.h; y++) { - float *srcp1 = analysis.getLine(y); - float *srcp2 = image->getLine(y); - float *dstp = dst->getLine(y); - for (int x = 0; x < analysis.w; x++) { - dstp[x] = srcp1[x] * srcp2[x]; - } - } -} - -// FIXME: SSE2 me -void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) -{ - g_assert(image->w == synthesis.w); - g_assert(image->h == synthesis.h); - if (isFlat) - return; - - for (int y = 0; y < synthesis.h; y++) { - float *srcp1 = image->getLine(y); - float *srcp2 = synthesis.getLine(y); - for (int x = 0; x < synthesis.w; x++) { - srcp1[x] *= srcp2[x]; - } - } + } + if (sum > (bw*bh-1.0f)) { /* Account for some rounding */ + isFlat = true; + } +} +// FIXME: SSE2 me +void FFTWindow::applyAnalysisWindow( FloatImagePlane *image, FloatImagePlane *dst ) +{ + g_assert(image->w == analysis.w); + g_assert(image->h == analysis.h); + g_assert(dst->w == analysis.w); + g_assert(dst->h == analysis.h); + if (isFlat) { + image->blitOnto(dst); + return; + } + for (int y = 0; y < analysis.h; y++) { + float *srcp1 = analysis.getLine(y); + float *srcp2 = image->getLine(y); + float *dstp = dst->getLine(y); + for (int x = 0; x < analysis.w; x++) { + dstp[x] = srcp1[x] * srcp2[x]; + } + } +} + +// FIXME: SSE2 me +void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) +{ + g_assert(image->w == synthesis.w); + g_assert(image->h == synthesis.h); + if (isFlat) + return; + + for (int y = 0; y < synthesis.h; y++) { + float *srcp1 = image->getLine(y); + float *srcp2 = synthesis.getLine(y); + for (int x = 0; x < synthesis.w; x++) { + srcp1[x] *= srcp2[x]; + } + } } \ No newline at end of file Modified: trunk/plugins/denoise/floatimageplane.cpp =================================================================== --- trunk/plugins/denoise/floatimageplane.cpp 2009-03-14 12:21:18 UTC (rev 2244) +++ trunk/plugins/denoise/floatimageplane.cpp 2009-03-14 12:41:13 UTC (rev 2245) @@ -154,7 +154,7 @@ } void FloatImagePlane::blitOnto( FloatImagePlane *dst ) { - g_assert(p->w == w); - g_assert(p->h == h); + g_assert(dst->w == w); + g_assert(dst->h == h); FBitBlt((guchar*)dst->data, dst->pitch*sizeof(float),(guchar*)data,pitch*sizeof(float),w*sizeof(float),h); } \ No newline at end of file Modified: trunk/plugins/denoise/jobqueue.cpp =================================================================== --- trunk/plugins/denoise/jobqueue.cpp 2009-03-14 12:21:18 UTC (rev 2244) +++ trunk/plugins/denoise/jobqueue.cpp 2009-03-14 12:41:13 UTC (rev 2245) @@ -57,7 +57,7 @@ { vector j; pthread_mutex_lock(&job_mutex); - n = MIN(n,jobs.size()); + n = MIN(n,(int)jobs.size()); for (int i = 0; i < n; i++) { j.push_back(jobs[0]); jobs.erase(jobs.begin()); From klauspost at gmail.com Sat Mar 14 15:43:15 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 14 Mar 2009 15:43:15 +0100 Subject: [Rawstudio-commit] r2246 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-14 15:43:15 +0100 (Sat, 14 Mar 2009) New Revision: 2246 Modified: trunk/plugins/denoise/fftdenoiser.cpp Log: Denoiser: Fixed race condition. Fixed image not being altered. Added better speed reporting. Sorry about inconsistent EOL. Modified: trunk/plugins/denoise/fftdenoiser.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiser.cpp 2009-03-14 12:41:13 UTC (rev 2245) +++ trunk/plugins/denoise/fftdenoiser.cpp 2009-03-14 14:43:15 UTC (rev 2246) @@ -104,6 +104,10 @@ } } } + + for (guint i = 0; i < nThreads; i++) + threads[i].jobsEnded(); + delete finished_jobs; delete waiting_jobs; } @@ -124,6 +128,10 @@ delete j; jobs_added++; } + + for (guint i = 0; i < nThreads; i++) + threads[i].jobsEnded(); + delete waiting_jobs; delete finished_jobs; } From klauspost at gmail.com Sat Mar 14 15:44:47 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 14 Mar 2009 15:44:47 +0100 Subject: [Rawstudio-commit] r2247 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-14 15:44:47 +0100 (Sat, 14 Mar 2009) New Revision: 2247 Modified: trunk/plugins/denoise/denoise.c trunk/plugins/denoise/denoisethread.cpp trunk/plugins/denoise/denoisethread.h trunk/plugins/denoise/fftdenoiseryuv.cpp trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/jobqueue.cpp Log: Denoiser: Fixed race condition. Fixed image not being altered. Added better speed reporting. Sorry about inconsistent EOL. Modified: trunk/plugins/denoise/denoise.c =================================================================== --- trunk/plugins/denoise/denoise.c 2009-03-14 14:43:15 UTC (rev 2246) +++ trunk/plugins/denoise/denoise.c 2009-03-14 14:44:47 UTC (rev 2247) @@ -195,7 +195,9 @@ GTimer *gt = g_timer_new(); denoiseImage(&denoise->info); - printf("Denoising with sigma:%f. sigmaChroma:%f Took:%.03fsec\n", denoise->info.sigmaLuma, denoise->info.sigmaChroma, g_timer_elapsed(gt, NULL)); + gfloat time = g_timer_elapsed(gt, NULL); + gfloat mpps = (output->w*output->h) / (time*1000000.0); + printf("Denoising took:%.03fsec, %.03fMpix/sec\n", time, mpps ); g_timer_destroy(gt); return output; Modified: trunk/plugins/denoise/denoisethread.cpp =================================================================== --- trunk/plugins/denoise/denoisethread.cpp 2009-03-14 14:43:15 UTC (rev 2246) +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-14 14:44:47 UTC (rev 2247) @@ -1,19 +1,19 @@ -/* -* Copyright (C) 2009 Klaus Post -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "denoisethread.h" #include "complexfilter.h" @@ -70,11 +70,18 @@ pthread_mutex_unlock(&run_thread_mutex); } +void DenoiseThread::jobsEnded() +{ + pthread_mutex_lock(&run_thread_mutex); + waiting = 0; + finished = 0; + pthread_mutex_unlock(&run_thread_mutex); +} + void DenoiseThread::runDenoise() { + pthread_mutex_lock(&run_thread_mutex); while (!exitThread) { - pthread_mutex_lock(&run_thread_mutex); pthread_cond_wait(&run_thread,&run_thread_mutex); // Wait for jobs - pthread_mutex_unlock(&run_thread_mutex); vector jobs; if (waiting) jobs = waiting->getJobsPercent(10); @@ -101,16 +108,17 @@ default: break; } - finished->addJob(j); + finished->addJob(j); if (jobs.empty()) jobs = waiting->getJobsPercent(10); } } + pthread_mutex_unlock(&run_thread_mutex); } - -void DenoiseThread::procesFFT( FFTJob* j ) -{ + +void DenoiseThread::procesFFT( FFTJob* j ) +{ FloatImagePlane* input = j->p->in; if (!complex) Modified: trunk/plugins/denoise/denoisethread.h =================================================================== --- trunk/plugins/denoise/denoisethread.h 2009-03-14 14:43:15 UTC (rev 2246) +++ trunk/plugins/denoise/denoisethread.h 2009-03-14 14:44:47 UTC (rev 2247) @@ -1,19 +1,19 @@ -/* -* Copyright (C) 2009 Klaus Post -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef denoisethread_h__ @@ -31,6 +31,7 @@ DenoiseThread(void); virtual ~DenoiseThread(void); void addJobs(JobQueue *waiting, JobQueue *finished); + void jobsEnded(); void runDenoise(); fftwf_plan forward; fftwf_plan reverse; Modified: trunk/plugins/denoise/fftdenoiseryuv.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-03-14 14:43:15 UTC (rev 2246) +++ trunk/plugins/denoise/fftdenoiseryuv.cpp 2009-03-14 14:44:47 UTC (rev 2247) @@ -63,7 +63,7 @@ if (abort) return; // Convert back - waitForJobs(img.getPackInterleavedYUVJobs(image)); + waitForJobs(outImg.getPackInterleavedYUVJobs(image)); } Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-14 14:43:15 UTC (rev 2246) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-14 14:44:47 UTC (rev 2247) @@ -1,19 +1,19 @@ -/* -* Copyright (C) 2009 Klaus Post -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "floatplanarimage.h" #include "complexfilter.h" @@ -58,12 +58,12 @@ p[i]->mirrorEdges(ox, oy); } -void FloatPlanarImage::setFilter( int plane, ComplexFilter *f, FFTWindow *window ) -{ - if (plane >= nPlanes) - return; - p[plane]->filter = f; - p[plane]->window = window; +void FloatPlanarImage::setFilter( int plane, ComplexFilter *f, FFTWindow *window ) +{ + if (plane >= nPlanes) + return; + p[plane]->filter = f; + p[plane]->window = window; } // TODO: Begs to be SSE2 and/or SMP. @@ -133,7 +133,7 @@ allocate_planes(); int threads = rs_get_number_of_processor_cores()*4; - int hEvery = (image->h+threads)/threads; + int hEvery = MAX(1,(image->h+threads)/threads); for (int i = 0; i < threads; i++) { ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_TOFLOAT_YUV); j->start_y = i*hEvery; @@ -178,7 +178,7 @@ } int threads = rs_get_number_of_processor_cores()*4; - int hEvery = (image->h+threads)/threads; + int hEvery = MAX(1,(image->h+threads)/threads); for (int i = 0; i < threads; i++) { ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_FROMFLOAT_YUV); j->start_y = i*hEvery; @@ -228,11 +228,11 @@ g_assert(plane>=0 && planeapplySlice(slice); } - -FloatImagePlane* FloatPlanarImage::getPlaneSliceFrom( int plane, int x, int y ) -{ + +FloatImagePlane* FloatPlanarImage::getPlaneSliceFrom( int plane, int x, int y ) +{ g_assert(plane>=0 && planegetSlice(x,y,ox,oy); -} - + return p[plane]->getSlice(x,y,ox,oy); +} + Modified: trunk/plugins/denoise/jobqueue.cpp =================================================================== --- trunk/plugins/denoise/jobqueue.cpp 2009-03-14 14:43:15 UTC (rev 2246) +++ trunk/plugins/denoise/jobqueue.cpp 2009-03-14 14:44:47 UTC (rev 2247) @@ -35,6 +35,8 @@ JobQueue::~JobQueue(void) { + pthread_mutex_lock(&job_mutex); + pthread_mutex_unlock(&job_mutex); pthread_mutex_destroy(&job_mutex); pthread_cond_destroy(&job_added_notify); } From klauspost at gmail.com Sat Mar 14 15:59:34 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 14 Mar 2009 15:59:34 +0100 Subject: [Rawstudio-commit] r2248 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-14 15:59:33 +0100 (Sat, 14 Mar 2009) New Revision: 2248 Modified: trunk/plugins/denoise/complexblock.cpp trunk/plugins/denoise/complexblock.h trunk/plugins/denoise/complexfilter.h trunk/plugins/denoise/denoisethread.cpp trunk/plugins/denoise/denoisethread.h trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/planarimageslice.cpp trunk/plugins/denoise/planarimageslice.h Log: Denoiser: All files to Unix EOL, to avoid confused editors and diffs. Modified: trunk/plugins/denoise/complexblock.cpp =================================================================== --- trunk/plugins/denoise/complexblock.cpp 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/complexblock.cpp 2009-03-14 14:59:33 UTC (rev 2248) @@ -14,21 +14,21 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#include "complexblock.h" -#include - - -ComplexBlock::ComplexBlock(int _w, int _h): w(_w), h(_h) -{ - pitch = w * sizeof(fftwf_complex); - complex = (fftwf_complex*)fftwf_malloc(h*pitch); - g_assert(complex); -} - -ComplexBlock::~ComplexBlock(void) -{ - fftwf_free(complex); - complex = 0; -} - +*/ +#include "complexblock.h" +#include + + +ComplexBlock::ComplexBlock(int _w, int _h): w(_w), h(_h) +{ + pitch = w * sizeof(fftwf_complex); + complex = (fftwf_complex*)fftwf_malloc(h*pitch); + g_assert(complex); +} + +ComplexBlock::~ComplexBlock(void) +{ + fftwf_free(complex); + complex = 0; +} + Modified: trunk/plugins/denoise/complexblock.h =================================================================== --- trunk/plugins/denoise/complexblock.h 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/complexblock.h 2009-03-14 14:59:33 UTC (rev 2248) @@ -14,22 +14,22 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef complexblock_h__ -#define complexblock_h__ -#include "fftw3.h" +*/ + +#ifndef complexblock_h__ +#define complexblock_h__ +#include "fftw3.h" #include - -class ComplexBlock -{ -public: - ComplexBlock(int w, int h); - ~ComplexBlock(void); - fftwf_complex* complex; - const int w; - const int h; -private: - int pitch; -}; -#endif // complexblock_h__ + +class ComplexBlock +{ +public: + ComplexBlock(int w, int h); + ~ComplexBlock(void); + fftwf_complex* complex; + const int w; + const int h; +private: + int pitch; +}; +#endif // complexblock_h__ Modified: trunk/plugins/denoise/complexfilter.h =================================================================== --- trunk/plugins/denoise/complexfilter.h 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/complexfilter.h 2009-03-14 14:59:33 UTC (rev 2248) @@ -14,90 +14,90 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef complexfilter_h__ -#define complexfilter_h__ -#include "complexblock.h" -#include "floatimageplane.h" - -class FFTWindow; - -class ComplexFilter -{ -public: - ComplexFilter(int block_width, int block_height); - ComplexFilter(const ComplexFilter& p); - virtual ~ComplexFilter(void); - void process(ComplexBlock* block); +*/ + +#ifndef complexfilter_h__ +#define complexfilter_h__ +#include "complexblock.h" +#include "floatimageplane.h" + +class FFTWindow; + +class ComplexFilter +{ +public: + ComplexFilter(int block_width, int block_height); + ComplexFilter(const ComplexFilter& p); + virtual ~ComplexFilter(void); + void process(ComplexBlock* block); virtual void setSharpen( float sharpen, float sigmaSharpenMin, float sigmaSharpenMax, float scutoff ); -protected: - virtual void processNoSharpen(ComplexBlock* block) = 0; - virtual void processSharpen(ComplexBlock* block) = 0; - const int bw; - const int bh; - const float norm; // Normalization factor - float sharpen; - float sigmaSquaredSharpenMin; - float sigmaSquaredSharpenMax; - FloatImagePlane *sharpenWindow; -}; - -class ComplexWienerFilter : public ComplexFilter -{ -public: - ComplexWienerFilter(int block_width, int block_height, float beta, float sigma); - virtual ~ComplexWienerFilter(void); -protected: - virtual void processNoSharpen(ComplexBlock* block); - virtual void processSharpen(ComplexBlock* block); - const float beta; - float sigmaSquaredNoiseNormed; -}; - -class ComplexWienerFilterDeGrid : public ComplexFilter -{ -public: - ComplexWienerFilterDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window); - virtual ~ComplexWienerFilterDeGrid(void); -protected: - virtual void processNoSharpen(ComplexBlock* block); - virtual void processSharpen(ComplexBlock* block); - const float beta; - float sigmaSquaredNoiseNormed; - float degrid; - const ComplexBlock* grid; - FFTWindow *window; -}; - -class ComplexPatternFilter : public ComplexFilter -{ -public: - ComplexPatternFilter(int block_width, int block_height, float beta, FloatImagePlane* pattern, float pattern_strength ); - virtual ~ComplexPatternFilter(void); -protected: - virtual void processNoSharpen(ComplexBlock* block); - virtual void processSharpen(ComplexBlock* block); - const float beta; - FloatImagePlane* pattern; - const float pfactor; -}; - - -class ComplexFilterPatternDeGrid : public ComplexFilter -{ -public: - ComplexFilterPatternDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window, FloatImagePlane *pattern); - virtual ~ComplexFilterPatternDeGrid(void); -protected: - virtual void processNoSharpen(ComplexBlock* block); - virtual void processSharpen(ComplexBlock* block); - const float beta; - float sigmaSquaredNoiseNormed; - float degrid; - const ComplexBlock* grid; - FFTWindow *window; - FloatImagePlane *pattern; -}; - -#endif // complexfilter_h__ +protected: + virtual void processNoSharpen(ComplexBlock* block) = 0; + virtual void processSharpen(ComplexBlock* block) = 0; + const int bw; + const int bh; + const float norm; // Normalization factor + float sharpen; + float sigmaSquaredSharpenMin; + float sigmaSquaredSharpenMax; + FloatImagePlane *sharpenWindow; +}; + +class ComplexWienerFilter : public ComplexFilter +{ +public: + ComplexWienerFilter(int block_width, int block_height, float beta, float sigma); + virtual ~ComplexWienerFilter(void); +protected: + virtual void processNoSharpen(ComplexBlock* block); + virtual void processSharpen(ComplexBlock* block); + const float beta; + float sigmaSquaredNoiseNormed; +}; + +class ComplexWienerFilterDeGrid : public ComplexFilter +{ +public: + ComplexWienerFilterDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window); + virtual ~ComplexWienerFilterDeGrid(void); +protected: + virtual void processNoSharpen(ComplexBlock* block); + virtual void processSharpen(ComplexBlock* block); + const float beta; + float sigmaSquaredNoiseNormed; + float degrid; + const ComplexBlock* grid; + FFTWindow *window; +}; + +class ComplexPatternFilter : public ComplexFilter +{ +public: + ComplexPatternFilter(int block_width, int block_height, float beta, FloatImagePlane* pattern, float pattern_strength ); + virtual ~ComplexPatternFilter(void); +protected: + virtual void processNoSharpen(ComplexBlock* block); + virtual void processSharpen(ComplexBlock* block); + const float beta; + FloatImagePlane* pattern; + const float pfactor; +}; + + +class ComplexFilterPatternDeGrid : public ComplexFilter +{ +public: + ComplexFilterPatternDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window, FloatImagePlane *pattern); + virtual ~ComplexFilterPatternDeGrid(void); +protected: + virtual void processNoSharpen(ComplexBlock* block); + virtual void processSharpen(ComplexBlock* block); + const float beta; + float sigmaSquaredNoiseNormed; + float degrid; + const ComplexBlock* grid; + FFTWindow *window; + FloatImagePlane *pattern; +}; + +#endif // complexfilter_h__ Modified: trunk/plugins/denoise/denoisethread.cpp =================================================================== --- trunk/plugins/denoise/denoisethread.cpp 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-14 14:59:33 UTC (rev 2248) @@ -1,145 +1,145 @@ -/* -* Copyright (C) 2009 Klaus Post -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#include "denoisethread.h" -#include "complexfilter.h" -#include "fftwindow.h" -#include "floatplanarimage.h" - -void *StartDenoiseThread(void *_this) { - DenoiseThread *d = (DenoiseThread*)_this; - d->threadExited = false; - d->runDenoise(); - d->threadExited = true; - pthread_exit(NULL); - return NULL; -} - -DenoiseThread::DenoiseThread(void) { - exitThread = false; - threadExited = false; - pthread_mutex_init(&run_thread_mutex, NULL); - pthread_cond_init (&run_thread, NULL); // Signal thread to run - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - pthread_create(&thread_id,&attr,StartDenoiseThread,this); - pthread_attr_destroy(&attr); - complex = 0; - input_plane = 0; -} - -DenoiseThread::~DenoiseThread(void) { - if (!threadExited) - exitThread = true; - waiting = 0; - pthread_mutex_lock(&run_thread_mutex); - pthread_cond_signal(&run_thread); // Start thread - pthread_mutex_unlock(&run_thread_mutex); - pthread_join(thread_id, NULL); - pthread_mutex_destroy(&run_thread_mutex); - pthread_cond_destroy(&run_thread); - if (complex) - delete complex; - complex = 0; - if (input_plane) - delete input_plane; - input_plane = 0; -} - -void DenoiseThread::addJobs( JobQueue *_waiting, JobQueue *_finished ) -{ - pthread_mutex_lock(&run_thread_mutex); - waiting = _waiting; - finished = _finished; - pthread_cond_signal(&run_thread); - pthread_mutex_unlock(&run_thread_mutex); -} - -void DenoiseThread::jobsEnded() -{ - pthread_mutex_lock(&run_thread_mutex); - waiting = 0; - finished = 0; - pthread_mutex_unlock(&run_thread_mutex); -} - -void DenoiseThread::runDenoise() { - pthread_mutex_lock(&run_thread_mutex); - while (!exitThread) { - pthread_cond_wait(&run_thread,&run_thread_mutex); // Wait for jobs - vector jobs; - if (waiting) - jobs = waiting->getJobsPercent(10); - while (!exitThread && !jobs.empty()) { - Job* j = jobs[0]; - jobs.erase(jobs.begin()); - - switch (j->type) { - case JOB_FFT: - procesFFT((FFTJob*)j); - break; - case JOB_CONVERT_FROMFLOAT_YUV: - { - ImgConvertJob *job = (ImgConvertJob*)j; - job->img->packInterleavedYUV(job); - break; - } - case JOB_CONVERT_TOFLOAT_YUV: - { - ImgConvertJob *job = (ImgConvertJob*)j; - job->img->unpackInterleavedYUV(job); - break; - } - default: - break; - } - finished->addJob(j); - if (jobs.empty()) - jobs = waiting->getJobsPercent(10); - - } - } - pthread_mutex_unlock(&run_thread_mutex); -} - -void DenoiseThread::procesFFT( FFTJob* j ) -{ - FloatImagePlane* input = j->p->in; - - if (!complex) - complex = new ComplexBlock(input->w, input->h); - if (!input_plane) { - input_plane = new FloatImagePlane(input->w, input->h); - input_plane->allocateImage(); - } - - j->p->window->applyAnalysisWindow(input, input_plane); - - fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); - - g_assert(j->p->filter); - if (j->p->filter) - j->p->filter->process(complex); - - j->p->allocateOut(); - - fftwf_execute_dft_c2r(reverse, complex->complex, j->p->out->data); - //j->p->window->applySynthesisWindow(j->p->out); - -} +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "denoisethread.h" +#include "complexfilter.h" +#include "fftwindow.h" +#include "floatplanarimage.h" + +void *StartDenoiseThread(void *_this) { + DenoiseThread *d = (DenoiseThread*)_this; + d->threadExited = false; + d->runDenoise(); + d->threadExited = true; + pthread_exit(NULL); + return NULL; +} + +DenoiseThread::DenoiseThread(void) { + exitThread = false; + threadExited = false; + pthread_mutex_init(&run_thread_mutex, NULL); + pthread_cond_init (&run_thread, NULL); // Signal thread to run + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_create(&thread_id,&attr,StartDenoiseThread,this); + pthread_attr_destroy(&attr); + complex = 0; + input_plane = 0; +} + +DenoiseThread::~DenoiseThread(void) { + if (!threadExited) + exitThread = true; + waiting = 0; + pthread_mutex_lock(&run_thread_mutex); + pthread_cond_signal(&run_thread); // Start thread + pthread_mutex_unlock(&run_thread_mutex); + pthread_join(thread_id, NULL); + pthread_mutex_destroy(&run_thread_mutex); + pthread_cond_destroy(&run_thread); + if (complex) + delete complex; + complex = 0; + if (input_plane) + delete input_plane; + input_plane = 0; +} + +void DenoiseThread::addJobs( JobQueue *_waiting, JobQueue *_finished ) +{ + pthread_mutex_lock(&run_thread_mutex); + waiting = _waiting; + finished = _finished; + pthread_cond_signal(&run_thread); + pthread_mutex_unlock(&run_thread_mutex); +} + +void DenoiseThread::jobsEnded() +{ + pthread_mutex_lock(&run_thread_mutex); + waiting = 0; + finished = 0; + pthread_mutex_unlock(&run_thread_mutex); +} + +void DenoiseThread::runDenoise() { + pthread_mutex_lock(&run_thread_mutex); + while (!exitThread) { + pthread_cond_wait(&run_thread,&run_thread_mutex); // Wait for jobs + vector jobs; + if (waiting) + jobs = waiting->getJobsPercent(10); + while (!exitThread && !jobs.empty()) { + Job* j = jobs[0]; + jobs.erase(jobs.begin()); + + switch (j->type) { + case JOB_FFT: + procesFFT((FFTJob*)j); + break; + case JOB_CONVERT_FROMFLOAT_YUV: + { + ImgConvertJob *job = (ImgConvertJob*)j; + job->img->packInterleavedYUV(job); + break; + } + case JOB_CONVERT_TOFLOAT_YUV: + { + ImgConvertJob *job = (ImgConvertJob*)j; + job->img->unpackInterleavedYUV(job); + break; + } + default: + break; + } + finished->addJob(j); + if (jobs.empty()) + jobs = waiting->getJobsPercent(10); + + } + } + pthread_mutex_unlock(&run_thread_mutex); +} + +void DenoiseThread::procesFFT( FFTJob* j ) +{ + FloatImagePlane* input = j->p->in; + + if (!complex) + complex = new ComplexBlock(input->w, input->h); + if (!input_plane) { + input_plane = new FloatImagePlane(input->w, input->h); + input_plane->allocateImage(); + } + + j->p->window->applyAnalysisWindow(input, input_plane); + + fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); + + g_assert(j->p->filter); + if (j->p->filter) + j->p->filter->process(complex); + + j->p->allocateOut(); + + fftwf_execute_dft_c2r(reverse, complex->complex, j->p->out->data); + //j->p->window->applySynthesisWindow(j->p->out); + +} \ No newline at end of file Modified: trunk/plugins/denoise/denoisethread.h =================================================================== --- trunk/plugins/denoise/denoisethread.h 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/denoisethread.h 2009-03-14 14:59:33 UTC (rev 2248) @@ -1,51 +1,51 @@ -/* -* Copyright (C) 2009 Klaus Post -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef denoisethread_h__ -#define denoisethread_h__ - -#include "fftw3.h" -#include "jobqueue.h" -#include "pthread.h" -#include "complexblock.h" -#include "floatimageplane.h" - -class DenoiseThread -{ -public: - DenoiseThread(void); - virtual ~DenoiseThread(void); - void addJobs(JobQueue *waiting, JobQueue *finished); - void jobsEnded(); - void runDenoise(); - fftwf_plan forward; - fftwf_plan reverse; - ComplexBlock *complex; - FloatImagePlane *input_plane; - pthread_t thread_id; - pthread_cond_t run_thread; - pthread_mutex_t run_thread_mutex; - gboolean exitThread; - gboolean threadExited; -private: - JobQueue *waiting; - JobQueue *finished; - void procesFFT(FFTJob* job); - -}; -#endif // denoisethread_h__ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef denoisethread_h__ +#define denoisethread_h__ + +#include "fftw3.h" +#include "jobqueue.h" +#include "pthread.h" +#include "complexblock.h" +#include "floatimageplane.h" + +class DenoiseThread +{ +public: + DenoiseThread(void); + virtual ~DenoiseThread(void); + void addJobs(JobQueue *waiting, JobQueue *finished); + void jobsEnded(); + void runDenoise(); + fftwf_plan forward; + fftwf_plan reverse; + ComplexBlock *complex; + FloatImagePlane *input_plane; + pthread_t thread_id; + pthread_cond_t run_thread; + pthread_mutex_t run_thread_mutex; + gboolean exitThread; + gboolean threadExited; +private: + JobQueue *waiting; + JobQueue *finished; + void procesFFT(FFTJob* job); + +}; +#endif // denoisethread_h__ Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-14 14:59:33 UTC (rev 2248) @@ -1,238 +1,238 @@ -/* -* Copyright (C) 2009 Klaus Post -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program 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 General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#include "floatplanarimage.h" -#include "complexfilter.h" - -FloatPlanarImage::FloatPlanarImage(void) { - p = 0; -} - -FloatPlanarImage::FloatPlanarImage( const FloatPlanarImage &img ) -{ - nPlanes = img.nPlanes; - p = new FloatImagePlane*[nPlanes]; - for (int i = 0; i < nPlanes; i++) - p[i] = new FloatImagePlane(img.p[i]->w, img.p[i]->h, i); - - bw = img.bw; - bh = img.bh; - ox = img.ox; - oy = img.oy; -} - -FloatPlanarImage::~FloatPlanarImage(void) { - if (p != 0) { - for (int i = 0; i < nPlanes; i++) { - if (p[i]) - delete p[i]; - p[i] = 0; - } - delete[] p; - p = 0; - } -} - -void FloatPlanarImage::allocate_planes() { - for (int i = 0; i < nPlanes; i++) - p[i]->allocateImage(); -} - -void FloatPlanarImage::mirrorEdges() -{ - for (int i = 0; i < nPlanes; i++) - p[i]->mirrorEdges(ox, oy); -} - -void FloatPlanarImage::setFilter( int plane, ComplexFilter *f, FFTWindow *window ) -{ - if (plane >= nPlanes) - return; - p[plane]->filter = f; - p[plane]->window = window; -} - -// TODO: Begs to be SSE2 and/or SMP. -void FloatPlanarImage::unpackInterleaved( const RS_IMAGE16* image ) -{ - // Already demosaiced - if (image->channels != 3) - return; - - nPlanes = 3; - g_assert(p == 0); - p = new FloatImagePlane*[nPlanes]; - - for (int i = 0; i < nPlanes; i++) - p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); - - allocate_planes(); - - for (int y = 0; y < image->h; y++ ) { - const gushort* pix = GET_PIXEL(image,0,y); - gfloat *rp = p[0]->getAt(ox, y+oy); - gfloat *gp = p[1]->getAt(ox, y+oy); - gfloat *bp = p[2]->getAt(ox, y+oy); - for (int x=0; xw; x++) { - *rp++ = (float)(*pix); - *gp++ = (float)(*(pix+1)); - *bp++ = (float)(*(pix+2)); - pix += image->pixelsize; - } - } -} - -// TODO: Begs to be SSE2 and/or SMP. Scalar int<->float is incredibly slow. -void FloatPlanarImage::packInterleaved( RS_IMAGE16* image ) -{ - for (int i = 0; i < nPlanes; i++) { - g_assert(p[i]->w == image->w+ox*2); - g_assert(p[i]->h == image->h+oy*2); - } - - for (int y = 0; y < image->h; y++ ) { - for (int c = 0; cgetAt(ox, y+oy); - gushort* out = GET_PIXEL(image,0,y) + c; - for (int x=0; xw; x++) { - int p = (int)*(in++); - *out = clampbits(p,16); - out += image->pixelsize; - } - } - } -} - -JobQueue* FloatPlanarImage::getUnpackInterleavedYUVJobs(RS_IMAGE16* image) { - // Already demosaiced - JobQueue* queue = new JobQueue(); - - if (image->channels != 3) - return queue; - - g_assert(p == 0); - nPlanes = 3; - p = new FloatImagePlane*[nPlanes]; - - for (int i = 0; i < nPlanes; i++) - p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); - - allocate_planes(); - int threads = rs_get_number_of_processor_cores()*4; - int hEvery = MAX(1,(image->h+threads)/threads); - for (int i = 0; i < threads; i++) { - ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_TOFLOAT_YUV); - j->start_y = i*hEvery; - j->end_y = MIN((i+1)*hEvery,image->h); - j->rs = image; - queue->addJob(j); - } - return queue; -} - -// TODO: Begs to be SSE2. -void FloatPlanarImage::unpackInterleavedYUV( const ImgConvertJob* j ) -{ - RS_IMAGE16* image = j->rs; - - for (int y = j->start_y; y < j->end_y; y++ ) { - const gushort* pix = GET_PIXEL(image,0,y); - gfloat *Y = p[0]->getAt(ox, y+oy); - gfloat *Cb = p[1]->getAt(ox, y+oy); - gfloat *Cr = p[2]->getAt(ox, y+oy); - for (int x=0; xw; x++) { - float r = (float)(*pix); - float g = (float)(*(pix+1)); - float b = (float)(*(pix+2)); - *Y++ = r * 0.299 + g * 0.587 + b * 0.114 ; - *Cb++ = r * -0.169 + g * -0.331 + b * 0.499; - *Cr++ = r * 0.499 + g * -0.418 - b * 0.0813; - pix += image->pixelsize; - } - } -} - -JobQueue* FloatPlanarImage::getPackInterleavedYUVJobs(RS_IMAGE16* image) { - JobQueue* queue = new JobQueue(); - - if (image->channels != 3) - return queue; - - for (int i = 0; i < nPlanes; i++) { - g_assert(p[i]->w == image->w+ox*2); - g_assert(p[i]->h == image->h+oy*2); - } - - int threads = rs_get_number_of_processor_cores()*4; - int hEvery = MAX(1,(image->h+threads)/threads); - for (int i = 0; i < threads; i++) { - ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_FROMFLOAT_YUV); - j->start_y = i*hEvery; - j->end_y = MIN((i+1)*hEvery,image->h); - j->rs = image; - queue->addJob(j); - } - return queue; -} - -// TODO: Begs to be SSE2. Scalar int<->float is incredibly slow. -void FloatPlanarImage::packInterleavedYUV( const ImgConvertJob* j) -{ - RS_IMAGE16* image = j->rs; - - for (int y = j->start_y; y < j->end_y; y++ ) { - gfloat *Y = p[0]->getAt(ox, y+oy); - gfloat *Cb = p[1]->getAt(ox, y+oy); - gfloat *Cr = p[2]->getAt(ox, y+oy); - gushort* out = GET_PIXEL(image,0,y); - for (int x=0; xw; x++) { - int r = (int)(Y[x] + 1.402 * Cr[x]); - int g = (int)(Y[x] - 0.344 * Cb[x] - 0.714 * Cr[x]); - int b = (int)(Y[x] + 1.772 * Cb[x]); - out[0] = clampbits(r,16); - out[1] = clampbits(g,16); - out[2] = clampbits(b,16); - out += image->pixelsize; - } - } -} - - - -JobQueue* FloatPlanarImage::getJobs() { - JobQueue *jobs = new JobQueue(); - - for (int i = 0; i < nPlanes; i++) - p[i]->addJobs(jobs, bw, bh, ox, oy); - - return jobs; -} - -void FloatPlanarImage::applySlice( PlanarImageSlice *slice ) -{ - int plane = slice->out->plane_id; - g_assert(plane>=0 && planeapplySlice(slice); -} - -FloatImagePlane* FloatPlanarImage::getPlaneSliceFrom( int plane, int x, int y ) -{ - g_assert(plane>=0 && planegetSlice(x,y,ox,oy); -} - - +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include "floatplanarimage.h" +#include "complexfilter.h" + +FloatPlanarImage::FloatPlanarImage(void) { + p = 0; +} + +FloatPlanarImage::FloatPlanarImage( const FloatPlanarImage &img ) +{ + nPlanes = img.nPlanes; + p = new FloatImagePlane*[nPlanes]; + for (int i = 0; i < nPlanes; i++) + p[i] = new FloatImagePlane(img.p[i]->w, img.p[i]->h, i); + + bw = img.bw; + bh = img.bh; + ox = img.ox; + oy = img.oy; +} + +FloatPlanarImage::~FloatPlanarImage(void) { + if (p != 0) { + for (int i = 0; i < nPlanes; i++) { + if (p[i]) + delete p[i]; + p[i] = 0; + } + delete[] p; + p = 0; + } +} + +void FloatPlanarImage::allocate_planes() { + for (int i = 0; i < nPlanes; i++) + p[i]->allocateImage(); +} + +void FloatPlanarImage::mirrorEdges() +{ + for (int i = 0; i < nPlanes; i++) + p[i]->mirrorEdges(ox, oy); +} + +void FloatPlanarImage::setFilter( int plane, ComplexFilter *f, FFTWindow *window ) +{ + if (plane >= nPlanes) + return; + p[plane]->filter = f; + p[plane]->window = window; +} + +// TODO: Begs to be SSE2 and/or SMP. +void FloatPlanarImage::unpackInterleaved( const RS_IMAGE16* image ) +{ + // Already demosaiced + if (image->channels != 3) + return; + + nPlanes = 3; + g_assert(p == 0); + p = new FloatImagePlane*[nPlanes]; + + for (int i = 0; i < nPlanes; i++) + p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); + + allocate_planes(); + + for (int y = 0; y < image->h; y++ ) { + const gushort* pix = GET_PIXEL(image,0,y); + gfloat *rp = p[0]->getAt(ox, y+oy); + gfloat *gp = p[1]->getAt(ox, y+oy); + gfloat *bp = p[2]->getAt(ox, y+oy); + for (int x=0; xw; x++) { + *rp++ = (float)(*pix); + *gp++ = (float)(*(pix+1)); + *bp++ = (float)(*(pix+2)); + pix += image->pixelsize; + } + } +} + +// TODO: Begs to be SSE2 and/or SMP. Scalar int<->float is incredibly slow. +void FloatPlanarImage::packInterleaved( RS_IMAGE16* image ) +{ + for (int i = 0; i < nPlanes; i++) { + g_assert(p[i]->w == image->w+ox*2); + g_assert(p[i]->h == image->h+oy*2); + } + + for (int y = 0; y < image->h; y++ ) { + for (int c = 0; cgetAt(ox, y+oy); + gushort* out = GET_PIXEL(image,0,y) + c; + for (int x=0; xw; x++) { + int p = (int)*(in++); + *out = clampbits(p,16); + out += image->pixelsize; + } + } + } +} + +JobQueue* FloatPlanarImage::getUnpackInterleavedYUVJobs(RS_IMAGE16* image) { + // Already demosaiced + JobQueue* queue = new JobQueue(); + + if (image->channels != 3) + return queue; + + g_assert(p == 0); + nPlanes = 3; + p = new FloatImagePlane*[nPlanes]; + + for (int i = 0; i < nPlanes; i++) + p[i] = new FloatImagePlane(image->w+ox*2, image->h+oy*2, i); + + allocate_planes(); + int threads = rs_get_number_of_processor_cores()*4; + int hEvery = MAX(1,(image->h+threads)/threads); + for (int i = 0; i < threads; i++) { + ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_TOFLOAT_YUV); + j->start_y = i*hEvery; + j->end_y = MIN((i+1)*hEvery,image->h); + j->rs = image; + queue->addJob(j); + } + return queue; +} + +// TODO: Begs to be SSE2. +void FloatPlanarImage::unpackInterleavedYUV( const ImgConvertJob* j ) +{ + RS_IMAGE16* image = j->rs; + + for (int y = j->start_y; y < j->end_y; y++ ) { + const gushort* pix = GET_PIXEL(image,0,y); + gfloat *Y = p[0]->getAt(ox, y+oy); + gfloat *Cb = p[1]->getAt(ox, y+oy); + gfloat *Cr = p[2]->getAt(ox, y+oy); + for (int x=0; xw; x++) { + float r = (float)(*pix); + float g = (float)(*(pix+1)); + float b = (float)(*(pix+2)); + *Y++ = r * 0.299 + g * 0.587 + b * 0.114 ; + *Cb++ = r * -0.169 + g * -0.331 + b * 0.499; + *Cr++ = r * 0.499 + g * -0.418 - b * 0.0813; + pix += image->pixelsize; + } + } +} + +JobQueue* FloatPlanarImage::getPackInterleavedYUVJobs(RS_IMAGE16* image) { + JobQueue* queue = new JobQueue(); + + if (image->channels != 3) + return queue; + + for (int i = 0; i < nPlanes; i++) { + g_assert(p[i]->w == image->w+ox*2); + g_assert(p[i]->h == image->h+oy*2); + } + + int threads = rs_get_number_of_processor_cores()*4; + int hEvery = MAX(1,(image->h+threads)/threads); + for (int i = 0; i < threads; i++) { + ImgConvertJob *j = new ImgConvertJob(this,JOB_CONVERT_FROMFLOAT_YUV); + j->start_y = i*hEvery; + j->end_y = MIN((i+1)*hEvery,image->h); + j->rs = image; + queue->addJob(j); + } + return queue; +} + +// TODO: Begs to be SSE2. Scalar int<->float is incredibly slow. +void FloatPlanarImage::packInterleavedYUV( const ImgConvertJob* j) +{ + RS_IMAGE16* image = j->rs; + + for (int y = j->start_y; y < j->end_y; y++ ) { + gfloat *Y = p[0]->getAt(ox, y+oy); + gfloat *Cb = p[1]->getAt(ox, y+oy); + gfloat *Cr = p[2]->getAt(ox, y+oy); + gushort* out = GET_PIXEL(image,0,y); + for (int x=0; xw; x++) { + int r = (int)(Y[x] + 1.402 * Cr[x]); + int g = (int)(Y[x] - 0.344 * Cb[x] - 0.714 * Cr[x]); + int b = (int)(Y[x] + 1.772 * Cb[x]); + out[0] = clampbits(r,16); + out[1] = clampbits(g,16); + out[2] = clampbits(b,16); + out += image->pixelsize; + } + } +} + + + +JobQueue* FloatPlanarImage::getJobs() { + JobQueue *jobs = new JobQueue(); + + for (int i = 0; i < nPlanes; i++) + p[i]->addJobs(jobs, bw, bh, ox, oy); + + return jobs; +} + +void FloatPlanarImage::applySlice( PlanarImageSlice *slice ) +{ + int plane = slice->out->plane_id; + g_assert(plane>=0 && planeapplySlice(slice); +} + +FloatImagePlane* FloatPlanarImage::getPlaneSliceFrom( int plane, int x, int y ) +{ + g_assert(plane>=0 && planegetSlice(x,y,ox,oy); +} + + Modified: trunk/plugins/denoise/planarimageslice.cpp =================================================================== --- trunk/plugins/denoise/planarimageslice.cpp 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/planarimageslice.cpp 2009-03-14 14:59:33 UTC (rev 2248) @@ -14,30 +14,30 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "planarimageslice.h" -#include "floatimageplane.h" - -PlanarImageSlice::PlanarImageSlice(void) -{ - filter = 0; - in = 0; - out = 0; -} - -PlanarImageSlice::~PlanarImageSlice(void) { - if (out) - delete out; - out = 0; - if (in) - delete in; - in = 0; -} - -void PlanarImageSlice::allocateOut() { - if (out) - return; - out = new FloatImagePlane(in->w, in->h, in->plane_id); - out->allocateImage(); +*/ + +#include "planarimageslice.h" +#include "floatimageplane.h" + +PlanarImageSlice::PlanarImageSlice(void) +{ + filter = 0; + in = 0; + out = 0; } + +PlanarImageSlice::~PlanarImageSlice(void) { + if (out) + delete out; + out = 0; + if (in) + delete in; + in = 0; +} + +void PlanarImageSlice::allocateOut() { + if (out) + return; + out = new FloatImagePlane(in->w, in->h, in->plane_id); + out->allocateImage(); +} Modified: trunk/plugins/denoise/planarimageslice.h =================================================================== --- trunk/plugins/denoise/planarimageslice.h 2009-03-14 14:44:47 UTC (rev 2247) +++ trunk/plugins/denoise/planarimageslice.h 2009-03-14 14:59:33 UTC (rev 2248) @@ -14,31 +14,31 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef planarimageslice_h__ -#define planarimageslice_h__ -#include - - -class FloatImagePlane; -class ComplexFilter; -class FFTWindow; - -class PlanarImageSlice -{ -public: - PlanarImageSlice(void); - virtual ~PlanarImageSlice(void); - FloatImagePlane *in; - FloatImagePlane *out; - void allocateOut(); - gint offset_x; - gint offset_y; - gint overlap_x; - gint overlap_y; - ComplexFilter *filter; - FFTWindow *window; -}; - -#endif // planarimageslice_h__ +*/ + +#ifndef planarimageslice_h__ +#define planarimageslice_h__ +#include + + +class FloatImagePlane; +class ComplexFilter; +class FFTWindow; + +class PlanarImageSlice +{ +public: + PlanarImageSlice(void); + virtual ~PlanarImageSlice(void); + FloatImagePlane *in; + FloatImagePlane *out; + void allocateOut(); + gint offset_x; + gint offset_y; + gint overlap_x; + gint overlap_y; + ComplexFilter *filter; + FFTWindow *window; +}; + +#endif // planarimageslice_h__ From klauspost at gmail.com Sat Mar 14 17:51:13 2009 From: klauspost at gmail.com (Klaus Post) Date: Sat, 14 Mar 2009 17:51:13 +0100 Subject: [Rawstudio-commit] r2249 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-14 17:51:12 +0100 (Sat, 14 Mar 2009) New Revision: 2249 Modified: trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h Log: Denoiser: Slightly faster when sharpening only. Simplification by inheritance. Modified: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp 2009-03-14 14:59:33 UTC (rev 2248) +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-14 16:51:12 UTC (rev 2249) @@ -85,13 +85,64 @@ processNoSharpen(block); } + /** DeGridComplexFilter **/ +DeGridComplexFilter::DeGridComplexFilter(int block_width, int block_height, float _degrid, FFTWindow *_window, fftwf_plan plan_forward) : +ComplexFilter(block_width, block_height), +degrid(_degrid), +window(_window) +{ + grid = new ComplexBlock(bw, bh); + FloatImagePlane realGrid(bw, bh); + realGrid.allocateImage(); + float* f = realGrid.data; + int count = bh*realGrid.pitch; + + for (int i = 0 ; i < count; i++){ + f[i] = 65535.0f; + } + window->applyAnalysisWindow(&realGrid,&realGrid); + fftwf_execute_dft_r2c(plan_forward, f, grid->complex); +} + +DeGridComplexFilter::~DeGridComplexFilter( void ) +{ + delete grid; +} + +void DeGridComplexFilter::processSharpenOnly(ComplexBlock* block) { + int x,y; + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + for (y=0; ygetLine(y); + for (x=0; xapplyAnalysisWindow(&realGrid,&realGrid); - fftwf_execute_dft_r2c(plan_forward, f, grid->complex); } ComplexWienerFilterDeGrid::~ComplexWienerFilterDeGrid( void ) { - delete grid; } @@ -252,6 +289,8 @@ void ComplexWienerFilterDeGrid::processSharpen( ComplexBlock* block ) { + if (sigmaSquaredNoiseNormed <= 1e-15f) + return processSharpenOnly(block); float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; @@ -286,29 +325,15 @@ fftwf_plan plan_forward, FFTWindow *_window, FloatImagePlane *_pattern) : -ComplexFilter(block_width, block_height), -beta(_beta), -degrid(_degrid), -window(_window), +DeGridComplexFilter(block_width, block_height, _degrid, _window, plan_forward), pattern(_pattern) { + beta = _beta; sigmaSquaredNoiseNormed = _sigma*_sigma/norm; - grid = new ComplexBlock(bw, bh); - FloatImagePlane realGrid(bw, bh); - realGrid.allocateImage(); - float* f = realGrid.data; - int count = bh*realGrid.pitch; - - for (int i = 0 ; i < count; i++){ - f[i] = 65535.0f; - } - window->applyAnalysisWindow(&realGrid,&realGrid); - fftwf_execute_dft_r2c(plan_forward, f, grid->complex); } ComplexFilterPatternDeGrid::~ComplexFilterPatternDeGrid( void ) { - delete grid; } @@ -347,6 +372,9 @@ void ComplexFilterPatternDeGrid::processSharpen( ComplexBlock* block ) { + if (sigmaSquaredNoiseNormed <= 1e-15f) + return processSharpenOnly(block); + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; Modified: trunk/plugins/denoise/complexfilter.h =================================================================== --- trunk/plugins/denoise/complexfilter.h 2009-03-14 14:59:33 UTC (rev 2248) +++ trunk/plugins/denoise/complexfilter.h 2009-03-14 16:51:12 UTC (rev 2249) @@ -37,12 +37,25 @@ const int bw; const int bh; const float norm; // Normalization factor + float beta; float sharpen; float sigmaSquaredSharpenMin; float sigmaSquaredSharpenMax; FloatImagePlane *sharpenWindow; }; +class DeGridComplexFilter : public ComplexFilter +{ +public: + DeGridComplexFilter(int block_width, int block_height, float degrid, FFTWindow *window, fftwf_plan plan_forward); + virtual ~DeGridComplexFilter(void); +protected: + virtual void processSharpenOnly(ComplexBlock* block); + const float degrid; + FFTWindow *window; + ComplexBlock* grid; +}; + class ComplexWienerFilter : public ComplexFilter { public: @@ -51,11 +64,10 @@ protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); - const float beta; float sigmaSquaredNoiseNormed; }; -class ComplexWienerFilterDeGrid : public ComplexFilter +class ComplexWienerFilterDeGrid : public DeGridComplexFilter { public: ComplexWienerFilterDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window); @@ -63,10 +75,7 @@ protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); - const float beta; float sigmaSquaredNoiseNormed; - float degrid; - const ComplexBlock* grid; FFTWindow *window; }; @@ -78,13 +87,12 @@ protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); - const float beta; FloatImagePlane* pattern; const float pfactor; }; -class ComplexFilterPatternDeGrid : public ComplexFilter +class ComplexFilterPatternDeGrid : public DeGridComplexFilter { public: ComplexFilterPatternDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window, FloatImagePlane *pattern); @@ -92,11 +100,7 @@ protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); - const float beta; float sigmaSquaredNoiseNormed; - float degrid; - const ComplexBlock* grid; - FFTWindow *window; FloatImagePlane *pattern; }; From anders at brander.dk Sat Mar 14 19:04:11 2009 From: anders at brander.dk (Anders Brander) Date: Sat, 14 Mar 2009 19:04:11 +0100 Subject: [Rawstudio-commit] r2250 - trunk/plugins/meta-tiff Message-ID: Author: abrander Date: 2009-03-14 19:04:11 +0100 (Sat, 14 Mar 2009) New Revision: 2250 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: [250] Added camera white balance for Sony A700. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 16:51:12 UTC (rev 2249) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 18:04:11 UTC (rev 2250) @@ -20,12 +20,23 @@ #include #include #include +#include /* sony_decrypt(): htonl() */ +#include /* memcpy() */ /* It is required having some arbitrary maximum exposure time to prevent borked * shutter speed values being interpreted from the tiff. * 8h seems to be reasonable, even for astronomists with extra battery packs */ #define EXPO_TIME_MAXVAL (8*60.0*60.0) +typedef struct { + RSMetadata meta; + gint sony_offset; + gint sony_length; + gint sony_key; + guint pad[128]; + guint p; +} SonyMeta; + struct IFD { gushort tag; gushort type; @@ -50,6 +61,8 @@ static gboolean makernote_olympus_imageprocessing(RAWFILE *rawfile, guint base, guint offset, RSMetadata *meta); static gboolean makernote_panasonic(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean makernote_pentax(RAWFILE *rawfile, guint offset, RSMetadata *meta); +static void sony_decrypt(SonyMeta *sony, guint *data, gint len); +static gboolean private_sony(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean exif_reader(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean ifd_reader(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean thumbnail_reader(const gchar *service, RAWFILE *rawfile, guint offset, guint length, RSMetadata *meta); @@ -834,7 +847,105 @@ return TRUE; } +static void +sony_decrypt(SonyMeta *sony, guint *data, gint len) +{ + while (len--) + *data++ ^= sony->pad[sony->p++ & 127] = sony->pad[(sony->p+1) & 127] ^ sony->pad[(sony->p+65) & 127]; +} + static gboolean +private_sony(RAWFILE *rawfile, guint offset, RSMetadata *meta) +{ + gushort number_of_entries; + struct IFD ifd; + gint i; + gint key; + SonyMeta *sony = (SonyMeta *) meta; + + if(!raw_get_ushort(rawfile, offset, &number_of_entries)) + return FALSE; + + if (number_of_entries>5000) + return FALSE; + + offset += 2; + + while(number_of_entries--) + { + read_ifd(rawfile, offset, &ifd); + offset += 12; + + switch(ifd.tag) + { + case 0x7200: /* SR2SubIFDOffset */ + sony->sony_offset = ifd.value_offset; + break; + case 0x7201: /* SR2SubIFDLength */ + sony->sony_length = ifd.value_offset; + break; + case 0x7221: /* SR2SubIFDKey */ + sony->sony_key = ifd.value_offset; + + /* Initialize decrypter */ + key = sony->sony_key; + for (sony->p=0; sony->p < 4; sony->p++) + sony->pad[sony->p] = key = key * 48828125 + 1; + sony->pad[3] = sony->pad[3] << 1 | (sony->pad[0]^sony->pad[2]) >> 31; + for (sony->p=4; sony->p < 127; sony->p++) + sony->pad[sony->p] = (sony->pad[sony->p-4]^sony->pad[sony->p-2]) << 1 | (sony->pad[sony->p-3]^sony->pad[sony->p-1]) >> 31; + for (sony->p=0; sony->p < 127; sony->p++) + sony->pad[sony->p] = htonl(sony->pad[sony->p]); + break; + } + } + + if ((sony->sony_offset > 0) && (sony->sony_length > 0) && (sony->sony_key != 0)) + { + gpointer buf = g_new0(guchar, sony->sony_length); + if (raw_strcpy(rawfile, sony->sony_offset, buf, sony->sony_length)) + { + sony_decrypt(sony, buf, sony->sony_length/4); + gushort *sbuf = (gushort *)(buf); + gushort tag_count = sbuf[0]; + struct IFD *private_ifd; + + for(i=0;itag) + { + case 0x7303: /* WB_GRBGLevels */ + sbuf = (gushort *)(buf + private_ifd->value_offset - sony->sony_offset); + meta->cam_mul[1] = (gdouble) sbuf[0]; + meta->cam_mul[0] = (gdouble) sbuf[1]; + meta->cam_mul[2] = (gdouble) sbuf[2]; + meta->cam_mul[3] = (gdouble) sbuf[3]; + + rs_metadata_normalize_wb(meta); + break; + case 0x7313: /* WB_RGGBLevels */ + sbuf = (gushort *)(buf + private_ifd->value_offset - sony->sony_offset); + meta->cam_mul[0] = (gdouble) sbuf[0]; + meta->cam_mul[1] = (gdouble) sbuf[1]; + meta->cam_mul[3] = (gdouble) sbuf[2]; + meta->cam_mul[2] = (gdouble) sbuf[3]; + + rs_metadata_normalize_wb(meta); + break; + } + } + } + } + + return TRUE; +} + +static gboolean exif_reader(RAWFILE *rawfile, guint offset, RSMetadata *meta) { gushort number_of_entries = 0; @@ -983,8 +1094,8 @@ meta->make = MAKE_PHASEONE; else if (raw_strcmp(rawfile, ifd.value_offset, "SAMSUNG", 7)) meta->make = MAKE_SAMSUNG; - else if (raw_strcmp(rawfile, ifd.value_offset, "SONY", 4)) - meta->make = MAKE_SONY; + /* Do not detect SONY, we don't want to call private_sony() unless + we're sure we have a hidden SonyMeta */ else if (raw_strcmp(rawfile, ifd.value_offset, "FUJIFILM", 4)) meta->make = MAKE_FUJIFILM; else if (raw_strcmp(rawfile, ifd.value_offset, "SEIKO EPSON", 11)) @@ -1051,6 +1162,10 @@ meta->cam_mul[3] = meta->cam_mul[1]; } break; + case 0xc634: /* DNG: PrivateData */ + if (meta->make == MAKE_SONY) + private_sony(rawfile, ifd.value_offset, meta); + break; } } @@ -1238,15 +1353,29 @@ return ret; } +static void +sony_load_meta(const gchar *service, RAWFILE *rawfile, guint offset, RSMetadata *meta) +{ + SonyMeta sony; + sony.sony_offset = 0; + sony.sony_length = 0; + sony.sony_key = 0; + meta->make = MAKE_SONY; + + memcpy(&sony, meta, sizeof(RSMetadata)); + tif_load_meta(service, rawfile, offset, RS_METADATA(&sony)); + memcpy(meta, &sony, sizeof(RSMetadata)); +} + G_MODULE_EXPORT void rs_plugin_load(RSPlugin *plugin) { rs_filetype_register_meta_loader(".cr2", "Canon CR2", tif_load_meta, 10); rs_filetype_register_meta_loader(".nef", "Nikon NEF", tif_load_meta, 10); rs_filetype_register_meta_loader(".tif", "Canon TIFF", tif_load_meta, 10); - rs_filetype_register_meta_loader(".arw", "Sony", tif_load_meta, 10); - rs_filetype_register_meta_loader(".sr2", "Sony", tif_load_meta, 10); - rs_filetype_register_meta_loader(".srf", "Sony", tif_load_meta, 10); + rs_filetype_register_meta_loader(".arw", "Sony", sony_load_meta, 10); + rs_filetype_register_meta_loader(".sr2", "Sony", sony_load_meta, 10); + rs_filetype_register_meta_loader(".srf", "Sony", sony_load_meta, 10); rs_filetype_register_meta_loader(".kdc", "Kodak", tif_load_meta, 10); rs_filetype_register_meta_loader(".dcr", "Kodak", tif_load_meta, 10); rs_filetype_register_meta_loader(".orf", "Olympus", tif_load_meta, 10); From anders at brander.dk Sat Mar 14 23:20:25 2009 From: anders at brander.dk (Anders Brander) Date: Sat, 14 Mar 2009 23:20:25 +0100 Subject: [Rawstudio-commit] r2251 - trunk/plugins/meta-tiff Message-ID: Author: abrander Date: 2009-03-14 23:20:24 +0100 (Sat, 14 Mar 2009) New Revision: 2251 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: Added camera wb support for some Hasselblad models. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 18:04:11 UTC (rev 2250) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 22:20:24 UTC (rev 2251) @@ -1154,12 +1154,13 @@ /* The following tags are from the DNG spec, they should be safe */ case 0xc628: /* DNG: AsShotNeutral */ - if (ifd.type == TIFF_FIELD_TYPE_RATIONAL && ifd.count == 3) + if (((ifd.type == TIFF_FIELD_TYPE_RATIONAL)||(ifd.type == TIFF_FIELD_TYPE_SRATIONAL)) && ifd.count == 3) { meta->cam_mul[0] = 1.0/get_rational(rawfile, ifd.value_offset); meta->cam_mul[1] = 1.0/get_rational(rawfile, ifd.value_offset+8); meta->cam_mul[2] = 1.0/get_rational(rawfile, ifd.value_offset+16); meta->cam_mul[3] = meta->cam_mul[1]; + rs_metadata_normalize_wb(meta); } break; case 0xc634: /* DNG: PrivateData */ From anders at brander.dk Sun Mar 15 00:21:47 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 15 Mar 2009 00:21:47 +0100 Subject: [Rawstudio-commit] r2252 - trunk/plugins/meta-tiff Message-ID: Author: abrander Date: 2009-03-15 00:21:47 +0100 (Sun, 15 Mar 2009) New Revision: 2252 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: Added camera wb support for Nikon D1X. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 22:20:24 UTC (rev 2251) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 23:21:47 UTC (rev 2252) @@ -467,25 +467,36 @@ raw_get_ushort(rawfile, offset+2, &meta->iso); break; case 0x000c: /* D1 White Balance */ - raw_get_uint(rawfile, offset, &uint_temp1); + printf("%s\n", meta->model_ascii); + if (g_str_equal(meta->model_ascii, "NIKON D1X")) + { + meta->cam_mul[0] = get_rational(rawfile, offset); + meta->cam_mul[2] = get_rational(rawfile, offset+8); + meta->cam_mul[1] = get_rational(rawfile, offset+16); + meta->cam_mul[3] = get_rational(rawfile, offset+24); + rs_metadata_normalize_wb(meta); + } + else + { + /* This is fucked, where did these two magic constants come from? */ + raw_get_float(rawfile, uint_temp1, &float_temp1); + raw_get_float(rawfile, uint_temp1+4, &float_temp2); + meta->cam_mul[0] = (gdouble) (float_temp1/float_temp2)/1.0;//2.218750; - /* This is fucked, where did these two magic constants come from? */ - raw_get_float(rawfile, uint_temp1, &float_temp1); - raw_get_float(rawfile, uint_temp1+4, &float_temp2); - meta->cam_mul[0] = (gdouble) (float_temp1/float_temp2)/2.218750; + raw_get_float(rawfile, uint_temp1+8, &float_temp1); + raw_get_float(rawfile, uint_temp1+12, &float_temp2); + meta->cam_mul[2] = (gdouble) (float_temp1/float_temp2)/1.0;//1.148438; - raw_get_float(rawfile, uint_temp1+8, &float_temp1); - raw_get_float(rawfile, uint_temp1+12, &float_temp2); - meta->cam_mul[2] = (gdouble) (float_temp1/float_temp2)/1.148438; + raw_get_float(rawfile, uint_temp1+16, &float_temp1); + raw_get_float(rawfile, uint_temp1+20, &float_temp2); + meta->cam_mul[1] = (gdouble) (float_temp1/float_temp2); - raw_get_float(rawfile, uint_temp1+16, &float_temp1); - raw_get_float(rawfile, uint_temp1+20, &float_temp2); - meta->cam_mul[1] = (gdouble) (float_temp1/float_temp2); + raw_get_float(rawfile, uint_temp1+24, &float_temp1); + raw_get_float(rawfile, uint_temp1+28, &float_temp2); + meta->cam_mul[3] = (gdouble) (float_temp1/float_temp2); - raw_get_float(rawfile, uint_temp1+24, &float_temp1); - raw_get_float(rawfile, uint_temp1+28, &float_temp2); - meta->cam_mul[3] = (gdouble) (float_temp1/float_temp2); - rs_metadata_normalize_wb(meta); + rs_metadata_normalize_wb(meta); + } break; case 0x0011: /* NikonPreview */ raw_get_uint(rawfile, offset, &uint_temp1); From anders at kvistmail.dk Sun Mar 15 00:49:42 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Sun, 15 Mar 2009 00:49:42 +0100 Subject: [Rawstudio-commit] r2253 - trunk/src Message-ID: Author: akv Date: 2009-03-15 00:49:42 +0100 (Sun, 15 Mar 2009) New Revision: 2253 Modified: trunk/src/rs-preview-widget.c Log: Only using gtk_window_set_deletable() if GTK version is 2.10 or higher. Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-14 23:21:47 UTC (rev 2252) +++ trunk/src/rs-preview-widget.c 2009-03-14 23:49:42 UTC (rev 2253) @@ -629,7 +629,9 @@ gtk_window_set_decorated (GTK_WINDOW (window), FALSE); gtk_window_set_keep_above(GTK_WINDOW(window), TRUE); gtk_window_set_accept_focus(GTK_WINDOW(window), FALSE); +#if GTK_CHECK_VERSION(2,10,0) gtk_window_set_deletable(GTK_WINDOW(window), FALSE); +#endif gtk_window_set_skip_pager_hint(GTK_WINDOW(window), TRUE); gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE); gtk_window_set_title(GTK_WINDOW(window), "Rawstudio lights out helper"); From anders at kvistmail.dk Sun Mar 15 00:52:58 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Sun, 15 Mar 2009 00:52:58 +0100 Subject: [Rawstudio-commit] r2254 - trunk/librawstudio Message-ID: Author: akv Date: 2009-03-15 00:52:57 +0100 (Sun, 15 Mar 2009) New Revision: 2254 Modified: trunk/librawstudio/rs-job-queue.c Log: Only using gtk_window_set_deletable() if GTK version is 2.10 or higher. Modified: trunk/librawstudio/rs-job-queue.c =================================================================== --- trunk/librawstudio/rs-job-queue.c 2009-03-14 23:49:42 UTC (rev 2253) +++ trunk/librawstudio/rs-job-queue.c 2009-03-14 23:52:57 UTC (rev 2254) @@ -87,7 +87,6 @@ gtk_container_add(GTK_CONTAINER(job_queue->window), job_queue->box); - gtk_window_set_deletable(GTK_WINDOW(job_queue->window), FALSE); gtk_window_set_accept_focus(GTK_WINDOW(job_queue->window), FALSE); gtk_window_set_keep_above(GTK_WINDOW(job_queue->window), TRUE); gtk_window_set_skip_pager_hint(GTK_WINDOW(job_queue->window), TRUE); @@ -100,6 +99,10 @@ gtk_window_set_opacity(GTK_WINDOW(job_queue->window), 0.75); #endif +#if GTK_CHECK_VERSION(2,10,0) + gtk_window_set_deletable(GTK_WINDOW(job_queue->window), FALSE); +#endif + /* Set the gravity, so that resizes will still result in a window * positioned in the lower left */ gtk_window_set_gravity(GTK_WINDOW(job_queue->window), GDK_GRAVITY_SOUTH_EAST); From anders at brander.dk Sun Mar 15 02:36:32 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 15 Mar 2009 02:36:32 +0100 Subject: [Rawstudio-commit] r2255 - trunk/plugins/meta-tiff Message-ID: Author: abrander Date: 2009-03-15 02:36:31 +0100 (Sun, 15 Mar 2009) New Revision: 2255 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: Removed debug-printf. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-14 23:52:57 UTC (rev 2254) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-15 01:36:31 UTC (rev 2255) @@ -467,7 +467,6 @@ raw_get_ushort(rawfile, offset+2, &meta->iso); break; case 0x000c: /* D1 White Balance */ - printf("%s\n", meta->model_ascii); if (g_str_equal(meta->model_ascii, "NIKON D1X")) { meta->cam_mul[0] = get_rational(rawfile, offset); From klauspost at gmail.com Sun Mar 15 15:26:44 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 15 Mar 2009 15:26:44 +0100 Subject: [Rawstudio-commit] r2256 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-15 15:26:44 +0100 (Sun, 15 Mar 2009) New Revision: 2256 Added: trunk/plugins/denoise/complexfilter-x86.cpp Modified: trunk/plugins/denoise/Makefile.am trunk/plugins/denoise/complexblock.cpp trunk/plugins/denoise/complexblock.h trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h trunk/plugins/denoise/denoisethread.cpp trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/fftwindow.h trunk/plugins/denoise/floatimageplane.cpp trunk/plugins/denoise/floatimageplane.h Log: Denoiser: Optimized sharpen only, SSE & SSE3 (approx 2x as fast), skip unprocessed blocks (1/3 workload). Modified: trunk/plugins/denoise/Makefile.am =================================================================== --- trunk/plugins/denoise/Makefile.am 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/Makefile.am 2009-03-15 14:26:44 UTC (rev 2256) @@ -22,6 +22,7 @@ denoise_la_SOURCES = denoise.c \ complexblock.cpp \ complexfilter.cpp \ + complexfilter-x86.cpp \ denoisethread.cpp \ fftdenoiser.cpp \ fftdenoiseryuv.cpp\ Modified: trunk/plugins/denoise/complexblock.cpp =================================================================== --- trunk/plugins/denoise/complexblock.cpp 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/complexblock.cpp 2009-03-15 14:26:44 UTC (rev 2256) @@ -17,6 +17,7 @@ */ #include "complexblock.h" #include +#include "floatimageplane.h" ComplexBlock::ComplexBlock(int _w, int _h): w(_w), h(_h) @@ -24,11 +25,14 @@ pitch = w * sizeof(fftwf_complex); complex = (fftwf_complex*)fftwf_malloc(h*pitch); g_assert(complex); + temp = new FloatImagePlane(256,1); + temp->allocateImage(); } ComplexBlock::~ComplexBlock(void) { fftwf_free(complex); complex = 0; + delete temp; } Modified: trunk/plugins/denoise/complexblock.h =================================================================== --- trunk/plugins/denoise/complexblock.h 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/complexblock.h 2009-03-15 14:26:44 UTC (rev 2256) @@ -21,12 +21,15 @@ #include "fftw3.h" #include +class FloatImagePlane; + class ComplexBlock { public: ComplexBlock(int w, int h); ~ComplexBlock(void); fftwf_complex* complex; + FloatImagePlane *temp; const int w; const int h; private: Added: trunk/plugins/denoise/complexfilter-x86.cpp =================================================================== --- trunk/plugins/denoise/complexfilter-x86.cpp (rev 0) +++ trunk/plugins/denoise/complexfilter-x86.cpp 2009-03-15 14:26:44 UTC (rev 2256) @@ -0,0 +1,182 @@ +/* +* Copyright (C) 2009 Klaus Post +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program 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 General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "complexfilter.h" +#include +#include "fftwindow.h" + + +#if defined (__i386__) || defined (__x86_64__) + +void DeGridComplexFilter::processSharpenOnlySSE3(ComplexBlock* block) { + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. + float *wsharpen = sharpenWindow->getLine(0); + + for (int i = 0; i < 4; i++) { + temp[i+0] = 1e-15f; // 0 + temp[i+4] = gridfraction; // 16 + temp[i+8] = sigmaSquaredSharpenMin; // 32 + temp[i+12] = sigmaSquaredSharpenMax; // 48 + temp[i+16] = 1.0f; // 64 + } + int size = bw*bh; + asm volatile + ( + "loop_sharpenonly_sse3:\n" + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 + + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory + "movaps %%xmm5, %%xmm3\n" + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained + "movaps %%xmm1, %%xmm5\n" + + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared + "movaps 32(%1), %%xmm6\n" // Move sigmaSquaredSharpenMin into xmm6 + "haddps %%xmm5, %%xmm4\n" //r0+i0 r1+i1 r2+i2 r3+i3 r4+i4 (all squared) (SSE3!) - xmm 5 free + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) + "movaps 48(%1), %%xmm7\n" // Move sigmaSquaredSharpenMax into xmm7 + + // float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; + "movaps %%xmm4, %%xmm5\n" // Copy psd into xmm5 + "addps %%xmm7, %%xmm4\n" // xmm4 = psd + sigmaSquaredSharpenMax + "mulps %%xmm5, %%xmm7\n" // xmm7 = psd*sigmaSquaredSharpenMax + "addps %%xmm6, %%xmm5\n" //xmm5 = psd + sigmaSquaredSharpenMin //xmm6 free + + "mulps %%xmm4, %%xmm5\n" // (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) xmm4 free + "movaps (%4), %%xmm6\n" // load wsharpen[0->4] + "rcpps %%xmm5, %%xmm5\n" // 1 / (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) (stall) + "mulps %%xmm5, %%xmm7\n" // psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) - xmm5 free + "movaps 64(%1), %%xmm5\n" // Load "1.0" + "sqrtps %%xmm7, %%xmm7\n" // sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) + "mulps %%xmm6, %%xmm7\n" // multiply wsharpen + "addps %%xmm5, %%xmm7\n" // + 1.0 xmm7 = sfact + "movaps %%xmm7, %%xmm5\n" + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 + + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact + "addps %%xmm2, %%xmm0\n" // add gridcorrection + "addps %%xmm3, %%xmm1\n" // add gridcorrection + "movaps %%xmm0, (%2)\n" // Store + "movaps %%xmm1, 16(%2)\n" // Store + "sub $4, %0\n" // size -=4 + "add $32, %2\n" // outcur+=32 + "add $32, %3\n" // gridsample+=32 + "add $16, %4\n" // wsharpen+=16 + "cmp $0, %0\n" + "jg loop_sharpenonly_sse3\n" + : /* no output registers */ + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample), "r"(wsharpen) + : /* %0 %1 %2 %3 %4 */ + ); +} +void DeGridComplexFilter::processSharpenOnlySSE(ComplexBlock* block) { + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. + float *wsharpen = sharpenWindow->getLine(0); + + for (int i = 0; i < 4; i++) { + temp[i+0] = 1e-15f; // 0 + temp[i+4] = gridfraction; // 16 + temp[i+8] = sigmaSquaredSharpenMin; // 32 + temp[i+12] = sigmaSquaredSharpenMax; // 48 + temp[i+16] = 1.0f; // 64 + } + int size = bw*bh; + asm volatile + ( + "loop_sharpenonly_sse:\n" + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 + + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory + "movaps %%xmm5, %%xmm3\n" + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained + "movaps %%xmm1, %%xmm5\n" + + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared + + "movaps %%xmm4, %%xmm7\n" + "shufps $136, %%xmm5, %%xmm4\n" // xmm7 r0r1 r2r3 [10 00 10 00 = 136] + "shufps $221, %%xmm5, %%xmm7\n" // xmm6 i0i1 i2i3 [11 01 11 01 = 221] + "movaps 32(%1), %%xmm6\n" // Move sigmaSquaredSharpenMin into xmm6 + "addps %%xmm7, %%xmm4\n" + "movaps 48(%1), %%xmm7\n" // Move sigmaSquaredSharpenMax into xmm7 + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) + + // float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; + "movaps %%xmm4, %%xmm5\n" // Copy psd into xmm5 + "addps %%xmm7, %%xmm4\n" // xmm4 = psd + sigmaSquaredSharpenMax + "mulps %%xmm5, %%xmm7\n" // xmm7 = psd*sigmaSquaredSharpenMax + "addps %%xmm6, %%xmm5\n" //xmm5 = psd + sigmaSquaredSharpenMin //xmm6 free + + "mulps %%xmm4, %%xmm5\n" // (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) xmm4 free + "movaps (%4), %%xmm6\n" // load wsharpen[0->4] + "rcpps %%xmm5, %%xmm5\n" // 1 / (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) (stall) + "mulps %%xmm5, %%xmm7\n" // psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) - xmm5 free + "movaps 64(%1), %%xmm5\n" // Load "1.0" + "sqrtps %%xmm7, %%xmm7\n" // sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) + "mulps %%xmm6, %%xmm7\n" // multiply wsharpen + "addps %%xmm5, %%xmm7\n" // + 1.0 xmm7 = sfact + "movaps %%xmm7, %%xmm5\n" + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 + + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact + "addps %%xmm2, %%xmm0\n" // add gridcorrection + "addps %%xmm3, %%xmm1\n" // add gridcorrection + "movaps %%xmm0, (%2)\n" // Store + "movaps %%xmm1, 16(%2)\n" // Store + "sub $4, %0\n" // size -=4 + "add $32, %2\n" // outcur+=32 + "add $32, %3\n" // gridsample+=32 + "add $16, %4\n" // wsharpen+=16 + "cmp $0, %0\n" + "jg loop_sharpenonly_sse\n" + : /* no output registers */ + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample), "r"(wsharpen) + : /* %0 %1 %2 %3 %4 */ + ); +} + +#endif // defined (__i386__) || defined (__x86_64__) + Modified: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-15 14:26:44 UTC (rev 2256) @@ -85,6 +85,12 @@ processNoSharpen(block); } +gboolean ComplexFilter::skipBlock() { + if (ABS(sharpen) >0.001f) + return false; + return true; +} + /** DeGridComplexFilter **/ DeGridComplexFilter::DeGridComplexFilter(int block_width, int block_height, float _degrid, FFTWindow *_window, fftwf_plan plan_forward) : ComplexFilter(block_width, block_height), @@ -110,6 +116,10 @@ } void DeGridComplexFilter::processSharpenOnly(ComplexBlock* block) { +#if defined (__i386__) || defined (__x86_64__) + processSharpenOnlySSE(block); + return; +#endif int x,y; fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; @@ -118,12 +128,11 @@ for (y=0; ygetLine(y); for (x=0; x0.001f) + return false; + if (sigmaSquaredNoiseNormed > 1e-15f) + return false; + return true; +} + void ComplexWienerFilter::processNoSharpen( ComplexBlock* block ) { float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 @@ -242,6 +261,14 @@ g_assert(!"Not implemented"); } +gboolean ComplexPatternFilter::skipBlock() { + if (ABS(sharpen) >0.001f) + return false; + if (pfactor > 1e-15f) + return false; + return true; +} + ComplexWienerFilterDeGrid::ComplexWienerFilterDeGrid( int block_width, int block_height, float _beta, float _sigma, float _degrid, fftwf_plan plan_forward, FFTWindow *_window) @@ -255,10 +282,18 @@ { } +gboolean ComplexWienerFilterDeGrid::skipBlock() { + if (ABS(sharpen) >0.001f) + return false; + if (sigmaSquaredNoiseNormed > 1e-15f) + return false; + return true; +} - void ComplexWienerFilterDeGrid::processNoSharpen( ComplexBlock* block ) { + if (sigmaSquaredNoiseNormed <= 1e-15f) + return; float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; @@ -336,6 +371,9 @@ { } +gboolean ComplexFilterPatternDeGrid::skipBlock() { + return false; +} void ComplexFilterPatternDeGrid::processNoSharpen( ComplexBlock* block ) Modified: trunk/plugins/denoise/complexfilter.h =================================================================== --- trunk/plugins/denoise/complexfilter.h 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/complexfilter.h 2009-03-15 14:26:44 UTC (rev 2256) @@ -31,9 +31,10 @@ virtual ~ComplexFilter(void); void process(ComplexBlock* block); virtual void setSharpen( float sharpen, float sigmaSharpenMin, float sigmaSharpenMax, float scutoff ); + virtual gboolean skipBlock(); protected: virtual void processNoSharpen(ComplexBlock* block) = 0; - virtual void processSharpen(ComplexBlock* block) = 0; + virtual void processSharpen(ComplexBlock* block) = 0; const int bw; const int bh; const float norm; // Normalization factor @@ -51,6 +52,10 @@ virtual ~DeGridComplexFilter(void); protected: virtual void processSharpenOnly(ComplexBlock* block); +#if defined (__i386__) || defined (__x86_64__) + void processSharpenOnlySSE(ComplexBlock* block); + void processSharpenOnlySSE3(ComplexBlock* block); +#endif const float degrid; FFTWindow *window; ComplexBlock* grid; @@ -61,6 +66,7 @@ public: ComplexWienerFilter(int block_width, int block_height, float beta, float sigma); virtual ~ComplexWienerFilter(void); + virtual gboolean skipBlock(); protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); @@ -72,6 +78,7 @@ public: ComplexWienerFilterDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window); virtual ~ComplexWienerFilterDeGrid(void); + virtual gboolean skipBlock(); protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); @@ -84,6 +91,7 @@ public: ComplexPatternFilter(int block_width, int block_height, float beta, FloatImagePlane* pattern, float pattern_strength ); virtual ~ComplexPatternFilter(void); + virtual gboolean skipBlock(); protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); @@ -97,6 +105,7 @@ public: ComplexFilterPatternDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window, FloatImagePlane *pattern); virtual ~ComplexFilterPatternDeGrid(void); + virtual gboolean skipBlock(); protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); Modified: trunk/plugins/denoise/denoisethread.cpp =================================================================== --- trunk/plugins/denoise/denoisethread.cpp 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-15 14:26:44 UTC (rev 2256) @@ -120,9 +120,18 @@ void DenoiseThread::procesFFT( FFTJob* j ) { FloatImagePlane* input = j->p->in; + g_assert(j->p->filter); + if (j->p->filter->skipBlock()) { + j->p->allocateOut(); + input->blitOnto(j->p->out); + j->p->out->multiply((float)(input->w * input->h)); + return; + } + if (!complex) complex = new ComplexBlock(input->w, input->h); + if (!input_plane) { input_plane = new FloatImagePlane(input->w, input->h); input_plane->allocateImage(); @@ -132,9 +141,7 @@ fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); - g_assert(j->p->filter); - if (j->p->filter) - j->p->filter->process(complex); + j->p->filter->process(complex); j->p->allocateOut(); Modified: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-15 14:26:44 UTC (rev 2256) @@ -139,6 +139,14 @@ image->blitOnto(dst); return; } + +#if defined (__i386__) || defined (__x86_64__) +/* if (analysis.pitch == dst->pitch && ((dst->pitch&15) == 0)) { + applyAnalysisWindowSSE( image, dst); + return; + }*/ +#endif // defined (__i386__) || defined (__x86_64__) + for (int y = 0; y < analysis.h; y++) { float *srcp1 = analysis.getLine(y); float *srcp2 = image->getLine(y); @@ -149,6 +157,45 @@ } } + +#if defined (__i386__) || defined (__x86_64__) + +// FIXME: Fix, if needed. Crashes. +void FFTWindow::applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ) +{ + int sizew = analysis.pitch * 4; // Size in bytes + float* srcp1 = image->getLine(0); + g_assert(analysis.pitch == dst->pitch); + g_assert(analysis.w == dst->pitch); + int remainpitch = image->pitch*4 - sizew; + asm volatile + ( +// "mov (%3), %3\n" + "loop_analysis_sse_ua:\n" +// "prefetcht0 (%1,%3)\n" // Prefetch next line + "movups (%1), %%xmm0\n" // src1 pt1 + "movups 16(%1), %%xmm1\n" // src1 pt2 + "movaps (%0), %%xmm2\n" // window pt1 + "movaps 16(%0), %%xmm3\n" // window pt2 + "mulps %%xmm0, %%xmm2\n" // p1 multiplied + "mulps %%xmm1, %%xmm3\n" // p1 multiplied + "movaps %%xmm2, (%2)\n" // store pt1 + "movaps %%xmm3, 16(%2)\n" // stote pt2 + "add $32, %0\n" + "add $32, %1\n" + "sub $32 ,%4\n" + "cmp $0, %4\n" + "jg loop_analysis_sse_ua\n" + "add %3, %1\n" // Add pitch + "dec %5\n" + "jnz loop_analysis_sse_ua" + : /* no output registers */ + : "r" (analysis.getLine(0)), "r" (srcp1), "r" (dst->getLine(0)), "r" (&remainpitch), "r"(sizew), "r" (image->h) + : /* %0 %1 %2 %3 %4 %5 */ + ); +} +#endif // defined (__i386__) || defined (__x86_64__) + // FIXME: SSE2 me void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) { Modified: trunk/plugins/denoise/fftwindow.h =================================================================== --- trunk/plugins/denoise/fftwindow.h 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/fftwindow.h 2009-03-15 14:26:44 UTC (rev 2256) @@ -14,27 +14,30 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ -#ifndef fftwindow_h__ -#define fftwindow_h__ -#include "floatimageplane.h" - - -class FFTWindow -{ -public: - FFTWindow(int _w, int _h); - virtual ~FFTWindow(void); - FloatImagePlane analysis; - FloatImagePlane synthesis; - void createHalfCosineWindow(int ox, int oy); - void createRaisedCosineWindow(int ox, int oy); - void createSqrtHalfCosineWindow(int ox, int oy); - void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); - void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image -private: +*/ +#ifndef fftwindow_h__ +#define fftwindow_h__ +#include "floatimageplane.h" + + +class FFTWindow +{ +public: + FFTWindow(int _w, int _h); + virtual ~FFTWindow(void); + FloatImagePlane analysis; + FloatImagePlane synthesis; + void createHalfCosineWindow(int ox, int oy); + void createRaisedCosineWindow(int ox, int oy); + void createSqrtHalfCosineWindow(int ox, int oy); + void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); +#if defined (__i386__) || defined (__x86_64__) + void applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ); +#endif + void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image +private: void createWindow( FloatImagePlane &window, int ox, float* wx); bool isFlat; -}; - -#endif // fftwindow_h__ +}; + +#endif // fftwindow_h__ Modified: trunk/plugins/denoise/floatimageplane.cpp =================================================================== --- trunk/plugins/denoise/floatimageplane.cpp 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/floatimageplane.cpp 2009-03-15 14:26:44 UTC (rev 2256) @@ -153,8 +153,20 @@ } } -void FloatImagePlane::blitOnto( FloatImagePlane *dst ) { +void FloatImagePlane::blitOnto( FloatImagePlane *dst ) +{ g_assert(dst->w == w); g_assert(dst->h == h); FBitBlt((guchar*)dst->data, dst->pitch*sizeof(float),(guchar*)data,pitch*sizeof(float),w*sizeof(float),h); -} \ No newline at end of file +} + +void FloatImagePlane::multiply(float factor) +{ + for (int y = 0; y < h; y++ ) { + float* src = getAt(0,y); + for (int x = 0; x < w; x++) { + src[x] *= factor; + } + } +} + Modified: trunk/plugins/denoise/floatimageplane.h =================================================================== --- trunk/plugins/denoise/floatimageplane.h 2009-03-15 01:36:31 UTC (rev 2255) +++ trunk/plugins/denoise/floatimageplane.h 2009-03-15 14:26:44 UTC (rev 2256) @@ -39,6 +39,7 @@ gfloat* getAt(int x, int y); FloatImagePlane* getSlice(int x,int y,int new_w, int new_h); void blitOnto(FloatImagePlane *dst); + void multiply(float mul); void addJobs(JobQueue *jobs, int bw, int bh, int ox, int oy); void applySlice(PlanarImageSlice *p); const int w; From anders at kvistmail.dk Sun Mar 15 16:06:13 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Sun, 15 Mar 2009 16:06:13 +0100 Subject: [Rawstudio-commit] r2256 - trunk/plugins/denoise In-Reply-To: References: Message-ID: <49BD1965.1070700@kvistmail.dk> Den fejler under compile p? linux... libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../.. -DPACKAGE_DATA_DIR=\"/usr/local/share\" -DPACKAGE_LOCALE_DIR=\"/usr/local/share/locale\" -DORBIT2=1 -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libxml2 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I../../librawstudio/ -Wall -g3 -O4 -g -O2 -MT fftwindow.lo -MD -MP -MF .deps/fftwindow.Tpo -c fftwindow.cpp -fPIC -DPIC -o .libs/fftwindow.o fftwindow.cpp: In member function ?void FFTWindow::applyAnalysisWindowSSE(FloatImagePlane*, FloatImagePlane*)?: fftwindow.cpp:195: error: can't find a register in class ?GENERAL_REGS? while reloading ?asm? fftwindow.cpp:195: error: ?asm? operand has impossible constraints make[3]: *** [fftwindow.lo] Error 1 Klaus Post wrote: > Author: post > Date: 2009-03-15 15:26:44 +0100 (Sun, 15 Mar 2009) > New Revision: 2256 > > Added: > trunk/plugins/denoise/complexfilter-x86.cpp > Modified: > trunk/plugins/denoise/Makefile.am > trunk/plugins/denoise/complexblock.cpp > trunk/plugins/denoise/complexblock.h > trunk/plugins/denoise/complexfilter.cpp > trunk/plugins/denoise/complexfilter.h > trunk/plugins/denoise/denoisethread.cpp > trunk/plugins/denoise/fftwindow.cpp > trunk/plugins/denoise/fftwindow.h > trunk/plugins/denoise/floatimageplane.cpp > trunk/plugins/denoise/floatimageplane.h > Log: > Denoiser: Optimized sharpen only, SSE & SSE3 (approx 2x as fast), skip unprocessed blocks (1/3 workload). > > Modified: trunk/plugins/denoise/Makefile.am > =================================================================== > --- trunk/plugins/denoise/Makefile.am 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/Makefile.am 2009-03-15 14:26:44 UTC (rev 2256) > @@ -22,6 +22,7 @@ > denoise_la_SOURCES = denoise.c \ > complexblock.cpp \ > complexfilter.cpp \ > + complexfilter-x86.cpp \ > denoisethread.cpp \ > fftdenoiser.cpp \ > fftdenoiseryuv.cpp\ > > Modified: trunk/plugins/denoise/complexblock.cpp > =================================================================== > --- trunk/plugins/denoise/complexblock.cpp 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/complexblock.cpp 2009-03-15 14:26:44 UTC (rev 2256) > @@ -17,6 +17,7 @@ > */ > #include "complexblock.h" > #include > +#include "floatimageplane.h" > > > ComplexBlock::ComplexBlock(int _w, int _h): w(_w), h(_h) > @@ -24,11 +25,14 @@ > pitch = w * sizeof(fftwf_complex); > complex = (fftwf_complex*)fftwf_malloc(h*pitch); > g_assert(complex); > + temp = new FloatImagePlane(256,1); > + temp->allocateImage(); > } > > ComplexBlock::~ComplexBlock(void) > { > fftwf_free(complex); > complex = 0; > + delete temp; > } > > > Modified: trunk/plugins/denoise/complexblock.h > =================================================================== > --- trunk/plugins/denoise/complexblock.h 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/complexblock.h 2009-03-15 14:26:44 UTC (rev 2256) > @@ -21,12 +21,15 @@ > #include "fftw3.h" > #include > > +class FloatImagePlane; > + > class ComplexBlock > { > public: > ComplexBlock(int w, int h); > ~ComplexBlock(void); > fftwf_complex* complex; > + FloatImagePlane *temp; > const int w; > const int h; > private: > > Added: trunk/plugins/denoise/complexfilter-x86.cpp > =================================================================== > --- trunk/plugins/denoise/complexfilter-x86.cpp (rev 0) > +++ trunk/plugins/denoise/complexfilter-x86.cpp 2009-03-15 14:26:44 UTC (rev 2256) > @@ -0,0 +1,182 @@ > +/* > +* Copyright (C) 2009 Klaus Post > +* > +* This program is free software; you can redistribute it and/or > +* modify it under the terms of the GNU General Public License > +* as published by the Free Software Foundation; either version 2 > +* of the License, or (at your option) any later version. > +* > +* This program 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 General Public License for more details. > +* > +* You should have received a copy of the GNU General Public License > +* along with this program; if not, write to the Free Software > +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. > +*/ > + > +#include "complexfilter.h" > +#include > +#include "fftwindow.h" > + > + > +#if defined (__i386__) || defined (__x86_64__) > + > +void DeGridComplexFilter::processSharpenOnlySSE3(ComplexBlock* block) { > + fftwf_complex* outcur = block->complex; > + fftwf_complex* gridsample = grid->complex; > + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; > + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. > + float *wsharpen = sharpenWindow->getLine(0); > + > + for (int i = 0; i < 4; i++) { > + temp[i+0] = 1e-15f; // 0 > + temp[i+4] = gridfraction; // 16 > + temp[i+8] = sigmaSquaredSharpenMin; // 32 > + temp[i+12] = sigmaSquaredSharpenMax; // 48 > + temp[i+16] = 1.0f; // 64 > + } > + int size = bw*bh; > + asm volatile > + ( > + "loop_sharpenonly_sse3:\n" > + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 > + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 > + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 > + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 > + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 > + > + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) > + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) > + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory > + "movaps %%xmm5, %%xmm3\n" > + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) > + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - > + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained > + "movaps %%xmm1, %%xmm5\n" > + > + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared > + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared > + "movaps 32(%1), %%xmm6\n" // Move sigmaSquaredSharpenMin into xmm6 > + "haddps %%xmm5, %%xmm4\n" //r0+i0 r1+i1 r2+i2 r3+i3 r4+i4 (all squared) (SSE3!) - xmm 5 free > + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) > + "movaps 48(%1), %%xmm7\n" // Move sigmaSquaredSharpenMax into xmm7 > + > + // float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; > + "movaps %%xmm4, %%xmm5\n" // Copy psd into xmm5 > + "addps %%xmm7, %%xmm4\n" // xmm4 = psd + sigmaSquaredSharpenMax > + "mulps %%xmm5, %%xmm7\n" // xmm7 = psd*sigmaSquaredSharpenMax > + "addps %%xmm6, %%xmm5\n" //xmm5 = psd + sigmaSquaredSharpenMin //xmm6 free > + > + "mulps %%xmm4, %%xmm5\n" // (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) xmm4 free > + "movaps (%4), %%xmm6\n" // load wsharpen[0->4] > + "rcpps %%xmm5, %%xmm5\n" // 1 / (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) (stall) > + "mulps %%xmm5, %%xmm7\n" // psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) - xmm5 free > + "movaps 64(%1), %%xmm5\n" // Load "1.0" > + "sqrtps %%xmm7, %%xmm7\n" // sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) > + "mulps %%xmm6, %%xmm7\n" // multiply wsharpen > + "addps %%xmm5, %%xmm7\n" // + 1.0 xmm7 = sfact > + "movaps %%xmm7, %%xmm5\n" > + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 > + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 > + > + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact > + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact > + "addps %%xmm2, %%xmm0\n" // add gridcorrection > + "addps %%xmm3, %%xmm1\n" // add gridcorrection > + "movaps %%xmm0, (%2)\n" // Store > + "movaps %%xmm1, 16(%2)\n" // Store > + "sub $4, %0\n" // size -=4 > + "add $32, %2\n" // outcur+=32 > + "add $32, %3\n" // gridsample+=32 > + "add $16, %4\n" // wsharpen+=16 > + "cmp $0, %0\n" > + "jg loop_sharpenonly_sse3\n" > + : /* no output registers */ > + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample), "r"(wsharpen) > + : /* %0 %1 %2 %3 %4 */ > + ); > +} > +void DeGridComplexFilter::processSharpenOnlySSE(ComplexBlock* block) { > + fftwf_complex* outcur = block->complex; > + fftwf_complex* gridsample = grid->complex; > + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; > + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. > + float *wsharpen = sharpenWindow->getLine(0); > + > + for (int i = 0; i < 4; i++) { > + temp[i+0] = 1e-15f; // 0 > + temp[i+4] = gridfraction; // 16 > + temp[i+8] = sigmaSquaredSharpenMin; // 32 > + temp[i+12] = sigmaSquaredSharpenMax; // 48 > + temp[i+16] = 1.0f; // 64 > + } > + int size = bw*bh; > + asm volatile > + ( > + "loop_sharpenonly_sse:\n" > + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 > + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 > + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 > + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 > + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 > + > + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) > + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) > + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory > + "movaps %%xmm5, %%xmm3\n" > + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) > + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - > + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained > + "movaps %%xmm1, %%xmm5\n" > + > + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared > + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared > + > + "movaps %%xmm4, %%xmm7\n" > + "shufps $136, %%xmm5, %%xmm4\n" // xmm7 r0r1 r2r3 [10 00 10 00 = 136] > + "shufps $221, %%xmm5, %%xmm7\n" // xmm6 i0i1 i2i3 [11 01 11 01 = 221] > + "movaps 32(%1), %%xmm6\n" // Move sigmaSquaredSharpenMin into xmm6 > + "addps %%xmm7, %%xmm4\n" > + "movaps 48(%1), %%xmm7\n" // Move sigmaSquaredSharpenMax into xmm7 > + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) > + > + // float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; > + "movaps %%xmm4, %%xmm5\n" // Copy psd into xmm5 > + "addps %%xmm7, %%xmm4\n" // xmm4 = psd + sigmaSquaredSharpenMax > + "mulps %%xmm5, %%xmm7\n" // xmm7 = psd*sigmaSquaredSharpenMax > + "addps %%xmm6, %%xmm5\n" //xmm5 = psd + sigmaSquaredSharpenMin //xmm6 free > + > + "mulps %%xmm4, %%xmm5\n" // (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) xmm4 free > + "movaps (%4), %%xmm6\n" // load wsharpen[0->4] > + "rcpps %%xmm5, %%xmm5\n" // 1 / (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) (stall) > + "mulps %%xmm5, %%xmm7\n" // psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) - xmm5 free > + "movaps 64(%1), %%xmm5\n" // Load "1.0" > + "sqrtps %%xmm7, %%xmm7\n" // sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) > + "mulps %%xmm6, %%xmm7\n" // multiply wsharpen > + "addps %%xmm5, %%xmm7\n" // + 1.0 xmm7 = sfact > + "movaps %%xmm7, %%xmm5\n" > + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 > + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 > + > + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact > + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact > + "addps %%xmm2, %%xmm0\n" // add gridcorrection > + "addps %%xmm3, %%xmm1\n" // add gridcorrection > + "movaps %%xmm0, (%2)\n" // Store > + "movaps %%xmm1, 16(%2)\n" // Store > + "sub $4, %0\n" // size -=4 > + "add $32, %2\n" // outcur+=32 > + "add $32, %3\n" // gridsample+=32 > + "add $16, %4\n" // wsharpen+=16 > + "cmp $0, %0\n" > + "jg loop_sharpenonly_sse\n" > + : /* no output registers */ > + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample), "r"(wsharpen) > + : /* %0 %1 %2 %3 %4 */ > + ); > +} > + > +#endif // defined (__i386__) || defined (__x86_64__) > + > > Modified: trunk/plugins/denoise/complexfilter.cpp > =================================================================== > --- trunk/plugins/denoise/complexfilter.cpp 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-15 14:26:44 UTC (rev 2256) > @@ -85,6 +85,12 @@ > processNoSharpen(block); > } > > +gboolean ComplexFilter::skipBlock() { > + if (ABS(sharpen) >0.001f) > + return false; > + return true; > +} > + > /** DeGridComplexFilter **/ > DeGridComplexFilter::DeGridComplexFilter(int block_width, int block_height, float _degrid, FFTWindow *_window, fftwf_plan plan_forward) : > ComplexFilter(block_width, block_height), > @@ -110,6 +116,10 @@ > } > > void DeGridComplexFilter::processSharpenOnly(ComplexBlock* block) { > +#if defined (__i386__) || defined (__x86_64__) > + processSharpenOnlySSE(block); > + return; > +#endif > int x,y; > fftwf_complex* outcur = block->complex; > fftwf_complex* gridsample = grid->complex; > @@ -118,12 +128,11 @@ > for (y=0; y float *wsharpen = sharpenWindow->getLine(y); > for (x=0; x - float psd = (outcur[x][0]*outcur[x][0] + outcur[x][1]*outcur[x][1]); > float gridcorrection0 = gridfraction*gridsample[x][0]; > float re = outcur[x][0] - gridcorrection0; > float gridcorrection1 = gridfraction*gridsample[x][1]; > float im = outcur[x][1] - gridcorrection1; > - psd = (re*re + im*im) + 1e-15f;// power spectrum density > + float psd = (re*re + im*im) + 1e-15f;// power spectrum density > //improved sharpen mode to prevent grid artifactes and to limit sharpening both fo low and high amplitudes > float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; > re *= sfact; // apply filter on real part > @@ -136,6 +145,8 @@ > wsharpen += bw; > } > } > + > + > /**** Basic Wiener Filter *****/ > > > @@ -149,6 +160,14 @@ > > ComplexWienerFilter::~ComplexWienerFilter( void ){} > > +gboolean ComplexWienerFilter::skipBlock() { > + if (ABS(sharpen) >0.001f) > + return false; > + if (sigmaSquaredNoiseNormed > 1e-15f) > + return false; > + return true; > +} > + > void ComplexWienerFilter::processNoSharpen( ComplexBlock* block ) > { > float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 > @@ -242,6 +261,14 @@ > g_assert(!"Not implemented"); > } > > +gboolean ComplexPatternFilter::skipBlock() { > + if (ABS(sharpen) >0.001f) > + return false; > + if (pfactor > 1e-15f) > + return false; > + return true; > +} > + > ComplexWienerFilterDeGrid::ComplexWienerFilterDeGrid( int block_width, int block_height, > float _beta, float _sigma, float _degrid, > fftwf_plan plan_forward, FFTWindow *_window) > @@ -255,10 +282,18 @@ > { > } > > +gboolean ComplexWienerFilterDeGrid::skipBlock() { > + if (ABS(sharpen) >0.001f) > + return false; > + if (sigmaSquaredNoiseNormed > 1e-15f) > + return false; > + return true; > +} > > - > void ComplexWienerFilterDeGrid::processNoSharpen( ComplexBlock* block ) > { > + if (sigmaSquaredNoiseNormed <= 1e-15f) > + return; > float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 > int x,y; > float psd; > @@ -336,6 +371,9 @@ > { > } > > +gboolean ComplexFilterPatternDeGrid::skipBlock() { > + return false; > +} > > > void ComplexFilterPatternDeGrid::processNoSharpen( ComplexBlock* block ) > > Modified: trunk/plugins/denoise/complexfilter.h > =================================================================== > --- trunk/plugins/denoise/complexfilter.h 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/complexfilter.h 2009-03-15 14:26:44 UTC (rev 2256) > @@ -31,9 +31,10 @@ > virtual ~ComplexFilter(void); > void process(ComplexBlock* block); > virtual void setSharpen( float sharpen, float sigmaSharpenMin, float sigmaSharpenMax, float scutoff ); > + virtual gboolean skipBlock(); > protected: > virtual void processNoSharpen(ComplexBlock* block) = 0; > - virtual void processSharpen(ComplexBlock* block) = 0; > + virtual void processSharpen(ComplexBlock* block) = 0; > const int bw; > const int bh; > const float norm; // Normalization factor > @@ -51,6 +52,10 @@ > virtual ~DeGridComplexFilter(void); > protected: > virtual void processSharpenOnly(ComplexBlock* block); > +#if defined (__i386__) || defined (__x86_64__) > + void processSharpenOnlySSE(ComplexBlock* block); > + void processSharpenOnlySSE3(ComplexBlock* block); > +#endif > const float degrid; > FFTWindow *window; > ComplexBlock* grid; > @@ -61,6 +66,7 @@ > public: > ComplexWienerFilter(int block_width, int block_height, float beta, float sigma); > virtual ~ComplexWienerFilter(void); > + virtual gboolean skipBlock(); > protected: > virtual void processNoSharpen(ComplexBlock* block); > virtual void processSharpen(ComplexBlock* block); > @@ -72,6 +78,7 @@ > public: > ComplexWienerFilterDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window); > virtual ~ComplexWienerFilterDeGrid(void); > + virtual gboolean skipBlock(); > protected: > virtual void processNoSharpen(ComplexBlock* block); > virtual void processSharpen(ComplexBlock* block); > @@ -84,6 +91,7 @@ > public: > ComplexPatternFilter(int block_width, int block_height, float beta, FloatImagePlane* pattern, float pattern_strength ); > virtual ~ComplexPatternFilter(void); > + virtual gboolean skipBlock(); > protected: > virtual void processNoSharpen(ComplexBlock* block); > virtual void processSharpen(ComplexBlock* block); > @@ -97,6 +105,7 @@ > public: > ComplexFilterPatternDeGrid(int block_width, int block_height, float beta, float sigma, float degrid, fftwf_plan plan, FFTWindow *window, FloatImagePlane *pattern); > virtual ~ComplexFilterPatternDeGrid(void); > + virtual gboolean skipBlock(); > protected: > virtual void processNoSharpen(ComplexBlock* block); > virtual void processSharpen(ComplexBlock* block); > > Modified: trunk/plugins/denoise/denoisethread.cpp > =================================================================== > --- trunk/plugins/denoise/denoisethread.cpp 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-15 14:26:44 UTC (rev 2256) > @@ -120,9 +120,18 @@ > void DenoiseThread::procesFFT( FFTJob* j ) > { > FloatImagePlane* input = j->p->in; > + g_assert(j->p->filter); > > + if (j->p->filter->skipBlock()) { > + j->p->allocateOut(); > + input->blitOnto(j->p->out); > + j->p->out->multiply((float)(input->w * input->h)); > + return; > + } > + > if (!complex) > complex = new ComplexBlock(input->w, input->h); > + > if (!input_plane) { > input_plane = new FloatImagePlane(input->w, input->h); > input_plane->allocateImage(); > @@ -132,9 +141,7 @@ > > fftwf_execute_dft_r2c(forward, input_plane->data, complex->complex); > > - g_assert(j->p->filter); > - if (j->p->filter) > - j->p->filter->process(complex); > + j->p->filter->process(complex); > > j->p->allocateOut(); > > > Modified: trunk/plugins/denoise/fftwindow.cpp > =================================================================== > --- trunk/plugins/denoise/fftwindow.cpp 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-15 14:26:44 UTC (rev 2256) > @@ -139,6 +139,14 @@ > image->blitOnto(dst); > return; > } > + > +#if defined (__i386__) || defined (__x86_64__) > +/* if (analysis.pitch == dst->pitch && ((dst->pitch&15) == 0)) { > + applyAnalysisWindowSSE( image, dst); > + return; > + }*/ > +#endif // defined (__i386__) || defined (__x86_64__) > + > for (int y = 0; y < analysis.h; y++) { > float *srcp1 = analysis.getLine(y); > float *srcp2 = image->getLine(y); > @@ -149,6 +157,45 @@ > } > } > > + > +#if defined (__i386__) || defined (__x86_64__) > + > +// FIXME: Fix, if needed. Crashes. > +void FFTWindow::applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ) > +{ > + int sizew = analysis.pitch * 4; // Size in bytes > + float* srcp1 = image->getLine(0); > + g_assert(analysis.pitch == dst->pitch); > + g_assert(analysis.w == dst->pitch); > + int remainpitch = image->pitch*4 - sizew; > + asm volatile > + ( > +// "mov (%3), %3\n" > + "loop_analysis_sse_ua:\n" > +// "prefetcht0 (%1,%3)\n" // Prefetch next line > + "movups (%1), %%xmm0\n" // src1 pt1 > + "movups 16(%1), %%xmm1\n" // src1 pt2 > + "movaps (%0), %%xmm2\n" // window pt1 > + "movaps 16(%0), %%xmm3\n" // window pt2 > + "mulps %%xmm0, %%xmm2\n" // p1 multiplied > + "mulps %%xmm1, %%xmm3\n" // p1 multiplied > + "movaps %%xmm2, (%2)\n" // store pt1 > + "movaps %%xmm3, 16(%2)\n" // stote pt2 > + "add $32, %0\n" > + "add $32, %1\n" > + "sub $32 ,%4\n" > + "cmp $0, %4\n" > + "jg loop_analysis_sse_ua\n" > + "add %3, %1\n" // Add pitch > + "dec %5\n" > + "jnz loop_analysis_sse_ua" > + : /* no output registers */ > + : "r" (analysis.getLine(0)), "r" (srcp1), "r" (dst->getLine(0)), "r" (&remainpitch), "r"(sizew), "r" (image->h) > + : /* %0 %1 %2 %3 %4 %5 */ > + ); > +} > +#endif // defined (__i386__) || defined (__x86_64__) > + > // FIXME: SSE2 me > void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) > { > > Modified: trunk/plugins/denoise/fftwindow.h > =================================================================== > --- trunk/plugins/denoise/fftwindow.h 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/fftwindow.h 2009-03-15 14:26:44 UTC (rev 2256) > @@ -14,27 +14,30 @@ > * You should have received a copy of the GNU General Public License > * along with this program; if not, write to the Free Software > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. > -*/ > -#ifndef fftwindow_h__ > -#define fftwindow_h__ > -#include "floatimageplane.h" > - > - > -class FFTWindow > -{ > -public: > - FFTWindow(int _w, int _h); > - virtual ~FFTWindow(void); > - FloatImagePlane analysis; > - FloatImagePlane synthesis; > - void createHalfCosineWindow(int ox, int oy); > - void createRaisedCosineWindow(int ox, int oy); > - void createSqrtHalfCosineWindow(int ox, int oy); > - void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); > - void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image > -private: > +*/ > +#ifndef fftwindow_h__ > +#define fftwindow_h__ > +#include "floatimageplane.h" > + > + > +class FFTWindow > +{ > +public: > + FFTWindow(int _w, int _h); > + virtual ~FFTWindow(void); > + FloatImagePlane analysis; > + FloatImagePlane synthesis; > + void createHalfCosineWindow(int ox, int oy); > + void createRaisedCosineWindow(int ox, int oy); > + void createSqrtHalfCosineWindow(int ox, int oy); > + void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); > +#if defined (__i386__) || defined (__x86_64__) > + void applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ); > +#endif > + void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image > +private: > void createWindow( FloatImagePlane &window, int ox, float* wx); > bool isFlat; > -}; > - > -#endif // fftwindow_h__ > +}; > + > +#endif // fftwindow_h__ > > Modified: trunk/plugins/denoise/floatimageplane.cpp > =================================================================== > --- trunk/plugins/denoise/floatimageplane.cpp 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/floatimageplane.cpp 2009-03-15 14:26:44 UTC (rev 2256) > @@ -153,8 +153,20 @@ > } > } > > -void FloatImagePlane::blitOnto( FloatImagePlane *dst ) { > +void FloatImagePlane::blitOnto( FloatImagePlane *dst ) > +{ > g_assert(dst->w == w); > g_assert(dst->h == h); > FBitBlt((guchar*)dst->data, dst->pitch*sizeof(float),(guchar*)data,pitch*sizeof(float),w*sizeof(float),h); > -} > \ No newline at end of file > +} > + > +void FloatImagePlane::multiply(float factor) > +{ > + for (int y = 0; y < h; y++ ) { > + float* src = getAt(0,y); > + for (int x = 0; x < w; x++) { > + src[x] *= factor; > + } > + } > +} > + > > Modified: trunk/plugins/denoise/floatimageplane.h > =================================================================== > --- trunk/plugins/denoise/floatimageplane.h 2009-03-15 01:36:31 UTC (rev 2255) > +++ trunk/plugins/denoise/floatimageplane.h 2009-03-15 14:26:44 UTC (rev 2256) > @@ -39,6 +39,7 @@ > gfloat* getAt(int x, int y); > FloatImagePlane* getSlice(int x,int y,int new_w, int new_h); > void blitOnto(FloatImagePlane *dst); > + void multiply(float mul); > void addJobs(JobQueue *jobs, int bw, int bh, int ox, int oy); > void applySlice(PlanarImageSlice *p); > const int w; > > > _______________________________________________ > Rawstudio-commit mailing list > Rawstudio-commit at rawstudio.org > http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit > From klauspost at gmail.com Sun Mar 15 16:23:45 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 15 Mar 2009 16:23:45 +0100 Subject: [Rawstudio-commit] r2257 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-15 16:23:44 +0100 (Sun, 15 Mar 2009) New Revision: 2257 Modified: trunk/plugins/denoise/complexfilter-x86.cpp Log: Denoiser: Optimized sharpen+denoise, SSE & SSE3 (approx 2x as fast). Removed unused and not working window code. Modified: trunk/plugins/denoise/complexfilter-x86.cpp =================================================================== --- trunk/plugins/denoise/complexfilter-x86.cpp 2009-03-15 14:26:44 UTC (rev 2256) +++ trunk/plugins/denoise/complexfilter-x86.cpp 2009-03-15 15:23:44 UTC (rev 2257) @@ -178,5 +178,190 @@ ); } + +void ComplexWienerFilterDeGrid::processSharpen_SSE3( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. + float *wsharpen = sharpenWindow->getLine(0); + + for (int i = 0; i < 4; i++) { + temp[i+0] = 1e-15f; // 0 + temp[i+4] = gridfraction; // 16 + temp[i+8] = sigmaSquaredSharpenMin; // 32 + temp[i+12] = sigmaSquaredSharpenMax; // 48 + temp[i+16] = 1.0f; // 64 + temp[i+20] = sigmaSquaredNoiseNormed; // 72 + temp[i+24] = lowlimit; // 96 + } + int size = bw*bh; + asm volatile + ( + "loop_wienerdegridsharpen_sse3:\n" + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 + + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory + "movaps %%xmm5, %%xmm3\n" + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained + "movaps %%xmm1, %%xmm5\n" + + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared + "haddps %%xmm5, %%xmm4\n" //r0+i0 r1+i1 r2+i2 r3+i3 r4+i4 (all squared) (SSE3!) - xmm 5 free + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) + + //WienerFactor = MAX((psd - sigmaSquaredNoiseNormed)/psd, lowlimit); // limited Wiener filter + + "movaps 80(%1), %%xmm5\n" //sigmaSquaredNoiseNormed in xmm5 + "movaps %%xmm4, %%xmm6\n" // Copy psd into xmm6 + "rcpps %%xmm4, %%xmm7\n" // xmm7: (1 / psd) + "subps %%xmm5, %%xmm6\n" // xmm6 (psd) - xmm5 (ssnn) xmm5 free + "movaps 96(%1), %%xmm5\n" // xmm5 = lowlimit + "mulps %%xmm7, %%xmm6\n" // xmm6 = (psd - sigmaSquaredNoiseNormed)/psd + "maxps %%xmm5, %%xmm6\n" // xmm6 = Wienerfactor = MAX(xmm6, lowlimit) + + // float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; + "movaps 48(%1), %%xmm7\n" // Move sigmaSquaredSharpenMax into xmm7 + "movaps %%xmm4, %%xmm5\n" // Copy psd into xmm5 + "addps %%xmm7, %%xmm4\n" // xmm4 = psd + sigmaSquaredSharpenMax + "mulps %%xmm5, %%xmm7\n" // xmm7 = psd*sigmaSquaredSharpenMax + "addps 32(%1), %%xmm5\n" //xmm5 = psd + sigmaSquaredSharpenMin //xmm6 free + + "mulps %%xmm4, %%xmm5\n" // (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) xmm4 free + "rcpps %%xmm5, %%xmm5\n" // 1 / (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) (stall) + "mulps %%xmm5, %%xmm7\n" // psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) - xmm5 free + "movaps 64(%1), %%xmm5\n" // Load "1.0" + "sqrtps %%xmm7, %%xmm7\n" // sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) + "mulps (%4), %%xmm7\n" // multiply wsharpen + "addps %%xmm5, %%xmm7\n" // + 1.0 xmm7 = sfact + "mulps %%xmm6, %%xmm7\n" // *= Wienerfactor + "movaps %%xmm7, %%xmm5\n" + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 + + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact + "addps %%xmm2, %%xmm0\n" // add gridcorrection + "addps %%xmm3, %%xmm1\n" // add gridcorrection + "movaps %%xmm0, (%2)\n" // Store + "movaps %%xmm1, 16(%2)\n" // Store + "sub $4, %0\n" // size -=4 + "add $32, %2\n" // outcur+=32 + "add $32, %3\n" // gridsample+=32 + "add $16, %4\n" // wsharpen+=16 + "cmp $0, %0\n" + "jg loop_wienerdegridsharpen_sse3\n" + : /* no output registers */ + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample), "r"(wsharpen) + : /* %0 %1 %2 %3 %4 */ + ); +} + +void ComplexWienerFilterDeGrid::processSharpen_SSE( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. + float *wsharpen = sharpenWindow->getLine(0); + + for (int i = 0; i < 4; i++) { + temp[i+0] = 1e-15f; // 0 + temp[i+4] = gridfraction; // 16 + temp[i+8] = sigmaSquaredSharpenMin; // 32 + temp[i+12] = sigmaSquaredSharpenMax; // 48 + temp[i+16] = 1.0f; // 64 + temp[i+20] = sigmaSquaredNoiseNormed; // 72 + temp[i+24] = lowlimit; // 96 + } + int size = bw*bh; + asm volatile + ( + "loop_wienerdegridsharpen_sse:\n" + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 + + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory + "movaps %%xmm5, %%xmm3\n" + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained + "movaps %%xmm1, %%xmm5\n" + + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared + "movaps %%xmm4, %%xmm7\n" + "shufps $136, %%xmm5, %%xmm4\n" // xmm7 r0r1 r2r3 [10 00 10 00 = 136] + "shufps $221, %%xmm5, %%xmm7\n" // xmm6 i0i1 i2i3 [11 01 11 01 = 221] + "addps %%xmm7, %%xmm4\n" + + + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) + + //WienerFactor = MAX((psd - sigmaSquaredNoiseNormed)/psd, lowlimit); // limited Wiener filter + + "movaps 80(%1), %%xmm5\n" //sigmaSquaredNoiseNormed in xmm5 + "movaps %%xmm4, %%xmm6\n" // Copy psd into xmm6 + "rcpps %%xmm4, %%xmm7\n" // xmm7: (1 / psd) + "subps %%xmm5, %%xmm6\n" // xmm6 (psd) - xmm5 (ssnn) xmm5 free + "movaps 96(%1), %%xmm5\n" // xmm5 = lowlimit + "mulps %%xmm7, %%xmm6\n" // xmm6 = (psd - sigmaSquaredNoiseNormed)/psd + "maxps %%xmm5, %%xmm6\n" // xmm6 = Wienerfactor = MAX(xmm6, lowlimit) + + // float sfact = (1 + wsharpen[x]*sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) )) ; + "movaps 48(%1), %%xmm7\n" // Move sigmaSquaredSharpenMax into xmm7 + "movaps %%xmm4, %%xmm5\n" // Copy psd into xmm5 + "addps %%xmm7, %%xmm4\n" // xmm4 = psd + sigmaSquaredSharpenMax + "mulps %%xmm5, %%xmm7\n" // xmm7 = psd*sigmaSquaredSharpenMax + "addps 32(%1), %%xmm5\n" //xmm5 = psd + sigmaSquaredSharpenMin //xmm6 free + + "mulps %%xmm4, %%xmm5\n" // (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) xmm4 free + "rcpps %%xmm5, %%xmm5\n" // 1 / (psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax) (stall) + "mulps %%xmm5, %%xmm7\n" // psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) - xmm5 free + "movaps 64(%1), %%xmm5\n" // Load "1.0" + "sqrtps %%xmm7, %%xmm7\n" // sqrt( psd*sigmaSquaredSharpenMax/((psd + sigmaSquaredSharpenMin)*(psd + sigmaSquaredSharpenMax)) + "mulps (%4), %%xmm7\n" // multiply wsharpen + "addps %%xmm5, %%xmm7\n" // + 1.0 xmm7 = sfact + "mulps %%xmm6, %%xmm7\n" // *= Wienerfactor + "movaps %%xmm7, %%xmm5\n" + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 + + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact + "addps %%xmm2, %%xmm0\n" // add gridcorrection + "addps %%xmm3, %%xmm1\n" // add gridcorrection + "movaps %%xmm0, (%2)\n" // Store + "movaps %%xmm1, 16(%2)\n" // Store + "sub $4, %0\n" // size -=4 + "add $32, %2\n" // outcur+=32 + "add $32, %3\n" // gridsample+=32 + "add $16, %4\n" // wsharpen+=16 + "cmp $0, %0\n" + "jg loop_wienerdegridsharpen_sse\n" + : /* no output registers */ + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample), "r"(wsharpen) + : /* %0 %1 %2 %3 %4 */ + ); + +} + #endif // defined (__i386__) || defined (__x86_64__) From klauspost at gmail.com Sun Mar 15 16:30:18 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 15 Mar 2009 16:30:18 +0100 Subject: [Rawstudio-commit] r2258 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-15 16:30:17 +0100 (Sun, 15 Mar 2009) New Revision: 2258 Modified: trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/fftwindow.h Log: Denoiser: Optimized sharpen+denoise, SSE & SSE3 (approx 2x as fast). Removed unused and not working window code. Modified: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp 2009-03-15 15:23:44 UTC (rev 2257) +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-15 15:30:17 UTC (rev 2258) @@ -326,6 +326,10 @@ { if (sigmaSquaredNoiseNormed <= 1e-15f) return processSharpenOnly(block); +#if defined (__i386__) || defined (__x86_64__) + processSharpen_SSE3(block); + return; +#endif float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; Modified: trunk/plugins/denoise/complexfilter.h =================================================================== --- trunk/plugins/denoise/complexfilter.h 2009-03-15 15:23:44 UTC (rev 2257) +++ trunk/plugins/denoise/complexfilter.h 2009-03-15 15:30:17 UTC (rev 2258) @@ -82,6 +82,10 @@ protected: virtual void processNoSharpen(ComplexBlock* block); virtual void processSharpen(ComplexBlock* block); +#if defined (__i386__) || defined (__x86_64__) + virtual void processSharpen_SSE3(ComplexBlock* block); + virtual void processSharpen_SSE(ComplexBlock* block); +#endif float sigmaSquaredNoiseNormed; FFTWindow *window; }; Modified: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp 2009-03-15 15:23:44 UTC (rev 2257) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-15 15:30:17 UTC (rev 2258) @@ -140,13 +140,6 @@ return; } -#if defined (__i386__) || defined (__x86_64__) -/* if (analysis.pitch == dst->pitch && ((dst->pitch&15) == 0)) { - applyAnalysisWindowSSE( image, dst); - return; - }*/ -#endif // defined (__i386__) || defined (__x86_64__) - for (int y = 0; y < analysis.h; y++) { float *srcp1 = analysis.getLine(y); float *srcp2 = image->getLine(y); @@ -158,44 +151,6 @@ } -#if defined (__i386__) || defined (__x86_64__) - -// FIXME: Fix, if needed. Crashes. -void FFTWindow::applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ) -{ - int sizew = analysis.pitch * 4; // Size in bytes - float* srcp1 = image->getLine(0); - g_assert(analysis.pitch == dst->pitch); - g_assert(analysis.w == dst->pitch); - int remainpitch = image->pitch*4 - sizew; - asm volatile - ( -// "mov (%3), %3\n" - "loop_analysis_sse_ua:\n" -// "prefetcht0 (%1,%3)\n" // Prefetch next line - "movups (%1), %%xmm0\n" // src1 pt1 - "movups 16(%1), %%xmm1\n" // src1 pt2 - "movaps (%0), %%xmm2\n" // window pt1 - "movaps 16(%0), %%xmm3\n" // window pt2 - "mulps %%xmm0, %%xmm2\n" // p1 multiplied - "mulps %%xmm1, %%xmm3\n" // p1 multiplied - "movaps %%xmm2, (%2)\n" // store pt1 - "movaps %%xmm3, 16(%2)\n" // stote pt2 - "add $32, %0\n" - "add $32, %1\n" - "sub $32 ,%4\n" - "cmp $0, %4\n" - "jg loop_analysis_sse_ua\n" - "add %3, %1\n" // Add pitch - "dec %5\n" - "jnz loop_analysis_sse_ua" - : /* no output registers */ - : "r" (analysis.getLine(0)), "r" (srcp1), "r" (dst->getLine(0)), "r" (&remainpitch), "r"(sizew), "r" (image->h) - : /* %0 %1 %2 %3 %4 %5 */ - ); -} -#endif // defined (__i386__) || defined (__x86_64__) - // FIXME: SSE2 me void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) { Modified: trunk/plugins/denoise/fftwindow.h =================================================================== --- trunk/plugins/denoise/fftwindow.h 2009-03-15 15:23:44 UTC (rev 2257) +++ trunk/plugins/denoise/fftwindow.h 2009-03-15 15:30:17 UTC (rev 2258) @@ -31,9 +31,6 @@ void createRaisedCosineWindow(int ox, int oy); void createSqrtHalfCosineWindow(int ox, int oy); void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); -#if defined (__i386__) || defined (__x86_64__) - void applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ); -#endif void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image private: void createWindow( FloatImagePlane &window, int ox, float* wx); From anders at kvistmail.dk Sun Mar 15 16:58:43 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Sun, 15 Mar 2009 16:58:43 +0100 Subject: [Rawstudio-commit] r2259 - trunk/plugins/denoise Message-ID: Author: akv Date: 2009-03-15 16:58:43 +0100 (Sun, 15 Mar 2009) New Revision: 2259 Modified: trunk/plugins/denoise/Makefile.am Log: Added .h files in Makefile.am - needed for building of tarballs and daily builds. Modified: trunk/plugins/denoise/Makefile.am =================================================================== --- trunk/plugins/denoise/Makefile.am 2009-03-15 15:30:17 UTC (rev 2258) +++ trunk/plugins/denoise/Makefile.am 2009-03-15 15:58:43 UTC (rev 2259) @@ -20,14 +20,15 @@ denoise_la_LIBADD = @PACKAGE_LIBS@ denoise_la_LDFLAGS = -module -avoid-version denoise_la_SOURCES = denoise.c \ - complexblock.cpp \ - complexfilter.cpp \ - complexfilter-x86.cpp \ - denoisethread.cpp \ - fftdenoiser.cpp \ - fftdenoiseryuv.cpp\ - fftwindow.cpp \ - floatimageplane.cpp \ - floatplanarimage.cpp \ - jobqueue.cpp \ - planarimageslice.cpp + complexblock.cpp complexblock.h \ + complexfilter.cpp complexfilter.h \ + complexfilter-x86.cpp \ + denoiseinterface.h \ + denoisethread.cpp denoisethread.h \ + fftdenoiser.cpp fftdenoiser.h \ + fftdenoiseryuv.cpp fftdenoiseryuv.h \ + fftwindow.cpp fftwindow.h \ + floatimageplane.cpp floatimageplane.h \ + floatplanarimage.cpp floatplanarimage.h \ + jobqueue.cpp jobqueue.h \ + planarimageslice.cpp planarimageslice.h From anders at brander.dk Sun Mar 15 18:03:23 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 15 Mar 2009 18:03:23 +0100 Subject: [Rawstudio-commit] r2260 - in trunk: librawstudio src Message-ID: Author: abrander Date: 2009-03-15 18:03:23 +0100 (Sun, 15 Mar 2009) New Revision: 2260 Added: trunk/librawstudio/x86-cpu.h Removed: trunk/src/x86_cpu.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h trunk/librawstudio/rs-utils.c trunk/librawstudio/rs-utils.h trunk/src/arch-x86.c Log: Moved rs_detect_cpu_features() to librawstudio.h. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-03-15 15:58:43 UTC (rev 2259) +++ trunk/librawstudio/Makefile.am 2009-03-15 17:03:23 UTC (rev 2260) @@ -26,7 +26,8 @@ rs-color-transform.h \ rs-spline.h \ rs-curve.h \ - rs-stock.h + rs-stock.h \ + x86-cpu.h lib_LTLIBRARIES = librawstudio-1.1.la librawstudio_1_1_la_SOURCES = \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-03-15 15:58:43 UTC (rev 2259) +++ trunk/librawstudio/rawstudio.h 2009-03-15 17:03:23 UTC (rev 2260) @@ -48,6 +48,8 @@ #include "rs-curve.h" #include "rs-stock.h" +#include "x86-cpu.h" + #ifdef __cplusplus } /* extern "c" */ #endif Modified: trunk/librawstudio/rs-utils.c =================================================================== --- trunk/librawstudio/rs-utils.c 2009-03-15 15:58:43 UTC (rev 2259) +++ trunk/librawstudio/rs-utils.c 2009-03-15 17:03:23 UTC (rev 2260) @@ -18,6 +18,7 @@ */ #define _XOPEN_SOURCE /* strptime() */ +#include #include #include #include @@ -25,7 +26,6 @@ #include #include #include -#include "rs-utils.h" #define DOTDIR ".rawstudio" @@ -172,7 +172,108 @@ return num; } +#if defined (__i386__) || defined (__x86_64__) + /** + * Detect cpu features + * @return A bitmask of @RSCpuFlags + */ +guint +rs_detect_cpu_features() +{ +#define cpuid(cmd, eax, edx) \ + do { \ + eax = edx = 0; \ + asm ( \ + "push %%"REG_b"\n\t"\ + "cpuid\n\t" \ + "pop %%"REG_b"\n\t" \ + : "=a" (eax), "=d" (edx) \ + : "0" (cmd) \ + ); \ +} while(0) + guint eax; + guint edx; + static GStaticMutex lock = G_STATIC_MUTEX_INIT; + static guint cpuflags = -1; + + g_static_mutex_lock(&lock); + if (cpuflags == -1) + { + cpuflags = 0; + /* Test cpuid presence comparing eflags */ + asm ( + "push %%"REG_b"\n\t" + "pushf\n\t" + "pop %%"REG_a"\n\t" + "mov %%"REG_a", %%"REG_b"\n\t" + "xor $0x00200000, %%"REG_a"\n\t" + "push %%"REG_a"\n\t" + "popf\n\t" + "pushf\n\t" + "pop %%"REG_a"\n\t" + "cmp %%"REG_a", %%"REG_b"\n\t" + "je notfound\n\t" + "mov $1, %0\n\t" + "notfound:\n\t" + "pop %%"REG_b"\n\t" + : "=r" (eax) + : + : REG_a + + ); + + if (eax) + { + guint std_dsc; + guint ext_dsc; + + /* Get the standard level */ + cpuid(0x00000000, std_dsc, edx); + + if (std_dsc) + { + /* Request for standard features */ + cpuid(0x00000001, std_dsc, edx); + + if (edx & 0x00800000) + cpuflags |= RS_CPU_FLAG_MMX; + if (edx & 0x02000000) + cpuflags |= RS_CPU_FLAG_SSE; + if (edx & 0x00008000) + cpuflags |= RS_CPU_FLAG_CMOV; + } + + /* Is there extensions */ + cpuid(0x80000000, ext_dsc, edx); + + if (ext_dsc) + { + /* Request for extensions */ + cpuid(0x80000001, eax, edx); + + if (edx & 0x80000000) + cpuflags |= RS_CPU_FLAG_3DNOW; + if (edx & 0x00400000) + cpuflags |= RS_CPU_FLAG_MMX; + } + } + } + g_static_mutex_unlock(&lock); + + return(cpuflags); +#undef cpuid +} + +#else +guint +rs_detect_cpu_features() +{ + return 0; +} +#endif /* __i386__ || __x86_64__ */ + +/** * Return a path to the current config directory for Rawstudio - this is the * .rawstudio direcotry in home * @return A path to an existing directory Modified: trunk/librawstudio/rs-utils.h =================================================================== --- trunk/librawstudio/rs-utils.h 2009-03-15 15:58:43 UTC (rev 2259) +++ trunk/librawstudio/rs-utils.h 2009-03-15 17:03:23 UTC (rev 2260) @@ -73,6 +73,13 @@ rs_get_number_of_processor_cores(); /** + * Detect cpu features + * @return A bitmask of @RSCpuFlags + */ +guint +rs_detect_cpu_features(); + +/** * Return a path to the current config directory for Rawstudio - this is the * .rawstudio direcotry in home * @return A path to an existing directory Copied: trunk/librawstudio/x86-cpu.h (from rev 2241, trunk/src/x86_cpu.h) =================================================================== --- trunk/librawstudio/x86-cpu.h (rev 0) +++ trunk/librawstudio/x86-cpu.h 2009-03-15 17:03:23 UTC (rev 2260) @@ -0,0 +1,47 @@ +#ifndef __X86__CPU_H__ +#define __X86__CPU_H__ + +typedef enum { + RS_CPU_FLAG_MMX = 1<<0, + RS_CPU_FLAG_SSE = 1<<1, + RS_CPU_FLAG_CMOV = 1<<2, + RS_CPU_FLAG_3DNOW = 1<<3 +} RSCpuFlags; + +#if defined(__x86_64__) +# define REG_a "rax" +# define REG_b "rbx" +# define REG_c "rcx" +# define REG_d "rdx" +# define REG_D "rdi" +# define REG_S "rsi" +# define PTR_SIZE "8" + +# define REG_SP "rsp" +# define REG_BP "rbp" +# define REGBP rbp +# define REGa rax +# define REGb rbx +# define REGc rcx +# define REGSP rsp + +#else + +# define REG_a "eax" +# define REG_b "ebx" +# define REG_c "ecx" +# define REG_d "edx" +# define REG_D "edi" +# define REG_S "esi" +# define PTR_SIZE "4" + +# define REG_SP "esp" +# define REG_BP "ebp" +# define REGBP ebp +# define REGa eax +# define REGb ebx +# define REGc ecx +# define REGSP esp +#endif + +#endif Property changes on: trunk/librawstudio/x86-cpu.h ___________________________________________________________________ Name: svn:mergeinfo + Modified: trunk/src/arch-x86.c =================================================================== --- trunk/src/arch-x86.c 2009-03-15 15:58:43 UTC (rev 2259) +++ trunk/src/arch-x86.c 2009-03-15 17:03:23 UTC (rev 2260) @@ -21,30 +21,7 @@ #include -#include "x86_cpu.h" - - /****************************************************************************** - * Structures etc... - *****************************************************************************/ - -enum -{ - _MMX = 1<<0, - _SSE = 1<<1, - _CMOV = 1<<2, - _3DNOW = 1<<3 -}; - -/****************************************************************************** - * Function declarations - *****************************************************************************/ - -/* Detect cpu features */ -static guint -rs_detect_cpu_features(); - -/****************************************************************************** * The core feature of this module *****************************************************************************/ @@ -60,25 +37,25 @@ /* Bind functions according to available features */ /* Image size doubler */ - if (cpuflags & _MMX) + if (cpuflags & RS_CPU_FLAG_MMX) { // rs_image16_copy_double = rs_image16_copy_double_mmx; } /* Black and shift applier */ - if (cpuflags & _MMX) + if (cpuflags & RS_CPU_FLAG_MMX) { // rs_image16_open_dcraw_apply_black_and_shift = rs_image16_open_dcraw_apply_black_and_shift_mmx; } /* Photo renderers */ - if (cpuflags & _SSE) + if (cpuflags & RS_CPU_FLAG_SSE) { /* SSE is favored over 3dnow in case both are available */ transform_nocms8 = transform_nocms8_sse; transform_cms8 = transform_cms8_sse; } - else if (cpuflags & _3DNOW) + else if (cpuflags & RS_CPU_FLAG_3DNOW) { /* Only 3dnow */ transform_nocms8 = transform_nocms8_3dnow; @@ -86,88 +63,4 @@ } } -/****************************************************************************** - * Function definitions - *****************************************************************************/ - -#define cpuid(cmd, eax, edx) \ - do { \ - eax = edx = 0; \ - asm ( \ - "push %%"REG_b"\n\t"\ - "cpuid\n\t" \ - "pop %%"REG_b"\n\t" \ - : "=a" (eax), "=d" (edx) \ - : "0" (cmd) \ - ); \ -} while(0) - -static guint -rs_detect_cpu_features() -{ - guint eax; - guint edx; - guint cpuflags = 0; - - /* Test cpuid presence comparing eflags */ - asm ( - "push %%"REG_b"\n\t" - "pushf\n\t" - "pop %%"REG_a"\n\t" - "mov %%"REG_a", %%"REG_b"\n\t" - "xor $0x00200000, %%"REG_a"\n\t" - "push %%"REG_a"\n\t" - "popf\n\t" - "pushf\n\t" - "pop %%"REG_a"\n\t" - "cmp %%"REG_a", %%"REG_b"\n\t" - "je notfound\n\t" - "mov $1, %0\n\t" - "notfound:\n\t" - "pop %%"REG_b"\n\t" - : "=r" (eax) - : - : REG_a - - ); - - if (eax) - { - guint std_dsc; - guint ext_dsc; - - /* Get the standard level */ - cpuid(0x00000000, std_dsc, edx); - - if (std_dsc) - { - /* Request for standard features */ - cpuid(0x00000001, std_dsc, edx); - - if (edx & 0x00800000) - cpuflags |= _MMX; - if (edx & 0x02000000) - cpuflags |= _SSE; - if (edx & 0x00008000) - cpuflags |= _CMOV; - } - - /* Is there extensions */ - cpuid(0x80000000, ext_dsc, edx); - - if (ext_dsc) - { - /* Request for extensions */ - cpuid(0x80000001, eax, edx); - - if (edx & 0x80000000) - cpuflags |= _3DNOW; - if (edx & 0x00400000) - cpuflags |= _MMX; - } - } - return(cpuflags); -} - - #endif /* __i386__ || __x86_64__ */ Deleted: trunk/src/x86_cpu.h =================================================================== --- trunk/src/x86_cpu.h 2009-03-15 15:58:43 UTC (rev 2259) +++ trunk/src/x86_cpu.h 2009-03-15 17:03:23 UTC (rev 2260) @@ -1,40 +0,0 @@ -#ifndef __X86__CPU_H__ -#define __X86__CPU_H__ - -#if defined(__x86_64__) -# define REG_a "rax" -# define REG_b "rbx" -# define REG_c "rcx" -# define REG_d "rdx" -# define REG_D "rdi" -# define REG_S "rsi" -# define PTR_SIZE "8" - -# define REG_SP "rsp" -# define REG_BP "rbp" -# define REGBP rbp -# define REGa rax -# define REGb rbx -# define REGc rcx -# define REGSP rsp - -#else - -# define REG_a "eax" -# define REG_b "ebx" -# define REG_c "ecx" -# define REG_d "edx" -# define REG_D "edi" -# define REG_S "esi" -# define PTR_SIZE "4" - -# define REG_SP "esp" -# define REG_BP "ebp" -# define REGBP ebp -# define REGa eax -# define REGb ebx -# define REGc ecx -# define REGSP esp -#endif - -#endif From anders at brander.dk Sun Mar 15 19:15:02 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 15 Mar 2009 19:15:02 +0100 Subject: [Rawstudio-commit] r2261 - trunk/plugins/meta-tiff Message-ID: Author: abrander Date: 2009-03-15 19:15:01 +0100 (Sun, 15 Mar 2009) New Revision: 2261 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: Properly support Nikon D90 camera WB. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-15 17:03:23 UTC (rev 2260) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-15 18:15:01 UTC (rev 2261) @@ -467,7 +467,7 @@ raw_get_ushort(rawfile, offset+2, &meta->iso); break; case 0x000c: /* D1 White Balance */ - if (g_str_equal(meta->model_ascii, "NIKON D1X")) + if (g_str_equal(meta->model_ascii, "NIKON D1X") || g_str_equal(meta->model_ascii, "NIKON D90")) { meta->cam_mul[0] = get_rational(rawfile, offset); meta->cam_mul[2] = get_rational(rawfile, offset+8); @@ -503,6 +503,9 @@ meta->thumbnail_start += base; break; case 0x0097: /* white balance */ + if (g_str_equal(meta->model_ascii, "NIKON D90")) + break; + for(i=0;i<4;i++) { raw_get_uchar(rawfile, offset+i, &char_tmp); From anders at brander.dk Sun Mar 15 19:22:26 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 15 Mar 2009 19:22:26 +0100 Subject: [Rawstudio-commit] r2262 - trunk/src Message-ID: Author: abrander Date: 2009-03-15 19:22:26 +0100 (Sun, 15 Mar 2009) New Revision: 2262 Modified: trunk/src/rs-preview-widget.c Log: Now correctly casts sharpen-parameter to gint in rescale(). Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-15 18:15:01 UTC (rev 2261) +++ trunk/src/rs-preview-widget.c 2009-03-15 18:22:26 UTC (rev 2262) @@ -1229,7 +1229,7 @@ /* Update sharpen */ g_object_set(preview->filter_denoise[view], - "sharpen", preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen, + "sharpen", (gint) (preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen + 0.5), NULL); } From klauspost at gmail.com Sun Mar 15 21:30:17 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 15 Mar 2009 21:30:17 +0100 Subject: [Rawstudio-commit] r2263 - trunk/librawstudio Message-ID: Author: post Date: 2009-03-15 21:30:16 +0100 (Sun, 15 Mar 2009) New Revision: 2263 Modified: trunk/librawstudio/rs-utils.c trunk/librawstudio/x86-cpu.h Log: Added detection of recent AMD & Intel features to rs_detect_cpu_features() Modified: trunk/librawstudio/rs-utils.c =================================================================== --- trunk/librawstudio/rs-utils.c 2009-03-15 18:22:26 UTC (rev 2262) +++ trunk/librawstudio/rs-utils.c 2009-03-15 20:30:16 UTC (rev 2263) @@ -181,19 +181,20 @@ guint rs_detect_cpu_features() { -#define cpuid(cmd, eax, edx) \ +#define cpuid(cmd, eax, ecx, edx) \ do { \ eax = edx = 0; \ asm ( \ "push %%"REG_b"\n\t"\ "cpuid\n\t" \ "pop %%"REG_b"\n\t" \ - : "=a" (eax), "=d" (edx) \ + : "=a" (eax), "=c" (ecx), "=d" (edx) \ : "0" (cmd) \ ); \ } while(0) guint eax; guint edx; + guint ecx; static GStaticMutex lock = G_STATIC_MUTEX_INIT; static guint cpuflags = -1; @@ -229,38 +230,65 @@ guint ext_dsc; /* Get the standard level */ - cpuid(0x00000000, std_dsc, edx); + cpuid(0x00000000, std_dsc, ecx, edx); if (std_dsc) { /* Request for standard features */ - cpuid(0x00000001, std_dsc, edx); + cpuid(0x00000001, std_dsc, ecx, edx); if (edx & 0x00800000) cpuflags |= RS_CPU_FLAG_MMX; if (edx & 0x02000000) cpuflags |= RS_CPU_FLAG_SSE; + if (edx & 0x04000000) + cpuflags |= RS_CPU_FLAG_SSE2; if (edx & 0x00008000) cpuflags |= RS_CPU_FLAG_CMOV; + + if (ecx & 0x00000001) + cpuflags |= RS_CPU_FLAG_SSE3; + if (ecx & 0x00000200) + cpuflags |= RS_CPU_FLAG_SSSE3; + if (ecx & 0x00040000) + cpuflags |= RS_CPU_FLAG_SSE4_1; + if (ecx & 0x00080000) + cpuflags |= RS_CPU_FLAG_SSE4_2; } /* Is there extensions */ - cpuid(0x80000000, ext_dsc, edx); + cpuid(0x80000000, ext_dsc, ecx, edx); if (ext_dsc) { /* Request for extensions */ - cpuid(0x80000001, eax, edx); + cpuid(0x80000001, eax, ecx, edx); if (edx & 0x80000000) cpuflags |= RS_CPU_FLAG_3DNOW; + if (edx & 0x40000000) + cpuflags |= RS_CPU_FLAG_3DNOW_EXT; if (edx & 0x00400000) - cpuflags |= RS_CPU_FLAG_MMX; + cpuflags |= RS_CPU_FLAG_AMD_ISSE; } } } g_static_mutex_unlock(&lock); - +#if 0 +#define report(a, x) printf("Feature: "a" = %d\n", !!(cpuflags&x)); + report("RS_CPU_FLAG_MMX",RS_CPU_FLAG_MMX); + report("RS_CPU_FLAG_SSE",RS_CPU_FLAG_SSE); + report("RS_CPU_FLAG_CMOV",RS_CPU_FLAG_CMOV); + report("RS_CPU_FLAG_3DNOW",RS_CPU_FLAG_3DNOW); + report("RS_CPU_FLAG_3DNOW_EXT",RS_CPU_FLAG_3DNOW_EXT); + report("RS_CPU_FLAG_AMD_ISSE",RS_CPU_FLAG_AMD_ISSE); + report("RS_CPU_FLAG_SSE2",RS_CPU_FLAG_SSE2); + report("RS_CPU_FLAG_SSE3",RS_CPU_FLAG_SSE3); + report("RS_CPU_FLAG_SSSE3",RS_CPU_FLAG_SSSE3); + report("RS_CPU_FLAG_SSE4_1",RS_CPU_FLAG_SSE4_1); + report("RS_CPU_FLAG_SSE4_2",RS_CPU_FLAG_SSE4_2); +#undef report +#endif return(cpuflags); #undef cpuid } Modified: trunk/librawstudio/x86-cpu.h =================================================================== --- trunk/librawstudio/x86-cpu.h 2009-03-15 18:22:26 UTC (rev 2262) +++ trunk/librawstudio/x86-cpu.h 2009-03-15 20:30:16 UTC (rev 2263) @@ -5,7 +5,14 @@ RS_CPU_FLAG_MMX = 1<<0, RS_CPU_FLAG_SSE = 1<<1, RS_CPU_FLAG_CMOV = 1<<2, - RS_CPU_FLAG_3DNOW = 1<<3 + RS_CPU_FLAG_3DNOW = 1<<3, + RS_CPU_FLAG_3DNOW_EXT = 1<<4, + RS_CPU_FLAG_AMD_ISSE = 1<<5, + RS_CPU_FLAG_SSE2 = 1<<6, + RS_CPU_FLAG_SSE3 = 1<<7, + RS_CPU_FLAG_SSSE3 = 1<<8, + RS_CPU_FLAG_SSE4_1 = 1<<9, + RS_CPU_FLAG_SSE4_2 = 1<<10 } RSCpuFlags; #if defined(__x86_64__) From klauspost at gmail.com Sun Mar 15 21:35:03 2009 From: klauspost at gmail.com (Klaus Post) Date: Sun, 15 Mar 2009 21:35:03 +0100 Subject: [Rawstudio-commit] r2264 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-15 21:35:02 +0100 (Sun, 15 Mar 2009) New Revision: 2264 Modified: trunk/plugins/denoise/complexfilter-x86.cpp trunk/plugins/denoise/complexfilter.cpp trunk/plugins/denoise/complexfilter.h trunk/plugins/denoise/fftdenoiser.cpp trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/fftwindow.h trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/floatplanarimage.h Log: Slightly faster short to int conversion. Fixed FFTWindow sometimes being disabled. Added SSE FFT Window multiplier. Added SSE and SSE3 optimized denoiser with no sharpening. Modified: trunk/plugins/denoise/complexfilter-x86.cpp =================================================================== --- trunk/plugins/denoise/complexfilter-x86.cpp 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/complexfilter-x86.cpp 2009-03-15 20:35:02 UTC (rev 2264) @@ -194,7 +194,7 @@ temp[i+8] = sigmaSquaredSharpenMin; // 32 temp[i+12] = sigmaSquaredSharpenMax; // 48 temp[i+16] = 1.0f; // 64 - temp[i+20] = sigmaSquaredNoiseNormed; // 72 + temp[i+20] = sigmaSquaredNoiseNormed; // 80 temp[i+24] = lowlimit; // 96 } int size = bw*bh; @@ -363,5 +363,150 @@ } +void ComplexWienerFilterDeGrid::processNoSharpen_SSE( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. + + for (int i = 0; i < 4; i++) { + temp[i+0] = 1e-15f; // 0 + temp[i+4] = gridfraction; // 16 + temp[i+8] = sigmaSquaredNoiseNormed; // 32 + temp[i+12] = lowlimit; // 48 + } + int size = bw*bh; + asm volatile + ( + "loop_wienerdegridnosharpen_sse:\n" + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 + + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory + "movaps %%xmm5, %%xmm3\n" + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained + "movaps %%xmm1, %%xmm5\n" + + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared + "movaps %%xmm4, %%xmm7\n" + "shufps $136, %%xmm5, %%xmm4\n" // xmm7 r0r1 r2r3 [10 00 10 00 = 136] + "shufps $221, %%xmm5, %%xmm7\n" // xmm6 i0i1 i2i3 [11 01 11 01 = 221] + "addps %%xmm7, %%xmm4\n" + + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) + + //WienerFactor = MAX((psd - sigmaSquaredNoiseNormed)/psd, lowlimit); // limited Wiener filter + + "movaps 32(%1), %%xmm5\n" //sigmaSquaredNoiseNormed in xmm5 + "movaps %%xmm4, %%xmm6\n" // Copy psd into xmm6 + "rcpps %%xmm4, %%xmm7\n" // xmm7: (1 / psd) + "subps %%xmm5, %%xmm6\n" // xmm6 (psd) - xmm5 (ssnn) xmm5 free + "movaps 48(%1), %%xmm5\n" // xmm5 = lowlimit + "mulps %%xmm7, %%xmm6\n" // xmm6 = (psd - sigmaSquaredNoiseNormed)/psd + "maxps %%xmm6, %%xmm5\n" // xmm6 = Wienerfactor = MAX(xmm6, lowlimit) + + "movaps %%xmm5, %%xmm7\n" + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 + + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact + "addps %%xmm2, %%xmm0\n" // add gridcorrection + "addps %%xmm3, %%xmm1\n" // add gridcorrection + "movaps %%xmm0, (%2)\n" // Store + "movaps %%xmm1, 16(%2)\n" // Store + "sub $4, %0\n" // size -=4 + "add $32, %2\n" // outcur+=32 + "add $32, %3\n" // gridsample+=32 + "cmp $0, %0\n" + "jg loop_wienerdegridnosharpen_sse\n" + : /* no output registers */ + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample) + : /* %0 %1 %2 %3 */ + ); + +} + +void ComplexWienerFilterDeGrid::processNoSharpen_SSE3( ComplexBlock* block ) +{ + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 + fftwf_complex* outcur = block->complex; + fftwf_complex* gridsample = grid->complex; + float gridfraction = degrid*outcur[0][0]/gridsample[0][0]; + float* temp = block->temp->data; // Get aligned temp area, at least 256 bytes, only used by this thread. + + for (int i = 0; i < 4; i++) { + temp[i+0] = 1e-15f; // 0 + temp[i+4] = gridfraction; // 16 + temp[i+8] = sigmaSquaredNoiseNormed; // 32 + temp[i+12] = lowlimit; // 48 + } + int size = bw*bh; + asm volatile + ( + "loop_wienerdegridnosharpen_sse3:\n" + "movaps 16(%1),%%xmm6\n" // Load gridfraction into xmm6 + "movaps (%2), %%xmm0\n" // in r0i0 r1i1 + "movaps 16(%2), %%xmm1\n" //in r2i2 r3i3 + "movaps (%3), %%xmm4\n" // grid r0i0 r1i1 + "movaps 16(%3), %%xmm5\n" // grid r2i2 r3i3 + + "mulps %%xmm6, %%xmm4\n" //grid r0*gf i0*gf r1*gf i1*gf (xmm4: gridcorrection0 + 1) + "mulps %%xmm6, %%xmm5\n" //grid r2*gf i2*gf r3*gf i3*gf (gridfraction*gridsample[x]) + "movaps %%xmm4, %%xmm2\n" // maintain gridcorrection in memory + "movaps %%xmm5, %%xmm3\n" + "subps %%xmm4, %%xmm0\n" // re0 im0 re1 im1 (re = outcur[x][0] - gridcorrection0;, etc) (xmm0 - xmm4) + "subps %%xmm5, %%xmm1\n" // re2 im2 re3 im3 - + "movaps %%xmm0, %%xmm4\n" // copy re0+im0 ... into xmm4 and 5, xmm0 & 1 retained + "movaps %%xmm1, %%xmm5\n" + + "mulps %%xmm4, %%xmm4\n" //r0i0 r1i1 squared + "mulps %%xmm5, %%xmm5\n" //r2i2 r3i3 squared + "haddps %%xmm5, %%xmm4\n" //r0+i0 r1+i1 r2+i2 r3+i3 r4+i4 (all squared) (SSE3!) - xmm 5 free + + "addps (%1), %%xmm4\n" // add 1e-15 (xmm4: psd for all 4 pixels) + + //WienerFactor = MAX((psd - sigmaSquaredNoiseNormed)/psd, lowlimit); // limited Wiener filter + + "movaps 32(%1), %%xmm5\n" //sigmaSquaredNoiseNormed in xmm5 + "movaps %%xmm4, %%xmm6\n" // Copy psd into xmm6 + "rcpps %%xmm4, %%xmm7\n" // xmm7: (1 / psd) + "subps %%xmm5, %%xmm6\n" // xmm6 (psd) - xmm5 (ssnn) xmm5 free + "movaps 48(%1), %%xmm5\n" // xmm5 = lowlimit + "mulps %%xmm7, %%xmm6\n" // xmm6 = (psd - sigmaSquaredNoiseNormed)/psd + "maxps %%xmm6, %%xmm5\n" // xmm6 = Wienerfactor = MAX(xmm6, lowlimit) + + "movaps %%xmm5, %%xmm7\n" + "unpcklps %%xmm7, %%xmm7\n" // unpack low to xmm7 + "unpckhps %%xmm5, %%xmm5\n" // unpack high to xmm5 + + "mulps %%xmm7, %%xmm0\n" // re+im *= sfact + "mulps %%xmm5, %%xmm1\n" // re+im *= sfact + "addps %%xmm2, %%xmm0\n" // add gridcorrection + "addps %%xmm3, %%xmm1\n" // add gridcorrection + "movaps %%xmm0, (%2)\n" // Store + "movaps %%xmm1, 16(%2)\n" // Store + "sub $4, %0\n" // size -=4 + "add $32, %2\n" // outcur+=32 + "add $32, %3\n" // gridsample+=32 + "cmp $0, %0\n" + "jg loop_wienerdegridnosharpen_sse3\n" + : /* no output registers */ + : "r" (size), "r" (temp), "r" (outcur), "r" (gridsample) + : /* %0 %1 %2 %3 */ + ); +} + + #endif // defined (__i386__) || defined (__x86_64__) Modified: trunk/plugins/denoise/complexfilter.cpp =================================================================== --- trunk/plugins/denoise/complexfilter.cpp 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/complexfilter.cpp 2009-03-15 20:35:02 UTC (rev 2264) @@ -116,10 +116,15 @@ } void DeGridComplexFilter::processSharpenOnly(ComplexBlock* block) { + #if defined (__i386__) || defined (__x86_64__) - processSharpenOnlySSE(block); - return; + guint cpu = rs_detect_cpu_features(); + if (cpu & RS_CPU_FLAG_SSE3) + return processSharpenOnlySSE3(block); + else if (cpu & RS_CPU_FLAG_SSE) + return processSharpenOnlySSE(block); #endif + int x,y; fftwf_complex* outcur = block->complex; fftwf_complex* gridsample = grid->complex; @@ -294,6 +299,15 @@ { if (sigmaSquaredNoiseNormed <= 1e-15f) return; + +#if defined (__i386__) || defined (__x86_64__) + guint cpu = rs_detect_cpu_features(); + if (cpu & RS_CPU_FLAG_SSE3) + return processNoSharpen_SSE3(block); + else if (cpu & RS_CPU_FLAG_SSE) + return processNoSharpen_SSE(block); +#endif + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; @@ -326,10 +340,15 @@ { if (sigmaSquaredNoiseNormed <= 1e-15f) return processSharpenOnly(block); + #if defined (__i386__) || defined (__x86_64__) - processSharpen_SSE3(block); - return; + guint cpu = rs_detect_cpu_features(); + if (cpu & RS_CPU_FLAG_SSE3) + return processSharpen_SSE3(block); + else if (cpu & RS_CPU_FLAG_SSE) + return processSharpen_SSE(block); #endif + float lowlimit = (beta-1)/beta; // (beta-1)/beta>=0 int x,y; float psd; Modified: trunk/plugins/denoise/complexfilter.h =================================================================== --- trunk/plugins/denoise/complexfilter.h 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/complexfilter.h 2009-03-15 20:35:02 UTC (rev 2264) @@ -85,6 +85,8 @@ #if defined (__i386__) || defined (__x86_64__) virtual void processSharpen_SSE3(ComplexBlock* block); virtual void processSharpen_SSE(ComplexBlock* block); + virtual void processNoSharpen_SSE(ComplexBlock* block); + virtual void processNoSharpen_SSE3(ComplexBlock* block); #endif float sigmaSquaredNoiseNormed; FFTWindow *window; Modified: trunk/plugins/denoise/fftdenoiser.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiser.cpp 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/fftdenoiser.cpp 2009-03-15 20:35:02 UTC (rev 2264) @@ -28,13 +28,14 @@ nThreads = rs_get_number_of_processor_cores(); threads = new DenoiseThread[nThreads]; initializeFFT(); + FloatPlanarImage::initConvTable(); } FFTDenoiser::~FFTDenoiser(void) { delete[] threads; fftwf_destroy_plan(plan_forward); - fftwf_destroy_plan(plan_reverse); + fftwf_destroy_plan(plan_reverse); } void FFTDenoiser::denoiseImage( RS_IMAGE16* image ) Modified: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-15 20:35:02 UTC (rev 2264) @@ -32,8 +32,13 @@ analysis(FloatImagePlane(_w, _h)), synthesis(FloatImagePlane(_w,_h)) { + analysisIsFlat = true; + synthesisIsFlat = true; analysis.allocateImage(); synthesis.allocateImage(); +#if defined (__i386__) || defined (__x86_64__) + SSEAvailable == !!(rs_detect_cpu_features() & RS_CPU_FLAG_SSE); +#endif } @@ -54,7 +59,8 @@ createWindow(analysis, ox, wanx); createWindow(synthesis, ox, wsynx); - + analysisIsFlat = false; + synthesisIsFlat = false; delete[] wanx; delete[] wsynx; } @@ -71,6 +77,8 @@ createWindow(analysis, ox, wanx); createWindow(synthesis, ox, wsynx); + analysisIsFlat = false; + synthesisIsFlat = false; delete[] wanx; delete[] wsynx; @@ -91,12 +99,14 @@ createWindow(analysis, ox, wanx); createWindow(synthesis, ox, wsynx); + analysisIsFlat = true; + synthesisIsFlat = false; delete[] wanx; delete[] wsynx; } -void FFTWindow::createWindow( FloatImagePlane &window, int overlap, float* weight) +float FFTWindow::createWindow( FloatImagePlane &window, int overlap, float* weight) { //Setup the 2D window; int bw = window.w; @@ -124,21 +134,26 @@ sum += factor; } } - if (sum > (bw*bh-1.0f)) { /* Account for some rounding */ - isFlat = true; - } + return sum; } -// FIXME: SSE2 me + void FFTWindow::applyAnalysisWindow( FloatImagePlane *image, FloatImagePlane *dst ) { g_assert(image->w == analysis.w); g_assert(image->h == analysis.h); g_assert(dst->w == analysis.w); g_assert(dst->h == analysis.h); - if (isFlat) { + + if (analysisIsFlat) { image->blitOnto(dst); return; } +#if defined (__i386__) || defined (__x86_64__) + if (SSEAvailable && (analysis.w & 15) == 0) { + applyAnalysisWindowSSE( image, dst); + return; + } +#endif // defined (__i386__) || defined (__x86_64__) for (int y = 0; y < analysis.h; y++) { float *srcp1 = analysis.getLine(y); @@ -150,13 +165,82 @@ } } +#if defined (__i386__) || defined (__x86_64__) -// FIXME: SSE2 me +void FFTWindow::applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ) +{ + for (int y = 0; y < analysis.h; y++) { + int sizew = analysis.w>>4; // Size in loops + float* src1 = image->getLine(y); + if ((uintptr_t)src1 & 15) { + asm volatile + ( + "loop_analysis_sse_ua:\n" + "prefetcht0 (%4)\n" // Prefetch next line + "movups (%1), %%xmm0\n" // src1 pt1 + "movups 16(%1), %%xmm1\n" // src1 pt2 + "movups 32(%1), %%xmm2\n" // src1 pt3 + "movups 48(%1), %%xmm3\n" // src1 pt4 + "mulps (%0), %%xmm0\n" // src1 * window pt1 + "mulps 16(%0), %%xmm1\n" // src1 * window pt2 + "mulps 32(%0), %%xmm2\n" // src1 * window pt3 + "mulps 48(%0), %%xmm3\n" // src1 * window pt4 + "movaps %%xmm0, (%2)\n" // store pt1 + "movaps %%xmm1, 16(%2)\n" // stote pt2 + "movaps %%xmm2, 32(%2)\n" // store pt1 + "movaps %%xmm3, 48(%2)\n" // stote pt2 + "add $64, %0\n" + "add $64, %1\n" + "add $64, %2\n" + "add $64, %4\n" + "dec %3\n" + "jnz loop_analysis_sse_ua\n" + + : /* no output registers */ + : "r" (analysis.getLine(y)), "r" (src1), "r" (dst->getLine(y)), "r" (sizew), "r" (&src1[image->pitch]) + : /* %0 %1 %2 %3 %4 */ + ); + } else { + asm volatile + ( + "loop_analysis_sse_a:\n" + "prefetcht0 (%4)\n" // Prefetch next line + "movaps (%1), %%xmm0\n" // src1 pt1 + "movaps 16(%1), %%xmm1\n" // src1 pt2 + "movaps 32(%1), %%xmm2\n" // src1 pt3 + "movaps 48(%1), %%xmm3\n" // src1 pt4 + "mulps (%0), %%xmm0\n" // src1 * window pt1 + "mulps 16(%0), %%xmm1\n" // src1 * window pt2 + "mulps 32(%0), %%xmm2\n" // src1 * window pt3 + "mulps 48(%0), %%xmm3\n" // src1 * window pt4 + "movaps %%xmm0, (%2)\n" // store pt1 + "movaps %%xmm1, 16(%2)\n" // stote pt2 + "movaps %%xmm2, 32(%2)\n" // store pt1 + "movaps %%xmm3, 48(%2)\n" // stote pt2 + "add $64, %0\n" + "add $64, %1\n" + "add $64, %2\n" + "add $64, %4\n" + "dec %3\n" + "jnz loop_analysis_sse_a\n" + + : /* no output registers */ + : "r" (analysis.getLine(y)), "r" (src1), "r" (dst->getLine(y)), "r" (sizew), "r" (&src1[image->pitch]) + : /* %0 %1 %2 %3 %4 */ + ); + } + } +} + +#endif // defined (__i386__) || defined (__x86_64__) + + +// FIXME: SSE2 me, if used some time in the future void FFTWindow::applySynthesisWindow( FloatImagePlane *image ) { g_assert(image->w == synthesis.w); g_assert(image->h == synthesis.h); - if (isFlat) + if (synthesisIsFlat) return; for (int y = 0; y < synthesis.h; y++) { Modified: trunk/plugins/denoise/fftwindow.h =================================================================== --- trunk/plugins/denoise/fftwindow.h 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/fftwindow.h 2009-03-15 20:35:02 UTC (rev 2264) @@ -33,8 +33,11 @@ void applyAnalysisWindow(FloatImagePlane *image, FloatImagePlane *dst); void applySynthesisWindow( FloatImagePlane *image ); // Inplace, written back to image private: - void createWindow( FloatImagePlane &window, int ox, float* wx); - bool isFlat; + void applyAnalysisWindowSSE( FloatImagePlane *image, FloatImagePlane *dst ); + float createWindow( FloatImagePlane &window, int ox, float* wx); // Returns sum + bool analysisIsFlat; + bool synthesisIsFlat; + bool SSEAvailable; }; #endif // fftwindow_h__ Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-15 20:35:02 UTC (rev 2264) @@ -144,6 +144,8 @@ return queue; } +static float shortToInt[65535]; + // TODO: Begs to be SSE2. void FloatPlanarImage::unpackInterleavedYUV( const ImgConvertJob* j ) { @@ -155,9 +157,9 @@ gfloat *Cb = p[1]->getAt(ox, y+oy); gfloat *Cr = p[2]->getAt(ox, y+oy); for (int x=0; xw; x++) { - float r = (float)(*pix); - float g = (float)(*(pix+1)); - float b = (float)(*(pix+2)); + float r = shortToInt[(*pix)]; + float g = shortToInt[(*(pix+1))]; + float b = shortToInt[(*(pix+2))]; *Y++ = r * 0.299 + g * 0.587 + b * 0.114 ; *Cb++ = r * -0.169 + g * -0.331 + b * 0.499; *Cr++ = r * 0.499 + g * -0.418 - b * 0.0813; @@ -235,4 +237,10 @@ return p[plane]->getSlice(x,y,ox,oy); } +void FloatPlanarImage::initConvTable() { + for (int i = 0; i < 65535; i++) { + shortToInt[i] = (float)i; + } +} + Modified: trunk/plugins/denoise/floatplanarimage.h =================================================================== --- trunk/plugins/denoise/floatplanarimage.h 2009-03-15 20:30:16 UTC (rev 2263) +++ trunk/plugins/denoise/floatplanarimage.h 2009-03-15 20:35:02 UTC (rev 2264) @@ -14,43 +14,44 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#ifndef floatplanarimage_h__ -#define floatplanarimage_h__ -#include "floatimageplane.h" -#include "jobqueue.h" -#include "fftwindow.h" - -// A container and utility class - -class FloatPlanarImage -{ -public: - FloatPlanarImage(void); - FloatPlanarImage( const FloatPlanarImage &img ); // Creates image with similar features - - virtual ~FloatPlanarImage(void); - void allocate_planes(); - void mirrorEdges(); - FloatImagePlane **p; - int nPlanes; - void unpackInterleaved(const RS_IMAGE16* image); - void packInterleaved( RS_IMAGE16* image ); - void applySlice(PlanarImageSlice *p); +*/ + +#ifndef floatplanarimage_h__ +#define floatplanarimage_h__ +#include "floatimageplane.h" +#include "jobqueue.h" +#include "fftwindow.h" + +// A container and utility class + +class FloatPlanarImage +{ +public: + FloatPlanarImage(void); + FloatPlanarImage( const FloatPlanarImage &img ); // Creates image with similar features + + virtual ~FloatPlanarImage(void); + void allocate_planes(); + void mirrorEdges(); + FloatImagePlane **p; + int nPlanes; + void unpackInterleaved(const RS_IMAGE16* image); + void packInterleaved( RS_IMAGE16* image ); + void applySlice(PlanarImageSlice *p); void setFilter( int plane, ComplexFilter *f, FFTWindow *window); - JobQueue* getJobs(); + JobQueue* getJobs(); void unpackInterleavedYUV( const ImgConvertJob* j ); void packInterleavedYUV( const ImgConvertJob* j); JobQueue* getUnpackInterleavedYUVJobs(RS_IMAGE16* image); JobQueue* getPackInterleavedYUVJobs(RS_IMAGE16* image); FloatImagePlane* getPlaneSliceFrom(int plane, int x, int y); - int bw; // Block width - int bh; // Block height - int ox; // Overlap pixels - int oy; // Overlap pixels - -}; -#endif // floatplanarimage_h__ - + + int bw; // Block width + int bh; // Block height + int ox; // Overlap pixels + int oy; // Overlap pixels + static void initConvTable(); +}; +#endif // floatplanarimage_h__ + inline guint clampbits(gint x, guint n) { guint32 _y_temp; if( (_y_temp=x>>n) ) x = ~_y_temp >> (32-n); return x;} From anders at kvistmail.dk Mon Mar 16 09:48:19 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Mon, 16 Mar 2009 09:48:19 +0100 Subject: [Rawstudio-commit] r2265 - trunk/src Message-ID: Author: akv Date: 2009-03-16 09:48:19 +0100 (Mon, 16 Mar 2009) New Revision: 2265 Modified: trunk/src/Makefile.am Log: x86_cpu.h has been moved to librawstudio. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-03-15 20:35:02 UTC (rev 2264) +++ trunk/src/Makefile.am 2009-03-16 08:48:19 UTC (rev 2265) @@ -42,7 +42,7 @@ rs-tiff.c rs-tiff.h \ rs-arch.h \ arch-generic.c \ - arch-x86.c x86_cpu.h \ + arch-x86.c \ filename.c filename.h \ rs-store.c rs-store.h \ rs-preview-widget.c rs-preview-widget.h \ From anders at brander.dk Mon Mar 16 19:36:46 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 16 Mar 2009 19:36:46 +0100 Subject: [Rawstudio-commit] r2266 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-16 19:36:46 +0100 (Mon, 16 Mar 2009) New Revision: 2266 Modified: trunk/librawstudio/rs-image16.c Log: Now guarantees 16 byte alignment on row start in RS_IMAGE16. Modified: trunk/librawstudio/rs-image16.c =================================================================== --- trunk/librawstudio/rs-image16.c 2009-03-16 08:48:19 UTC (rev 2265) +++ trunk/librawstudio/rs-image16.c 2009-03-16 18:36:46 UTC (rev 2266) @@ -70,7 +70,8 @@ { RS_IMAGE16 *self = (RS_IMAGE16 *)obj; - g_free(self->pixels); + if (self->pixels) + free(self->pixels); /* Chain up to the parent class */ G_OBJECT_CLASS (parent_class)->finalize (obj); @@ -777,6 +778,7 @@ RS_IMAGE16 * rs_image16_new(const guint width, const guint height, const guint channels, const guint pixelsize) { + gint ret; RS_IMAGE16 *rsi; g_assert(width < 65536); @@ -791,12 +793,25 @@ rsi = g_object_new(RS_TYPE_IMAGE16, NULL); rsi->w = width; rsi->h = height; - rsi->pitch = PITCH(width); - rsi->rowstride = rsi->pitch * pixelsize; + rsi->rowstride = PITCH(width * pixelsize); + rsi->pitch = rsi->rowstride / pixelsize; rsi->channels = channels; rsi->pixelsize = pixelsize; rsi->filters = 0; - rsi->pixels = g_new0(gushort, rsi->h*rsi->rowstride); + + /* Allocate actual pixels */ + ret = posix_memalign(&rsi->pixels, 16, rsi->h*rsi->rowstride * sizeof(gushort)); + if (ret > 0) + { + rsi->pixels = NULL; + g_object_unref(rsi); + return NULL; + } + + /* Verify alignment */ + g_assert((GPOINTER_TO_INT(rsi->pixels) % 16) == 0); + g_assert((rsi->rowstride % 16) == 0); + return(rsi); } From klauspost at gmail.com Mon Mar 16 20:54:19 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 16 Mar 2009 20:54:19 +0100 Subject: [Rawstudio-commit] r2267 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-16 20:54:19 +0100 (Mon, 16 Mar 2009) New Revision: 2267 Modified: trunk/plugins/denoise/fftwindow.cpp trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/floatplanarimage.h Log: Denoiser: SSE3 optimized RGB to YUV conversion. Fine tuned fft window prefetch. Modified: trunk/plugins/denoise/fftwindow.cpp =================================================================== --- trunk/plugins/denoise/fftwindow.cpp 2009-03-16 18:36:46 UTC (rev 2266) +++ trunk/plugins/denoise/fftwindow.cpp 2009-03-16 19:54:19 UTC (rev 2267) @@ -149,7 +149,7 @@ return; } #if defined (__i386__) || defined (__x86_64__) - if (SSEAvailable && (analysis.w & 15) == 0) { + if (SSEAvailable && ((analysis.w & 15) == 0)) { applyAnalysisWindowSSE( image, dst); return; } @@ -176,7 +176,7 @@ asm volatile ( "loop_analysis_sse_ua:\n" - "prefetcht0 (%4)\n" // Prefetch next line + "prefetchnta (%4)\n" // Prefetch next line (Used once only, so don't pollute cache) "movups (%1), %%xmm0\n" // src1 pt1 "movups 16(%1), %%xmm1\n" // src1 pt2 "movups 32(%1), %%xmm2\n" // src1 pt3 @@ -186,9 +186,9 @@ "mulps 32(%0), %%xmm2\n" // src1 * window pt3 "mulps 48(%0), %%xmm3\n" // src1 * window pt4 "movaps %%xmm0, (%2)\n" // store pt1 - "movaps %%xmm1, 16(%2)\n" // stote pt2 + "movaps %%xmm1, 16(%2)\n" // store pt2 "movaps %%xmm2, 32(%2)\n" // store pt1 - "movaps %%xmm3, 48(%2)\n" // stote pt2 + "movaps %%xmm3, 48(%2)\n" // store pt2 "add $64, %0\n" "add $64, %1\n" "add $64, %2\n" @@ -204,7 +204,7 @@ asm volatile ( "loop_analysis_sse_a:\n" - "prefetcht0 (%4)\n" // Prefetch next line + "prefetchnta (%4)\n" // Prefetch next line (Used once only, so don't pollute cache) "movaps (%1), %%xmm0\n" // src1 pt1 "movaps 16(%1), %%xmm1\n" // src1 pt2 "movaps 32(%1), %%xmm2\n" // src1 pt3 @@ -214,9 +214,9 @@ "mulps 32(%0), %%xmm2\n" // src1 * window pt3 "mulps 48(%0), %%xmm3\n" // src1 * window pt4 "movaps %%xmm0, (%2)\n" // store pt1 - "movaps %%xmm1, 16(%2)\n" // stote pt2 + "movaps %%xmm1, 16(%2)\n" // store pt2 "movaps %%xmm2, 32(%2)\n" // store pt1 - "movaps %%xmm3, 48(%2)\n" // stote pt2 + "movaps %%xmm3, 48(%2)\n" // store pt2 "add $64, %0\n" "add $64, %1\n" "add $64, %2\n" Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-16 18:36:46 UTC (rev 2266) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-16 19:54:19 UTC (rev 2267) @@ -146,10 +146,14 @@ static float shortToInt[65535]; -// TODO: Begs to be SSE2. void FloatPlanarImage::unpackInterleavedYUV( const ImgConvertJob* j ) { RS_IMAGE16* image = j->rs; +#if defined (__i386__) || defined (__x86_64__) + guint cpu = rs_detect_cpu_features(); + if ((image->pixelsize == 4 ) && (cpu & RS_CPU_FLAG_SSE3) && ((ox&3)==0)) + return unpackInterleavedYUV_SSE3(j); +#endif for (int y = j->start_y; y < j->end_y; y++ ) { const gushort* pix = GET_PIXEL(image,0,y); @@ -168,6 +172,74 @@ } } +#if defined (__i386__) || defined (__x86_64__) + +void FloatPlanarImage::unpackInterleavedYUV_SSE3( const ImgConvertJob* j ) +{ + RS_IMAGE16* image = j->rs; + float* temp = p[0]->data; + temp[0] = 0.299f; temp[1] = 0.587f; temp[2] = 0.114f; temp[3] = 0.0f; + temp[4] = -0.169f; temp[5] = -0.331f; temp[6] = 0.499; temp[7] = 0.0f; + temp[8] = 0.499f; temp[9] = -0.418f; temp[10] = -0.0813f; temp[11] = 0.0f; + asm volatile + ( + "movaps (%0), %%xmm5\n" // Y values + "movaps 16(%0), %%xmm6\n" // Cb values + "movaps 32(%0), %%xmm7\n" // Cr values + : // no output registers + : "r" (temp) + : // %0 + ); + for (int y = j->start_y; y < j->end_y; y++ ) { + const gushort* pix = GET_PIXEL(image,0,y); + gfloat *Y = p[0]->getAt(ox, y+oy); + gfloat *Cb = p[1]->getAt(ox, y+oy); + gfloat *Cr = p[2]->getAt(ox, y+oy); + int n = (image->w+1)>>1; + asm volatile + ( + + "loopback_uiYUV_SSE3:\n" + "movdqa (%0), %%xmm1\n" // Load 2 pixels p0p1 + "punpcklwd %%xmm1, %%xmm0\n" // xmm0: unpack p0, xx xx| b0 xx| g0 xx | r0 xx + "punpckhwd %%xmm1, %%xmm1\n" // xmm1: unpack p1, xx xx| b1 b1| g1 g1 | r1 r1 + "psrld $16, %%xmm0\n" // Shift down p0, 00 xx| 00 b0 | 00 g0 | 00 r0 + "psrld $16, %%xmm1\n" // Shift down p1 + "cvtdq2ps %%xmm0, %%xmm0\n" // Convert to float xx | b0 | g0 | r0 + "cvtdq2ps %%xmm1, %%xmm1\n" // Convert to float xx | b1 | g1 | r1 + "movaps %%xmm0, %%xmm2\n" + "movaps %%xmm1, %%xmm3\n" + "mulps %%xmm5, %%xmm2\n" // Y coefficients output to p0 + "mulps %%xmm5, %%xmm3\n" // Y for p1 + "movaps %%xmm1, %%xmm4\n" // p1 + "haddps %%xmm3, %%xmm2\n" // Y coefficients xmm 3 free [two lower Y p0][two upper Y p0] + "movaps %%xmm0, %%xmm3\n" // p0 + "mulps %%xmm7, %%xmm0\n" // Cr coefficients output to p0 + "mulps %%xmm7, %%xmm1\n" // Cr coeffs to p1 + "mulps %%xmm6, %%xmm3\n" // Cb coefficients output to p0 + "mulps %%xmm6, %%xmm4\n" // Cb coeffs to p1 + "haddps %%xmm1, %%xmm0\n" // Cr coefficients + "haddps %%xmm4, %%xmm3\n" // Cb coefficients xmm4 free + "haddps %%xmm0, %%xmm0\n" // Two Cr ready for output in lower + "haddps %%xmm3, %%xmm2\n" // lower: Y ready for output, high Cb ready for output + "movq %%xmm2, (%1)\n" // Store Y + "movq %%xmm0, (%3)\n" // Store Cr + "movhps %%xmm2, (%2)\n" // Store Cb + "add $8, %1\n" + "add $8, %2\n" + "add $8, %3\n" + "add $16, %0\n" + "dec %4\n" + "jnz loopback_uiYUV_SSE3\n" + "emms\n" + : // no output registers + : "r" (pix), "r" (Y), "r" (Cb), "r" (Cr), "r"(n) + : // %0 %1 %2 %3 %4 + ); + } +} +#endif // defined (__i386__) || defined (__x86_64__) + JobQueue* FloatPlanarImage::getPackInterleavedYUVJobs(RS_IMAGE16* image) { JobQueue* queue = new JobQueue(); Modified: trunk/plugins/denoise/floatplanarimage.h =================================================================== --- trunk/plugins/denoise/floatplanarimage.h 2009-03-16 18:36:46 UTC (rev 2266) +++ trunk/plugins/denoise/floatplanarimage.h 2009-03-16 19:54:19 UTC (rev 2267) @@ -41,6 +41,9 @@ void setFilter( int plane, ComplexFilter *f, FFTWindow *window); JobQueue* getJobs(); void unpackInterleavedYUV( const ImgConvertJob* j ); +#if defined (__i386__) || defined (__x86_64__) + void unpackInterleavedYUV_SSE3( const ImgConvertJob* j ); +#endif void packInterleavedYUV( const ImgConvertJob* j); JobQueue* getUnpackInterleavedYUVJobs(RS_IMAGE16* image); JobQueue* getPackInterleavedYUVJobs(RS_IMAGE16* image); From klauspost at gmail.com Mon Mar 16 23:22:50 2009 From: klauspost at gmail.com (Klaus Post) Date: Mon, 16 Mar 2009 23:22:50 +0100 Subject: [Rawstudio-commit] rawspeed r68 - RawSpeed Message-ID: Author: post Date: 2009-03-16 23:22:50 +0100 (Mon, 16 Mar 2009) New Revision: 68 Modified: RawSpeed/RawImage.cpp RawSpeed/rawstudio-plugin.makefile Log: - Fixed bad crop. - Copy camera.xml to rawstudio homedir on install. Modified: RawSpeed/RawImage.cpp =================================================================== --- RawSpeed/RawImage.cpp 2009-03-13 07:45:11 UTC (rev 67) +++ RawSpeed/RawImage.cpp 2009-03-16 22:22:50 UTC (rev 68) @@ -1,23 +1,23 @@ #include "StdAfx.h" #include "RawImage.h" #include "RawDecoder.h" // For exceptions -/* - RawSpeed - RAW file decoder. - - Copyright (C) 2009 Klaus Post - - 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 2 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, write to the Free Software +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2009 Klaus Post + + 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA http://www.klauspost.com @@ -102,13 +102,13 @@ if (blackLevel < 0 || whitePoint == 65536) { // Estimate int b = 65536; int m = 0; - for(int row=10;row>14,16); } Modified: RawSpeed/rawstudio-plugin.makefile =================================================================== --- RawSpeed/rawstudio-plugin.makefile 2009-03-13 07:45:11 UTC (rev 67) +++ RawSpeed/rawstudio-plugin.makefile 2009-03-16 22:22:50 UTC (rev 68) @@ -55,6 +55,7 @@ install: load-rawspeed.so cp -a load-rawspeed.so $(INSTALLPATH) + cp -a ../cameras.xml ~/.rawstudio clean: rm -f *.o *.so From klauspost at gmail.com Wed Mar 18 18:24:37 2009 From: klauspost at gmail.com (Klaus Post) Date: Wed, 18 Mar 2009 18:24:37 +0100 Subject: [Rawstudio-commit] rawspeed r69 - / RawSpeed Message-ID: Author: post Date: 2009-03-18 18:24:36 +0100 (Wed, 18 Mar 2009) New Revision: 69 Modified: RawSpeed/DngDecoder.cpp RawSpeed/TiffEntry.cpp cameras.xml credits.txt Log: - Proper DNG Black extraction. - Updated camera profiles with new blacklevels. Modified: RawSpeed/DngDecoder.cpp =================================================================== --- RawSpeed/DngDecoder.cpp 2009-03-16 22:22:50 UTC (rev 68) +++ RawSpeed/DngDecoder.cpp 2009-03-18 17:24:36 UTC (rev 69) @@ -315,6 +315,23 @@ if (top_left.y & 1) cfa.shiftDown(); + const gushort *blackdim = raw->getEntry(BLACKLEVELREPEATDIM)->getShortArray(); + int black = 65536; + if (blackdim[0] != 0 && blackdim[1] != 0) { + if (raw->hasEntry(BLACKLEVELDELTAV)) { + const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray(); + int blackbase = blackarray[0] / blackarray[1]; + const guint *blackarrayv = raw->getEntry(BLACKLEVELDELTAV)->getIntArray(); + for (int i = 0; i < new_size.y; i++) + black = min(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]); + } else { + const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray(); + black = blackarray[0] / blackarray[1]; + } + } else { + black = 0; + } + cout << "" << endl; cout << "" << endl; cout << "" << ColorFilterArray::colorToString(cfa.getColorAt(0,0)) << ""; @@ -325,18 +342,8 @@ cout << "" << endl; int white = raw->getEntry(WHITELEVEL)->getInt(); - int b = 65536; - for(int row=10;rowdim.y-10;row++) - { - gushort *pixel = (gushort*)&mRaw->getData()[row*mRaw->pitch+10*mRaw->bpp]; - for(int col=10;col<(mRaw->dim.x-20);col++) - { - b = MIN(*pixel, b); - pixel++; - } - } - cout << "" << endl; + cout << "" << endl; cout << "" <BLUE - + @@ -19,7 +19,7 @@ BLUE - + @@ -29,7 +29,7 @@ BLUE - + @@ -39,7 +39,7 @@ BLUE - + @@ -49,7 +49,7 @@ BLUE - + @@ -59,7 +59,7 @@ BLUE - + @@ -69,7 +69,7 @@ GREEN - + @@ -79,7 +79,7 @@ BLUE - + @@ -89,7 +89,7 @@ BLUE - + @@ -99,7 +99,7 @@ BLUE - + @@ -109,7 +109,7 @@ BLUE - + @@ -119,7 +119,7 @@ BLUE - + @@ -129,7 +129,7 @@ BLUE - + @@ -139,7 +139,7 @@ GREEN - + @@ -149,7 +149,7 @@ BLUE - + @@ -159,7 +159,7 @@ GREEN - + @@ -169,7 +169,7 @@ BLUE - + @@ -179,7 +179,7 @@ GREEN - + @@ -199,7 +199,7 @@ RED - + @@ -209,7 +209,7 @@ BLUE - + @@ -219,7 +219,7 @@ GREEN - + @@ -289,7 +289,7 @@ RED - + @@ -339,7 +339,7 @@ RED - + @@ -349,7 +349,7 @@ UNKNOWN - + @@ -369,7 +369,7 @@ RED - + @@ -379,7 +379,7 @@ GREEN - + @@ -399,7 +399,7 @@ BLUE - + @@ -409,7 +409,7 @@ BLUE - + @@ -419,7 +419,7 @@ BLUE - + @@ -429,7 +429,7 @@ GREEN - + @@ -439,7 +439,7 @@ BLUE - + @@ -449,7 +449,7 @@ BLUE - + @@ -459,7 +459,7 @@ BLUE - + @@ -469,7 +469,7 @@ BLUE - + @@ -479,7 +479,7 @@ BLUE - + @@ -499,7 +499,7 @@ GREEN - + @@ -509,7 +509,7 @@ BLUE - + @@ -519,7 +519,7 @@ BLUE - + @@ -529,7 +529,7 @@ BLUE - + @@ -539,7 +539,7 @@ BLUE - + @@ -589,7 +589,7 @@ BLUE - + @@ -599,7 +599,7 @@ BLUE - + @@ -609,8 +609,6 @@ BLUE - + - - Modified: credits.txt =================================================================== --- credits.txt 2009-03-16 22:22:50 UTC (rev 68) +++ credits.txt 2009-03-18 17:24:36 UTC (rev 69) @@ -12,3 +12,9 @@ * dcraw by David Coffin * http://www.cybercom.net/~dcoffin/ + +Thanks to: + + * Laurent Clevy for his excellent CR2 documentation project: + * http://lclevy.free.fr/cr2/index.html + From klauspost at gmail.com Wed Mar 18 20:25:42 2009 From: klauspost at gmail.com (Klaus Post) Date: Wed, 18 Mar 2009 20:25:42 +0100 Subject: [Rawstudio-commit] rawspeed r70 - RawSpeed Message-ID: Author: post Date: 2009-03-18 20:25:42 +0100 (Wed, 18 Mar 2009) New Revision: 70 Added: RawSpeed/compile-rawstudio.sh Modified: RawSpeed/BlackArea.h RawSpeed/DngDecoder.cpp RawSpeed/RawImage.cpp RawSpeed/Rw2Decoder.cpp RawSpeed/rawstudio-plugin-api.cpp Log: - Apply actual DNG Black to images. - Fixed compiler warnings. - Fixed uncompressed DNGs. - Added compile and install script. Modified: RawSpeed/BlackArea.h =================================================================== --- RawSpeed/BlackArea.h 2009-03-18 17:24:36 UTC (rev 69) +++ RawSpeed/BlackArea.h 2009-03-18 19:25:42 UTC (rev 70) @@ -5,7 +5,7 @@ public: BlackArea(int offset, int size, gboolean isVertical); virtual ~BlackArea(void); + guint offset; // Offset in bayer pixels. + guint size; // Size in bayer pixels. gboolean isVertical; // Otherwise horizontal - guint size; // Size in bayer pixels. - guint offset; // Offset in bayer pixels. }; Modified: RawSpeed/DngDecoder.cpp =================================================================== --- RawSpeed/DngDecoder.cpp 2009-03-18 17:24:36 UTC (rev 69) +++ RawSpeed/DngDecoder.cpp 2009-03-18 19:25:42 UTC (rev 70) @@ -2,23 +2,23 @@ #include "DngDecoder.h" #include -/* - RawSpeed - RAW file decoder. - - Copyright (C) 2009 Klaus Post - - 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 2 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, write to the Free Software +/* + RawSpeed - RAW file decoder. + + Copyright (C) 2009 Klaus Post + + 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA http://www.klauspost.com @@ -99,17 +99,17 @@ const unsigned short* pDim = raw->getEntry(CFAREPEATPATTERNDIM)->getShortArray(); // Get the size const unsigned char* cPat = raw->getEntry(CFAPATTERN)->getData(); // Does NOT contain dimensions as some documents state - +/* if (raw->hasEntry(CFAPLANECOLOR)) { TiffEntry* e = raw->getEntry(CFAPLANECOLOR); const unsigned char* cPlaneOrder = e->getData(); // Map from the order in the image, to the position in the CFA -/* printf("Planecolor: "); + printf("Planecolor: "); for (guint i = 0; i < e->count; i++) { printf("%u,",cPlaneOrder[i]); } - printf("\n"); */ + printf("\n"); } - +*/ iPoint2D cfaSize(pDim[1],pDim[0]); if (pDim[0] != 2) ThrowRDE("DNG Decoder: Unsupported CFA configuration."); @@ -246,13 +246,18 @@ } catch (TiffParserException) { ThrowRDE("DNG Decoder: Image could not be read."); } + iPoint2D new_size(mRaw->dim.x, mRaw->dim.y); #ifndef PRINT_INFO // Crop if (raw->hasEntry(ACTIVEAREA)) { const guint *corners = raw->getEntry(ACTIVEAREA)->getIntArray(); iPoint2D top_left(corners[1], corners[0]); - iPoint2D new_size(corners[3]-corners[1], corners[2]-corners[0]); + new_size = iPoint2D(corners[3]-corners[1], corners[2]-corners[0]); mRaw->subFrame(top_left,new_size); + if (top_left.x & 1) + mRaw->cfa.shiftLeft(); + if (top_left.y & 1) + mRaw->cfa.shiftDown(); } #endif // Linearization @@ -271,12 +276,29 @@ guint cw = mRaw->dim.x*mRaw->getCpp(); gushort* pixels = (gushort*)mRaw->getData(0,y); for (guint x = 0; x < cw; x++) { - *pixels++ = table[*pixels]; + pixels[x] = table[pixels[x]]; } } } mRaw->whitePoint = raw->getEntry(WHITELEVEL)->getInt(); + const gushort *blackdim = raw->getEntry(BLACKLEVELREPEATDIM)->getShortArray(); + int black = 65536; + if (blackdim[0] != 0 && blackdim[1] != 0) { + if (raw->hasEntry(BLACKLEVELDELTAV)) { + const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray(); + int blackbase = blackarray[0] / blackarray[1]; + const gint *blackarrayv = (const gint*)raw->getEntry(BLACKLEVELDELTAV)->getIntArray(); + for (int i = 0; i < new_size.y; i++) + black = MIN(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]); + } else { + const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray(); + black = blackarray[0] / blackarray[1]; + } + } else { + black = 0; + } + mRaw->blackLevel = black; return mRaw; } @@ -321,9 +343,9 @@ if (raw->hasEntry(BLACKLEVELDELTAV)) { const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray(); int blackbase = blackarray[0] / blackarray[1]; - const guint *blackarrayv = raw->getEntry(BLACKLEVELDELTAV)->getIntArray(); + const gint *blackarrayv = (const gint*)raw->getEntry(BLACKLEVELDELTAV)->getIntArray(); for (int i = 0; i < new_size.y; i++) - black = min(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]); + black = MIN(black, blackbase + blackarrayv[i*2] / blackarrayv[i*2+1]); } else { const guint *blackarray = raw->getEntry(BLACKLEVEL)->getIntArray(); black = blackarray[0] / blackarray[1]; Modified: RawSpeed/RawImage.cpp =================================================================== --- RawSpeed/RawImage.cpp 2009-03-18 17:24:36 UTC (rev 69) +++ RawSpeed/RawImage.cpp 2009-03-18 19:25:42 UTC (rev 70) @@ -24,15 +24,17 @@ */ RawImageData::RawImageData(void): -dim(0,0), bpp(0), isCFA(true), dataRefCount(0),data(0), cpp(1), -blackLevel(-1), whitePoint(65536) +dim(0,0), bpp(0), isCFA(true), +blackLevel(-1), whitePoint(65536), +dataRefCount(0), data(0), cpp(1) { pthread_mutex_init(&mymutex, NULL); } -RawImageData::RawImageData(iPoint2D _dim, guint _bpc, guint cpp) : -dim(_dim), bpp(_bpc), dataRefCount(0),data(0), -blackLevel(-1), whitePoint(65536) +RawImageData::RawImageData(iPoint2D _dim, guint _bpc, guint _cpp) : +dim(_dim), bpp(_bpc), +blackLevel(-1), whitePoint(65536), +dataRefCount(0),data(0), cpp(cpp) { createData(); pthread_mutex_init(&mymutex, NULL); Modified: RawSpeed/Rw2Decoder.cpp =================================================================== --- RawSpeed/Rw2Decoder.cpp 2009-03-18 17:24:36 UTC (rev 69) +++ RawSpeed/Rw2Decoder.cpp 2009-03-18 19:25:42 UTC (rev 70) @@ -14,7 +14,7 @@ RawImage Rw2Decoder::decodeRaw() { ThrowRDE("RW2 Decoder: Not supported"); - +/* vector data = mRootIFD->getIFDsWithTag(PANASONIC_STRIPOFFSET); if (data.empty()) @@ -30,8 +30,8 @@ // guint width = raw->getEntry()->getInt(); guint height = raw->getEntry((TiffTag)3)->getInt(); - guint bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt(); - return mRaw; + guint bitPerPixel = raw->getEntry(BITSPERSAMPLE)->getInt();*/ + return NULL; } void Rw2Decoder::decodeMetaData( CameraMetaData *meta ) Added: RawSpeed/compile-rawstudio.sh =================================================================== --- RawSpeed/compile-rawstudio.sh (rev 0) +++ RawSpeed/compile-rawstudio.sh 2009-03-18 19:25:42 UTC (rev 70) @@ -0,0 +1,3 @@ +#!/bin/sh + +make -f rawstudio-plugin.makefile all && sudo make -f rawstudio-plugin.makefile install \ No newline at end of file Property changes on: RawSpeed/compile-rawstudio.sh ___________________________________________________________________ Name: svn:executable + * Modified: RawSpeed/rawstudio-plugin-api.cpp =================================================================== --- RawSpeed/rawstudio-plugin-api.cpp 2009-03-18 17:24:36 UTC (rev 69) +++ RawSpeed/rawstudio-plugin-api.cpp 2009-03-18 19:25:42 UTC (rev 70) @@ -73,7 +73,7 @@ if (cpp == 1) image = rs_image16_new(r->dim.x, r->dim.y, cpp, cpp); else if (cpp == 3) - image = rs_image16_new(r->dim.x, r->dim.y, 3, 3); + image = rs_image16_new(r->dim.x, r->dim.y, 3, 4); else { printf("Unsupported component per pixel count"); return NULL; @@ -84,8 +84,8 @@ if (r->isCFA) { - printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); - printf("%s", r->cfa.asString().c_str()); +// printf("DCRAW filter:%x\n",r->cfa.getDcrawFilter()); +// printf("%s", r->cfa.asString().c_str()); } if (cpp == 1) { From anders at kvistmail.dk Thu Mar 19 00:59:25 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Thu, 19 Mar 2009 00:59:25 +0100 Subject: [Rawstudio-commit] r2268 - trunk/src Message-ID: Author: akv Date: 2009-03-19 00:59:24 +0100 (Thu, 19 Mar 2009) New Revision: 2268 Modified: trunk/src/filename.c Log: Added date and time to parsed filename. Modified: trunk/src/filename.c =================================================================== --- trunk/src/filename.c 2009-03-16 19:54:19 UTC (rev 2267) +++ trunk/src/filename.c 2009-03-18 23:59:24 UTC (rev 2268) @@ -28,6 +28,7 @@ #include "conf_interface.h" #include "gettext.h" #include "gtk-helper.h" +#include "rs-metadata.h" static void filename_entry_changed_writeback(GtkEntry *entry, gpointer user_data); static void filename_entry_changed_writeconf(GtkEntry *entry, gpointer user_data); @@ -53,12 +54,19 @@ gboolean file_exists = FALSE; gint i = 1; gchar *basename; + RSMetadata *metadata = rs_metadata_new_from_file(filename); if (filename == NULL) return NULL; if (in == NULL) return NULL; basename = g_path_get_basename(filename); output = g_strrstr(basename, "."); + + /* Prepare time/date */ + struct tm *tm = g_new0(struct tm, 1); + time_t tt = (time_t) metadata->timestamp; + gmtime_r(&tt, tm); + if (output != NULL) { *output = '\0'; } @@ -144,6 +152,30 @@ m += 1; n += 2; break; + case 'd': + { + gchar *result = g_new0(gchar, 11); + strftime(result, 11, "%Y-%m-%d", tm); + strcpy(&temp[m], result); + + n += 2; + m += strlen(result); + + g_free(result); + break; + } + case 't': + { + gchar *result = g_new0(gchar, 9); + strftime(result, 9, "%H:%M:%S", tm); + strcpy(&temp[m], result); + + n += 2; + m += strlen(result); + + g_free(result); + break; + } default: temp[m++] = in[n]; temp[m++] = in[n+1]; @@ -177,6 +209,8 @@ } while (file_exists == TRUE); g_free(basename); + g_free(tm); + g_object_unref(metadata); return output; } @@ -226,12 +260,28 @@ }; static void +add_d(GtkMenuItem *menuitem, GtkBin *combo) +{ + GtkWidget *entry = gtk_bin_get_child(combo); + gtk_entry_append_text(GTK_ENTRY(entry), "%d"); +}; + +static void +add_t(GtkMenuItem *menuitem, GtkBin *combo) +{ + GtkWidget *entry = gtk_bin_get_child(combo); + gtk_entry_append_text(GTK_ENTRY(entry), "%t"); +}; + +static void filename_add_clicked(GtkButton *button, gpointer user_data) { gui_menu_popup(GTK_WIDGET(button), user_data, _("%f - Original filename"), add_f, _("%2c - Incremental counter"), add_c, _("%s - Setting id (A, B or C)"), add_s, + _("%d - Date from EXIF (YYYY-MM-DD)"), add_d, + _("%t - Time from EXIF (HH:MM:SS)"), add_t, -1 ); } From anders at kvistmail.dk Thu Mar 19 01:12:46 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Thu, 19 Mar 2009 01:12:46 +0100 Subject: [Rawstudio-commit] r2269 - trunk/src Message-ID: Author: akv Date: 2009-03-19 01:12:45 +0100 (Thu, 19 Mar 2009) New Revision: 2269 Modified: trunk/src/rs-photo.c Log: Fixing calculation of auto wb. Modified: trunk/src/rs-photo.c =================================================================== --- trunk/src/rs-photo.c 2009-03-18 23:59:24 UTC (rev 2268) +++ trunk/src/rs-photo.c 2009-03-19 00:12:45 UTC (rev 2269) @@ -448,8 +448,8 @@ for (c=0; c < 8; c++) dsum[c] = 0.0; - for (row=0; row < photo->input->h-7; row += 8) - for (col=0; col < photo->input->w-7; col += 8) + for (row=0; row < photo->input->h-15; row += 8) + for (col=0; col < photo->input->w-15; col += 8) { memset (sum, 0, sizeof sum); for (y=row; y < row+8; y++) From klauspost at gmail.com Thu Mar 19 17:03:15 2009 From: klauspost at gmail.com (Klaus Post) Date: Thu, 19 Mar 2009 17:03:15 +0100 Subject: [Rawstudio-commit] r2270 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-19 17:03:15 +0100 (Thu, 19 Mar 2009) New Revision: 2270 Modified: trunk/plugins/denoise/denoisethread.cpp trunk/plugins/denoise/fftdenoiser.cpp trunk/plugins/denoise/floatimageplane.cpp trunk/plugins/denoise/floatplanarimage.cpp trunk/plugins/denoise/floatplanarimage.h trunk/plugins/denoise/planarimageslice.cpp trunk/plugins/denoise/planarimageslice.h Log: - Faster block skipping on unprocessed blocks. - Temporary fix to green/magenta cast, by multiplying typical WB in to RGB conversion. - Added disabled and untested SSE4 RGB->YUV x64 code. Modified: trunk/plugins/denoise/denoisethread.cpp =================================================================== --- trunk/plugins/denoise/denoisethread.cpp 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/denoisethread.cpp 2009-03-19 16:03:15 UTC (rev 2270) @@ -123,9 +123,6 @@ g_assert(j->p->filter); if (j->p->filter->skipBlock()) { - j->p->allocateOut(); - input->blitOnto(j->p->out); - j->p->out->multiply((float)(input->w * input->h)); return; } Modified: trunk/plugins/denoise/fftdenoiser.cpp =================================================================== --- trunk/plugins/denoise/fftdenoiser.cpp 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/fftdenoiser.cpp 2009-03-19 16:03:15 UTC (rev 2270) @@ -192,7 +192,7 @@ info->sigmaChroma = 1.0f; info->sharpenLuma = 0.0f; info->sharpenChroma = 0.0f; - info->sharpenCutoffLuma = 0.3f; + info->sharpenCutoffLuma = 0.10f; info->sharpenCutoffChroma = 0.3f; info->sharpenMinSigmaLuma = 4.0f; info->sharpenMinSigmaChroma = 4.0f; Modified: trunk/plugins/denoise/floatimageplane.cpp =================================================================== --- trunk/plugins/denoise/floatimageplane.cpp 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/floatimageplane.cpp 2009-03-19 16:03:15 UTC (rev 2270) @@ -124,10 +124,35 @@ return s; } +//TODO: SSE2 me. +void FBitBlt(guchar* dstp, int dst_pitch, const guchar* srcp, int src_pitch, int row_size, int height) { + if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { + memcpy(dstp, srcp, row_size*height); + return; + } + for (int y=height; y>0; --y) { + memcpy(dstp, srcp, row_size); + dstp += dst_pitch; + srcp += src_pitch; + } +} + void FloatImagePlane::applySlice( PlanarImageSlice *p ) { int start_y = p->offset_y + p->overlap_y; + int start_x = p->offset_x + p->overlap_x; + g_assert(start_y >= 0); + g_assert(start_x >= 0); + g_assert(start_y < h); + g_assert(start_x < w); + + if (p->blockSkipped) { + FBitBlt((guchar*)getAt(start_x,start_y), pitch*sizeof(float), + (const guchar*)p->in->getAt(p->overlap_x,p->overlap_y), p->in->pitch*sizeof(float), + p->in->w*sizeof(float)-p->overlap_x*2*sizeof(float), p->in->h-p->overlap_y*2); + return; + } + int end_y = p->offset_y + p->out->h - p->overlap_y; - int start_x = p->offset_x + p->overlap_x; int end_x = p->offset_x + p->out->w - p->overlap_x; float normalization = 1.0f / (float)(p->out->w * p->out->h); @@ -140,18 +165,6 @@ } } -//TODO: SSE2 me. -void FBitBlt(guchar* dstp, int dst_pitch, const guchar* srcp, int src_pitch, int row_size, int height) { - if (height == 1 || (dst_pitch == src_pitch && src_pitch == row_size)) { - memcpy(dstp, srcp, row_size*height); - return; - } - for (int y=height; y>0; --y) { - memcpy(dstp, srcp, row_size); - dstp += dst_pitch; - srcp += src_pitch; - } -} void FloatImagePlane::blitOnto( FloatImagePlane *dst ) { Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-19 16:03:15 UTC (rev 2270) @@ -151,6 +151,10 @@ RS_IMAGE16* image = j->rs; #if defined (__i386__) || defined (__x86_64__) guint cpu = rs_detect_cpu_features(); +#if defined (__x86_64__) +// if ((image->pixelsize == 4 ) && (cpu & RS_CPU_FLAG_SSE4_1) && ((ox&3)==0)) // TODO: Test before enabling +// return unpackInterleavedYUV_SSE4(j); +#endif if ((image->pixelsize == 4 ) && (cpu & RS_CPU_FLAG_SSE3) && ((ox&3)==0)) return unpackInterleavedYUV_SSE3(j); #endif @@ -181,6 +185,10 @@ temp[0] = 0.299f; temp[1] = 0.587f; temp[2] = 0.114f; temp[3] = 0.0f; temp[4] = -0.169f; temp[5] = -0.331f; temp[6] = 0.499; temp[7] = 0.0f; temp[8] = 0.499f; temp[9] = -0.418f; temp[10] = -0.0813f; temp[11] = 0.0f; + for (int i = 0; i < 3; i++) { + temp[i*4] *= 2.4150f; + temp[i*4+2] *= 1.4140f; + } asm volatile ( "movaps (%0), %%xmm5\n" // Y values @@ -240,6 +248,98 @@ } #endif // defined (__i386__) || defined (__x86_64__) +#if defined (__x86_64__) + +void FloatPlanarImage::unpackInterleavedYUV_SSE4( const ImgConvertJob* j ) +{ + RS_IMAGE16* image = j->rs; + float* temp = p[0]->data; + temp[0] = 0.299f; temp[1] = 0.587f; temp[2] = 0.114f; temp[3] = 0.0f; + temp[4] = -0.169f; temp[5] = -0.331f; temp[6] = 0.499; temp[7] = 0.0f; + temp[8] = 0.499f; temp[9] = -0.418f; temp[10] = -0.0813f; temp[11] = 0.0f; + for (int i = 0; i < 3; i++) { + temp[i*4] *= 2.4150f; + temp[i*4+2] *= 1.4140f; + } + asm volatile + ( + "movaps (%0), %%xmm13\n" // Y values + "movaps 16(%0), %%xmm14\n" // Cb values + "movaps 32(%0), %%xmm15\n" // Cr values + : // no output registers + : "r" (temp) + : // %0 + ); + for (int y = j->start_y; y < j->end_y; y++ ) { + const gushort* pix = GET_PIXEL(image,0,y); + gfloat *Y = p[0]->getAt(ox, y+oy); + gfloat *Cb = p[1]->getAt(ox, y+oy); + gfloat *Cr = p[2]->getAt(ox, y+oy); + int n = (image->w+3)>>2; + asm volatile + ( + "loopback_uiYUV_SSE4:\n" // We attempt to spread out dpps instructions due to high latency + "movdqa (%0), %%xmm2\n" // Load 2 pixels p0p1 + "pxor %%xmm1, %%xmm1\n" // 0 + "pmovzxwd %%xmm1, %%xmm0\n" // and unpack p0 into xmm0 + "punpckhwd %%xmm2, %%xmm1\n" // xmm1: unpack p1 + "movdqa 16(%0), %%xmm4\n" // Load 2 pixels p2p3 + "pxor %%xmm3, %%xmm3\n" // 0 + "pmovzxwd %%xmm4, %%xmm2\n" // unpack p2 into xmm2 + "punpckhwd %%xmm4, %%xmm3\n" // unpack p3 into xmm3 + "cvtdq2ps %%xmm0, %%xmm0\n" // Convert to float xx | b0 | g0 | r0 + "cvtdq2ps %%xmm1, %%xmm1\n" // Convert to float xx | b1 | g1 | r1 + "movaps %%xmm0, %%xmm4\n" + "cvtdq2ps %%xmm2, %%xmm2\n" // Convert to float xx | b0 | g0 | r0 + "movaps %%xmm1, %%xmm5\n" + "dpps $241, %%xmm13, %%xmm4\n" // p0 Y - f1 = 241 + "cvtdq2ps %%xmm3, %%xmm3\n" // Convert to float xx | b1 | g1 | r1 + "dpps $242, %%xmm13, %%xmm5\n" // p1 Y - f2 = 242 + "movaps %%xmm2, %%xmm6\n" + "dpps $244, %%xmm13, %%xmm6\n" // p2 Y - f4 = 244 + "movaps %%xmm3, %%xmm7\n" + "dpps $248, %%xmm13, %%xmm7\n" // p3 Y - f8 = 248 + "movaps %%xmm4, %%xmm8\n" // Y into xmm8 + "movaps %%xmm0, %%xmm4\n" + "orps %%xmm5, %%xmm8\n" + "dpps $241, %%xmm14, %%xmm4\n" // p0 Cb - f1 = 241 + "movaps %%xmm1, %%xmm5\n" + "orps %%xmm6, %%xmm8\n" + "dpps $242, %%xmm14, %%xmm5\n" // p1 Cb - f2 = 242 + "movaps %%xmm2, %%xmm6\n" + "orps %%xmm7, %%xmm8\n" + "movaps %%xmm3, %%xmm7\n" + "dpps $244, %%xmm14, %%xmm6\n" // p2 Cb - f4 = 244 + "orps %%xmm5, %%xmm4\n" // Cb into xmm4 + "dpps $248, %%xmm14, %%xmm7\n" // p3 Cb - f8 = 248 + "orps %%xmm6, %%xmm4\n" + "dpps $241, %%xmm15, %%xmm0\n" // p0 Cr - f1 = 241 + "orps %%xmm7, %%xmm4\n" + "dpps $242, %%xmm15, %%xmm1\n" // p1 Cr - f2 = 242 + "dpps $244, %%xmm15, %%xmm2\n" // p2 Cr - f4 = 244 + "orps %%xmm1, %%xmm0\n" // Cr into xmm0 + "dpps $248, %%xmm15, %%xmm3\n" // p3 Cr - f8 = 248 + "orps %%xmm2, %%xmm0\n" + "movdqa %%xmm8, (%1)\n" // Store Y + "orps %%xmm3, %%xmm0\n" + "movdqa %%xmm4, (%2)\n" // Store Cb + "movdqa %%xmm0, (%3)\n" // Store Cr + "add $16, %1\n" + "add $16, %2\n" + "add $16, %3\n" + "add $32, %0\n" + "dec %4\n" + "jnz loopback_uiYUV_SSE4\n" + "emms\n" + : // no output registers + : "r" (pix), "r" (Y), "r" (Cb), "r" (Cr), "r"(n) + : // %0 %1 %2 %3 %4 + ); + } +} +#endif// defined (__x86_64__) + + JobQueue* FloatPlanarImage::getPackInterleavedYUVJobs(RS_IMAGE16* image) { JobQueue* queue = new JobQueue(); @@ -274,9 +374,9 @@ gfloat *Cr = p[2]->getAt(ox, y+oy); gushort* out = GET_PIXEL(image,0,y); for (int x=0; xw; x++) { - int r = (int)(Y[x] + 1.402 * Cr[x]); + int r = (int)((Y[x] + 1.402 * Cr[x]) * (1.0f/2.415f)); int g = (int)(Y[x] - 0.344 * Cb[x] - 0.714 * Cr[x]); - int b = (int)(Y[x] + 1.772 * Cb[x]); + int b = (int)((Y[x] + 1.772 * Cb[x]) * (1.0f/1.414f)); out[0] = clampbits(r,16); out[1] = clampbits(g,16); out[2] = clampbits(b,16); @@ -286,7 +386,6 @@ } - JobQueue* FloatPlanarImage::getJobs() { JobQueue *jobs = new JobQueue(); @@ -297,8 +396,8 @@ } void FloatPlanarImage::applySlice( PlanarImageSlice *slice ) -{ - int plane = slice->out->plane_id; +{ + int plane = slice->in->plane_id; g_assert(plane>=0 && planeapplySlice(slice); } Modified: trunk/plugins/denoise/floatplanarimage.h =================================================================== --- trunk/plugins/denoise/floatplanarimage.h 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/floatplanarimage.h 2009-03-19 16:03:15 UTC (rev 2270) @@ -44,6 +44,9 @@ #if defined (__i386__) || defined (__x86_64__) void unpackInterleavedYUV_SSE3( const ImgConvertJob* j ); #endif +#if defined (__x86_64__) + void unpackInterleavedYUV_SSE4( const ImgConvertJob* j ); +#endif void packInterleavedYUV( const ImgConvertJob* j); JobQueue* getUnpackInterleavedYUVJobs(RS_IMAGE16* image); JobQueue* getPackInterleavedYUVJobs(RS_IMAGE16* image); Modified: trunk/plugins/denoise/planarimageslice.cpp =================================================================== --- trunk/plugins/denoise/planarimageslice.cpp 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/planarimageslice.cpp 2009-03-19 16:03:15 UTC (rev 2270) @@ -24,6 +24,7 @@ filter = 0; in = 0; out = 0; + blockSkipped = true; } PlanarImageSlice::~PlanarImageSlice(void) { @@ -40,4 +41,5 @@ return; out = new FloatImagePlane(in->w, in->h, in->plane_id); out->allocateImage(); + blockSkipped = false; } Modified: trunk/plugins/denoise/planarimageslice.h =================================================================== --- trunk/plugins/denoise/planarimageslice.h 2009-03-19 00:12:45 UTC (rev 2269) +++ trunk/plugins/denoise/planarimageslice.h 2009-03-19 16:03:15 UTC (rev 2270) @@ -37,6 +37,7 @@ gint offset_y; gint overlap_x; gint overlap_y; + gboolean blockSkipped; ComplexFilter *filter; FFTWindow *window; }; From klauspost at gmail.com Thu Mar 19 17:14:24 2009 From: klauspost at gmail.com (Klaus Post) Date: Thu, 19 Mar 2009 17:14:24 +0100 Subject: [Rawstudio-commit] r2271 - trunk/plugins/denoise Message-ID: Author: post Date: 2009-03-19 17:14:23 +0100 (Thu, 19 Mar 2009) New Revision: 2271 Modified: trunk/plugins/denoise/floatplanarimage.cpp Log: Denoise: Made temporary WB correction a define. Modified: trunk/plugins/denoise/floatplanarimage.cpp =================================================================== --- trunk/plugins/denoise/floatplanarimage.cpp 2009-03-19 16:03:15 UTC (rev 2270) +++ trunk/plugins/denoise/floatplanarimage.cpp 2009-03-19 16:14:23 UTC (rev 2271) @@ -145,6 +145,8 @@ } static float shortToInt[65535]; +#define WB_R_CORR 2.4150f +#define WB_B_CORR 1.4140f void FloatPlanarImage::unpackInterleavedYUV( const ImgConvertJob* j ) { @@ -168,9 +170,9 @@ float r = shortToInt[(*pix)]; float g = shortToInt[(*(pix+1))]; float b = shortToInt[(*(pix+2))]; - *Y++ = r * 0.299 + g * 0.587 + b * 0.114 ; - *Cb++ = r * -0.169 + g * -0.331 + b * 0.499; - *Cr++ = r * 0.499 + g * -0.418 - b * 0.0813; + *Y++ = r * 0.299 * WB_R_CORR + g * 0.587 + b * 0.114 * WB_B_CORR ; + *Cb++ = r * -0.169 * WB_R_CORR + g * -0.331 + b * 0.499 * WB_B_CORR; + *Cr++ = r * 0.499 * WB_R_CORR + g * -0.418 - b * 0.0813 * WB_B_CORR; pix += image->pixelsize; } } @@ -186,8 +188,8 @@ temp[4] = -0.169f; temp[5] = -0.331f; temp[6] = 0.499; temp[7] = 0.0f; temp[8] = 0.499f; temp[9] = -0.418f; temp[10] = -0.0813f; temp[11] = 0.0f; for (int i = 0; i < 3; i++) { - temp[i*4] *= 2.4150f; - temp[i*4+2] *= 1.4140f; + temp[i*4] *= WB_R_CORR; + temp[i*4+2] *= WB_B_CORR; } asm volatile ( @@ -258,8 +260,8 @@ temp[4] = -0.169f; temp[5] = -0.331f; temp[6] = 0.499; temp[7] = 0.0f; temp[8] = 0.499f; temp[9] = -0.418f; temp[10] = -0.0813f; temp[11] = 0.0f; for (int i = 0; i < 3; i++) { - temp[i*4] *= 2.4150f; - temp[i*4+2] *= 1.4140f; + temp[i*4] *= WB_R_CORR; + temp[i*4+2] *= WB_B_CORR; } asm volatile ( @@ -338,6 +340,8 @@ } } #endif// defined (__x86_64__) +#undef WB_R_CORR +#undef WB_B_CORR JobQueue* FloatPlanarImage::getPackInterleavedYUVJobs(RS_IMAGE16* image) { From anders at brander.dk Tue Mar 24 02:16:43 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 24 Mar 2009 02:16:43 +0100 Subject: [Rawstudio-commit] r2272 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-24 02:16:43 +0100 (Tue, 24 Mar 2009) New Revision: 2272 Modified: trunk/librawstudio/rs-filter.c Log: Modified rs_filter_get_image() to print some performance statistics. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-03-19 16:14:23 UTC (rev 2271) +++ trunk/librawstudio/rs-filter.c 2009-03-24 01:16:43 UTC (rev 2272) @@ -145,16 +145,43 @@ rs_filter_get_image(RSFilter *filter) { filter_debug("rs_filter_get_image(%s [%p])", RS_FILTER_NAME(filter), filter); + + /* This timer-hack will break badly when multithreaded! */ + static gfloat last_elapsed = 0.0; + static count = -1; + gfloat elapsed; + static GTimer *gt = NULL; + RS_IMAGE16 *image; g_assert(RS_IS_FILTER(filter)); + if (count == -1) + gt = g_timer_new(); + count++; + if (RS_FILTER_GET_CLASS(filter)->get_image) image = RS_FILTER_GET_CLASS(filter)->get_image(filter); else image = rs_filter_get_image(filter->previous); + elapsed = g_timer_elapsed(gt, NULL) - last_elapsed; + + printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); + if (elapsed > 0.001) + printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(image->w*image->h))/elapsed/1000000.0); + printf("\n"); + last_elapsed += elapsed; + g_assert(RS_IS_IMAGE16(image) || (image == NULL)); + count--; + if (count == -1) + { + last_elapsed = 0.0; + printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); + g_timer_destroy(gt); + } + return image; } From anders at brander.dk Thu Mar 26 19:35:34 2009 From: anders at brander.dk (Anders Brander) Date: Thu, 26 Mar 2009 19:35:34 +0100 Subject: [Rawstudio-commit] r2273 - trunk/src Message-ID: Author: abrander Date: 2009-03-26 19:35:33 +0100 (Thu, 26 Mar 2009) New Revision: 2273 Modified: trunk/src/rs-exif.cc Log: Fixed exporting .nef with exiv 0.18 (Patch by Jonas Pedersen). Modified: trunk/src/rs-exif.cc =================================================================== --- trunk/src/rs-exif.cc 2009-03-24 01:16:43 UTC (rev 2272) +++ trunk/src/rs-exif.cc 2009-03-26 18:35:33 UTC (rev 2273) @@ -58,8 +58,13 @@ #if EXIV2_TEST_VERSION(0,13,0) "Exif.Nikon3.Preview", #endif - "Exif.Nikon3.NEFThumbnailSize", +#if EXIV2_TEST_VERSION(0,18,0) + "Exif.Nikon3.RawImageCenter", +#else + "Exif.Nikon3.NEFThumbnailSize", +#endif + #if EXIV2_TEST_VERSION(0,17,91) "Exif.NikonPreview.JPEGInterchangeFormat", #endif From anders at brander.dk Sat Mar 28 16:02:50 2009 From: anders at brander.dk (Anders Brander) Date: Sat, 28 Mar 2009 16:02:50 +0100 Subject: [Rawstudio-commit] r2274 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-28 16:02:50 +0100 (Sat, 28 Mar 2009) New Revision: 2274 Modified: trunk/librawstudio/rs-plugin.c Log: Fixed rs_plugin_get_property() for PROP_FILENAME. Modified: trunk/librawstudio/rs-plugin.c =================================================================== --- trunk/librawstudio/rs-plugin.c 2009-03-26 18:35:33 UTC (rev 2273) +++ trunk/librawstudio/rs-plugin.c 2009-03-28 15:02:50 UTC (rev 2274) @@ -97,7 +97,7 @@ switch (param_id) { case PROP_FILENAME: - g_value_get_string (value); + g_value_set_string(value, plugin->filename); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); From anders at brander.dk Sun Mar 29 15:06:20 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 15:06:20 +0200 Subject: [Rawstudio-commit] r2275 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-29 15:06:19 +0200 (Sun, 29 Mar 2009) New Revision: 2275 Added: trunk/librawstudio/rs-icc-profile.c trunk/librawstudio/rs-icc-profile.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h Log: Added RSIccProfile. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-03-28 15:02:50 UTC (rev 2274) +++ trunk/librawstudio/Makefile.am 2009-03-29 13:06:19 UTC (rev 2275) @@ -11,6 +11,7 @@ library_include_HEADERS = rawstudio.h rs-types.h rs-macros.h \ rs-plugin.h \ rs-rawfile.h \ + rs-icc-profile.h \ rs-image.h \ rs-image16.h \ rs-metadata.h \ @@ -33,6 +34,7 @@ librawstudio_1_1_la_SOURCES = \ rs-plugin.c rs-plugin.h \ rs-rawfile.c rs-rawfile.h \ + rs-icc-profile.c rs-icc-profile.h \ rs-image.c rs-image.h \ rs-image16.c rs-image16.h \ rs-metadata.c rs-metadata.h \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-03-28 15:02:50 UTC (rev 2274) +++ trunk/librawstudio/rawstudio.h 2009-03-29 13:06:19 UTC (rev 2275) @@ -31,6 +31,7 @@ #include "rs-rawfile.h" #include "rs-settings.h" +#include "rs-icc-profile.h" #include "rs-image.h" #include "rs-image16.h" #include "rs-metadata.h" Added: trunk/librawstudio/rs-icc-profile.c =================================================================== --- trunk/librawstudio/rs-icc-profile.c (rev 0) +++ trunk/librawstudio/rs-icc-profile.c 2009-03-29 13:06:19 UTC (rev 2275) @@ -0,0 +1,339 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include /* ntohl() */ +#include +#include +#include "rs-icc-profile.h" + +struct _RSIccProfile { + GObject parent; + gboolean dispose_has_run; + + gchar *filename; + gchar *map; + gsize map_length; + RSIccProfile_ColorSpace colorspace; + RSIccProfile_Class profile_class; +}; + +G_DEFINE_TYPE (RSIccProfile, rs_icc_profile, G_TYPE_OBJECT) + +static void get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec); +static void set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +static gboolean read_from_file(RSIccProfile *profile, const gchar *path); +static gboolean read_from_memory(RSIccProfile *profile, gchar *map, gsize map_length, gboolean copy); + +GType +rs_icc_colorspace_get_type(void) +{ + static GType icc_colorspace_type = 0; + + static const GEnumValue icc_colorspace[] = { + {RS_ICC_COLORSPACE_UNDEFINED, "Colorspace not available", "n/a"}, + {RS_ICC_COLORSPACE_XYZ, "XYZ", "xyz"}, + {RS_ICC_COLORSPACE_LAB, "Lab", "lab"}, + {RS_ICC_COLORSPACE_LUV, "Luv", "luv"}, + {RS_ICC_COLORSPACE_YCBCR, "YCbCr", "ycbcr"}, + {RS_ICC_COLORSPACE_YXY, "Yxy", "YXY"}, + {RS_ICC_COLORSPACE_RGB, "RGB", "rgb"}, + {RS_ICC_COLORSPACE_GREY, "Grey", "grey"}, + {RS_ICC_COLORSPACE_HSV, "HSV", "hsv"}, + {RS_ICC_COLORSPACE_HLS, "HLS", "hls"}, + {RS_ICC_COLORSPACE_CMYK, "CMYK", "cmyk"}, + {RS_ICC_COLORSPACE_CMY, "CMY", "cmy"}, + {0, NULL, NULL} + }; + + if (!icc_colorspace_type) + icc_colorspace_type = g_enum_register_static("RSIccColorSpace", icc_colorspace); + + return icc_colorspace_type; +} + +GType +icc_profile_class_get_type(void) +{ + static GType icc_profile_class_type = 0; + + static const GEnumValue icc_profile_class[] = { + {RS_ICC_PROFILE_UNDEFINED, "Profile class undefined", "n/a"}, + {RS_ICC_PROFILE_INPUT, "Input Device profile", "input"}, + {RS_ICC_PROFILE_DISPLAY, "Display Device profile", "display"}, + {RS_ICC_PROFILE_OUTPUT, "Output Device profile", "output"}, + {RS_ICC_PROFILE_DEVICELINK, "DeviceLinkprofile", "devicelink"}, + {RS_ICC_PROFILE_COLORSPACE_CONVERSION, "ColorSpace Conversion profile", "colorspace-conversion"}, + {RS_ICC_PROFILE_ACSTRACT, "Abstract profile", "abstract"}, + {RS_ICC_PROFILE_NAMED_COLOR, "Named colour profile", "named-color"}, + {0, NULL, NULL} + }; + + if (!icc_profile_class_type) + icc_profile_class_type = g_enum_register_static("RSIccProfileClass", icc_profile_class); + + return icc_profile_class_type; +} + +GType +rs_icc_intent_get_type(void) +{ + static GType rs_icc_intent_type = 0; + + static const GEnumValue rs_icc_intents[] = { + {RS_ICC_INTENT_PERCEPTUAL, "Perceptual intent", "perceptual"}, + {RS_ICC_INTENT_RELATIVE_COLORIMETRIC, "Relative colorimetric", "relative"}, + {RS_ICC_INTENT_SATURATION, "Saturation", "saturation"}, + {RS_ICC_INTENT_ABSOLUTE_COLORIMETRIC, "Absolute colorimetric", "absolute"}, + {0, NULL, NULL}, + }; + + if (!rs_icc_intent_type) + rs_icc_intent_type = g_enum_register_static("RSIccIntent", rs_icc_intents); + + return rs_icc_intent_type; +} + +enum { + PROP_0, + PROP_FILENAME, + PROP_COLORSPACE, + PROP_CLASS +}; + +static void +dispose(GObject *object) +{ + RSIccProfile *profile = RS_ICC_PROFILE(object); + + if (!profile->dispose_has_run) + { + g_free(profile->filename); + g_free(profile->map); + + profile->dispose_has_run = TRUE; + } + + /* Chain up */ + G_OBJECT_CLASS(rs_icc_profile_parent_class)->dispose(object); +} + +static void +finalize(GObject *object) +{ + G_OBJECT_CLASS(rs_icc_profile_parent_class)->finalize(object); +} + +static void +rs_icc_profile_class_init(RSIccProfileClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = get_property; + object_class->set_property = set_property; + + g_object_class_install_property(object_class, + PROP_FILENAME, g_param_spec_string( + "filename", "Filename", "The filename of the loaded profile", + NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_COLORSPACE, g_param_spec_enum( + "colorspace", "colorspace", "Profile colorspace", + RS_TYPE_ICC_COLORSPACE, RS_ICC_COLORSPACE_UNDEFINED, G_PARAM_READABLE)); + + g_object_class_install_property(object_class, + PROP_CLASS, g_param_spec_enum( + "profile-class", "profile-class", "Profile class", + RS_TYPE_ICC_PROFILE_CLASS, RS_ICC_PROFILE_UNDEFINED, G_PARAM_READABLE)); + + object_class->dispose = dispose; + object_class->finalize = finalize; +} + +static void +get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + RSIccProfile *profile = RS_ICC_PROFILE(object); + + switch (property_id) + { + case PROP_FILENAME: + g_value_set_string(value, profile->filename); + break; + case PROP_COLORSPACE: + g_value_set_enum(value, profile->colorspace); + break; + case PROP_CLASS: + g_value_set_enum(value, profile->profile_class); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + RSIccProfile *profile = RS_ICC_PROFILE(object); + + switch (property_id) + { + case PROP_FILENAME: + g_free(profile->filename); + profile->filename = g_value_dup_string(value); + read_from_file(profile, profile->filename); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +rs_icc_profile_init(RSIccProfile *profile) +{ + profile->dispose_has_run = FALSE; + profile->filename = NULL; + profile->map = NULL; + profile->map_length = 0; + profile->colorspace = RS_ICC_COLORSPACE_UNDEFINED; + profile->profile_class = 0; +} + +static gboolean +read_from_file(RSIccProfile *profile, const gchar *path) +{ + gboolean ret = FALSE; + struct stat st; + GError *error; + + g_stat(path, &st); + + /* We only accept files below 10MiB */ + if (st.st_size > (10*1024*1024)) + return ret; + + /* Or more than the ICC header... */ + if (st.st_size < 128) + return ret; + + if (profile->map) + g_free(profile->map); + + error = NULL; + if(g_file_get_contents(path, &profile->map, &profile->map_length, &error)) + ret = read_from_memory(profile, profile->map, profile->map_length, FALSE); + else if (error) + g_warning("GError: '%s'", error->message); + + return ret; +} + +static gboolean +read_from_memory(RSIccProfile *profile, gchar *map, gsize map_length, gboolean copy) +{ + /* For now, we don't fail :) */ + gboolean ret = TRUE; + + if (copy) + profile->map = g_memdup(map, map_length); + else + profile->map = map; + + profile->map_length = map_length; + + /* Macro for reading unsigned integers from ICC profiles */ +#define _GUINT(map, offset) (ntohl(*((guint *)(&map[offset])))) + profile->colorspace = _GUINT(profile->map, 16); + profile->profile_class = _GUINT(profile->map, 12); +#undef _GUINT + + return ret; +} + +/** + * Construct new RSIccProfile from an ICC profile on disk + * @param path An absolute path to an ICC profile + * @return A new RSIccProfile object or NULL on error + */ +RSIccProfile * +rs_icc_profile_new_from_file(const gchar *path) +{ + g_assert(path != NULL); + g_assert(path[0] == G_DIR_SEPARATOR); + + RSIccProfile *profile = g_object_new (RS_TYPE_ICC_PROFILE, NULL); + + if (!read_from_file(profile, path)) + { + g_object_unref(profile); + profile = NULL; + } + + return profile; +} + +/** + * Construct new RSIccProfile from an in-memory ICC profile + * @param map A pointer to a complete ICC profile + * @param map_length The length of the profile in bytes + * @param copy TRUE if the data should be copied, FALSE otherwise + * @return A new RSIccProfile object or NULL on error + */ +RSIccProfile * +rs_icc_profile_new_from_memory(gchar *map, gsize map_length, gboolean copy) +{ + g_assert(map != NULL); + g_assert(map_length >= 0); + + RSIccProfile *profile = g_object_new (RS_TYPE_ICC_PROFILE, NULL); + + if (!read_from_memory(profile, map, map_length, copy)) + { + g_object_unref(profile); + profile = NULL; + } + + return profile; +} + +/** + * Get binary profile data + * @param profile A RSIccProfile + * @param map A pointer to a gchar pointer + * @param map_length A pointer to a gsize, the length of the profile will be written here + */ +gboolean +rs_icc_profile_get_data(RSIccProfile *profile, gchar **map, gsize *map_length) +{ + gboolean ret = FALSE; + + g_assert(RS_IS_ICC_PROFILE(profile)); + g_assert(map != NULL); + g_assert(map_length != NULL); + + if (profile->map) + { + *map = g_memdup(profile->map, profile->map_length); + *map_length = profile->map_length; + ret = TRUE; + } + + return ret; +} Added: trunk/librawstudio/rs-icc-profile.h =================================================================== --- trunk/librawstudio/rs-icc-profile.h (rev 0) +++ trunk/librawstudio/rs-icc-profile.h 2009-03-29 13:06:19 UTC (rev 2275) @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef RS_ICC_PROFILE_H +#define RS_ICC_PROFILE_H + +#include + +G_BEGIN_DECLS + +#define RS_TYPE_ICC_PROFILE rs_icc_profile_get_type() +#define RS_ICC_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_ICC_PROFILE, RSIccProfile)) +#define RS_ICC_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_ICC_PROFILE, RSIccProfileClass)) +#define RS_IS_ICC_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_ICC_PROFILE)) +#define RS_IS_ICC_PROFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_ICC_PROFILE)) +#define RS_ICC_PROFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_ICC_PROFILE, RSIccProfileClass)) + +typedef struct _RSIccProfile RSIccProfile; + +typedef struct { + GObjectClass parent_class; +} RSIccProfileClass; + +GType rs_icc_profile_get_type(void); + +typedef enum { + RS_ICC_COLORSPACE_UNDEFINED = 0x0, + RS_ICC_COLORSPACE_XYZ = 0x58595A20, + RS_ICC_COLORSPACE_LAB = 0x4C616220, + RS_ICC_COLORSPACE_LUV = 0x4C757620, + RS_ICC_COLORSPACE_YCBCR = 0x59436272, + RS_ICC_COLORSPACE_YXY = 0x59787920, + RS_ICC_COLORSPACE_RGB = 0x52474220, + RS_ICC_COLORSPACE_GREY = 0x47524159, + RS_ICC_COLORSPACE_HSV = 0x48535620, + RS_ICC_COLORSPACE_HLS = 0x484C5320, + RS_ICC_COLORSPACE_CMYK = 0x434D594B, + RS_ICC_COLORSPACE_CMY = 0x434D5920 +} RSIccProfile_ColorSpace; + +#define RS_TYPE_ICC_COLORSPACE rs_icc_colorspace_get_type() +GType rs_icc_colorspace_get_type(void); + +typedef enum { + RS_ICC_PROFILE_UNDEFINED = 0x0, + RS_ICC_PROFILE_INPUT = 0x73636E72, + RS_ICC_PROFILE_DISPLAY = 0x6D6E7472, + RS_ICC_PROFILE_OUTPUT = 0x70727472, + RS_ICC_PROFILE_DEVICELINK = 0x6C696E6B, + RS_ICC_PROFILE_COLORSPACE_CONVERSION = 0x73706163, + RS_ICC_PROFILE_ACSTRACT = 0x61627374, + RS_ICC_PROFILE_NAMED_COLOR = 0x6E6D636C +} RSIccProfile_Class; + +#define RS_TYPE_ICC_PROFILE_CLASS rs_icc_profile_class_get_type() +GType icc_profile_class_get_type(void); + +typedef enum { + RS_ICC_INTENT_PERCEPTUAL = 0, + RS_ICC_INTENT_RELATIVE_COLORIMETRIC = 1, + RS_ICC_INTENT_SATURATION = 2, + RS_ICC_INTENT_ABSOLUTE_COLORIMETRIC = 3 +} RSIccIntent; + +#define RS_TYPE_ICC_INTENT rs_icc_intent_get_type() +GType rs_icc_intent_get_type(void); + +/** + * Construct new RSIccProfile from an ICC profile on disk + * @param path An absolute path to an ICC profile + * @return A new RSIccProfile object or NULL on error + */ +RSIccProfile * +rs_icc_profile_new_from_file(const gchar *path); + +/** + * Construct new RSIccProfile from an in-memory ICC profile + * @param map A pointer to a complete ICC profile + * @param map_length The length of the profile in bytes + * @param copy TRUE if the data should be copied, FALSE otherwise + * @return A new RSIccProfile object or NULL on error + */ +RSIccProfile * +rs_icc_profile_new_from_memory(gchar *map, gsize map_length, gboolean copy); + +/** + * Get binary profile data + * @param profile A RSIccProfile + * @param map A pointer to a gchar pointer + * @param map_length A pointer to a gsize, the length of the profile will be written here + */ +gboolean +rs_icc_profile_get_data(RSIccProfile *icc, gchar **data, gsize *length); + +G_END_DECLS + +#endif /* RS_ICC_PROFILE_H */ From anders at brander.dk Sun Mar 29 15:17:19 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 15:17:19 +0200 Subject: [Rawstudio-commit] r2276 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-29 15:17:19 +0200 (Sun, 29 Mar 2009) New Revision: 2276 Modified: trunk/librawstudio/rs-icc-profile.c Log: Renamed icc_profile_class_get_type() to rs_icc_profile_class_get_type(). Modified: trunk/librawstudio/rs-icc-profile.c =================================================================== --- trunk/librawstudio/rs-icc-profile.c 2009-03-29 13:06:19 UTC (rev 2275) +++ trunk/librawstudio/rs-icc-profile.c 2009-03-29 13:17:19 UTC (rev 2276) @@ -69,7 +69,7 @@ } GType -icc_profile_class_get_type(void) +rs_icc_profile_class_get_type(void) { static GType icc_profile_class_type = 0; From anders at brander.dk Sun Mar 29 17:47:15 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 17:47:15 +0200 Subject: [Rawstudio-commit] r2277 - trunk/plugins/resample Message-ID: Author: abrander Date: 2009-03-29 17:47:14 +0200 (Sun, 29 Mar 2009) New Revision: 2277 Modified: trunk/plugins/resample/resample.c Log: Only call rs_filter_changed() from RSResample if needed. Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-03-29 13:17:19 UTC (rev 2276) +++ trunk/plugins/resample/resample.c 2009-03-29 15:47:14 UTC (rev 2277) @@ -142,12 +142,18 @@ switch (property_id) { case PROP_WIDTH: - resample->new_width = g_value_get_int(value); - rs_filter_changed(RS_FILTER(object)); + if (g_value_get_int(value) != resample->new_width) + { + resample->new_width = g_value_get_int(value); + rs_filter_changed(RS_FILTER(object)); + } break; case PROP_HEIGHT: - resample->new_height = g_value_get_int(value); - rs_filter_changed(RS_FILTER(object)); + if (g_value_get_int(value) != resample->new_height) + { + resample->new_height = g_value_get_int(value); + rs_filter_changed(RS_FILTER(object)); + } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); From anders at brander.dk Sun Mar 29 18:21:17 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 18:21:17 +0200 Subject: [Rawstudio-commit] r2278 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-29 18:21:17 +0200 (Sun, 29 Mar 2009) New Revision: 2278 Modified: trunk/librawstudio/rs-filter.c Log: Don't segfault in rs_filter_get_image() if filter returns NULL. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-03-29 15:47:14 UTC (rev 2277) +++ trunk/librawstudio/rs-filter.c 2009-03-29 16:21:17 UTC (rev 2278) @@ -20,7 +20,7 @@ #include #include "rs-filter.h" -#if 0 /* Change to 1 to enable debugging info */ +#if 1 /* Change to 1 to enable debugging info */ #define filter_debug g_debug #else #define filter_debug(...) @@ -167,7 +167,7 @@ elapsed = g_timer_elapsed(gt, NULL) - last_elapsed; printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); - if (elapsed > 0.001) + if ((elapsed > 0.001) && (image != NULL)) printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(image->w*image->h))/elapsed/1000000.0); printf("\n"); last_elapsed += elapsed; From anders at brander.dk Sun Mar 29 18:22:08 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 18:22:08 +0200 Subject: [Rawstudio-commit] r2279 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-29 18:22:08 +0200 (Sun, 29 Mar 2009) New Revision: 2279 Modified: trunk/librawstudio/rs-filter.c Log: Print more verbose statistics in rs_filter_get_image(). Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-03-29 16:21:17 UTC (rev 2278) +++ trunk/librawstudio/rs-filter.c 2009-03-29 16:22:08 UTC (rev 2279) @@ -169,6 +169,9 @@ printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); if ((elapsed > 0.001) && (image != NULL)) printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(image->w*image->h))/elapsed/1000000.0); + if (image) + printf(" [w: %d, h: %d, channels: %d, pixelsize: %d, rowstride: %d]", + image->w, image->h, image->channels, image->pixelsize, image->rowstride); printf("\n"); last_elapsed += elapsed; From anders at brander.dk Sun Mar 29 18:24:59 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 18:24:59 +0200 Subject: [Rawstudio-commit] r2280 - in trunk/plugins: demosaic denoise resample Message-ID: Author: abrander Date: 2009-03-29 18:24:59 +0200 (Sun, 29 Mar 2009) New Revision: 2280 Modified: trunk/plugins/demosaic/demosaic.c trunk/plugins/denoise/denoise.c trunk/plugins/resample/resample.c Log: Fixed RSDemosaic, RSDenoise and RSResample to cope with rs_filter_get_image() returning other types (NULL) than RS_IMAGE16. Modified: trunk/plugins/demosaic/demosaic.c =================================================================== --- trunk/plugins/demosaic/demosaic.c 2009-03-29 16:22:08 UTC (rev 2279) +++ trunk/plugins/demosaic/demosaic.c 2009-03-29 16:24:59 UTC (rev 2280) @@ -160,6 +160,8 @@ gushort *dest; input = rs_filter_get_image(filter->previous); + if (!RS_IS_IMAGE16(input)) + return input; /* Just pass on output from previous filter if the image is not CFA */ if (input->filters == 0) Modified: trunk/plugins/denoise/denoise.c =================================================================== --- trunk/plugins/denoise/denoise.c 2009-03-29 16:22:08 UTC (rev 2279) +++ trunk/plugins/denoise/denoise.c 2009-03-29 16:24:59 UTC (rev 2280) @@ -178,6 +178,8 @@ RS_IMAGE16 *input; RS_IMAGE16 *output; input = rs_filter_get_image(filter->previous); + if (!RS_IS_FILTER(input)) + return input; if ((denoise->sharpen + denoise->denoise_luma + denoise->denoise_chroma) == 0) return input; Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-03-29 16:22:08 UTC (rev 2279) +++ trunk/plugins/resample/resample.c 2009-03-29 16:24:59 UTC (rev 2280) @@ -145,6 +145,7 @@ if (g_value_get_int(value) != resample->new_width) { resample->new_width = g_value_get_int(value); + printf("new_width: %d\n", resample->new_width); rs_filter_changed(RS_FILTER(object)); } break; @@ -152,6 +153,7 @@ if (g_value_get_int(value) != resample->new_height) { resample->new_height = g_value_get_int(value); + printf("new_height: %d\n", resample->new_height); rs_filter_changed(RS_FILTER(object)); } break; @@ -193,6 +195,8 @@ gint input_height = rs_filter_get_height(filter->previous); input = rs_filter_get_image(filter->previous); + if (!RS_IS_IMAGE16(input)) + return input; /* Simply return the input, if we don't scale */ if ((input_width == resample->new_width) && (input_height == resample->new_height)) From anders at brander.dk Sun Mar 29 18:31:45 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 18:31:45 +0200 Subject: [Rawstudio-commit] r2281 - in trunk: librawstudio plugins/resample Message-ID: Author: abrander Date: 2009-03-29 18:31:45 +0200 (Sun, 29 Mar 2009) New Revision: 2281 Modified: trunk/librawstudio/rs-filter.c trunk/plugins/resample/resample.c Log: Removed a few debug messages. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-03-29 16:24:59 UTC (rev 2280) +++ trunk/librawstudio/rs-filter.c 2009-03-29 16:31:45 UTC (rev 2281) @@ -20,7 +20,7 @@ #include #include "rs-filter.h" -#if 1 /* Change to 1 to enable debugging info */ +#if 0 /* Change to 1 to enable debugging info */ #define filter_debug g_debug #else #define filter_debug(...) Modified: trunk/plugins/resample/resample.c =================================================================== --- trunk/plugins/resample/resample.c 2009-03-29 16:24:59 UTC (rev 2280) +++ trunk/plugins/resample/resample.c 2009-03-29 16:31:45 UTC (rev 2281) @@ -145,7 +145,6 @@ if (g_value_get_int(value) != resample->new_width) { resample->new_width = g_value_get_int(value); - printf("new_width: %d\n", resample->new_width); rs_filter_changed(RS_FILTER(object)); } break; @@ -153,7 +152,6 @@ if (g_value_get_int(value) != resample->new_height) { resample->new_height = g_value_get_int(value); - printf("new_height: %d\n", resample->new_height); rs_filter_changed(RS_FILTER(object)); } break; From anders at brander.dk Sun Mar 29 18:37:28 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 18:37:28 +0200 Subject: [Rawstudio-commit] r2282 - trunk/src Message-ID: Author: abrander Date: 2009-03-29 18:37:28 +0200 (Sun, 29 Mar 2009) New Revision: 2282 Modified: trunk/src/rs-photo.c Log: Fixed rs_photo_set_angle() to correctly emit spatial-changed. Modified: trunk/src/rs-photo.c =================================================================== --- trunk/src/rs-photo.c 2009-03-29 16:31:45 UTC (rev 2281) +++ trunk/src/rs-photo.c 2009-03-29 16:37:28 UTC (rev 2282) @@ -227,12 +227,18 @@ extern void rs_photo_set_angle(RS_PHOTO *photo, gdouble angle, gboolean relative) { + gdouble previous; if (!photo) return; + previous = photo->angle; + if (relative) photo->angle += angle; else photo->angle = angle; + + if (ABS(previous - photo->angle) > 0.01) + g_signal_emit(photo, signals[SPATIAL_CHANGED], 0, NULL); } /** From anders at brander.dk Sun Mar 29 18:57:14 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 18:57:14 +0200 Subject: [Rawstudio-commit] r2283 - trunk/src Message-ID: Author: abrander Date: 2009-03-29 18:57:14 +0200 (Sun, 29 Mar 2009) New Revision: 2283 Modified: trunk/src/application.c trunk/src/application.h trunk/src/gtk-interface.c trunk/src/rs-preview-widget.c trunk/src/rs-preview-widget.h Log: Moved shared filters from RSPreviewWidget to RS_BLOB. Modified: trunk/src/application.c =================================================================== --- trunk/src/application.c 2009-03-29 16:37:28 UTC (rev 2282) +++ trunk/src/application.c 2009-03-29 16:57:14 UTC (rev 2283) @@ -130,6 +130,10 @@ { if (photo == rs->photo) { + /* Update crop and rotate filters */ + g_object_set(rs->filter_crop, "rectangle", rs_photo_get_crop(photo), NULL); + g_object_set(rs->filter_rotate, "angle", rs_photo_get_angle(photo), NULL); + /* Update histogram dataset */ if (rs->histogram_dataset) rs_image16_free(rs->histogram_dataset); @@ -167,6 +171,7 @@ /* Set photo in preview-widget */ rs_preview_widget_set_photo(RS_PREVIEW_WIDGET(rs->preview), photo); + g_object_set(rs->filter_input, "image", photo->input, NULL); /* Save photo in blob */ rs->photo = photo; @@ -333,6 +338,8 @@ RS_BLOB * rs_new(void) { + RSFilter *cache; + RS_BLOB *rs; guint c; rs = g_malloc(sizeof(RS_BLOB)); @@ -343,6 +350,15 @@ rs->current_setting = 0; for(c=0;c<3;c++) rs->settings[c] = rs_settings_new(); + + /* Build basic filter chain */ + rs->filter_input = rs_filter_new("RSInputImage16", NULL); + rs->filter_demosaic = rs_filter_new("RSDemosaic", rs->filter_input); + cache = rs_filter_new("RSCache", rs->filter_demosaic); + rs->filter_rotate = rs_filter_new("RSRotate", cache); + rs->filter_crop = rs_filter_new("RSCrop", rs->filter_rotate); + rs->filter_end = rs->filter_crop; + return(rs); } @@ -617,14 +633,13 @@ rs_init_filetypes(); gtk_init(&argc, &argv); check_install(); + rs_plugin_manager_load_all_plugins(); rs = rs_new(); rs->queue->cms = rs->cms = rs_cms_init(); rs_stock_init(); - rs_plugin_manager_load_all_plugins(); - #if GTK_CHECK_VERSION(2,10,0) gtk_link_button_set_uri_hook(runuri,NULL,NULL); #endif Modified: trunk/src/application.h =================================================================== --- trunk/src/application.h 2009-03-29 16:37:28 UTC (rev 2282) +++ trunk/src/application.h 2009-03-29 16:57:14 UTC (rev 2283) @@ -69,6 +69,13 @@ GtkWidget *iconbox; GtkWidget *toolbox; GtkWidget *preview; + + /* Generic filter chain */ + RSFilter *filter_input; + RSFilter *filter_demosaic; + RSFilter *filter_rotate; + RSFilter *filter_crop; + RSFilter *filter_end; } RS_BLOB; enum { Modified: trunk/src/gtk-interface.c =================================================================== --- trunk/src/gtk-interface.c 2009-03-29 16:37:28 UTC (rev 2282) +++ trunk/src/gtk-interface.c 2009-03-29 16:57:14 UTC (rev 2283) @@ -991,6 +991,7 @@ /* Preview area */ rs->preview = rs_preview_widget_new(); + rs_preview_widget_set_filter(RS_PREVIEW_WIDGET(rs->preview), rs->filter_end); rs_preview_widget_set_cms(RS_PREVIEW_WIDGET(rs->preview), rs_cms_get_transform(rs->cms, TRANSFORM_DISPLAY)); rs_conf_get_color(CONF_PREBGCOLOR, &bgcolor); rs_preview_widget_set_bgcolor(RS_PREVIEW_WIDGET(rs->preview), &bgcolor); Modified: trunk/src/rs-preview-widget.c =================================================================== --- trunk/src/rs-preview-widget.c 2009-03-29 16:37:28 UTC (rev 2282) +++ trunk/src/rs-preview-widget.c 2009-03-29 16:57:14 UTC (rev 2283) @@ -134,11 +134,8 @@ COORD straighten_start; COORD straighten_end; gfloat straighten_angle; + RSFilter *filter_input; - RSFilter *filter_input[MAX_VIEWS]; - RSFilter *filter_demosaic[MAX_VIEWS]; - RSFilter *filter_crop[MAX_VIEWS]; - RSFilter *filter_rotate[MAX_VIEWS]; RSFilter *filter_resample[MAX_VIEWS]; RSFilter *filter_denoise[MAX_VIEWS]; RSFilter *filter_cache[MAX_VIEWS]; @@ -188,7 +185,6 @@ static gboolean motion(GtkWidget *widget, GdkEventMotion *event, gpointer user_data); static gboolean leave(GtkWidget *widget, GdkEventCrossing *event, gpointer user_data); static void settings_changed(RS_PHOTO *photo, RSSettingsMask mask, RSPreviewWidget *preview); -static void spatial_changed(RS_PHOTO *photo, RSPreviewWidget *preview); static void filter_changed(RSFilter *filter, RSPreviewWidget *preview); static void buffer_notify(GObject *gobject, GParamSpec *arg1, gpointer user_data); static void crop_aspect_changed(gpointer active, gpointer user_data); @@ -298,14 +294,10 @@ gtk_table_attach(table, preview->vscrollbar, 1, 2, 0, 1, GTK_SHRINK, GTK_EXPAND|GTK_FILL, 0, 0); gtk_table_attach(table, preview->hscrollbar, 0, 1, 1, 2, GTK_EXPAND|GTK_FILL, GTK_SHRINK, 0, 0); + preview->filter_input = NULL; for(i=0;ifilter_input[i] = rs_filter_new("RSInputImage16", NULL); - preview->filter_demosaic[i] = rs_filter_new("RSDemosaic", preview->filter_input[i]); - preview->filter_cache[i] = rs_filter_new("RSCache", preview->filter_demosaic[i]); - preview->filter_rotate[i] = rs_filter_new("RSRotate", preview->filter_cache[i]); - preview->filter_crop[i] = rs_filter_new("RSCrop", preview->filter_rotate[i]); - preview->filter_resample[i] = rs_filter_new("RSResample", preview->filter_crop[i]); + preview->filter_resample[i] = rs_filter_new("RSResample", NULL); preview->filter_cache[i] = rs_filter_new("RSCache", preview->filter_resample[i]); preview->filter_denoise[i] = rs_filter_new("RSDenoise", preview->filter_cache[i]); preview->filter_cache[i] = rs_filter_new("RSCache", preview->filter_denoise[i]); @@ -419,7 +411,6 @@ if (preview->photo) { g_signal_connect(G_OBJECT(preview->photo), "settings-changed", G_CALLBACK(settings_changed), preview); - g_signal_connect(G_OBJECT(preview->photo), "spatial-changed", G_CALLBACK(spatial_changed), preview); for(view=0;viewviews;view++) { - g_object_set(preview->filter_input[view], "image", preview->photo->input, NULL); - g_object_set(preview->filter_rotate[view], "angle", preview->photo->angle, "orientation", preview->photo->orientation, NULL); - g_object_set(preview->filter_crop[view], "rectangle", preview->photo->crop, NULL); g_object_set(preview->filter_denoise[view], "sharpen", (gint) (preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen), NULL); rescale(preview, view); } @@ -439,6 +427,22 @@ } /** + * Set input filter for a RSPreviewWidget + * @param preview A RSPreviewWidget + * @param filter A filter to listen for + */ +void +rs_preview_widget_set_filter(RSPreviewWidget *preview, RSFilter *filter) +{ + g_assert(RS_IS_PREVIEW_WIDGET(preview)); + g_assert(RS_IS_FILTER(filter)); + + preview->filter_input = filter; + rs_filter_set_previous(preview->filter_resample[0], preview->filter_input); + rescale(preview, 0); +} + +/** * Sets the CMS transform function used * @param preview A RSPreviewWidget * @param transform The transform to use @@ -725,7 +729,7 @@ g_assert(RS_IS_PREVIEW_WIDGET(preview)); - if (!preview->photo) + if (rs_filter_get_width(preview->filter_input) < 0) return; if (!GTK_WIDGET_DRAWABLE(GTK_WIDGET(preview))) @@ -893,11 +897,8 @@ if (preview->photo->crop) { - gint view; preview->roi = *preview->photo->crop; rs_photo_set_crop(preview->photo, NULL); - for(view=0;viewviews;view++) - g_object_set(preview->filter_crop[view], "rectangle", NULL, NULL); preview->state = CROP_IDLE; rs_preview_widget_update(preview, TRUE); } @@ -912,18 +913,11 @@ void rs_preview_widget_uncrop(RSPreviewWidget *preview) { - gint view; - g_assert(RS_IS_PREVIEW_WIDGET(preview)); if (!preview->photo) return; rs_photo_set_crop(preview->photo, NULL); - - for(view=0;viewviews;view++) - g_object_set(preview->filter_crop[view], "rectangle", NULL, NULL); - - /* FIXME: Manual redraw might be needed? */ } /** @@ -948,12 +942,9 @@ void rs_preview_widget_unstraighten(RSPreviewWidget *preview) { - gint view; g_assert(RS_IS_PREVIEW_WIDGET(preview)); - preview->photo->angle = 0.0f; - for(view=0;viewviews;view++) - g_object_set(preview->filter_rotate[view], "angle", 0.0, NULL); + rs_photo_set_angle(preview->photo, 0.0, FALSE); } static void @@ -1128,7 +1119,7 @@ g_return_if_fail(VIEW_IS_VALID(view)); - if (!preview->photo) + if (rs_filter_get_width(preview->filter_input) < 0) return; if (!ISDIRTY(preview->dirty[view], BUFFER)) @@ -1139,6 +1130,9 @@ source = rs_filter_get_image(preview->filter_end[view]); + if (!RS_IS_IMAGE16(source)) + return; + width = source->w; height = source->h; @@ -1187,22 +1181,22 @@ /* FIXME: This is outdated */ - if (!preview->photo) - return; - g_return_if_fail(VIEW_IS_VALID(view)); get_max_size(preview, &max_width, &max_height); - rs_image16_transform_getwh(preview->photo->input, preview->photo->crop, preview->photo->angle, preview->photo->orientation, &width, &height); + width = rs_filter_get_width(preview->filter_input); + height = rs_filter_get_height(preview->filter_input); + if (width < 0) + return; + width = MIN(width, max_width); height = MIN(height, max_height); - /* FIXME: Don't expect crop to be previous */ - preview->scale = ((gfloat) width) / ((gfloat) rs_filter_get_width(preview->filter_crop[0])); - preview->scale = MIN(preview->scale, ((gfloat) height) / ((gfloat) rs_filter_get_height(preview->filter_crop[0]))); - width = preview->scale * rs_filter_get_width(preview->filter_crop[0]); - height = preview->scale * rs_filter_get_height(preview->filter_crop[0]); + preview->scale = ((gfloat) width) / ((gfloat) rs_filter_get_width(preview->filter_input)); + preview->scale = MIN(preview->scale, ((gfloat) height) / ((gfloat) rs_filter_get_height(preview->filter_input))); + width = preview->scale * rs_filter_get_width(preview->filter_input); + height = preview->scale * rs_filter_get_height(preview->filter_input); if (preview->zoom_to_fit) g_object_set(preview->filter_resample[view], "width", width, @@ -1214,8 +1208,8 @@ GUI_CATCHUP(); gdouble upper; g_object_set(preview->filter_resample[view], - "width", rs_filter_get_width(preview->filter_crop[0]), - "height", rs_filter_get_height(preview->filter_crop[0]), + "width", rs_filter_get_width(preview->filter_input), + "height", rs_filter_get_height(preview->filter_input), NULL); preview->scale = 1.0; gdk_window_set_cursor(GTK_WIDGET(rawstudio_window)->window, NULL); @@ -1228,9 +1222,10 @@ } /* Update sharpen */ - g_object_set(preview->filter_denoise[view], - "sharpen", (gint) (preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen + 0.5), - NULL); + if (preview->photo) + g_object_set(preview->filter_denoise[view], + "sharpen", (gint) (preview->scale * preview->photo->settings[preview->snapshot[view]]->sharpen + 0.5), + NULL); } static void @@ -1785,14 +1780,10 @@ && (event->button==1) && (preview->state & STRAIGHTEN_MOVE)) { - gint i; preview->straighten_end.x = (gint) (event->x+0.5f); preview->straighten_end.y = (gint) (event->y+0.5f); - preview->photo->angle += preview->straighten_angle; preview->state = WB_PICKER; - - for(i=0;ifilter_rotate[view], "angle", preview->photo->angle, NULL); + rs_photo_set_angle(preview->photo, preview->straighten_angle, TRUE); } return FALSE; } @@ -2081,17 +2072,6 @@ } static void -spatial_changed(RS_PHOTO *photo, RSPreviewWidget *preview) -{ - gint view; - for(view=0;viewviews; view++) - { - g_object_set(preview->filter_rotate[view], "angle", photo->angle, "orientation", photo->orientation, NULL); - g_object_set(preview->filter_crop[view], "rectangle", photo->crop, NULL); - } -} - -static void filter_changed(RSFilter *filter, RSPreviewWidget *preview) { gint view; @@ -2103,6 +2083,7 @@ { DIRTY(preview->dirty[view], BUFFER); DIRTY(preview->dirty[view], SCREEN); + rescale(preview, 0); rs_preview_widget_update(preview, TRUE); } } @@ -2172,11 +2153,8 @@ DIRTY(preview->dirty[view], SCREEN); if (accept) - { rs_photo_set_crop(preview->photo, &preview->roi); - for(view=0;viewviews;view++) - g_object_set(preview->filter_crop[view], "rectangle", &preview->roi, NULL); - } + gtk_widget_destroy(preview->tool); preview->state = WB_PICKER; Modified: trunk/src/rs-preview-widget.h =================================================================== --- trunk/src/rs-preview-widget.h 2009-03-29 16:37:28 UTC (rev 2282) +++ trunk/src/rs-preview-widget.h 2009-03-29 16:57:14 UTC (rev 2283) @@ -87,6 +87,13 @@ extern void rs_preview_widget_set_photo(RSPreviewWidget *preview, RS_PHOTO *photo); /** + * Set input filter for a RSPreviewWidget + * @param preview A RSPreviewWidget + * @param filter A filter to listen for + */ +extern void rs_preview_widget_set_filter(RSPreviewWidget *preview, RSFilter *filter); + +/** * Sets the CMS transform function used * @param preview A RSPreviewWidget * @param transform The transform to use From anders at brander.dk Sun Mar 29 19:17:24 2009 From: anders at brander.dk (Anders Brander) Date: Sun, 29 Mar 2009 19:17:24 +0200 Subject: [Rawstudio-commit] r2284 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-29 19:17:23 +0200 (Sun, 29 Mar 2009) New Revision: 2284 Modified: trunk/librawstudio/rs-color-transform.c Log: Added an assertion to rs_color_transform_set_from_settings(). Modified: trunk/librawstudio/rs-color-transform.c =================================================================== --- trunk/librawstudio/rs-color-transform.c 2009-03-29 16:57:14 UTC (rev 2283) +++ trunk/librawstudio/rs-color-transform.c 2009-03-29 17:17:23 UTC (rev 2284) @@ -203,6 +203,7 @@ gboolean update_tables = FALSE; g_assert(rct != NULL); + g_assert(RS_IS_SETTINGS(settings)); if (mask & (MASK_EXPOSURE|MASK_SATURATION|MASK_HUE)) { From anders at brander.dk Mon Mar 30 01:45:58 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 30 Mar 2009 01:45:58 +0200 Subject: [Rawstudio-commit] r2285 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-30 01:45:58 +0200 (Mon, 30 Mar 2009) New Revision: 2285 Modified: trunk/librawstudio/rs-filter.c trunk/librawstudio/rs-filter.h Log: Added get_image8() method to RSFilterClass. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-03-29 17:17:23 UTC (rev 2284) +++ trunk/librawstudio/rs-filter.c 2009-03-29 23:45:58 UTC (rev 2285) @@ -50,6 +50,7 @@ G_TYPE_NONE, 0); klass->get_image = NULL; + klass->get_image8 = NULL; klass->get_width = NULL; klass->get_height = NULL; klass->previous_changed = NULL; @@ -189,6 +190,55 @@ } /** + * Get 8 bit output image from a RSFilter + * @param filter A RSFilter + * @return A RS_IMAGE16, this must be unref'ed + */ +GdkPixbuf * +rs_filter_get_image8(RSFilter *filter) +{ + filter_debug("rs_filter_get_image8(%s [%p])", RS_FILTER_NAME(filter), filter); + + /* This timer-hack will break badly when multithreaded! */ + static gfloat last_elapsed = 0.0; + static count = -1; + gfloat elapsed; + static GTimer *gt = NULL; + + GdkPixbuf *image = NULL; + g_assert(RS_IS_FILTER(filter)); + + if (count == -1) + gt = g_timer_new(); + count++; + + if (RS_FILTER_GET_CLASS(filter)->get_image8) + image = RS_FILTER_GET_CLASS(filter)->get_image8(filter); + else if (filter->previous) + image = rs_filter_get_image8(filter->previous); + + elapsed = g_timer_elapsed(gt, NULL) - last_elapsed; + + printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); + if ((elapsed > 0.001) && (image != NULL)) + printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(gdk_pixbuf_get_width(image)*gdk_pixbuf_get_height(image)))/elapsed/1000000.0); + printf("\n"); + last_elapsed += elapsed; + + g_assert(GDK_IS_PIXBUF(image) || (image == NULL)); + + count--; + if (count == -1) + { + last_elapsed = 0.0; + printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); + g_timer_destroy(gt); + } + + return image; +} + +/** * Get the returned width of a RSFilter * @param filter A RSFilter * @return Width in pixels Modified: trunk/librawstudio/rs-filter.h =================================================================== --- trunk/librawstudio/rs-filter.h 2009-03-29 17:17:23 UTC (rev 2284) +++ trunk/librawstudio/rs-filter.h 2009-03-29 23:45:58 UTC (rev 2285) @@ -83,6 +83,7 @@ GObjectClass parent_class; const gchar *name; RS_IMAGE16 *(*get_image)(RSFilter *filter); + GdkPixbuf *(*get_image8)(RSFilter *filter); gint (*get_width)(RSFilter *filter); gint (*get_height)(RSFilter *filter); void (*previous_changed)(RSFilter *filter, RSFilter *parent); @@ -120,6 +121,14 @@ extern RS_IMAGE16 *rs_filter_get_image(RSFilter *filter); /** + * Get 8 bit output image from a RSFilter + * @param filter A RSFilter + * @return A RS_IMAGE16, this must be unref'ed + */ +GdkPixbuf * +rs_filter_get_image8(RSFilter *filter); + +/** * Get the returned width of a RSFilter * @param filter A RSFilter * @return Width in pixels From anders at brander.dk Mon Mar 30 01:48:38 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 30 Mar 2009 01:48:38 +0200 Subject: [Rawstudio-commit] r2285 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-30 01:45:58 +0200 (Mon, 30 Mar 2009) New Revision: 2285 Modified: trunk/librawstudio/rs-filter.c trunk/librawstudio/rs-filter.h Log: Added get_image8() method to RSFilterClass. Modified: trunk/librawstudio/rs-filter.c =================================================================== --- trunk/librawstudio/rs-filter.c 2009-03-29 17:17:23 UTC (rev 2284) +++ trunk/librawstudio/rs-filter.c 2009-03-29 23:45:58 UTC (rev 2285) @@ -50,6 +50,7 @@ G_TYPE_NONE, 0); klass->get_image = NULL; + klass->get_image8 = NULL; klass->get_width = NULL; klass->get_height = NULL; klass->previous_changed = NULL; @@ -189,6 +190,55 @@ } /** + * Get 8 bit output image from a RSFilter + * @param filter A RSFilter + * @return A RS_IMAGE16, this must be unref'ed + */ +GdkPixbuf * +rs_filter_get_image8(RSFilter *filter) +{ + filter_debug("rs_filter_get_image8(%s [%p])", RS_FILTER_NAME(filter), filter); + + /* This timer-hack will break badly when multithreaded! */ + static gfloat last_elapsed = 0.0; + static count = -1; + gfloat elapsed; + static GTimer *gt = NULL; + + GdkPixbuf *image = NULL; + g_assert(RS_IS_FILTER(filter)); + + if (count == -1) + gt = g_timer_new(); + count++; + + if (RS_FILTER_GET_CLASS(filter)->get_image8) + image = RS_FILTER_GET_CLASS(filter)->get_image8(filter); + else if (filter->previous) + image = rs_filter_get_image8(filter->previous); + + elapsed = g_timer_elapsed(gt, NULL) - last_elapsed; + + printf("%s took: \033[32m%.0f\033[0mms", RS_FILTER_NAME(filter), elapsed*1000); + if ((elapsed > 0.001) && (image != NULL)) + printf(" [\033[33m%.01f\033[0mMpix/s]", ((gfloat)(gdk_pixbuf_get_width(image)*gdk_pixbuf_get_height(image)))/elapsed/1000000.0); + printf("\n"); + last_elapsed += elapsed; + + g_assert(GDK_IS_PIXBUF(image) || (image == NULL)); + + count--; + if (count == -1) + { + last_elapsed = 0.0; + printf("Complete chain took: \033[32m%.0f\033[0mms\n\n", g_timer_elapsed(gt, NULL)*1000.0); + g_timer_destroy(gt); + } + + return image; +} + +/** * Get the returned width of a RSFilter * @param filter A RSFilter * @return Width in pixels Modified: trunk/librawstudio/rs-filter.h =================================================================== --- trunk/librawstudio/rs-filter.h 2009-03-29 17:17:23 UTC (rev 2284) +++ trunk/librawstudio/rs-filter.h 2009-03-29 23:45:58 UTC (rev 2285) @@ -83,6 +83,7 @@ GObjectClass parent_class; const gchar *name; RS_IMAGE16 *(*get_image)(RSFilter *filter); + GdkPixbuf *(*get_image8)(RSFilter *filter); gint (*get_width)(RSFilter *filter); gint (*get_height)(RSFilter *filter); void (*previous_changed)(RSFilter *filter, RSFilter *parent); @@ -120,6 +121,14 @@ extern RS_IMAGE16 *rs_filter_get_image(RSFilter *filter); /** + * Get 8 bit output image from a RSFilter + * @param filter A RSFilter + * @return A RS_IMAGE16, this must be unref'ed + */ +GdkPixbuf * +rs_filter_get_image8(RSFilter *filter); + +/** * Get the returned width of a RSFilter * @param filter A RSFilter * @return Width in pixels From anders at brander.dk Mon Mar 30 01:49:37 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 30 Mar 2009 01:49:37 +0200 Subject: [Rawstudio-commit] r2286 - trunk/plugins/cache Message-ID: Author: abrander Date: 2009-03-30 01:49:37 +0200 (Mon, 30 Mar 2009) New Revision: 2286 Modified: trunk/plugins/cache/cache.c Log: Added get_image8() support to RSCache. Modified: trunk/plugins/cache/cache.c =================================================================== --- trunk/plugins/cache/cache.c 2009-03-29 23:45:58 UTC (rev 2285) +++ trunk/plugins/cache/cache.c 2009-03-29 23:49:37 UTC (rev 2286) @@ -33,6 +33,7 @@ RSFilter parent; RS_IMAGE16 *image; + GdkPixbuf *image8; gboolean ignore_changed; gint latency; }; @@ -51,6 +52,7 @@ static void get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); static void set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); static RS_IMAGE16 *get_image(RSFilter *filter); +static GdkPixbuf *get_image8(RSFilter *filter); static void previous_changed(RSFilter *filter, RSFilter *parent); G_MODULE_EXPORT void @@ -77,6 +79,7 @@ filter_class->name = "Listen for changes and caches image data"; filter_class->get_image = get_image; + filter_class->get_image8 = get_image8; filter_class->previous_changed = previous_changed; } @@ -84,6 +87,7 @@ rs_cache_init(RSCache *cache) { cache->image = NULL; + cache->image8 = NULL; cache->ignore_changed = FALSE; cache->latency = 1; } @@ -129,6 +133,17 @@ return (cache->image) ? g_object_ref(cache->image) : NULL; } +static GdkPixbuf * +get_image8(RSFilter *filter) +{ + RSCache *cache = RS_CACHE(filter); + + if (!cache->image8) + cache->image8 = rs_filter_get_image8(filter->previous); + + return (cache->image8) ? g_object_ref(cache->image8) : NULL; +} + static gboolean previous_changed_timeout_func(gpointer data) { @@ -149,6 +164,11 @@ cache->image = NULL; + if (cache->image8) + g_object_unref(cache->image8); + + cache->image8 = NULL; + if (cache->latency > 0) { if (!cache->ignore_changed) From anders at brander.dk Mon Mar 30 02:07:04 2009 From: anders at brander.dk (Anders Brander) Date: Mon, 30 Mar 2009 02:07:04 +0200 Subject: [Rawstudio-commit] r2287 - trunk/src Message-ID: Author: abrander Date: 2009-03-30 02:07:03 +0200 (Mon, 30 Mar 2009) New Revision: 2287 Modified: trunk/src/application.c Log: Added a RSCache after RSCrop in RS_BLOB. Modified: trunk/src/application.c =================================================================== --- trunk/src/application.c 2009-03-29 23:49:37 UTC (rev 2286) +++ trunk/src/application.c 2009-03-30 00:07:03 UTC (rev 2287) @@ -357,8 +357,10 @@ cache = rs_filter_new("RSCache", rs->filter_demosaic); rs->filter_rotate = rs_filter_new("RSRotate", cache); rs->filter_crop = rs_filter_new("RSCrop", rs->filter_rotate); - rs->filter_end = rs->filter_crop; + cache = rs_filter_new("RSCache", rs->filter_crop); + rs->filter_end = cache; + return(rs); } From anders at kvistmail.dk Tue Mar 31 01:54:20 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Tue, 31 Mar 2009 01:54:20 +0200 Subject: [Rawstudio-commit] r2288 - trunk/plugins/lensfun Message-ID: Author: akv Date: 2009-03-31 01:54:20 +0200 (Tue, 31 Mar 2009) New Revision: 2288 Modified: trunk/plugins/lensfun/lensfun.c Log: changed "lens" to "lens_make" and added "lens_model" as we need to specify make of lens too. Modified: trunk/plugins/lensfun/lensfun.c =================================================================== --- trunk/plugins/lensfun/lensfun.c 2009-03-30 00:07:03 UTC (rev 2287) +++ trunk/plugins/lensfun/lensfun.c 2009-03-30 23:54:20 UTC (rev 2288) @@ -35,7 +35,8 @@ gchar *make; gchar *model; - gchar *lens; + gchar *lens_make; + gchar *lens_model; gfloat focal; gfloat aperture; }; @@ -50,7 +51,8 @@ PROP_0, PROP_MAKE, PROP_MODEL, - PROP_LENS, + PROP_LENS_MAKE, + PROP_LENS_MODEL, PROP_FOCAL, PROP_APERTURE, }; @@ -90,11 +92,16 @@ NULL, G_PARAM_READWRITE) ); g_object_class_install_property(object_class, - PROP_LENS, g_param_spec_string( - "lens", "lens", "The lens of the camera (ie. \"Canon EF-S 18-55mm f/3.5-5.6\")", + PROP_LENS_MAKE, g_param_spec_string( + "lens_make", "lens_make", "The make of the lens (ie. \"Canon\")", NULL, G_PARAM_READWRITE) ); g_object_class_install_property(object_class, + PROP_LENS_MODEL, g_param_spec_string( + "lens_model", "lens_model", "The model of the lens (ie. \"Canon EF-S 18-55mm f/3.5-5.6\")", + NULL, G_PARAM_READWRITE) + ); + g_object_class_install_property(object_class, PROP_FOCAL, g_param_spec_float( "focal", "focal", "focal", 0.0, G_MAXFLOAT, 50.0, G_PARAM_READWRITE) @@ -114,7 +121,8 @@ { lensfun->make = NULL; lensfun->model = NULL; - lensfun->lens = NULL; + lensfun->lens_make = NULL; + lensfun->lens_model = NULL; lensfun->focal = 50.0; /* Well... */ lensfun->aperture = 5.6; } @@ -132,9 +140,12 @@ case PROP_MODEL: g_value_set_string(value, lensfun->model); break; - case PROP_LENS: - g_value_set_string(value, lensfun->lens); + case PROP_LENS_MAKE: + g_value_set_string(value, lensfun->lens_make); break; + case PROP_LENS_MODEL: + g_value_set_string(value, lensfun->lens_model); + break; case PROP_FOCAL: g_value_set_float(value, lensfun->focal); break; @@ -161,10 +172,14 @@ g_free(lensfun->model); lensfun->model = g_value_dup_string(value); break; - case PROP_LENS: - g_free(lensfun->lens); - lensfun->lens = g_value_dup_string(value); + case PROP_LENS_MAKE: + g_free(lensfun->lens_make); + lensfun->lens_make = g_value_dup_string(value); break; + case PROP_LENS_MODEL: + g_free(lensfun->lens_model); + lensfun->lens_model = g_value_dup_string(value); + break; case PROP_FOCAL: lensfun->focal = g_value_get_float(value); break; @@ -185,7 +200,7 @@ input = rs_filter_get_image(filter->previous); - gint i, row, col; + gint i, j, row, col; lfDatabase *ldb = lf_db_new (); if (!ldb) @@ -219,8 +234,8 @@ } const lfLens **lenses = NULL; - if (lensfun->lens) - lenses = lf_db_find_lenses_hd(ldb, cameras[0], lensfun->make, lensfun->lens, 0); + if (lensfun->lens_make && lensfun->lens_model) + lenses = lf_db_find_lenses_hd(ldb, cameras[0], lensfun->lens_make, lensfun->lens_model, 0); if (!lenses) { @@ -228,6 +243,21 @@ return NULL; } + for (i = 0; lenses [i]; i++) + { + g_print ("Lens: %s / %s\n", + lf_mlstr_get (lenses [i]->Maker), + lf_mlstr_get (lenses [i]->Model)); + g_print ("\tCrop factor: %g\n", lenses [i]->CropFactor); + g_print ("\tFocal: %g-%g\n", lenses [i]->MinFocal, lenses [i]->MaxFocal); + g_print ("\tAperture: %g-%g\n", lenses [i]->MinAperture, lenses [i]->MaxAperture); + g_print ("\tCenter: %g,%g\n", lenses [i]->CenterX, lenses [i]->CenterY); + g_print ("\tCCI: %g/%g/%g\n", lenses [i]->RedCCI, lenses [i]->GreenCCI, lenses [i]->BlueCCI); + if (lenses [i]->Mounts) + for (j = 0; lenses [i]->Mounts [j]; j++) + g_print ("\tMount: %s\n", lf_db_mount_name (ldb, lenses [i]->Mounts [j])); + } + const lfLens *lens = lenses [0]; lf_free (lenses); From anders at brander.dk Tue Mar 31 18:30:25 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 31 Mar 2009 18:30:25 +0200 Subject: [Rawstudio-commit] r2289 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-31 18:30:24 +0200 (Tue, 31 Mar 2009) New Revision: 2289 Modified: trunk/librawstudio/rs-metadata.c trunk/librawstudio/rs-metadata.h Log: Added lens data to RSMetadata. Modified: trunk/librawstudio/rs-metadata.c =================================================================== --- trunk/librawstudio/rs-metadata.c 2009-03-30 23:54:20 UTC (rev 2288) +++ trunk/librawstudio/rs-metadata.c 2009-03-31 16:30:24 UTC (rev 2289) @@ -97,6 +97,13 @@ metadata->cam_mul[i] = 1.0f; matrix4_identity(&metadata->adobe_coeff); metadata->thumbnail = NULL; + + /* Lens info */ + metadata->lens_min_focal = -1.0; + metadata->lens_max_focal = -1.0; + metadata->lens_min_aperture = -1.0; + metadata->lens_max_aperture = -1.0; + metadata->lens_identifier = NULL; } RSMetadata* @@ -105,7 +112,7 @@ return g_object_new (RS_TYPE_METADATA, NULL); } -#define METACACHEVERSION 1 +#define METACACHEVERSION 2 static void rs_metadata_cache_save(RSMetadata *metadata, const gchar *filename) { @@ -158,6 +165,16 @@ xmlTextWriterWriteFormatElement(writer, BAD_CAST "color_tone", "%f", metadata->color_tone); if (metadata->focallength > 0) xmlTextWriterWriteFormatElement(writer, BAD_CAST "focallength", "%d", metadata->focallength); + if (metadata->lens_min_focal > -1.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "lens_min_focal", "%f", metadata->lens_min_focal); + if (metadata->lens_max_focal > -1.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "lens_max_focal", "%f", metadata->lens_max_focal); + if (metadata->lens_min_aperture > -1.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "lens_min_aperture", "%f", metadata->lens_min_aperture); + if (metadata->lens_max_aperture > -1.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "lens_max_aperture", "%f", metadata->lens_max_aperture); + if (metadata->lens_identifier) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "lens_identifier", metadata->lens_identifier); xmlTextWriterEndDocument(writer); xmlFreeTextWriter(writer); } @@ -318,6 +335,36 @@ metadata->focallength = atoi((gchar *) val); xmlFree(val); } + else if ((!xmlStrcmp(cur->name, BAD_CAST "lens_min_focal"))) + { + val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + metadata->lens_min_focal = atoi((gchar *) val); + xmlFree(val); + } + else if ((!xmlStrcmp(cur->name, BAD_CAST "lens_max_focal"))) + { + val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + metadata->lens_max_focal = atoi((gchar *) val); + xmlFree(val); + } + else if ((!xmlStrcmp(cur->name, BAD_CAST "lens_min_aperture"))) + { + val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + metadata->lens_min_aperture = atoi((gchar *) val); + xmlFree(val); + } + else if ((!xmlStrcmp(cur->name, BAD_CAST "lens_max_aperture"))) + { + val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + metadata->lens_max_aperture = atoi((gchar *) val); + xmlFree(val); + } + else if ((!xmlStrcmp(cur->name, BAD_CAST "lens_identifier"))) + { + val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + metadata->lens_identifier = g_strdup((gchar *)val); + xmlFree(val); + } cur = cur->next; } Modified: trunk/librawstudio/rs-metadata.h =================================================================== --- trunk/librawstudio/rs-metadata.h 2009-03-30 23:54:20 UTC (rev 2288) +++ trunk/librawstudio/rs-metadata.h 2009-03-31 16:30:24 UTC (rev 2289) @@ -76,6 +76,13 @@ gshort focallength; RS_MATRIX4 adobe_coeff; GdkPixbuf *thumbnail; + + /* Lens info */ + gdouble lens_min_focal; + gdouble lens_max_focal; + gdouble lens_min_aperture; + gdouble lens_max_aperture; + gchar *lens_identifier; }; typedef struct { From anders at brander.dk Tue Mar 31 19:43:50 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 31 Mar 2009 19:43:50 +0200 Subject: [Rawstudio-commit] r2290 - trunk/src Message-ID: Author: abrander Date: 2009-03-31 19:43:49 +0200 (Tue, 31 Mar 2009) New Revision: 2290 Modified: trunk/src/rs-batch.c Log: Now building correct batch-queue.xml filename. Modified: trunk/src/rs-batch.c =================================================================== --- trunk/src/rs-batch.c 2009-03-31 16:30:24 UTC (rev 2289) +++ trunk/src/rs-batch.c 2009-03-31 17:43:49 UTC (rev 2290) @@ -89,13 +89,7 @@ g_assert(queue != NULL); if (!batch_queue_filename) - { - const gchar *confdir = rs_confdir_get(); - GString *gs = g_string_new(confdir); - g_string_append(gs, "batch-queue.xml"); - batch_queue_filename = gs->str; - g_string_free(gs, FALSE); - } + batch_queue_filename = g_build_filename(rs_confdir_get(), "batch-queue.xml", NULL); if (!g_file_test(batch_queue_filename, G_FILE_TEST_IS_REGULAR)) return; From anders at kvistmail.dk Tue Mar 31 22:03:46 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Tue, 31 Mar 2009 22:03:46 +0200 Subject: [Rawstudio-commit] r2291 - trunk/plugins/meta-tiff Message-ID: Author: akv Date: 2009-03-31 22:03:46 +0200 (Tue, 31 Mar 2009) New Revision: 2291 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: Added reading of lens identifiers from metadata for CR2. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-31 17:43:49 UTC (rev 2290) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-31 20:03:46 UTC (rev 2291) @@ -52,6 +52,7 @@ static gfloat get_rational(RAWFILE *rawfile, guint offset); inline static void read_ifd(RAWFILE *rawfile, guint offset, struct IFD *ifd); +static gint CanonEv(gint val); static gboolean makernote_canon(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean makernote_leica(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean makernote_minolta(RAWFILE *rawfile, guint offset, RSMetadata *meta); @@ -185,6 +186,37 @@ } #endif +/* Rewritten from Exiftools - lib/Image/ExifTool/Canon.pm*/ +static gint +CanonEv(gint val) +{ + gint sign; + + /* temporarily make the number positive */ + if (val < 0) + { + val = -val; + sign = -1; + } + else + { + sign = 1; + } + + gint frac = val & 0x1f; + + /* remove fraction */ + val -= frac; + + /* Convert 1/3 and 2/3 codes */ + if (frac == 0x0c) + frac = 0x20 / 3; + else if (frac == 0x14) + frac = 0x40 / 3; + + return sign * (val + frac) / 0x20; +} + static gboolean makernote_canon(RAWFILE *rawfile, guint offset, RSMetadata *meta) { @@ -205,6 +237,52 @@ switch (ifd.tag) { + + case 0x0001: /* CanonCameraSettings */ + if (meta->make == MAKE_CANON) + { + gshort temp, focalunits; + + /* Lens ID */ + raw_get_short(rawfile, ifd.value_offset+44, &temp); + gfloat lens_id = (gfloat) temp; + + /* Focalunits */ + raw_get_short(rawfile, ifd.value_offset+50, &focalunits); + + /* Max Focal */ + raw_get_short(rawfile, ifd.value_offset+46, &temp); + meta->lens_max_focal = (gfloat) temp * (gfloat) focalunits; + + /* Min Focal */ + raw_get_short(rawfile, ifd.value_offset+48, &temp); + meta->lens_min_focal = (gfloat) temp * (gfloat) focalunits; + + /* Max Aperture */ + raw_get_short(rawfile, ifd.value_offset+52, &temp); + meta->lens_max_aperture = (gfloat) exp(CanonEv(temp)*log(2)/2); + + /* Min Aperture */ + raw_get_short(rawfile, ifd.value_offset+54, &temp); + meta->lens_min_aperture = (gfloat) exp(CanonEv(temp)*log(2)/2); + + /* Build identifier string */ + GString *identifier = g_string_new(""); + if (lens_id > 0) + g_string_append_printf(identifier, "ID:%.1f ",lens_id); + if (meta->lens_max_focal > 0) + g_string_append_printf(identifier, "maxF:%.0f ",meta->lens_max_focal); + if (meta->lens_min_focal > 0) + g_string_append_printf(identifier, "minF:%.0f ",meta->lens_min_focal); + if (meta->lens_max_aperture > 0) + g_string_append_printf(identifier, "maxF:%.1f ",meta->lens_max_aperture); + if (meta->lens_min_aperture > 0) + g_string_append_printf(identifier, "minF:%.0f ",meta->lens_min_aperture); + meta->lens_identifier = g_strdup(identifier->str); + g_string_free(identifier, TRUE); + + printf("identifier: %s\n",meta->lens_identifier); + } case 0x4001: /* white balance for mulpiple Canon cameras */ switch (ifd.count) { From anders at kvistmail.dk Tue Mar 31 22:57:36 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Tue, 31 Mar 2009 22:57:36 +0200 Subject: [Rawstudio-commit] r2292 - in trunk: librawstudio plugins/meta-tiff Message-ID: Author: akv Date: 2009-03-31 22:57:35 +0200 (Tue, 31 Mar 2009) New Revision: 2292 Modified: trunk/librawstudio/rs-utils.c trunk/librawstudio/rs-utils.h trunk/plugins/meta-tiff/tiff-meta.c Log: Moved CanonEv() from tiff-meta plugin to rs-utils.c|h. Modified: trunk/librawstudio/rs-utils.c =================================================================== --- trunk/librawstudio/rs-utils.c 2009-03-31 20:03:46 UTC (rev 2291) +++ trunk/librawstudio/rs-utils.c 2009-03-31 20:57:35 UTC (rev 2292) @@ -555,3 +555,34 @@ TEST_FILE_ACCESS(PACKAGE_DATA_DIR "/" PACKAGE "/rawstudio.gtkrc"); #undef TEST_FILE_ACCESS } + +/* Rewritten from Exiftools - lib/Image/ExifTool/Canon.pm*/ +gint +CanonEv(gint val) +{ + gint sign; + + /* temporarily make the number positive */ + if (val < 0) + { + val = -val; + sign = -1; + } + else + { + sign = 1; + } + + gint frac = val & 0x1f; + + /* remove fraction */ + val -= frac; + + /* Convert 1/3 and 2/3 codes */ + if (frac == 0x0c) + frac = 0x20 / 3; + else if (frac == 0x14) + frac = 0x40 / 3; + + return sign * (val + frac) / 0x20; +} Modified: trunk/librawstudio/rs-utils.h =================================================================== --- trunk/librawstudio/rs-utils.h 2009-03-31 20:03:46 UTC (rev 2291) +++ trunk/librawstudio/rs-utils.h 2009-03-31 20:57:35 UTC (rev 2292) @@ -148,4 +148,7 @@ extern void check_install(); +extern gint +CanonEv(gint val); + #endif /* RS_UTILS_H */ Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-31 20:03:46 UTC (rev 2291) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-31 20:57:35 UTC (rev 2292) @@ -52,7 +52,6 @@ static gfloat get_rational(RAWFILE *rawfile, guint offset); inline static void read_ifd(RAWFILE *rawfile, guint offset, struct IFD *ifd); -static gint CanonEv(gint val); static gboolean makernote_canon(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean makernote_leica(RAWFILE *rawfile, guint offset, RSMetadata *meta); static gboolean makernote_minolta(RAWFILE *rawfile, guint offset, RSMetadata *meta); @@ -186,37 +185,6 @@ } #endif -/* Rewritten from Exiftools - lib/Image/ExifTool/Canon.pm*/ -static gint -CanonEv(gint val) -{ - gint sign; - - /* temporarily make the number positive */ - if (val < 0) - { - val = -val; - sign = -1; - } - else - { - sign = 1; - } - - gint frac = val & 0x1f; - - /* remove fraction */ - val -= frac; - - /* Convert 1/3 and 2/3 codes */ - if (frac == 0x0c) - frac = 0x20 / 3; - else if (frac == 0x14) - frac = 0x40 / 3; - - return sign * (val + frac) / 0x20; -} - static gboolean makernote_canon(RAWFILE *rawfile, guint offset, RSMetadata *meta) { From anders at kvistmail.dk Tue Mar 31 22:58:32 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Tue, 31 Mar 2009 22:58:32 +0200 Subject: [Rawstudio-commit] r2293 - trunk/plugins/meta-tiff Message-ID: Author: akv Date: 2009-03-31 22:58:32 +0200 (Tue, 31 Mar 2009) New Revision: 2293 Modified: trunk/plugins/meta-tiff/tiff-meta.c Log: Removed debug line. Modified: trunk/plugins/meta-tiff/tiff-meta.c =================================================================== --- trunk/plugins/meta-tiff/tiff-meta.c 2009-03-31 20:57:35 UTC (rev 2292) +++ trunk/plugins/meta-tiff/tiff-meta.c 2009-03-31 20:58:32 UTC (rev 2293) @@ -248,8 +248,6 @@ g_string_append_printf(identifier, "minF:%.0f ",meta->lens_min_aperture); meta->lens_identifier = g_strdup(identifier->str); g_string_free(identifier, TRUE); - - printf("identifier: %s\n",meta->lens_identifier); } case 0x4001: /* white balance for mulpiple Canon cameras */ switch (ifd.count) From anders at kvistmail.dk Tue Mar 31 23:00:21 2009 From: anders at kvistmail.dk (Anders Kvist) Date: Tue, 31 Mar 2009 23:00:21 +0200 Subject: [Rawstudio-commit] r2294 - trunk/plugins/meta-ciff Message-ID: Author: akv Date: 2009-03-31 23:00:21 +0200 (Tue, 31 Mar 2009) New Revision: 2294 Modified: trunk/plugins/meta-ciff/ciff-meta.c Log: Added reading of lens identifiers from metadata for CRW. Modified: trunk/plugins/meta-ciff/ciff-meta.c =================================================================== --- trunk/plugins/meta-ciff/ciff-meta.c 2009-03-31 20:58:32 UTC (rev 2293) +++ trunk/plugins/meta-ciff/ciff-meta.c 2009-03-31 21:00:21 UTC (rev 2294) @@ -105,6 +105,45 @@ } raw_get_short(rawfile, absoffset+30, &temp); /* sharpness */ raw_get_short(rawfile, absoffset+84, &temp); /* color_tone */ + + gshort temp, focalunits; + + /* Lens ID */ + raw_get_short(rawfile, absoffset+44, &temp); + gfloat lens_id = (gfloat) temp; + /* Focalunits */ + raw_get_short(rawfile, absoffset+50, &focalunits); + + /* Max Focal */ + raw_get_short(rawfile, absoffset+46, &temp); + meta->lens_max_focal = (gfloat) temp * (gfloat) focalunits; + + /* Min Focal */ + raw_get_short(rawfile, absoffset+48, &temp); + meta->lens_min_focal = (gfloat) temp * (gfloat) focalunits; + + /* Max Aperture */ + raw_get_short(rawfile, absoffset+52, &temp); + meta->lens_max_aperture = (gfloat) exp(CanonEv(temp)*log(2)/2); + + /* Min Aperture */ + raw_get_short(rawfile, absoffset+54, &temp); + meta->lens_min_aperture = (gfloat) exp(CanonEv(temp)*log(2)/2); + + /* Build identifier string */ + GString *identifier = g_string_new(""); + if (lens_id > 0) + g_string_append_printf(identifier, "ID:%.1f ",lens_id); + if (meta->lens_max_focal > 0) + g_string_append_printf(identifier, "maxF:%.0f ",meta->lens_max_focal); + if (meta->lens_min_focal > 0) + g_string_append_printf(identifier, "minF:%.0f ",meta->lens_min_focal); + if (meta->lens_max_aperture > 0) + g_string_append_printf(identifier, "maxF:%.1f ",meta->lens_max_aperture); + if (meta->lens_min_aperture > 0) + g_string_append_printf(identifier, "minF:%.0f ",meta->lens_min_aperture); + meta->lens_identifier = g_strdup(identifier->str); + g_string_free(identifier, TRUE); break; case 0x2007: /* Preview image */ meta->preview_start = absoffset; From anders at brander.dk Tue Mar 31 23:06:03 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 31 Mar 2009 23:06:03 +0200 Subject: [Rawstudio-commit] r2295 - trunk/librawstudio Message-ID: Author: abrander Date: 2009-03-31 23:06:02 +0200 (Tue, 31 Mar 2009) New Revision: 2295 Added: trunk/librawstudio/rs-lens-db.c trunk/librawstudio/rs-lens-db.h trunk/librawstudio/rs-lens.c trunk/librawstudio/rs-lens.h Modified: trunk/librawstudio/Makefile.am trunk/librawstudio/rawstudio.h Log: Added RSLens and RSLensDb types. Modified: trunk/librawstudio/Makefile.am =================================================================== --- trunk/librawstudio/Makefile.am 2009-03-31 21:00:21 UTC (rev 2294) +++ trunk/librawstudio/Makefile.am 2009-03-31 21:06:02 UTC (rev 2295) @@ -14,6 +14,8 @@ rs-icc-profile.h \ rs-image.h \ rs-image16.h \ + rs-lens.h \ + rs-lens-db.h \ rs-metadata.h \ rs-filetypes.h \ rs-filter.h \ @@ -37,6 +39,8 @@ rs-icc-profile.c rs-icc-profile.h \ rs-image.c rs-image.h \ rs-image16.c rs-image16.h \ + rs-lens.c rs-lens.h \ + rs-lens-db.c rs-lens-db.h \ rs-metadata.c rs-metadata.h \ rs-filetypes.c rs-filetypes.h \ rs-filter.c rs-filter.h \ Modified: trunk/librawstudio/rawstudio.h =================================================================== --- trunk/librawstudio/rawstudio.h 2009-03-31 21:00:21 UTC (rev 2294) +++ trunk/librawstudio/rawstudio.h 2009-03-31 21:06:02 UTC (rev 2295) @@ -35,6 +35,8 @@ #include "rs-image.h" #include "rs-image16.h" #include "rs-metadata.h" +#include "rs-lens.h" +#include "rs-lens-db.h" #include "rs-filetypes.h" #include "rs-plugin.h" #include "rs-filter.h" Added: trunk/librawstudio/rs-lens-db.c =================================================================== --- trunk/librawstudio/rs-lens-db.c (rev 0) +++ trunk/librawstudio/rs-lens-db.c 2009-03-31 21:06:02 UTC (rev 2295) @@ -0,0 +1,331 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include "config.h" +#include "rs-lens-db.h" + +struct _RSLensDb { + GObject parent; + gboolean dispose_has_run; + + gchar *path; + GList *lenses; +}; + +static void open_db(RSLensDb *lens_db); + +G_DEFINE_TYPE (RSLensDb, rs_lens_db, G_TYPE_OBJECT) + +enum { + PROP_0, + PROP_PATH +}; + +static void +get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + RSLensDb *lens_db = RS_LENS_DB(object); + + switch (property_id) + { + case PROP_PATH: + g_value_set_string(value, lens_db->path); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + RSLensDb *lens_db = RS_LENS_DB(object); + + switch (property_id) + { + case PROP_PATH: + lens_db->path = g_value_dup_string(value); + open_db(lens_db); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +dispose(GObject *object) +{ + RSLensDb *lens_db = RS_LENS_DB(object); + + if (!lens_db->dispose_has_run) + { + g_free(lens_db->path); + lens_db->dispose_has_run = TRUE; + } + + G_OBJECT_CLASS (rs_lens_db_parent_class)->dispose (object); +} + +static void +rs_lens_db_class_init(RSLensDbClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = get_property; + object_class->set_property = set_property; + object_class->dispose = dispose; + + g_object_class_install_property(object_class, + PROP_PATH, g_param_spec_string( + "path", "Path", "Path to XML database", + NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); +} + +static void +rs_lens_db_init(RSLensDb *lens_db) +{ + lens_db->dispose_has_run = FALSE; + lens_db->path = NULL; + lens_db->lenses = NULL; +} + +static void +save_db(RSLensDb *lens_db) +{ + xmlTextWriterPtr writer; + GList *list; + + writer = xmlNewTextWriterFilename(lens_db->path, 0); + if (!writer) + return; + + xmlTextWriterSetIndent(writer, 1); + xmlTextWriterStartDocument(writer, NULL, "ISO-8859-1", NULL); + xmlTextWriterStartElement(writer, BAD_CAST "rawstudio-lens-database"); + + list = lens_db->lenses; + while (list) + { + gchar *identifier; + gchar *lensfun_identifier; + gdouble min_focal, max_focal, min_aperture, max_aperture; + + RSLens *lens = list->data; + + g_assert(RS_IS_LENS(lens)); + g_object_get(lens, + "identifier", &identifier, + "lensfun-identifier", &lensfun_identifier, + "min-focal", &min_focal, + "max-focal", &max_focal, + "min-aperture", &min_aperture, + "max-aperture", &max_aperture, + NULL); + + printf("min-focal: %.03f\n", min_focal); + xmlTextWriterStartElement(writer, BAD_CAST "lens"); + if (identifier) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "identifier", "%s", identifier); + if (lensfun_identifier) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "lensfun-identifier", "%s", lensfun_identifier); + if (min_focal > 0.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "min-focal", "%f", min_focal); + if (max_focal > 0.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "max-focal", "%f", max_focal); + if (min_aperture > 0.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "min-aperture", "%f", min_aperture); + if (max_aperture > 0.0) + xmlTextWriterWriteFormatElement(writer, BAD_CAST "max-aperture", "%f", max_aperture); + xmlTextWriterEndElement(writer); + + g_free(identifier); + g_free(lensfun_identifier); + + list = g_list_next (list); + } + + xmlTextWriterEndDocument(writer); + xmlFreeTextWriter(writer); + + return; +} + +static void +open_db(RSLensDb *lens_db) +{ + xmlDocPtr doc; + xmlNodePtr cur; + xmlNodePtr entry = NULL; + xmlChar *val; + + /* Some sanity checks */ + doc = xmlParseFile(lens_db->path); + if (!doc) + return; + + cur = xmlDocGetRootElement(doc); + if (cur && (xmlStrcmp(cur->name, BAD_CAST "rawstudio-lens-database") == 0)) + { + cur = cur->xmlChildrenNode; + while(cur) + { + if ((!xmlStrcmp(cur->name, BAD_CAST "lens"))) + { + RSLens *lens = rs_lens_new(); + + xmlChar *filename = NULL; + gint setting_id = -1; + + entry = cur->xmlChildrenNode; + + while (entry) + { + val = xmlNodeListGetString(doc, entry->xmlChildrenNode, 1); + if ((!xmlStrcmp(entry->name, BAD_CAST "identifier"))) + g_object_set(lens, "identifier", val, NULL); + else if ((!xmlStrcmp(entry->name, BAD_CAST "lensfun-identifier"))) + g_object_set(lens, "lensfun-identifier", val, NULL); + else if ((!xmlStrcmp(entry->name, BAD_CAST "min-focal"))) + g_object_set(lens, "min-focal", rs_atof(val), NULL); + else if ((!xmlStrcmp(entry->name, BAD_CAST "max-focal"))) + g_object_set(lens, "max-focal", rs_atof(val), NULL); + else if ((!xmlStrcmp(entry->name, BAD_CAST "min-aperture"))) + g_object_set(lens, "min-aperture", rs_atof(val), NULL); + else if ((!xmlStrcmp(entry->name, BAD_CAST "max-aperture"))) + g_object_set(lens, "max-aperture", rs_atof(val), NULL); + xmlFree(val); + entry = entry->next; + } + + lens_db->lenses = g_list_prepend(lens_db->lenses, lens); + } + cur = cur->next; + } + } + else + g_warning(PACKAGE " did not understand the format in %s", lens_db->path); + + xmlFreeDoc(doc); +} + +/** + * Instantiate a new RSLensDb + * @param path An absolute path to a XML-file containing the database + * @return A new RSLensDb with a refcount of 1 + */ +RSLensDb * +rs_lens_db_new(const char *path) +{ + g_assert(path != NULL); + g_assert(g_path_is_absolute(path)); + + return g_object_new (RS_TYPE_LENS_DB, "path", path, NULL); +} + +/** + * Get the default RSLensDb as used globally by Rawstudio + * @return A new RSLensDb, this should not be unref'ed after use! + */ +RSLensDb * +rs_lens_db_get_default(void) +{ + static GStaticMutex lock = G_STATIC_MUTEX_INIT; + static RSLensDb *lens_db = NULL; + + g_static_mutex_lock(&lock); + if (!lens_db) + { + gchar *path = g_build_filename(rs_confdir_get(), "lens-database.xml", NULL); + lens_db = rs_lens_db_new(path); + save_db(lens_db); + g_free(path); + } + g_static_mutex_unlock(&lock); + + return lens_db; +} + +/** + * Look up identifer in database + * @param lens_db A RSLensDb to search in + * @param identifier A lens identifier as generated by metadata subsystem + */ +RSLens * +rs_lens_db_get_from_identifier(RSLensDb *lens_db, const gchar *identifier) +{ + GList *list; + RSLens *lens, *ret = NULL; + + g_assert(RS_IS_LENS_DB(lens_db)); + g_assert(identifier != NULL); + + list = lens_db->lenses; + while (list) + { + gchar *rs_identifier = NULL; + lens = list->data; + + g_assert(RS_IS_LENS(lens)); + g_object_get(lens, "identifier", &rs_identifier, NULL); + + /* If we got a match, raise refcount by 1 and break out of the loop */ + if (g_str_equal(rs_identifier, identifier)) + { + ret = g_object_ref(lens); + break; + } + + list = g_list_next (list); + } + + return ret; +} + +/** + * Add a lens to the database - will only be added if the lens appear unique + * @param lens_db A RSLensDb + * @param lens A RSLens to add + */ +void * +rs_lens_db_add_lens(RSLensDb *lens_db, RSLens *lens) +{ + gchar *rs_identifier = NULL; + + g_assert(RS_IS_LENS_DB(lens_db)); + g_assert(RS_IS_LENS(lens)); + + g_object_get(lens, "identifier", &rs_identifier, NULL); + + if (rs_identifier) + { + RSLens *locallens = rs_lens_db_get_from_identifier(lens_db, rs_identifier); + + /* If we got a hit, no need to do anymore - we do not wan't duplicates */ + if (locallens) + g_object_unref(locallens); + else + { + lens_db->lenses = g_list_prepend(lens_db->lenses, g_object_ref(lens)); + save_db(lens_db); + } + } +} Added: trunk/librawstudio/rs-lens-db.h =================================================================== --- trunk/librawstudio/rs-lens-db.h (rev 0) +++ trunk/librawstudio/rs-lens-db.h 2009-03-31 21:06:02 UTC (rev 2295) @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef RS_LENS_DB_H +#define RS_LENS_DB_H + +#include +#include "rs-lens.h" + +G_BEGIN_DECLS + +#define RS_TYPE_LENS_DB rs_lens_db_get_type() +#define RS_LENS_DB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_LENS_DB, RSLensDb)) +#define RS_LENS_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_LENS_DB, RSLensDbClass)) +#define RS_IS_LENS_DB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_LENS_DB)) +#define RS_IS_LENS_DB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_LENS_DB)) +#define RS_LENS_DB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_LENS_DB, RSLensDbClass)) +GType rs_lens_db_get_type(void); + +typedef struct _RSLensDb RSLensDb; + +typedef struct { + GObjectClass parent_class; +} RSLensDbClass; + +/** + * Instantiate a new RSLensDb + * @param path An absolute path to a XML-file containing the database + * @return A new RSLensDb with a refcount of 1 + */ +RSLensDb * +rs_lens_db_new(const char *path); + +/** + * Get the default RSLensDb as used globally by Rawstudio + * @return A new RSLensDb, this should not be unref'ed after use! + */ +RSLensDb *rs_lens_db_get_default(void); + +/** + * Look up identifer in database + * @param lens_db A RSLensDb to search in + * @param identifier A lens identifier as generated by metadata subsystem + */ +RSLens *rs_lens_db_get_from_identifier(RSLensDb *lens_db, const gchar *identifier); + +/** + * Add a lens to the database - will only be added if the lens appear unique + * @param lens_db A RSLensDb + * @param lens A RSLens to add + */ +void *rs_lens_db_add_lens(RSLensDb *lens_db, RSLens *lens); + +G_END_DECLS + +#endif /* RS_LENS_DB_H */ Added: trunk/librawstudio/rs-lens.c =================================================================== --- trunk/librawstudio/rs-lens.c (rev 0) +++ trunk/librawstudio/rs-lens.c 2009-03-31 21:06:02 UTC (rev 2295) @@ -0,0 +1,214 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +struct _RSLens { + GObject parent; + gboolean dispose_has_run; + + gdouble min_focal; + gdouble max_focal; + gdouble min_aperture; + gdouble max_aperture; + gchar *identifier; + gchar *lensfun_identifier; +}; + +G_DEFINE_TYPE (RSLens, rs_lens, G_TYPE_OBJECT) + +enum { + PROP_0, + PROP_MIN_FOCAL, + PROP_MAX_FOCAL, + PROP_MIN_APERTURE, + PROP_MAX_APERTURE, + PROP_IDENTIFIER, + PROP_LENSFUN_IDENTIFIER +}; + +static void +get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) +{ + RSLens *lens = RS_LENS(object); + + switch (property_id) + { + case PROP_MIN_FOCAL: + g_value_set_double(value, lens->min_focal); + break; + case PROP_MAX_FOCAL: + g_value_set_double(value, lens->max_focal); + break; + case PROP_MIN_APERTURE: + g_value_set_double(value, lens->min_aperture); + break; + case PROP_MAX_APERTURE: + g_value_set_double(value, lens->max_aperture); + break; + case PROP_IDENTIFIER: + g_value_set_string(value, lens->identifier); + break; + case PROP_LENSFUN_IDENTIFIER: + g_value_set_string(value, lens->lensfun_identifier); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) +{ + RSLens *lens = RS_LENS(object); + + switch (property_id) + { + case PROP_MIN_FOCAL: + lens->min_focal = g_value_get_double(value); + break; + case PROP_MAX_FOCAL: + lens->max_focal = g_value_get_double(value); + break; + case PROP_MIN_APERTURE: + lens->min_aperture = g_value_get_double(value); + break; + case PROP_MAX_APERTURE: + lens->max_aperture = g_value_get_double(value); + break; + case PROP_IDENTIFIER: + g_free(lens->identifier); + lens->identifier = g_value_dup_string(value); + break; + case PROP_LENSFUN_IDENTIFIER: + g_free(lens->lensfun_identifier); + lens->lensfun_identifier = g_value_dup_string(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +dispose(GObject *object) +{ + RSLens *lens = RS_LENS(object); + + if (!lens->dispose_has_run) + { + g_free(lens->lensfun_identifier); + + lens->dispose_has_run = TRUE; + } + G_OBJECT_CLASS (rs_lens_parent_class)->dispose (object); +} + +static void +rs_lens_class_init(RSLensClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = get_property; + object_class->set_property = set_property; + object_class->dispose = dispose; + + g_object_class_install_property(object_class, + PROP_MIN_FOCAL, g_param_spec_double( + "min-focal", "min-focal", "Minimum focal", + -1.0, 20000.0, -1.0, G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_MAX_FOCAL, g_param_spec_double( + "max-focal", "max-focal", "Maximum focal", + -1.0, 20000.0, -1.0, G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_MIN_APERTURE, g_param_spec_double( + "min-aperture", "min-aperture", "Minimum aperture", + -1.0, 20000.0, -1.0, G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_MAX_APERTURE, g_param_spec_double( + "max-aperture", "max-aperture", "Maximum aperture", + -1.0, 20000.0, -1.0, G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_IDENTIFIER, g_param_spec_string( + "identifier", "Identifier", "Rawstudio generated lens identifier", + NULL, G_PARAM_READWRITE)); + + g_object_class_install_property(object_class, + PROP_LENSFUN_IDENTIFIER, g_param_spec_string( + "lensfun-identifier", "lensfun-identifier", "String helping Lensfun to identify the lens", + "", G_PARAM_READWRITE)); +} + +static void +rs_lens_init(RSLens *lens) +{ + lens->dispose_has_run = FALSE; + + lens->min_focal = -1.0; + lens->max_focal = -1.0; + lens->min_aperture = -1.0; + lens->max_aperture = -1.0; + lens->lensfun_identifier = NULL; +} + +/** + * Instantiate a new RSLens + * @return A new RSLens with a refcount of 1 + */ +RSLens * +rs_lens_new(void) +{ + return g_object_new (RS_TYPE_LENS, NULL); +} + +/** + * Instantiate a new RSLens from a RSMetadata + * @param metadata A RSMetadata type with lens information embedded + * @return A new RSLens with a refcount of 1 + */ +RSLens * +rs_lens_new_from_medadata(RSMetadata *metadata) +{ + g_assert(RS_IS_METADATA(metadata)); + + return g_object_new(RS_TYPE_LENS, + "identifier", metadata->lens_identifier, + "min-focal", metadata->lens_min_focal, + "max-focal", metadata->lens_max_focal, + "min-aperture", metadata->lens_min_aperture, + "max-aperture", metadata->lens_max_aperture, + NULL); +} + +/** + * Get the Lensfun idenfier from a RSLens + * @param lens A RSLens + * @return The identifier as used by Lensfun or NULL if unknown + */ +gchar * +rs_lens_get_lensfun_identifier(RSLens *lens) +{ + g_assert(RS_IS_LENS(lens)); + + return g_strdup(lens->lensfun_identifier); +} Added: trunk/librawstudio/rs-lens.h =================================================================== --- trunk/librawstudio/rs-lens.h (rev 0) +++ trunk/librawstudio/rs-lens.h 2009-03-31 21:06:02 UTC (rev 2295) @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2006-2009 Anders Brander and + * Anders Kvist + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef RS_LENS_H +#define RS_LENS_H + +#include +#include + +G_BEGIN_DECLS + +#define RS_TYPE_LENS rs_lens_get_type() +#define RS_LENS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RS_TYPE_LENS, RSLens)) +#define RS_LENS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RS_TYPE_LENS, RSLensClass)) +#define RS_IS_LENS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RS_TYPE_LENS)) +#define RS_IS_LENS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RS_TYPE_LENS)) +#define RS_LENS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RS_TYPE_LENS, RSLensClass)) +GType rs_lens_get_type(void); + +typedef struct _RSLens RSLens; + +typedef struct { + GObjectClass parent_class; +} RSLensClass; + +/** + * Instantiate a new RSLens + * @return A new RSLens with a refcount of 1 + */ +RSLens *rs_lens_new(void); + +/** + * Instantiate a new RSLens from a RSMetadata + * @param metadata A RSMetadata type with lens information embedded + * @return A new RSLens with a refcount of 1 + */ +RSLens *rs_lens_new_from_medadata(RSMetadata *metadata); + +/** + * Get the Lensfun idenfier from a RSLens + * @param lens A RSLens + * @return The identifier as used by Lensfun or NULL if unknown + */ +gchar *rs_lens_get_lensfun_identifier(RSLens *lens); + +G_END_DECLS + +#endif /* RS_LENS_H */ From anders at brander.dk Tue Mar 31 23:06:47 2009 From: anders at brander.dk (Anders Brander) Date: Tue, 31 Mar 2009 23:06:47 +0200 Subject: [Rawstudio-commit] r2296 - trunk/src Message-ID: Author: abrander Date: 2009-03-31 23:06:47 +0200 (Tue, 31 Mar 2009) New Revision: 2296 Modified: trunk/src/application.c Log: Try to populate lens database from rs_set_photo(). Modified: trunk/src/application.c =================================================================== --- trunk/src/application.c 2009-03-31 21:06:02 UTC (rev 2295) +++ trunk/src/application.c 2009-03-31 21:06:47 UTC (rev 2296) @@ -178,6 +178,15 @@ if (rs->photo) { + /* Try to add the lens to database */ + RSLensDb *lens_db = rs_lens_db_get_default(); + RSLens *lens = rs_lens_new_from_medadata(photo->metadata); + if (lens) + { + rs_lens_db_add_lens(lens_db, lens); + g_object_unref(lens); + } + g_signal_connect(G_OBJECT(rs->photo), "settings-changed", G_CALLBACK(photo_settings_changed), rs); g_signal_connect(G_OBJECT(rs->photo), "spatial-changed", G_CALLBACK(photo_spatial_changed), rs);