Hi! The DCP optimization was written about a month ago, but a bug gave some image corruption, so I had to debug it.
(Aparently 0 - 0 in float gives -0, and 0 * -0 still gives -0, which is not the same as 0 ;) But the rest is "realtime" :) Regards, Klaus Post http://www.klauspost.com On Sun, Sep 11, 2011 at 00:24, Erik Wognsen <[email protected]> wrote: > Do you guys usually work this fast or is it just some collected work being > committed? :-) > > > On Sat, Sep 10, 2011 at 22:22, Klaus Post <[email protected]> wrote: > >> Author: post >> Date: 2011-09-10 22:22:43 +0200 (Sat, 10 Sep 2011) >> New Revision: 4039 >> >> Modified: >> trunk/librawstudio/rs-lens-db-editor.c >> trunk/librawstudio/rs-lens-db-editor.h >> trunk/librawstudio/rs-lens-db.c >> trunk/librawstudio/rs-lens.c >> trunk/librawstudio/rs-lens.h >> trunk/plugins/lensfun/lensfun.c >> Log: >> Add option to lenses for correcting for fisheye effect. Selectable per >> lens. >> >> Modified: trunk/librawstudio/rs-lens-db-editor.c >> =================================================================== >> --- trunk/librawstudio/rs-lens-db-editor.c 2011-09-10 16:42:03 UTC >> (rev 4038) >> +++ trunk/librawstudio/rs-lens-db-editor.c 2011-09-10 20:22:43 UTC >> (rev 4039) >> @@ -46,6 +46,7 @@ >> GtkWidget *lensfun_model; >> GtkWidget *button; >> GtkWidget *checkbutton_enabled; >> + GtkWidget *checkbutton_defish; >> RSLens *lens; >> } SingleLensData; >> >> @@ -121,6 +122,7 @@ >> RS_LENS_DB_EDITOR_LENS_MODEL, lens->Model, >> RS_LENS_DB_EDITOR_ENABLED_ACTIVATABLE, TRUE, >> RS_LENS_DB_EDITOR_ENABLED, TRUE, >> + RS_LENS_DB_EDITOR_DEFISH, FALSE, >> -1); >> >> RSLens *rs_lens = NULL; >> @@ -132,6 +134,7 @@ >> rs_lens_set_lensfun_make(rs_lens, lens->Maker); >> rs_lens_set_lensfun_model(rs_lens, lens->Model); >> rs_lens_set_lensfun_enabled(rs_lens, TRUE); >> + rs_lens_set_lensfun_defish(rs_lens, FALSE); >> >> RSLensDb *lens_db = rs_lens_db_get_default(); >> >> @@ -489,6 +492,34 @@ >> } >> >> void >> +defish_clicked (GtkCellRendererToggle *cell_renderer_toggle, const gchar >> *path, gpointer user_data) >> +{ >> + GtkTreeIter iter; >> + gboolean enabled; >> + GtkTreeView *tree_view = GTK_TREE_VIEW(user_data); >> + GtkTreeModel *tree_model = gtk_tree_view_get_model(tree_view); >> + GtkTreePath* tree_path = gtk_tree_path_new_from_string(path); >> + >> + gtk_tree_model_get_iter(GTK_TREE_MODEL (tree_model), &iter, >> tree_path); >> + gtk_tree_model_get(GTK_TREE_MODEL (tree_model), &iter, >> RS_LENS_DB_EDITOR_DEFISH, &enabled, -1); >> + >> + gtk_list_store_set(GTK_LIST_STORE (tree_model), &iter, >> RS_LENS_DB_EDITOR_DEFISH, !enabled, -1); >> + >> + RSLens *rs_lens = NULL; >> + gtk_tree_model_get (tree_model, &iter, >> + RS_LENS_DB_EDITOR_LENS, &rs_lens, >> + -1); >> + >> + /* Set enabled/disabled to the selected RSLens */ >> + rs_lens_set_lensfun_defish(rs_lens, !enabled); >> + >> + RSLensDb *lens_db = rs_lens_db_get_default(); >> + >> + /* Force save of RSLensDb */ >> + rs_lens_db_save(lens_db); >> +} >> + >> +void >> update_lensfun(GtkButton *button, gpointer user_data) >> { >> GtkWidget *window = GTK_WIDGET(user_data); >> @@ -556,7 +587,7 @@ >> void >> rs_lens_db_editor(void) >> { >> - GtkTreeModel *tree_model = GTK_TREE_MODEL(gtk_list_store_new(10, >> G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, >> G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, >> G_TYPE_OBJECT)); >> + GtkTreeModel *tree_model = GTK_TREE_MODEL(gtk_list_store_new(11, >> G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, >> G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, >> G_TYPE_BOOLEAN, G_TYPE_OBJECT)); >> >> RSLensDb *lens_db = rs_lens_db_get_default(); >> fill_model(lens_db, tree_model); >> @@ -586,6 +617,7 @@ >> GtkCellRenderer *renderer_camera_make = >> gtk_cell_renderer_text_new(); >> GtkCellRenderer *renderer_camera_model = >> gtk_cell_renderer_text_new(); >> GtkCellRenderer *renderer_enabled = >> gtk_cell_renderer_toggle_new(); >> + GtkCellRenderer *renderer_defish = >> gtk_cell_renderer_toggle_new(); >> >> GtkTreeViewColumn *column_lens_make = >> gtk_tree_view_column_new_with_attributes (_("Lens make"), >> >> renderer_lens_make, >> @@ -616,6 +648,11 @@ >> "active", >> RS_LENS_DB_EDITOR_ENABLED, >> >> "activatable", RS_LENS_DB_EDITOR_ENABLED_ACTIVATABLE, >> >> NULL); >> + GtkTreeViewColumn *column_defish = >> gtk_tree_view_column_new_with_attributes (_("Defish"), >> + >> renderer_defish, >> + >> "active", RS_LENS_DB_EDITOR_DEFISH, >> + >> "activatable", RS_LENS_DB_EDITOR_ENABLED_ACTIVATABLE, >> + >> NULL); >> >> gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(tree_model), >> RS_LENS_DB_EDITOR_CAMERA_MODEL, GTK_SORT_ASCENDING); >> gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(tree_model), >> RS_LENS_DB_EDITOR_CAMERA_MODEL, rs_lens_db_editor_sort, NULL, NULL); >> @@ -625,6 +662,7 @@ >> >> g_signal_connect (renderer_enabled, "toggled", >> G_CALLBACK (toggle_clicked), view); >> + g_signal_connect (renderer_defish, "toggled", >> G_CALLBACK (defish_clicked), view); >> g_signal_connect(G_OBJECT(view), "button-press-event", >> G_CALLBACK(view_on_button_pressed), NULL); >> g_signal_connect(view, "popup-menu", (GCallback) >> view_popupmenu, NULL); >> >> @@ -635,6 +673,7 @@ >> gtk_tree_view_append_column (GTK_TREE_VIEW (view), >> column_camera_make); >> gtk_tree_view_append_column (GTK_TREE_VIEW (view), >> column_camera_model); >> gtk_tree_view_append_column (GTK_TREE_VIEW (view), >> column_enabled); >> + gtk_tree_view_append_column (GTK_TREE_VIEW (view), >> column_defish); >> >> gtk_tree_view_set_headers_visible(GTK_TREE_VIEW (view), TRUE); >> >> @@ -672,6 +711,7 @@ >> gchar *camera_make; >> gchar *camera_model; >> gboolean enabled; >> + gboolean defish; >> >> RSLens *lens = list->data; >> >> @@ -687,6 +727,7 @@ >> "camera-make", &camera_make, >> "camera-model", &camera_model, >> "enabled", &enabled, >> + "defish", &defish, >> NULL); >> >> const gchar *human_focal = rs_human_focal(min_focal, >> max_focal); >> @@ -708,6 +749,7 @@ >> RS_LENS_DB_EDITOR_CAMERA_MAKE, >> camera_make, >> RS_LENS_DB_EDITOR_CAMERA_MODEL, >> camera_model, >> RS_LENS_DB_EDITOR_ENABLED, enabled, >> + RS_LENS_DB_EDITOR_DEFISH, defish, >> RS_LENS_DB_EDITOR_ENABLED_ACTIVATABLE, >> enabled_activatable, >> RS_LENS_DB_EDITOR_LENS, lens, >> -1); >> @@ -898,6 +940,13 @@ >> } >> >> void >> +defish_lens(GtkCheckButton *checkbutton, gpointer user_data) >> +{ >> + RSLens *lens = user_data; >> + rs_lens_set_lensfun_defish(lens, >> gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton))); >> +} >> + >> +void >> open_full_lens_editor(GtkCheckButton *checkbutton, gpointer user_data) >> { >> rs_lens_db_editor(); >> @@ -920,6 +969,7 @@ >> gchar *camera_make; >> gchar *camera_model; >> gboolean enabled; >> + gboolean defish; >> >> g_assert(RS_IS_LENS(lens)); >> g_object_get(lens, >> @@ -933,6 +983,7 @@ >> "camera-make", &camera_make, >> "camera-model", &camera_model, >> "enabled", &enabled, >> + "defish", &defish, >> NULL); >> >> GtkWidget *editor = gtk_dialog_new(); >> @@ -993,7 +1044,9 @@ >> GtkWidget *label_camera_make = gtk_label_new(camera_make); >> GtkWidget *label_camera_model = gtk_label_new(camera_model); >> GtkWidget *checkbutton_enabled = >> gtk_check_button_new_with_label(_("Enable this lens")); >> + GtkWidget *checkbutton_defish = >> gtk_check_button_new_with_label(_("Enable Defish")); >> >> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_enabled), >> rs_lens_get_lensfun_enabled(lens)); >> + >> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbutton_defish), >> rs_lens_get_lensfun_defish(lens)); >> >> GtkWidget *button_set_lens = gtk_button_new_with_label(_("Set >> lens")); >> >> @@ -1006,6 +1059,7 @@ >> single_lens_data->lens = lens; >> single_lens_data->button = button_set_lens; >> single_lens_data->checkbutton_enabled = checkbutton_enabled; >> + single_lens_data->checkbutton_defish = checkbutton_defish; >> >> g_signal_connect(button_set_lens, "clicked", G_CALLBACK(set_lens), >> single_lens_data); >> >> @@ -1026,7 +1080,8 @@ >> gtk_table_attach_defaults(GTK_TABLE(table), label_lensfun_model, >> 1,2,7,8); >> gtk_table_attach_defaults(GTK_TABLE(table), button_set_lens, >> 1,2,6,8); >> gtk_table_attach_defaults(GTK_TABLE(table), sep2, 0,2,8,9); >> - gtk_table_attach_defaults(GTK_TABLE(table), checkbutton_enabled, >> 0,2,9,10); >> + gtk_table_attach_defaults(GTK_TABLE(table), checkbutton_enabled, >> 0,1,9,10); >> + gtk_table_attach_defaults(GTK_TABLE(table), checkbutton_defish, >> 1,2,9,10); >> >> /* Set spacing around separator in table */ >> gtk_table_set_row_spacing(GTK_TABLE(table), 4, 10); >> @@ -1043,6 +1098,7 @@ >> gtk_container_add (GTK_CONTAINER (frame), table); >> >> g_signal_connect(checkbutton_enabled, "toggled", >> G_CALLBACK(enable_lens), lens); >> + g_signal_connect(checkbutton_defish, "toggled", >> G_CALLBACK(defish_lens), lens); >> >> /* FIXME: Put lensfun update button in editor - for this to work, >> we cannot close the window when updating */ >> // GtkWidget *button_update_lensfun = >> gtk_button_new_with_label(_("Update lensfun database")); >> >> Modified: trunk/librawstudio/rs-lens-db-editor.h >> =================================================================== >> --- trunk/librawstudio/rs-lens-db-editor.h 2011-09-10 16:42:03 UTC >> (rev 4038) >> +++ trunk/librawstudio/rs-lens-db-editor.h 2011-09-10 20:22:43 UTC >> (rev 4039) >> @@ -29,6 +29,7 @@ >> RS_LENS_DB_EDITOR_CAMERA_MAKE, >> RS_LENS_DB_EDITOR_CAMERA_MODEL, >> RS_LENS_DB_EDITOR_ENABLED, >> + RS_LENS_DB_EDITOR_DEFISH, >> RS_LENS_DB_EDITOR_ENABLED_ACTIVATABLE, >> RS_LENS_DB_EDITOR_LENS >> }; >> >> Modified: trunk/librawstudio/rs-lens-db.c >> =================================================================== >> --- trunk/librawstudio/rs-lens-db.c 2011-09-10 16:42:03 UTC (rev 4038) >> +++ trunk/librawstudio/rs-lens-db.c 2011-09-10 20:22:43 UTC (rev 4039) >> @@ -137,6 +137,7 @@ >> gchar *camera_make; >> gchar *camera_model; >> gboolean enabled; >> + gboolean defish; >> >> RSLens *lens = list->data; >> >> @@ -152,6 +153,7 @@ >> "camera-make", &camera_make, >> "camera-model", &camera_model, >> "enabled", &enabled, >> + "defish", &defish, >> NULL); >> >> xmlTextWriterStartElement(writer, BAD_CAST "lens"); >> @@ -177,6 +179,7 @@ >> xmlTextWriterWriteFormatElement(writer, >> BAD_CAST "enabled", "%s", "TRUE"); >> if (!enabled) >> xmlTextWriterWriteFormatElement(writer, >> BAD_CAST "enabled", "%s", "FALSE"); >> + xmlTextWriterWriteFormatElement(writer, BAD_CAST >> "defish", "%s", defish ? "TRUE": "FALSE"); >> xmlTextWriterEndElement(writer); >> >> g_free(identifier); >> @@ -258,6 +261,11 @@ >> enabled = TRUE; >> g_object_set(lens, >> "enabled", enabled, NULL); >> } >> + else if ((!xmlStrcmp(entry->name, >> BAD_CAST "defish"))) >> + { >> + gboolean defish = >> g_strcmp0((gchar *) val, "TRUE") == 0; >> + g_object_set(lens, >> "defish", defish, NULL); >> + } >> xmlFree(val); >> entry = entry->next; >> } >> >> Modified: trunk/librawstudio/rs-lens.c >> =================================================================== >> --- trunk/librawstudio/rs-lens.c 2011-09-10 16:42:03 UTC (rev 4038) >> +++ trunk/librawstudio/rs-lens.c 2011-09-10 20:22:43 UTC (rev 4039) >> @@ -34,6 +34,7 @@ >> gchar *camera_make; >> gchar *camera_model; >> gboolean enabled; >> + gboolean defish; >> }; >> >> G_DEFINE_TYPE (RSLens, rs_lens, G_TYPE_OBJECT) >> @@ -50,7 +51,8 @@ >> PROP_LENSFUN_MODEL, >> PROP_CAMERA_MAKE, >> PROP_CAMERA_MODEL, >> - PROP_ENABLED >> + PROP_ENABLED, >> + PROP_DEFISH >> }; >> >> static void >> @@ -93,6 +95,9 @@ >> case PROP_ENABLED: >> g_value_set_boolean(value, lens->enabled); >> break; >> + case PROP_DEFISH: >> + g_value_set_boolean(value, lens->defish); >> + break; >> default: >> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, >> property_id, pspec); >> } >> @@ -140,6 +145,9 @@ >> case PROP_ENABLED: >> lens->enabled = g_value_get_boolean(value); >> break; >> + case PROP_DEFISH: >> + lens->defish = g_value_get_boolean(value); >> + break; >> default: >> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, >> property_id, pspec); >> } >> @@ -223,6 +231,12 @@ >> PROP_ENABLED, g_param_spec_boolean( >> "enabled", "enabled", "Specify whether the lens should be >> corrected or not", >> FALSE, G_PARAM_READWRITE)); >> + >> + g_object_class_install_property(object_class, >> + PROP_DEFISH, g_param_spec_boolean( >> + "defish", "defish", "Specify whether fisheye distortion >> should be corrected or not", >> + FALSE, G_PARAM_READWRITE)); >> + >> } >> >> static void >> @@ -240,6 +254,7 @@ >> lens->camera_make = NULL; >> lens->camera_model = NULL; >> lens->enabled = FALSE; >> + lens->defish = FALSE; >> } >> >> /** >> @@ -367,3 +382,19 @@ >> >> return lens->enabled; >> } >> + >> +void >> +rs_lens_set_lensfun_defish(RSLens *lens, gboolean enabled) >> +{ >> + g_assert(RS_IS_LENS(lens)); >> + >> + lens->defish = enabled; >> +} >> + >> +gboolean >> +rs_lens_get_lensfun_defish(RSLens *lens) >> +{ >> + g_assert(RS_IS_LENS(lens)); >> + >> + return lens->defish; >> +} >> >> Modified: trunk/librawstudio/rs-lens.h >> =================================================================== >> --- trunk/librawstudio/rs-lens.h 2011-09-10 16:42:03 UTC (rev 4038) >> +++ trunk/librawstudio/rs-lens.h 2011-09-10 20:22:43 UTC (rev 4039) >> @@ -77,6 +77,8 @@ >> void rs_lens_set_lensfun_model(RSLens *lens, gchar *model); >> void rs_lens_set_lensfun_enabled(RSLens *lens, gboolean enabled); >> gboolean rs_lens_get_lensfun_enabled(RSLens *lens); >> +void rs_lens_set_lensfun_defish(RSLens *lens, gboolean enabled); >> +gboolean rs_lens_get_lensfun_defish(RSLens *lens); >> >> G_END_DECLS >> >> >> Modified: trunk/plugins/lensfun/lensfun.c >> =================================================================== >> --- trunk/plugins/lensfun/lensfun.c 2011-09-10 16:42:03 UTC (rev 4038) >> +++ trunk/plugins/lensfun/lensfun.c 2011-09-10 20:22:43 UTC (rev 4039) >> @@ -53,6 +53,7 @@ >> gfloat tca_kb; >> gfloat vignetting; >> gboolean distortion_enabled; >> + gboolean defish; >> >> lfLens *selected_lens; >> const lfCamera *selected_camera; >> @@ -79,6 +80,7 @@ >> PROP_TCA_KB, >> PROP_VIGNETTING, >> PROP_DISTORTION_ENABLED, >> + PROP_DEFISH, >> }; >> >> static void get_property (GObject *object, guint property_id, GValue >> *value, GParamSpec *pspec); >> @@ -166,6 +168,11 @@ >> "distortion-enabled", "distortion-enabled", >> "distortion-enabled", >> FALSE, G_PARAM_READWRITE) >> ); >> + g_object_class_install_property(object_class, >> + PROP_DISTORTION_ENABLED, g_param_spec_boolean( >> + "defish", "defish", "defish", >> + FALSE, G_PARAM_READWRITE) >> + ); >> >> filter_class->name = "Lensfun filter"; >> filter_class->get_image = get_image; >> @@ -187,6 +194,7 @@ >> lensfun->tca_kb = 0.0; >> lensfun->vignetting = 0.0; >> lensfun->distortion_enabled = FALSE; >> + lensfun->defish = FALSE; >> >> /* Initialize Lensfun database */ >> lensfun->ldb = lf_db_new (); >> @@ -233,6 +241,9 @@ >> case PROP_DISTORTION_ENABLED: >> g_value_set_boolean(value, >> lensfun->distortion_enabled); >> break; >> + case PROP_DEFISH: >> + g_value_set_boolean(value, lensfun->defish); >> + break; >> default: >> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, >> property_id, pspec); >> } >> @@ -284,6 +295,11 @@ >> lensfun->distortion_enabled = >> g_value_get_boolean(value); >> rs_filter_changed(RS_FILTER(lensfun), >> RS_FILTER_CHANGED_PIXELDATA); >> break; >> + case PROP_DEFISH: >> + lensfun->DIRTY = TRUE; >> + lensfun->defish = g_value_get_boolean(value); >> + rs_filter_changed(RS_FILTER(lensfun), >> RS_FILTER_CHANGED_PIXELDATA); >> + break; >> default: >> G_OBJECT_WARN_INVALID_PROPERTY_ID (object, >> property_id, pspec); >> } >> @@ -533,6 +549,7 @@ >> } >> >> lensfun->distortion_enabled = >> rs_lens_get_lensfun_enabled(lensfun->lens); >> + lensfun->defish = >> rs_lens_get_lensfun_defish(lensfun->lens); >> if ((!lensfun->selected_lens || >> !lensfun->distortion_enabled) && lensfun->selected_camera) >> { >> // g_debug("Lensfun: Lens not found or lens is >> disabled. Using neutral lense."); >> @@ -583,7 +600,6 @@ >> if (lensfun->selected_lens && lf_lens_check((lfLens *) >> lensfun->selected_lens)) >> { >> gint effective_flags; >> - >> /* Set TCA */ >> if (ABS(lensfun->tca_kr) > 0.01f || ABS(lensfun->tca_kb) > >> 0.01f) >> { >> @@ -637,12 +653,13 @@ >> lensfun->aperture, /* aperture */ >> 1.0, /* distance */ >> 1.0, /* scale */ >> - LF_UNKNOWN, /* lfLensType targeom, */ /* FIXME: ? >> */ >> + lensfun->defish ? LF_RECTILINEAR : LF_UNKNOWN, /* >> lfLensType targeom, */ >> LF_MODIFY_ALL, /* flags */ /* FIXME: ? */ >> FALSE); /* reverse */ >> - >> +#if 0 >> /* Print flags used */ >> -#if 0 >> + g_debug("defish:%d", (int)lensfun->defish); >> + g_debug("crop:%f, focal:%f, aperture:%f ", >> lensfun->selected_camera->CropFactor, lensfun->focal, lensfun->aperture); >> GString *flags = g_string_new(""); >> if (effective_flags & LF_MODIFY_TCA) >> g_string_append(flags, " LF_MODIFY_TCA"); >> >> >> _______________________________________________ >> Rawstudio-commit mailing list >> [email protected] >> http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit >> > > > _______________________________________________ > Rawstudio-commit mailing list > [email protected] > http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit > >
_______________________________________________ Rawstudio-commit mailing list [email protected] http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit
