Author: post
Date: 2011-02-06 18:22:45 +0100 (Sun, 06 Feb 2011)
New Revision: 3813
Modified:
trunk/librawstudio/rs-metadata.c
trunk/librawstudio/rs-metadata.h
trunk/plugins/meta-tiff/tiff-meta.c
Log:
Move lens identification to meta-data class, and re-generate it when the cache
is loaded from disk - this will enable lens fixes to be applied to already
opened images.
Modified: trunk/librawstudio/rs-metadata.c
===================================================================
--- trunk/librawstudio/rs-metadata.c 2011-02-06 16:31:46 UTC (rev 3812)
+++ trunk/librawstudio/rs-metadata.c 2011-02-06 17:22:45 UTC (rev 3813)
@@ -43,6 +43,9 @@
g_free(metadata->time_ascii);
if (metadata->thumbnail)
g_object_unref(metadata->thumbnail);
+ if (metadata->lens_identifier)
+ g_free(metadata->lens_identifier);
+
}
/* Chain up */
@@ -104,6 +107,7 @@
metadata->lens_min_aperture = -1.0;
metadata->lens_max_aperture = -1.0;
metadata->lens_identifier = NULL;
+ metadata->fixed_lens_identifier = NULL;
}
RSMetadata*
@@ -112,7 +116,7 @@
return g_object_new (RS_TYPE_METADATA, NULL);
}
-#define METACACHEVERSION 5
+#define METACACHEVERSION 6
void
rs_metadata_cache_save(RSMetadata *metadata, const gchar *filename)
{
@@ -177,8 +181,8 @@
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", "%s", metadata->lens_identifier);
+ if (metadata->fixed_lens_identifier)
+ xmlTextWriterWriteFormatElement(writer, BAD_CAST
"fixed_lens_identifier", "%s", metadata->fixed_lens_identifier);
xmlTextWriterEndDocument(writer);
xmlFreeTextWriter(writer);
}
@@ -370,10 +374,10 @@
metadata->lens_max_aperture = atof((gchar *)
val);
xmlFree(val);
}
- else if ((!xmlStrcmp(cur->name, BAD_CAST
"lens_identifier")))
+ else if ((!xmlStrcmp(cur->name, BAD_CAST
"fixed_lens_identifier")))
{
val = xmlNodeListGetString(doc,
cur->xmlChildrenNode, 1);
- metadata->lens_identifier = g_strdup((gchar
*)val);
+ metadata->fixed_lens_identifier =
g_strdup((gchar *)val);
xmlFree(val);
}
@@ -408,6 +412,46 @@
}
#undef METACACHEVERSION
+
+static void generate_lens_identifier(RSMetadata *meta)
+{
+ /* Check if we already have an identifier from camera */
+ if (meta->fixed_lens_identifier)
+ {
+ meta->lens_identifier = meta->fixed_lens_identifier;
+ return;
+ }
+ /* These lenses are identified with varying aperture for lens depending
on actual focal length. We fix this by
+ setting the correct aperture values, so the lens only will show up
once in the lens db editor */
+ rs_lens_fix(meta);
+
+ /* Build identifier string */
+ GString *identifier = g_string_new("");
+ if (meta->lens_id > 0)
+ g_string_append_printf(identifier, "ID:%d ",meta->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);
+ if (identifier->len > 0)
+ meta->lens_identifier = g_strdup(identifier->str);
+ else
+ {
+ /* Most likely a hacked compact */
+ if (meta->make_ascii > 0)
+ g_string_append_printf(identifier, "make:%s
",meta->make_ascii);
+ if (meta->model_ascii > 0)
+ g_string_append_printf(identifier, "model:%s
",meta->model_ascii);
+ if (identifier->len > 0)
+ meta->lens_identifier = g_strdup(identifier->str);
+ }
+ g_string_free(identifier, TRUE);
+}
+
RSMetadata *
rs_metadata_new_from_file(const gchar *filename)
{
@@ -419,6 +463,7 @@
rs_metadata_cache_save(metadata, filename);
}
+ generate_lens_identifier(metadata);
return metadata;
}
@@ -430,10 +475,12 @@
if (rs_metadata_load_from_file(metadata, filename))
{
rs_metadata_cache_save(metadata, filename);
+ generate_lens_identifier(metadata);
return TRUE;
}
return FALSE;
}
+ generate_lens_identifier(metadata);
return TRUE;
}
Modified: trunk/librawstudio/rs-metadata.h
===================================================================
--- trunk/librawstudio/rs-metadata.h 2011-02-06 16:31:46 UTC (rev 3812)
+++ trunk/librawstudio/rs-metadata.h 2011-02-06 17:22:45 UTC (rev 3813)
@@ -87,6 +87,7 @@
gdouble lens_max_focal;
gdouble lens_min_aperture;
gdouble lens_max_aperture;
+ gchar *fixed_lens_identifier;
gchar *lens_identifier;
};
Modified: trunk/plugins/meta-tiff/tiff-meta.c
===================================================================
--- trunk/plugins/meta-tiff/tiff-meta.c 2011-02-06 16:31:46 UTC (rev 3812)
+++ trunk/plugins/meta-tiff/tiff-meta.c 2011-02-06 17:22:45 UTC (rev 3813)
@@ -76,7 +76,6 @@
static gboolean thumbnail_reader(const gchar *service, RAWFILE *rawfile, guint
offset, guint length, RSMetadata *meta);
static gboolean thumbnail_store(GdkPixbuf *pixbuf, RSMetadata *meta);
static GdkPixbuf* raw_thumbnail_reader(const gchar *service, RSMetadata *meta);
-static void generate_lens_identifier(RSMetadata *meta);
typedef enum tiff_field_type
{
@@ -275,7 +274,7 @@
lens_name = raw_strdup(rawfile, ifd.value_offset,
ifd.count);
/* We only add Canon lenses, since others are simply
registered as "30mm", etc. */
if (lens_name[0] == 'E' && lens_name[1] == 'F')
- meta->lens_identifier = g_strconcat("Canon ",
lens_name, NULL);
+ meta->fixed_lens_identifier =
g_strconcat("Canon ", lens_name, NULL);
g_free(lens_name);
break;
case 0x00a4: /* WhiteBalanceTable */
@@ -997,11 +996,11 @@
switch(ifd.tag)
{
case 81: /* Lens type */
- meta->lens_identifier = raw_strdup(rawfile,
ifd.value_offset, ifd.count);
+ meta->fixed_lens_identifier =
raw_strdup(rawfile, ifd.value_offset, ifd.count);
break;
case 82: /* Lens serial number */
- if (!meta->lens_identifier)
- meta->lens_identifier =
raw_strdup(rawfile, ifd.value_offset, ifd.count);
+ if (!meta->fixed_lens_identifier)
+ meta->fixed_lens_identifier =
raw_strdup(rawfile, ifd.value_offset, ifd.count);
break;
case 0x8769: /* ExifIFDPointer */
exif_reader(rawfile, ifd.value_offset, meta);
@@ -1695,9 +1694,6 @@
} while (next>0);
rs_metadata_normalize_wb(meta);
-
- /* Generate lens identifier */
- generate_lens_identifier(meta);
}
/**
@@ -1893,41 +1889,3 @@
rs_filetype_register_meta_loader(".tiff", "Generic TIFF meta loader",
tiff_load_meta, 10, RS_LOADER_FLAGS_RAW);
}
-
-void generate_lens_identifier(RSMetadata *meta)
-{
- /* Check if we already have an identifier from camera */
- if (meta->lens_identifier)
- return;
-
- /* These lenses are identified with varying aperture for lens depending
on actual focal length. We fix this by
- setting the correct aperture values, so the lens only will show up
once in the lens db editor */
- rs_lens_fix(meta);
-
-
- /* Build identifier string */
- GString *identifier = g_string_new("");
- if (meta->lens_id > 0)
- g_string_append_printf(identifier, "ID:%d ",meta->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);
- if (strlen(identifier->str) > 0)
- meta->lens_identifier = g_strdup(identifier->str);
- else
- {
- /* Most likely a hacked compact */
- if (meta->make_ascii > 0)
- g_string_append_printf(identifier, "make:%s
",meta->make_ascii);
- if (meta->model_ascii > 0)
- g_string_append_printf(identifier, "model:%s
",meta->model_ascii);
- if (strlen(identifier->str) > 0)
- meta->lens_identifier = g_strdup(identifier->str);
- }
- g_string_free(identifier, TRUE);
-}
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit