[Rawstudio-commit] r1504 - trunk/src

Anders Brander anders at brander.dk
Wed Nov 28 13:25:23 CET 2007


Author: abrander
Date: 2007-11-28 13:25:23 +0100 (Wed, 28 Nov 2007)
New Revision: 1504

Modified:
   trunk/src/rawstudio.c
   trunk/src/rawstudio.h
   trunk/src/tiff-meta.c
Log:
Added metadata-reading for Pentax.

Modified: trunk/src/rawstudio.c
===================================================================
--- trunk/src/rawstudio.c	2007-11-27 22:23:41 UTC (rev 1503)
+++ trunk/src/rawstudio.c	2007-11-28 12:25:23 UTC (rev 1504)
@@ -113,7 +113,7 @@
 	rs_add_filetype("raw", FILETYPE_RAW, ".raw", _("Panasonic raw"),
 		rs_photo_open_dcraw, rs_panasonic_load_thumb, rs_panasonic_load_meta, NULL);
 	rs_add_filetype("pef", FILETYPE_RAW, ".pef", _("Pentax raw"),
-		rs_photo_open_dcraw, rs_tiff_load_thumb, NULL, NULL);
+		rs_photo_open_dcraw, rs_tiff_load_thumb, rs_tiff_load_meta, NULL);
 	rs_add_filetype("dng", FILETYPE_RAW, "dng", _("Adobe Digital negative"),
 		rs_photo_open_dcraw, rs_tiff_load_thumb, rs_tiff_load_meta, NULL);
 	rs_add_filetype("jpeg", FILETYPE_JPEG, ".jpg", _("JPEG (Joint Photographic Experts Group)"),

Modified: trunk/src/rawstudio.h
===================================================================
--- trunk/src/rawstudio.h	2007-11-27 22:23:41 UTC (rev 1503)
+++ trunk/src/rawstudio.h	2007-11-28 12:25:23 UTC (rev 1504)
@@ -64,6 +64,7 @@
 	MAKE_NIKON,
 	MAKE_MINOLTA,
 	MAKE_PANASONIC,
+	MAKE_PENTAX,
 };
 
 enum {

Modified: trunk/src/tiff-meta.c
===================================================================
--- trunk/src/tiff-meta.c	2007-11-27 22:23:41 UTC (rev 1503)
+++ trunk/src/tiff-meta.c	2007-11-28 12:25:23 UTC (rev 1504)
@@ -30,6 +30,7 @@
 #define EXPO_TIME_MAXVAL (8*60.0*60.0)
 
 static void raw_nikon_makernote(RAWFILE *rawfile, guint offset, RS_METADATA *meta);
+static void raw_pentax_makernote(RAWFILE *rawfile, guint offset, RS_METADATA *meta);
 
 static void
 raw_nikon_makernote(RAWFILE *rawfile, guint offset, RS_METADATA *meta)
@@ -257,6 +258,56 @@
 	return;
 }
 
+static void
+raw_pentax_makernote(RAWFILE *rawfile, guint offset, RS_METADATA *meta)
+{
+	gushort number_of_entries;
+	gushort fieldtag=0;
+	gushort fieldtype;
+	gushort ushort_temp1=0;
+	guint valuecount;
+	guint uint_temp1=0;
+
+	if (raw_strcmp(rawfile, offset, "AOC", 3))
+		offset += 6;
+	else
+		return;
+
+	if(!raw_get_ushort(rawfile, offset, &number_of_entries))
+		return;
+
+	if (number_of_entries>5000)
+		return;
+
+	offset += 2;
+
+	while(number_of_entries--)
+	{
+		raw_get_ushort(rawfile, offset, &fieldtag);
+		raw_get_ushort(rawfile, offset+2, &fieldtype);
+		raw_get_uint(rawfile, offset+4, &valuecount);
+		offset += 8;
+
+		switch(fieldtag)
+		{
+			case 0x0201: /* White balance */
+				raw_get_uint(rawfile, offset, &uint_temp1);
+				raw_get_ushort(rawfile, uint_temp1, &ushort_temp1);
+				meta->cam_mul[0] = (gdouble) ushort_temp1;
+				raw_get_ushort(rawfile, uint_temp1+2, &ushort_temp1);
+				meta->cam_mul[1] = (gdouble) ushort_temp1;
+				raw_get_ushort(rawfile, uint_temp1+4, &ushort_temp1);
+				meta->cam_mul[3] = (gdouble) ushort_temp1;
+				raw_get_ushort(rawfile, uint_temp1+6, &ushort_temp1);
+				meta->cam_mul[2] = (gdouble) ushort_temp1;
+				rs_metadata_normalize_wb(meta);
+				break;
+		}
+		offset += 4;
+	}
+	return;
+}
+
 gboolean
 raw_ifd_walker(RAWFILE *rawfile, guint offset, RS_METADATA *meta)
 {
@@ -359,6 +410,8 @@
 					meta->make = MAKE_CANON;
 				else if (raw_strcmp(rawfile, uint_temp1, "NIKON", 5))
 					meta->make = MAKE_NIKON;
+				else if (raw_strcmp(rawfile, uint_temp1, "PENTAX", 5))
+					meta->make = MAKE_PENTAX;
 				break;
 			case 0x0088: /* Minolta */
 			case 0x0111: /* PreviewImageStart */
@@ -459,6 +512,8 @@
 					raw_nikon_makernote(rawfile, uint_temp1, meta);
 				else if (meta->make == MAKE_MINOLTA)
 					raw_ifd_walker(rawfile, uint_temp1, meta);
+				else if (meta->make == MAKE_PENTAX)
+					raw_pentax_makernote(rawfile, uint_temp1, meta);
 				break;
 			case 0x8769: /* ExifIFDPointer */
 				raw_get_uint(rawfile, offset, &uint_temp1);




More information about the Rawstudio-commit mailing list